cube-parameters
Version:
A sophisticated 3D model viewer built with React, TypeScript, and Three.js, featuring advanced visualization tools, measurement capabilities, and lighting controls.
4,250 lines • 1.21 MB
JavaScript
var JR=Object.defineProperty;var Ax=t=>{throw TypeError(t)};var eP=(t,e,n)=>e in t?JR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var kt=(t,e,n)=>eP(t,typeof e!="symbol"?e+"":e,n),op=(t,e,n)=>e.has(t)||Ax("Cannot "+n);var re=(t,e,n)=>(op(t,e,"read from private field"),n?n.call(t):e.get(t)),xt=(t,e,n)=>e.has(t)?Ax("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),rt=(t,e,n,r)=>(op(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Sn=(t,e,n)=>(op(t,e,"access private method"),n);var Lu=(t,e,n,r)=>({set _(i){rt(t,e,i,n)},get _(){return re(t,e,r)}});function tP(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function IM(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var kM={exports:{}},oh={},OM={exports:{}},lt={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var yu=Symbol.for("react.element"),nP=Symbol.for("react.portal"),rP=Symbol.for("react.fragment"),iP=Symbol.for("react.strict_mode"),sP=Symbol.for("react.profiler"),oP=Symbol.for("react.provider"),aP=Symbol.for("react.context"),lP=Symbol.for("react.forward_ref"),cP=Symbol.for("react.suspense"),uP=Symbol.for("react.memo"),dP=Symbol.for("react.lazy"),Cx=Symbol.iterator;function fP(t){return t===null||typeof t!="object"?null:(t=Cx&&t[Cx]||t["@@iterator"],typeof t=="function"?t:null)}var FM={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},UM=Object.assign,BM={};function Nl(t,e,n){this.props=t,this.context=e,this.refs=BM,this.updater=n||FM}Nl.prototype.isReactComponent={};Nl.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Nl.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function zM(){}zM.prototype=Nl.prototype;function g0(t,e,n){this.props=t,this.context=e,this.refs=BM,this.updater=n||FM}var v0=g0.prototype=new zM;v0.constructor=g0;UM(v0,Nl.prototype);v0.isPureReactComponent=!0;var Rx=Array.isArray,HM=Object.prototype.hasOwnProperty,y0={current:null},jM={key:!0,ref:!0,__self:!0,__source:!0};function VM(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)HM.call(e,r)&&!jM.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];i.children=l}if(t&&t.defaultProps)for(r in a=t.defaultProps,a)i[r]===void 0&&(i[r]=a[r]);return{$$typeof:yu,type:t,key:s,ref:o,props:i,_owner:y0.current}}function hP(t,e){return{$$typeof:yu,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function x0(t){return typeof t=="object"&&t!==null&&t.$$typeof===yu}function pP(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var Px=/\/+/g;function ap(t,e){return typeof t=="object"&&t!==null&&t.key!=null?pP(""+t.key):e.toString(36)}function Vd(t,e,n,r,i){var s=typeof t;(s==="undefined"||s==="boolean")&&(t=null);var o=!1;if(t===null)o=!0;else switch(s){case"string":case"number":o=!0;break;case"object":switch(t.$$typeof){case yu:case nP:o=!0}}if(o)return o=t,i=i(o),t=r===""?"."+ap(o,0):r,Rx(i)?(n="",t!=null&&(n=t.replace(Px,"$&/")+"/"),Vd(i,e,n,"",function(c){return c})):i!=null&&(x0(i)&&(i=hP(i,n+(!i.key||o&&o.key===i.key?"":(""+i.key).replace(Px,"$&/")+"/")+t)),e.push(i)),1;if(o=0,r=r===""?".":r+":",Rx(t))for(var a=0;a<t.length;a++){s=t[a];var l=r+ap(s,a);o+=Vd(s,e,n,l,i)}else if(l=fP(t),typeof l=="function")for(t=l.call(t),a=0;!(s=t.next()).done;)s=s.value,l=r+ap(s,a++),o+=Vd(s,e,n,l,i);else if(s==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return o}function Iu(t,e,n){if(t==null)return t;var r=[],i=0;return Vd(t,r,"","",function(s){return e.call(n,s,i++)}),r}function mP(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var jn={current:null},Gd={transition:null},gP={ReactCurrentDispatcher:jn,ReactCurrentBatchConfig:Gd,ReactCurrentOwner:y0};function GM(){throw Error("act(...) is not supported in production builds of React.")}lt.Children={map:Iu,forEach:function(t,e,n){Iu(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Iu(t,function(){e++}),e},toArray:function(t){return Iu(t,function(e){return e})||[]},only:function(t){if(!x0(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};lt.Component=Nl;lt.Fragment=rP;lt.Profiler=sP;lt.PureComponent=g0;lt.StrictMode=iP;lt.Suspense=cP;lt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=gP;lt.act=GM;lt.cloneElement=function(t,e,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var r=UM({},t.props),i=t.key,s=t.ref,o=t._owner;if(e!=null){if(e.ref!==void 0&&(s=e.ref,o=y0.current),e.key!==void 0&&(i=""+e.key),t.type&&t.type.defaultProps)var a=t.type.defaultProps;for(l in e)HM.call(e,l)&&!jM.hasOwnProperty(l)&&(r[l]=e[l]===void 0&&a!==void 0?a[l]:e[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];r.children=a}return{$$typeof:yu,type:t.type,key:i,ref:s,props:r,_owner:o}};lt.createContext=function(t){return t={$$typeof:aP,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:oP,_context:t},t.Consumer=t};lt.createElement=VM;lt.createFactory=function(t){var e=VM.bind(null,t);return e.type=t,e};lt.createRef=function(){return{current:null}};lt.forwardRef=function(t){return{$$typeof:lP,render:t}};lt.isValidElement=x0;lt.lazy=function(t){return{$$typeof:dP,_payload:{_status:-1,_result:t},_init:mP}};lt.memo=function(t,e){return{$$typeof:uP,type:t,compare:e===void 0?null:e}};lt.startTransition=function(t){var e=Gd.transition;Gd.transition={};try{t()}finally{Gd.transition=e}};lt.unstable_act=GM;lt.useCallback=function(t,e){return jn.current.useCallback(t,e)};lt.useContext=function(t){return jn.current.useContext(t)};lt.useDebugValue=function(){};lt.useDeferredValue=function(t){return jn.current.useDeferredValue(t)};lt.useEffect=function(t,e){return jn.current.useEffect(t,e)};lt.useId=function(){return jn.current.useId()};lt.useImperativeHandle=function(t,e,n){return jn.current.useImperativeHandle(t,e,n)};lt.useInsertionEffect=function(t,e){return jn.current.useInsertionEffect(t,e)};lt.useLayoutEffect=function(t,e){return jn.current.useLayoutEffect(t,e)};lt.useMemo=function(t,e){return jn.current.useMemo(t,e)};lt.useReducer=function(t,e,n){return jn.current.useReducer(t,e,n)};lt.useRef=function(t){return jn.current.useRef(t)};lt.useState=function(t){return jn.current.useState(t)};lt.useSyncExternalStore=function(t,e,n){return jn.current.useSyncExternalStore(t,e,n)};lt.useTransition=function(){return jn.current.useTransition()};lt.version="18.3.1";OM.exports=lt;var S=OM.exports;const he=IM(S),WM=tP({__proto__:null,default:he},[S]);/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var vP=S,yP=Symbol.for("react.element"),xP=Symbol.for("react.fragment"),_P=Object.prototype.hasOwnProperty,wP=vP.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,SP={key:!0,ref:!0,__self:!0,__source:!0};function XM(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)_P.call(e,r)&&!SP.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:yP,type:t,key:s,ref:o,props:i,_owner:wP.current}}oh.Fragment=xP;oh.jsx=XM;oh.jsxs=XM;kM.exports=oh;var y=kM.exports,$M={exports:{}},vr={},YM={exports:{}},KM={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(t){function e(D,V){var Q=D.length;D.push(V);e:for(;0<Q;){var J=Q-1>>>1,le=D[J];if(0<i(le,V))D[J]=V,D[Q]=le,Q=J;else break e}}function n(D){return D.length===0?null:D[0]}function r(D){if(D.length===0)return null;var V=D[0],Q=D.pop();if(Q!==V){D[0]=Q;e:for(var J=0,le=D.length,pe=le>>>1;J<pe;){var $=2*(J+1)-1,ee=D[$],se=$+1,Z=D[se];if(0>i(ee,Q))se<le&&0>i(Z,ee)?(D[J]=Z,D[se]=Q,J=se):(D[J]=ee,D[$]=Q,J=$);else if(se<le&&0>i(Z,Q))D[J]=Z,D[se]=Q,J=se;else break e}}return V}function i(D,V){var Q=D.sortIndex-V.sortIndex;return Q!==0?Q:D.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],c=[],f=1,u=null,d=3,h=!1,m=!1,v=!1,g=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(D){for(var V=n(c);V!==null;){if(V.callback===null)r(c);else if(V.startTime<=D)r(c),V.sortIndex=V.expirationTime,e(l,V);else break;V=n(c)}}function w(D){if(v=!1,_(D),!m)if(n(l)!==null)m=!0,O(M);else{var V=n(c);V!==null&&j(w,V.startTime-D)}}function M(D,V){m=!1,v&&(v=!1,p(C),C=-1),h=!0;var Q=d;try{for(_(V),u=n(l);u!==null&&(!(u.expirationTime>V)||D&&!N());){var J=u.callback;if(typeof J=="function"){u.callback=null,d=u.priorityLevel;var le=J(u.expirationTime<=V);V=t.unstable_now(),typeof le=="function"?u.callback=le:u===n(l)&&r(l),_(V)}else r(l);u=n(l)}if(u!==null)var pe=!0;else{var $=n(c);$!==null&&j(w,$.startTime-V),pe=!1}return pe}finally{u=null,d=Q,h=!1}}var T=!1,b=null,C=-1,A=5,E=-1;function N(){return!(t.unstable_now()-E<A)}function F(){if(b!==null){var D=t.unstable_now();E=D;var V=!0;try{V=b(!0,D)}finally{V?I():(T=!1,b=null)}}else T=!1}var I;if(typeof x=="function")I=function(){x(F)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,z=U.port2;U.port1.onmessage=F,I=function(){z.postMessage(null)}}else I=function(){g(F,0)};function O(D){b=D,T||(T=!0,I())}function j(D,V){C=g(function(){D(t.unstable_now())},V)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(D){D.callback=null},t.unstable_continueExecution=function(){m||h||(m=!0,O(M))},t.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<D?Math.floor(1e3/D):5},t.unstable_getCurrentPriorityLevel=function(){return d},t.unstable_getFirstCallbackNode=function(){return n(l)},t.unstable_next=function(D){switch(d){case 1:case 2:case 3:var V=3;break;default:V=d}var Q=d;d=V;try{return D()}finally{d=Q}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(D,V){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var Q=d;d=D;try{return V()}finally{d=Q}},t.unstable_scheduleCallback=function(D,V,Q){var J=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?J+Q:J):Q=J,D){case 1:var le=-1;break;case 2:le=250;break;case 5:le=1073741823;break;case 4:le=1e4;break;default:le=5e3}return le=Q+le,D={id:f++,callback:V,priorityLevel:D,startTime:Q,expirationTime:le,sortIndex:-1},Q>J?(D.sortIndex=Q,e(c,D),n(l)===null&&D===n(c)&&(v?(p(C),C=-1):v=!0,j(w,Q-J))):(D.sortIndex=le,e(l,D),m||h||(m=!0,O(M))),D},t.unstable_shouldYield=N,t.unstable_wrapCallback=function(D){var V=d;return function(){var Q=d;d=V;try{return D.apply(this,arguments)}finally{d=Q}}}})(KM);YM.exports=KM;var MP=YM.exports;/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var bP=S,gr=MP;function ce(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var qM=new Set,Oc={};function Zo(t,e){hl(t,e),hl(t+"Capture",e)}function hl(t,e){for(Oc[t]=e,t=0;t<e.length;t++)qM.add(e[t])}var qi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Vm=Object.prototype.hasOwnProperty,EP=/^[: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]*$/,Nx={},Dx={};function TP(t){return Vm.call(Dx,t)?!0:Vm.call(Nx,t)?!1:EP.test(t)?Dx[t]=!0:(Nx[t]=!0,!1)}function AP(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function CP(t,e,n,r){if(e===null||typeof e>"u"||AP(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Vn(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var xn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){xn[t]=new Vn(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];xn[e]=new Vn(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){xn[t]=new Vn(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){xn[t]=new Vn(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){xn[t]=new Vn(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){xn[t]=new Vn(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){xn[t]=new Vn(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){xn[t]=new Vn(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){xn[t]=new Vn(t,5,!1,t.toLowerCase(),null,!1,!1)});var _0=/[\-:]([a-z])/g;function w0(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(_0,w0);xn[e]=new Vn(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(_0,w0);xn[e]=new Vn(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(_0,w0);xn[e]=new Vn(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){xn[t]=new Vn(t,1,!1,t.toLowerCase(),null,!1,!1)});xn.xlinkHref=new Vn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){xn[t]=new Vn(t,1,!1,t.toLowerCase(),null,!0,!0)});function S0(t,e,n,r){var i=xn.hasOwnProperty(e)?xn[e]:null;(i!==null?i.type!==0:r||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(CP(e,n,i,r)&&(n=null),r||i===null?TP(e)&&(n===null?t.removeAttribute(e):t.setAttribute(e,""+n)):i.mustUseProperty?t[i.propertyName]=n===null?i.type===3?!1:"":n:(e=i.attributeName,r=i.attributeNamespace,n===null?t.removeAttribute(e):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?t.setAttributeNS(r,e,n):t.setAttribute(e,n))))}var is=bP.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ku=Symbol.for("react.element"),Ea=Symbol.for("react.portal"),Ta=Symbol.for("react.fragment"),M0=Symbol.for("react.strict_mode"),Gm=Symbol.for("react.profiler"),ZM=Symbol.for("react.provider"),QM=Symbol.for("react.context"),b0=Symbol.for("react.forward_ref"),Wm=Symbol.for("react.suspense"),Xm=Symbol.for("react.suspense_list"),E0=Symbol.for("react.memo"),ws=Symbol.for("react.lazy"),JM=Symbol.for("react.offscreen"),Lx=Symbol.iterator;function Kl(t){return t===null||typeof t!="object"?null:(t=Lx&&t[Lx]||t["@@iterator"],typeof t=="function"?t:null)}var zt=Object.assign,lp;function gc(t){if(lp===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);lp=e&&e[1]||""}return`
`+lp+t}var cp=!1;function up(t,e){if(!t||cp)return"";cp=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(c){var r=c}Reflect.construct(t,[],e)}else{try{e.call()}catch(c){r=c}t.call(e.prototype)}else{try{throw Error()}catch(c){r=c}t()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var i=c.stack.split(`
`),s=r.stack.split(`
`),o=i.length-1,a=s.length-1;1<=o&&0<=a&&i[o]!==s[a];)a--;for(;1<=o&&0<=a;o--,a--)if(i[o]!==s[a]){if(o!==1||a!==1)do if(o--,a--,0>a||i[o]!==s[a]){var l=`
`+i[o].replace(" at new "," at ");return t.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{cp=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?gc(t):""}function RP(t){switch(t.tag){case 5:return gc(t.type);case 16:return gc("Lazy");case 13:return gc("Suspense");case 19:return gc("SuspenseList");case 0:case 2:case 15:return t=up(t.type,!1),t;case 11:return t=up(t.type.render,!1),t;case 1:return t=up(t.type,!0),t;default:return""}}function $m(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Ta:return"Fragment";case Ea:return"Portal";case Gm:return"Profiler";case M0:return"StrictMode";case Wm:return"Suspense";case Xm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case QM:return(t.displayName||"Context")+".Consumer";case ZM:return(t._context.displayName||"Context")+".Provider";case b0:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case E0:return e=t.displayName||null,e!==null?e:$m(t.type)||"Memo";case ws:e=t._payload,t=t._init;try{return $m(t(e))}catch{}}return null}function PP(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return $m(e);case 8:return e===M0?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Xs(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function eb(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function NP(t){var e=eb(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Ou(t){t._valueTracker||(t._valueTracker=NP(t))}function tb(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=eb(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function gf(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}}function Ym(t,e){var n=e.checked;return zt({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Ix(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Xs(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function nb(t,e){e=e.checked,e!=null&&S0(t,"checked",e,!1)}function Km(t,e){nb(t,e);var n=Xs(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?qm(t,e.type,n):e.hasOwnProperty("defaultValue")&&qm(t,e.type,Xs(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function kx(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function qm(t,e,n){(e!=="number"||gf(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var vc=Array.isArray;function za(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i<n.length;i++)e["$"+n[i]]=!0;for(n=0;n<t.length;n++)i=e.hasOwnProperty("$"+t[n].value),t[n].selected!==i&&(t[n].selected=i),i&&r&&(t[n].defaultSelected=!0)}else{for(n=""+Xs(n),e=null,i=0;i<t.length;i++){if(t[i].value===n){t[i].selected=!0,r&&(t[i].defaultSelected=!0);return}e!==null||t[i].disabled||(e=t[i])}e!==null&&(e.selected=!0)}}function Zm(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(ce(91));return zt({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Ox(t,e){var n=e.value;if(n==null){if(n=e.children,e=e.defaultValue,n!=null){if(e!=null)throw Error(ce(92));if(vc(n)){if(1<n.length)throw Error(ce(93));n=n[0]}e=n}e==null&&(e=""),n=e}t._wrapperState={initialValue:Xs(n)}}function rb(t,e){var n=Xs(e.value),r=Xs(e.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),e.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),r!=null&&(t.defaultValue=""+r)}function Fx(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function ib(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Qm(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?ib(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Fu,sb=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,i){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,i)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Fu=Fu||document.createElement("div"),Fu.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Fu.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Fc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var bc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},DP=["Webkit","ms","Moz","O"];Object.keys(bc).forEach(function(t){DP.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),bc[e]=bc[t]})});function ob(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||bc.hasOwnProperty(t)&&bc[t]?(""+e).trim():e+"px"}function ab(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=ob(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var LP=zt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Jm(t,e){if(e){if(LP[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(ce(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(ce(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(ce(61))}if(e.style!=null&&typeof e.style!="object")throw Error(ce(62))}}function eg(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";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 tg=null;function T0(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ng=null,Ha=null,ja=null;function Ux(t){if(t=wu(t)){if(typeof ng!="function")throw Error(ce(280));var e=t.stateNode;e&&(e=dh(e),ng(t.stateNode,t.type,e))}}function lb(t){Ha?ja?ja.push(t):ja=[t]:Ha=t}function cb(){if(Ha){var t=Ha,e=ja;if(ja=Ha=null,Ux(t),e)for(t=0;t<e.length;t++)Ux(e[t])}}function ub(t,e){return t(e)}function db(){}var dp=!1;function fb(t,e,n){if(dp)return t(e,n);dp=!0;try{return ub(t,e,n)}finally{dp=!1,(Ha!==null||ja!==null)&&(db(),cb())}}function Uc(t,e){var n=t.stateNode;if(n===null)return null;var r=dh(n);if(r===null)return null;n=r[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(t=t.type,r=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!r;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(ce(231,e,typeof n));return n}var rg=!1;if(qi)try{var ql={};Object.defineProperty(ql,"passive",{get:function(){rg=!0}}),window.addEventListener("test",ql,ql),window.removeEventListener("test",ql,ql)}catch{rg=!1}function IP(t,e,n,r,i,s,o,a,l){var c=Array.prototype.slice.call(arguments,3);try{e.apply(n,c)}catch(f){this.onError(f)}}var Ec=!1,vf=null,yf=!1,ig=null,kP={onError:function(t){Ec=!0,vf=t}};function OP(t,e,n,r,i,s,o,a,l){Ec=!1,vf=null,IP.apply(kP,arguments)}function FP(t,e,n,r,i,s,o,a,l){if(OP.apply(this,arguments),Ec){if(Ec){var c=vf;Ec=!1,vf=null}else throw Error(ce(198));yf||(yf=!0,ig=c)}}function Qo(t){var e=t,n=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(n=e.return),t=e.return;while(t)}return e.tag===3?n:null}function hb(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function Bx(t){if(Qo(t)!==t)throw Error(ce(188))}function UP(t){var e=t.alternate;if(!e){if(e=Qo(t),e===null)throw Error(ce(188));return e!==t?null:t}for(var n=t,r=e;;){var i=n.return;if(i===null)break;var s=i.alternate;if(s===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===s.child){for(s=i.child;s;){if(s===n)return Bx(i),t;if(s===r)return Bx(i),e;s=s.sibling}throw Error(ce(188))}if(n.return!==r.return)n=i,r=s;else{for(var o=!1,a=i.child;a;){if(a===n){o=!0,n=i,r=s;break}if(a===r){o=!0,r=i,n=s;break}a=a.sibling}if(!o){for(a=s.child;a;){if(a===n){o=!0,n=s,r=i;break}if(a===r){o=!0,r=s,n=i;break}a=a.sibling}if(!o)throw Error(ce(189))}}if(n.alternate!==r)throw Error(ce(190))}if(n.tag!==3)throw Error(ce(188));return n.stateNode.current===n?t:e}function pb(t){return t=UP(t),t!==null?mb(t):null}function mb(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=mb(t);if(e!==null)return e;t=t.sibling}return null}var gb=gr.unstable_scheduleCallback,zx=gr.unstable_cancelCallback,BP=gr.unstable_shouldYield,zP=gr.unstable_requestPaint,Yt=gr.unstable_now,HP=gr.unstable_getCurrentPriorityLevel,A0=gr.unstable_ImmediatePriority,vb=gr.unstable_UserBlockingPriority,xf=gr.unstable_NormalPriority,jP=gr.unstable_LowPriority,yb=gr.unstable_IdlePriority,ah=null,yi=null;function VP(t){if(yi&&typeof yi.onCommitFiberRoot=="function")try{yi.onCommitFiberRoot(ah,t,void 0,(t.current.flags&128)===128)}catch{}}var Qr=Math.clz32?Math.clz32:XP,GP=Math.log,WP=Math.LN2;function XP(t){return t>>>=0,t===0?32:31-(GP(t)/WP|0)|0}var Uu=64,Bu=4194304;function yc(t){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: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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function _f(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=yc(a):(s&=o,s!==0&&(r=yc(s)))}else o=n&~i,o!==0?r=yc(o):s!==0&&(r=yc(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0<e;)n=31-Qr(e),i=1<<n,r|=t[n],e&=~i;return r}function $P(t,e){switch(t){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64: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 e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function YP(t,e){for(var n=t.suspendedLanes,r=t.pingedLanes,i=t.expirationTimes,s=t.pendingLanes;0<s;){var o=31-Qr(s),a=1<<o,l=i[o];l===-1?(!(a&n)||a&r)&&(i[o]=$P(a,e)):l<=e&&(t.expiredLanes|=a),s&=~a}}function sg(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function xb(){var t=Uu;return Uu<<=1,!(Uu&4194240)&&(Uu=64),t}function fp(t){for(var e=[],n=0;31>n;n++)e.push(t);return e}function xu(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Qr(e),t[e]=n}function KP(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0<n;){var i=31-Qr(n),s=1<<i;e[i]=0,r[i]=-1,t[i]=-1,n&=~s}}function C0(t,e){var n=t.entangledLanes|=e;for(t=t.entanglements;n;){var r=31-Qr(n),i=1<<r;i&e|t[r]&e&&(t[r]|=e),n&=~i}}var St=0;function _b(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var wb,R0,Sb,Mb,bb,og=!1,zu=[],Os=null,Fs=null,Us=null,Bc=new Map,zc=new Map,bs=[],qP="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 submit".split(" ");function Hx(t,e){switch(t){case"focusin":case"focusout":Os=null;break;case"dragenter":case"dragleave":Fs=null;break;case"mouseover":case"mouseout":Us=null;break;case"pointerover":case"pointerout":Bc.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":zc.delete(e.pointerId)}}function Zl(t,e,n,r,i,s){return t===null||t.nativeEvent!==s?(t={blockedOn:e,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[i]},e!==null&&(e=wu(e),e!==null&&R0(e)),t):(t.eventSystemFlags|=r,e=t.targetContainers,i!==null&&e.indexOf(i)===-1&&e.push(i),t)}function ZP(t,e,n,r,i){switch(e){case"focusin":return Os=Zl(Os,t,e,n,r,i),!0;case"dragenter":return Fs=Zl(Fs,t,e,n,r,i),!0;case"mouseover":return Us=Zl(Us,t,e,n,r,i),!0;case"pointerover":var s=i.pointerId;return Bc.set(s,Zl(Bc.get(s)||null,t,e,n,r,i)),!0;case"gotpointercapture":return s=i.pointerId,zc.set(s,Zl(zc.get(s)||null,t,e,n,r,i)),!0}return!1}function Eb(t){var e=Ao(t.target);if(e!==null){var n=Qo(e);if(n!==null){if(e=n.tag,e===13){if(e=hb(n),e!==null){t.blockedOn=e,bb(t.priority,function(){Sb(n)});return}}else if(e===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Wd(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var n=ag(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var r=new n.constructor(n.type,n);tg=r,n.target.dispatchEvent(r),tg=null}else return e=wu(n),e!==null&&R0(e),t.blockedOn=n,!1;e.shift()}return!0}function jx(t,e,n){Wd(t)&&n.delete(e)}function QP(){og=!1,Os!==null&&Wd(Os)&&(Os=null),Fs!==null&&Wd(Fs)&&(Fs=null),Us!==null&&Wd(Us)&&(Us=null),Bc.forEach(jx),zc.forEach(jx)}function Ql(t,e){t.blockedOn===e&&(t.blockedOn=null,og||(og=!0,gr.unstable_scheduleCallback(gr.unstable_NormalPriority,QP)))}function Hc(t){function e(i){return Ql(i,t)}if(0<zu.length){Ql(zu[0],t);for(var n=1;n<zu.length;n++){var r=zu[n];r.blockedOn===t&&(r.blockedOn=null)}}for(Os!==null&&Ql(Os,t),Fs!==null&&Ql(Fs,t),Us!==null&&Ql(Us,t),Bc.forEach(e),zc.forEach(e),n=0;n<bs.length;n++)r=bs[n],r.blockedOn===t&&(r.blockedOn=null);for(;0<bs.length&&(n=bs[0],n.blockedOn===null);)Eb(n),n.blockedOn===null&&bs.shift()}var Va=is.ReactCurrentBatchConfig,wf=!0;function JP(t,e,n,r){var i=St,s=Va.transition;Va.transition=null;try{St=1,P0(t,e,n,r)}finally{St=i,Va.transition=s}}function e2(t,e,n,r){var i=St,s=Va.transition;Va.transition=null;try{St=4,P0(t,e,n,r)}finally{St=i,Va.transition=s}}function P0(t,e,n,r){if(wf){var i=ag(t,e,n,r);if(i===null)Sp(t,e,r,Sf,n),Hx(t,r);else if(ZP(i,t,e,n,r))r.stopPropagation();else if(Hx(t,r),e&4&&-1<qP.indexOf(t)){for(;i!==null;){var s=wu(i);if(s!==null&&wb(s),s=ag(t,e,n,r),s===null&&Sp(t,e,r,Sf,n),s===i)break;i=s}i!==null&&r.stopPropagation()}else Sp(t,e,r,null,n)}}var Sf=null;function ag(t,e,n,r){if(Sf=null,t=T0(r),t=Ao(t),t!==null)if(e=Qo(t),e===null)t=null;else if(n=e.tag,n===13){if(t=hb(e),t!==null)return t;t=null}else if(n===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return Sf=t,null}function Tb(t){switch(t){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(HP()){case A0:return 1;case vb:return 4;case xf:case jP:return 16;case yb:return 536870912;default:return 16}default:return 16}}var Ds=null,N0=null,Xd=null;function Ab(){if(Xd)return Xd;var t,e=N0,n=e.length,r,i="value"in Ds?Ds.value:Ds.textContent,s=i.length;for(t=0;t<n&&e[t]===i[t];t++);var o=n-t;for(r=1;r<=o&&e[n-r]===i[s-r];r++);return Xd=i.slice(t,1<r?1-r:void 0)}function $d(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function Hu(){return!0}function Vx(){return!1}function yr(t){function e(n,r,i,s,o){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=s,this.target=o,this.currentTarget=null;for(var a in t)t.hasOwnProperty(a)&&(n=t[a],this[a]=n?n(s):s[a]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?Hu:Vx,this.isPropagationStopped=Vx,this}return zt(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Hu)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Hu)},persist:function(){},isPersistent:Hu}),e}var Dl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},D0=yr(Dl),_u=zt({},Dl,{view:0,detail:0}),t2=yr(_u),hp,pp,Jl,lh=zt({},_u,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:L0,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!==Jl&&(Jl&&t.type==="mousemove"?(hp=t.screenX-Jl.screenX,pp=t.screenY-Jl.screenY):pp=hp=0,Jl=t),hp)},movementY:function(t){return"movementY"in t?t.movementY:pp}}),Gx=yr(lh),n2=zt({},lh,{dataTransfer:0}),r2=yr(n2),i2=zt({},_u,{relatedTarget:0}),mp=yr(i2),s2=zt({},Dl,{animationName:0,elapsedTime:0,pseudoElement:0}),o2=yr(s2),a2=zt({},Dl,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),l2=yr(a2),c2=zt({},Dl,{data:0}),Wx=yr(c2),u2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},d2={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"},f2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function h2(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=f2[t])?!!e[t]:!1}function L0(){return h2}var p2=zt({},_u,{key:function(t){if(t.key){var e=u2[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=$d(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?d2[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:L0,charCode:function(t){return t.type==="keypress"?$d(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?$d(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),m2=yr(p2),g2=zt({},lh,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xx=yr(g2),v2=zt({},_u,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:L0}),y2=yr(v2),x2=zt({},Dl,{propertyName:0,elapsedTime:0,pseudoElement:0}),_2=yr(x2),w2=zt({},lh,{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}),S2=yr(w2),M2=[9,13,27,32],I0=qi&&"CompositionEvent"in window,Tc=null;qi&&"documentMode"in document&&(Tc=document.documentMode);var b2=qi&&"TextEvent"in window&&!Tc,Cb=qi&&(!I0||Tc&&8<Tc&&11>=Tc),$x=" ",Yx=!1;function Rb(t,e){switch(t){case"keyup":return M2.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pb(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Aa=!1;function E2(t,e){switch(t){case"compositionend":return Pb(e);case"keypress":return e.which!==32?null:(Yx=!0,$x);case"textInput":return t=e.data,t===$x&&Yx?null:t;default:return null}}function T2(t,e){if(Aa)return t==="compositionend"||!I0&&Rb(t,e)?(t=Ab(),Xd=N0=Ds=null,Aa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return Cb&&e.locale!=="ko"?null:e.data;default:return null}}var A2={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 Kx(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!A2[t.type]:e==="textarea"}function Nb(t,e,n,r){lb(r),e=Mf(e,"onChange"),0<e.length&&(n=new D0("onChange","change",null,n,r),t.push({event:n,listeners:e}))}var Ac=null,jc=null;function C2(t){jb(t,0)}function ch(t){var e=Pa(t);if(tb(e))return t}function R2(t,e){if(t==="change")return e}var Db=!1;if(qi){var gp;if(qi){var vp="oninput"in document;if(!vp){var qx=document.createElement("div");qx.setAttribute("oninput","return;"),vp=typeof qx.oninput=="function"}gp=vp}else gp=!1;Db=gp&&(!document.documentMode||9<document.documentMode)}function Zx(){Ac&&(Ac.detachEvent("onpropertychange",Lb),jc=Ac=null)}function Lb(t){if(t.propertyName==="value"&&ch(jc)){var e=[];Nb(e,jc,t,T0(t)),fb(C2,e)}}function P2(t,e,n){t==="focusin"?(Zx(),Ac=e,jc=n,Ac.attachEvent("onpropertychange",Lb)):t==="focusout"&&Zx()}function N2(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return ch(jc)}function D2(t,e){if(t==="click")return ch(e)}function L2(t,e){if(t==="input"||t==="change")return ch(e)}function I2(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var ti=typeof Object.is=="function"?Object.is:I2;function Vc(t,e){if(ti(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Vm.call(e,i)||!ti(t[i],e[i]))return!1}return!0}function Qx(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Jx(t,e){var n=Qx(t);t=0;for(var r;n;){if(n.nodeType===3){if(r=t+n.textContent.length,t<=e&&r>=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Qx(n)}}function Ib(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Ib(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function kb(){for(var t=window,e=gf();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=gf(t.document)}return e}function k0(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function k2(t){var e=kb(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Ib(n.ownerDocument.documentElement,n)){if(r!==null&&k0(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=Jx(n,s);var o=Jx(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<e.length;n++)t=e[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var O2=qi&&"documentMode"in document&&11>=document.documentMode,Ca=null,lg=null,Cc=null,cg=!1;function e_(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;cg||Ca==null||Ca!==gf(r)||(r=Ca,"selectionStart"in r&&k0(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Cc&&Vc(Cc,r)||(Cc=r,r=Mf(lg,"onSelect"),0<r.length&&(e=new D0("onSelect","select",null,e,n),t.push({event:e,listeners:r}),e.target=Ca)))}function ju(t,e){var n={};return n[t.toLowerCase()]=e.toLowerCase(),n["Webkit"+t]="webkit"+e,n["Moz"+t]="moz"+e,n}var Ra={animationend:ju("Animation","AnimationEnd"),animationiteration:ju("Animation","AnimationIteration"),animationstart:ju("Animation","AnimationStart"),transitionend:ju("Transition","TransitionEnd")},yp={},Ob={};qi&&(Ob=document.createElement("div").style,"AnimationEvent"in window||(delete Ra.animationend.animation,delete Ra.animationiteration.animation,delete Ra.animationstart.animation),"TransitionEvent"in window||delete Ra.transitionend.transition);function uh(t){if(yp[t])return yp[t];if(!Ra[t])return t;var e=Ra[t],n;for(n in e)if(e.hasOwnProperty(n)&&n in Ob)return yp[t]=e[n];return t}var Fb=uh("animationend"),Ub=uh("animationiteration"),Bb=uh("animationstart"),zb=uh("transitionend"),Hb=new Map,t_="abort auxClick 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(" ");function ro(t,e){Hb.set(t,e),Zo(e,[t])}for(var xp=0;xp<t_.length;xp++){var _p=t_[xp],F2=_p.toLowerCase(),U2=_p[0].toUpperCase()+_p.slice(1);ro(F2,"on"+U2)}ro(Fb,"onAnimationEnd");ro(Ub,"onAnimationIteration");ro(Bb,"onAnimationStart");ro("dblclick","onDoubleClick");ro("focusin","onFocus");ro("focusout","onBlur");ro(zb,"onTransitionEnd");hl("onMouseEnter",["mouseout","mouseover"]);hl("onMouseLeave",["mouseout","mouseover"]);hl("onPointerEnter",["pointerout","pointerover"]);hl("onPointerLeave",["pointerout","pointerover"]);Zo("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Zo("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Zo("onBeforeInput",["compositionend","keypress","textInput","paste"]);Zo("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Zo("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Zo("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xc="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(" "),B2=new Set("cancel close invalid load scroll toggle".split(" ").concat(xc));function n_(t,e,n){var r=t.type||"unknown-event";t.currentTarget=n,FP(r,e,void 0,t),t.currentTarget=null}function jb(t,e){e=(e&4)!==0;for(var n=0;n<t.length;n++){var r=t[n],i=r.event;r=r.listeners;e:{var s=void 0;if(e)for(var o=r.length-1;0<=o;o--){var a=r[o],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==s&&i.isPropagationStopped())break e;n_(i,a,c),s=l}else for(o=0;o<r.length;o++){if(a=r[o],l=a.instance,c=a.currentTarget,a=a.listener,l!==s&&i.isPropagationStopped())break e;n_(i,a,c),s=l}}}if(yf)throw t=ig,yf=!1,ig=null,t}function Dt(t,e){var n=e[pg];n===void 0&&(n=e[pg]=new Set);var r=t+"__bubble";n.has(r)||(Vb(e,t,2,!1),n.add(r))}function wp(t,e,n){var r=0;e&&(r|=4),Vb(n,t,r,e)}var Vu="_reactListening"+Math.random().toString(36).slice(2);function Gc(t){if(!t[Vu]){t[Vu]=!0,qM.forEach(function(n){n!=="selectionchange"&&(B2.has(n)||wp(n,!1,t),wp(n,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[Vu]||(e[Vu]=!0,wp("selectionchange",!1,e))}}function Vb(t,e,n,r){switch(Tb(e)){case 1:var i=JP;break;case 4:i=e2;break;default:i=P0}n=i.bind(null,e,n,t),i=void 0,!rg||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(i=!0),r?i!==void 0?t.addEventListener(e,n,{capture:!0,passive:i}):t.addEventListener(e,n,!0):i!==void 0?t.addEventListener(e,n,{passive:i}):t.addEventListener(e,n,!1)}function Sp(t,e,n,r,i){var s=r;if(!(e&1)&&!(e&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.parentNode===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===i||l.nodeType===8&&l.parentNode===i))return;o=o.return}for(;a!==null;){if(o=Ao(a),o===null)return;if(l=o.tag,l===5||l===6){r=s=o;continue e}a=a.parentNode}}r=r.return}fb(function(){var c=s,f=T0(n),u=[];e:{var d=Hb.get(t);if(d!==void 0){var h=D0,m=t;switch(t){case"keypress":if($d(n)===0)break e;case"keydown":case"keyup":h=m2;break;case"focusin":m="focus",h=mp;break;case"focusout":m="blur",h=mp;break;case"beforeblur":case"afterblur":h=mp;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=Gx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=r2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=y2;break;case Fb:case Ub:case Bb:h=o2;break;case zb:h=_2;break;case"scroll":h=t2;break;case"wheel":h=S2;break;case"copy":case"cut":case"paste":h=l2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=Xx}var v=(e&4)!==0,g=!v&&t==="scroll",p=v?d!==null?d+"Capture":null:d;v=[];for(var x=c,_;x!==null;){_=x;var w=_.stateNode;if(_.tag===5&&w!==null&&(_=w,p!==null&&(w=Uc(x,p),w!=null&&v.push(Wc(x,w,_)))),g)break;x=x.return}0<v.length&&(d=new h(d,m,null,n,f),u.push({event:d,listeners:v}))}}if(!(e&7)){e:{if(d=t==="mouseover"||t==="pointerover",h=t==="mouseout"||t==="pointerout",d&&n!==tg&&(m=n.relatedTarget||n.fromElement)&&(Ao(m)||m[Zi]))break e;if((h||d)&&(d=f.window===f?f:(d=f.ownerDocument)?d.defaultView||d.parentWindow:window,h?(m=n.relatedTarget||n.toElement,h=c,m=m?Ao(m):null,m!==null&&(g=Qo(m),m!==g||m.tag!==5&&m.tag!==6)&&(m=null)):(h=null,m=c),h!==m)){if(v=Gx,w="onMouseLeave",p="onMouseEnter",x="mouse",(t==="pointerout"||t==="pointerover")&&(v=Xx,w="onPointerLeave",p="onPointerEnter",x="pointer"),g=h==null?d:Pa(h),_=m==null?d:Pa(m),d=new v(w,x+"leave",h,n,f),d.target=g,d.relatedTarget=_,w=null,Ao(f)===c&&(v=new v(p,x+"enter",m,n,f),v.target=_,v.relatedTarget=g,w=v),g=w,h&&m)t:{for(v=h,p=m,x=0,_=v;_;_=ra(_))x++;for(_=0,w=p;w;w=ra(w))_++;for(;0<x-_;)v=ra(v),x--;for(;0<_-x;)p=ra(p),_--;for(;x--;){if(v===p||p!==null&&v===p.alternate)break t;v=ra(v),p=ra(p)}v=null}else v=null;h!==null&&r_(u,d,h,v,!1),m!==null&&g!==null&&r_(u,g,m,v,!0)}}e:{if(d=c?Pa(c):window,h=d.nodeName&&d.nodeName.toLowerCase(),h==="select"||h==="input"&&d.type==="file")var M=R2;else if(Kx(d))if(Db)M=L2;else{M=N2;var T=P2}else(h=d.nodeName)&&h.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(M=D2);if(M&&(M=M(t,c))){Nb(u,M,n,f);break e}T&&T(t,d,c),t==="focusout"&&(T=d._wrapperState)&&T.controlled&&d.type==="number"&&qm(d,"number",d.value)}switch(T=c?Pa(c):window,t){case"focusin":(Kx(T)||T.contentEditable==="true")&&(Ca=T,lg=c,Cc=null);break;case"focusout":Cc=lg=Ca=null;break;case"mousedown":cg=!0;break;case"contextmenu":case"mouseup":case"dragend":cg=!1,e_(u,n,f);break;case"selectionchange":if(O2)break;case"keydown":case"keyup":e_(u,n,f)}var b;if(I0)e:{switch(t){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Aa?Rb(t,n)&&(C="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(Cb&&n.locale!=="ko"&&(Aa||C!=="onCompositionStart"?C==="onCompositionEnd"&&Aa&&(b=Ab()):(Ds=f,N0="value"in Ds?Ds.value:Ds.textContent,Aa=!0)),T=Mf(c,C),0<T.length&&(C=new Wx(C,t,null,n,f),u.push({event:C,listeners:T}),b?C.data=b:(b=Pb(n),b!==null&&(C.data=b)))),(b=b2?E2(t,n):T2(t,n))&&(c=Mf(c,"onBeforeInput"),0<c.length&&(f=new Wx("onBeforeInput","beforeinput",null,n,f),u.push({event:f,listeners:c}),f.data=b))}jb(u,e)})}function Wc(t,e,n){return{instance:t,listener:e,currentTarget:n}}function Mf(t,e){for(var n=e+"Capture",r=[];t!==null;){var i=t,s=i.stateNode;i.tag===5&&s!==null&&(i=s,s=Uc(t,n),s!=null&&r.unshift(Wc(t,s,i)),s=Uc(t,e),s!=null&&r.push(Wc(t,s,i))),t=t.return}return r}function ra(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function r_(t,e,n,r,i){for(var s=e._reactName,o=[];n!==null&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,i?(l=Uc(n,s),l!=null&&o.unshift(Wc(n,l,a))):i||(l=Uc(n,s),l!=null&&o.push(Wc(n,l,a)))),n=n.return}o.length!==0&&t.push({event:e,listeners:o})}var z2=/\r\n?/g,H2=/\u0000|\uFFFD/g;function i_(t){return(typeof t=="string"?t:""+t).replace(z2,`
`).replace(H2,"")}function Gu(t,e,n){if(e=i_(e),i_(t)!==e&&n)throw Error(ce(425))}function bf(){}var ug=null,dg=null;function fg(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var hg=typeof setTimeout=="function"?setTimeout:void 0,j2=typeof clearTimeout=="function"?clearTimeout:void 0,s_=typeof Promise=="function"?Promise:void 0,V2=typeof queueMicrotask=="function"?queueMicrotask:typeof s_<"u"?function(t){return s_.resolve(null).then(t).catch(G2)}:hg;function G2(t){setTimeout(function(){throw t})}function Mp(t,e){var n=e,r=0;do{var i=n.nextSibling;if(t.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){t.removeChild(i),Hc(e);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);Hc(e)}function Bs(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function o_(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var Ll=Math.random().toString(36).slice(2),hi="__reactFiber$"+Ll,Xc="__reactProps$"+Ll,Zi="__reactContainer$"+Ll,pg="__reactEvents$"+Ll,W2="__reactListeners$"+Ll,X2="__reactHandles$"+Ll;function Ao(t){var e=t[hi];if(e)return e;for(var n=t.parentNode;n;){if(e=n[Zi]||n[hi]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=o_(t);t!==null;){if(n=t[hi])return n;t=o_(t)}return e}t=n,n=t.parentNode}return null}function wu(t){return t=t[hi]||t[Zi],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Pa(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(ce(33))}function dh(t){return t[Xc]||null}var mg=[],Na=-1;function io(t){return{current:t}}function It(t){0>Na||(t.current=mg[Na],mg[Na]=null,Na--)}function Ct(t,e){Na++,mg[Na]=t.current,t.current=e}var $s={},Dn=io($s),Qn=io(!1),Uo=$s;function pl(t,e){var n=t.type.contextTypes;if(!n)return $s;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Jn(t){return t=t.childContextTypes,t!=null}function Ef(){It(Qn),It(Dn)}function a_(t,e,n){if(Dn.current!==$s)throw Error(ce(168));Ct(Dn,e),Ct(Qn,n)}function Gb(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(ce(108,PP(t)||"Unknown",i));return zt({},n,r)}function Tf(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||$s,Uo=Dn.current,Ct(Dn,t),Ct(Qn,Qn.current),!0}function l_(t,e,n){var r=t.stateNode;if(!r)throw Error(ce(169));n?(t=Gb(t,e,Uo),r.__reactInternalMemoizedMergedChildContext=t,It(Qn),It(Dn),Ct(Dn,t)):It(Qn),Ct(Qn,n)}var zi=null,fh=!1,bp=!1;function Wb(t){zi===null?zi=[t]:zi.push(t)}function $2(t){fh=!0,Wb(t)}function so(){if(!bp&&zi!==null){bp=!0;var t=0,e=St;try{var n=zi;for(St=1;t<n.length;t++){var r=n[t];do r=r(!0);while(r!==null)}zi=null,fh=!1}catch(i){throw zi!==null&&(zi=zi.slice(t+1)),gb(A0,so),i}finally{St=e,bp=!1}}return null}var Da=[],La=0,Af=null,Cf=0,Mr=[],br=0,Bo=null,ji=1,Vi="";function xo(t,e){Da[La++]=Cf,Da[La++]=Af,Af=t,Cf=e}function Xb(t,e,n){Mr[br++]=ji,Mr[br++]=Vi,Mr[br++]=Bo,Bo=t;var r=ji;t=Vi;var i=32-Qr(r)-1;r&=~(1<<i),n+=1;var s=32-Qr(e)+i;if(30<s){var o=i-i%5;s=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ji=1<<32-Qr(e)+i|n<<i|r,Vi=s+t}else ji=1<<s|n<<i|r,Vi=t}function O0(t){t.return!==null&&(xo(t,1),Xb(t,1,0))}function F0(t){for(;t===Af;)Af=Da[--La],Da[La]=null,Cf=Da[--La],Da[La]=null;for(;t===Bo;)Bo=Mr[--br],Mr[br]=null,Vi=Mr[--br],Mr[br]=null,ji=Mr[--br],Mr[br]=null}var pr=null,fr=null,Ot=!1,Yr=null;function $b(t,e){var n=Ar(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.deletions,e===null?(t.deletions=[n],t.flags|=16):e.push(n)}function c_(t,e){switch(t.tag){case 5:var n=t.type;return e=e.nodeType!==1||n.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,pr=t,fr=Bs(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,pr=t,fr=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(n=Bo!==null?{id:ji,overflow:Vi}:null,t.memoizedState={dehydrated:e,treeContext:n,retryLane:1073741824},n=Ar(18,null,null,0),n.stateNode=e,n.return=t,t.child=n,pr=t,fr=null,!0):!1;default:return!1}}function gg(t){return(t.mode&1)!==0&&(t.flags&128)===0}function vg(t){if(Ot){var e=fr;if(e){var n=e;if(!c_(t,e)){if(gg(t))throw Error(ce(418));e=Bs(n.nextSibling);var r=pr;e&&c_(t,e)?$b(r,n):(t.flags=t.flags&-4097|2,Ot=!1,pr=t)}}else{if(gg(t))throw Error(ce(418));t.flags=t.flags&-4097|2,Ot=!1,pr=t}}}function u_(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;pr=t}function Wu(t){if(t!==pr)return!1;if(!Ot)return u_(t),Ot=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!fg(t.type,t.memoizedProps)),e&&(e=fr)){if(gg(t))throw Yb(),Error(ce(418));for(;e;)$b(t,e),e=Bs(e.nextSibling)}if(u_(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(ce(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(e===0){fr=Bs(t.nextSibling);break e}e--}else n!=="$"&&n!=="$!"&&n!=="$?"||e++}t=t.nextSibling}fr=null}}else fr=pr?Bs(t.stateNode.nextSibling):null;return!0}function Yb(){for(var t=fr;t;)t=Bs(t.nextSibling)}function ml(){fr=pr=null,Ot=!1}function U0(t){Yr===null?Yr=[t]:Yr.push(t)}var Y2=is.ReactCurrentBatchConfig;function ec(t,e,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(ce(309));var r=n.stateNode}if(!r)throw Error(ce(147,t));var i=r,s=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===s?e.ref:(e=function(o){var a=i.refs;o===null?delete a[s]:a[s]=o},e._stringRef=s,e)}if(typeof t!="string")throw Error(ce(284));if(!n._owner)throw Error(ce(290,t))}return t}function Xu(t,e){throw t=Object.prototype.toString.call(e),Error(ce(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function d_(t){var e=t._init;return e(t._payload)}function Kb(t){function e(p,x){if(t){var _=p.deletions;_===null?(p.deletions=[x],p.flags|=16):_.push(x)}}function n(p,x){if(!t)return null;for(;x!==null;)e(p,x),x=x.sibling;return null}function r(p,x){for(p=new Map;x!==null;)x.key!==null?p.set(x.key,x):p.set(x.index,x),x=x.sibling;return p}function i(p,x){return p=Vs(p,x),p.index=0,p.sibling=null,p}function s(p,x,_){return p.index=_,t?(_=p.alternate,_!==null?(_=_.index,_<x?(p.flags|=2,x):_):(p.flags|=2,x)):(p.flags|=1048576,x)}function o(p){return t&&p.alternate===null&&(p.flags|=2),p}function a(p,x,_,w){return x===null||x.tag!==6?(x=Np(_,p.mode,w),x.return=p,x):(x=i(x,_),x.return=p,x)}function l(p,x,_,w){var M=_.type;return M===Ta?f(p,x,_.props.children,w,_.key):x!==null&&(x.elementType===M||typeof M=="object"&&M!==null&&M.$$typeof===ws&&d_(M)===x.type)?(w=i(x,_.props),w.ref=ec(p,x,_),w.return=p,w):(w=ef(_.type,_.key,_.props,null,p.mode,w),w.ref=ec(p,x,_),w.return=p,w)}function c(p,x,_,w){return x===null||x.tag!==4||x.stateNode.containerInfo!==_.containerInfo||x.stateNode.implementation!==_.implementation?(x=Dp(_,p.mode,w),x.return=p,x):(x=i(x,_.children||[]),x.return=p,x)}function f(p,x,_,w,M){return x===null||x.tag!==7?(x=ko(_,p.mode,w,M),x.return=p,x):(x=i(x,_),x.return=p,x)}function u(p,x,_){if(typeof x=="string"&&x!==""||typeof x=="number")return x=Np(""+x,p.mode,_),x.return=p,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case ku:return _=ef(x.type,x.key,x.props,null,p.mode,_),_.ref=ec(p,null,x),_.return=p,_;case Ea:return x=Dp(x,p.mode,_),x.return=p,x;case ws:var w=x._init;return u(p,w(x._payload),_)}if(vc(x)||Kl(x))return x=ko(x,p.mode,_,null),x.return=p,x;Xu(p,x)}return null}function d(p,x,_,w){var M=x!==null?x.key:null;if(typeof _=="string"&&_!==""||typeof _=="number")return M!==null?null:a(p,x,""+_,w);if(typeof _=="object"&&_!==null){switch(_.$$typeof){case ku:return _.key===M?l(p,x,_,w):null;case Ea:return _.key===M?c(p,x,_,w):null;case ws:return M=_._init,d(p,x,M(_._payload),w)}if(vc(_)||Kl(_))return M!==null?null:f(p,x,_,w,null);Xu(p,_)}return null}function h(p,x,_,w,M){if(typeof w=="string"&&w!==""||typeof w=="number")return p=p.get(_)||null,a(x,p,""+w,M);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case ku:return p=p.get(w.key===null?_:w.key)||null,l(x,p,w,M);case Ea:return p=p.get(w.key===null?_:w.key)||null,c(x,p,w,M);case ws:var T=w._init;return h(p,x,_,T(w._payload),M)}if(vc(w)||Kl(w))return p=p.get(_)||null,f(x,p,w,M,null);Xu(x,w)}return null}function m(p,x,_,w){for(var M=null,T=null,b=x,C=x=0,A=null;b!==null&&C<_.length;C++){b.index>C?(A=b,b=null):A=b.sibling;var E=d(p,b,_[C],w);if(E===null){b===null&&(b=A);break}t&&b&&E.alternate===null&&e(p,b),x=s(E,x,C),T===null?M=E:T.sibling=E,T=E,b=A}if(C===_.length)return n(p,b),Ot&&xo(p,C),M;if(b===null){for(;C<_.length;C++)b=u(p,_[C],w),b!==null&&(x=s(b,x,C),T===null?M=b:T.sibling=b,T=b);return Ot&&xo(p,C),M}for(b=r(p,b);C<_.length;C++)A=h(b,p,C,_[C],w),A!==null&&(t&&A.alternate!==null&&b.delete(A.key===null?C:A.key),x=s(A,x,C),T===null?M=A:T.sibling=A,T=A);return t&&b.forEach(function(N){return e(p,N)}),Ot&&xo(p,C),M}function v(p,x,_,w){var M=Kl(_);if(typeof M!="function")throw Error(ce(150));if(_=M.call(_),_==null)throw Error(ce(151));for(var T=M=null,b=x,C=x=0,A=null,E=_.next();b!==null&&!E.done;C++,E=_.next()){b.index>C?(A=b,b=null):A=b.sibling;var N=d(p,b,E.value,w);if(N===null){b===null&&(b=A);break}t&&b&&N.alternate===null&&e(p,b),x=s(N,x,C),T===null?M=N:T.sibling=N,T=N,b=A}if(E.done)return n(p,b),Ot&&xo(p,C),M;if(b===null){for(;!E.done;C++,E=_.next())E=u(p,E.value,w),E!==null&&(x=s(E,x,C),T===null?M=E:T.sibling=E,T=E);return Ot&&xo(p,C),M}for(b=r(p,b);!E.done;C++,E=_.next())E=h(b,p,C,E.value,w),E!==null&&(t&&E.alternate!==null&&b.delete(E.key===null?C:E.key),x=s(E,x,C),T===null?M=E:T.sibling=E,T=E);return t&&b.forEach(function(F){return e(p,F)}),Ot&&xo(p,C),M}function g(p,x,_,w){if(typeof _=="object"&&_!==null&&_.type===Ta&&_.key===null&&(_=_.props.children),typeof _=="object"&&_!==null){switch(_.$$typeof){case ku:e:{for(var M=_.key,T=x;T!==null;){if(T.key===M){if(M=_.type,M===Ta){if(T.tag===7){n(p,T.sibling),x=i(T,_.props.children),x.return=p,p=x;break e}}else if(T.elementType===M||typeof M=="object"&&M!==null&&M.$$typeof===ws&&d_(M)===T.type){n(p,T.sibling),x=i(T,_.props),x.ref=ec(p,T,_),x.return=p,p=x;break e}n(p,T);break}else e(p,T);T=T.sibling}_.type===Ta?(x=ko(_.props.children,p.mode,w,_.key),x.return=p,p=x):(w=ef(_.type,_.key,_.props,null,p.mode,w),w.ref=ec(p,x,_),w.return=p,p=w)}return o(p);case Ea:e:{for(T=_.key;x!==null;){if(x.key===T)if(x.tag===4&&x.stateNode.containerInfo===_.containerInfo&&x.stateNode.implementation===_.implementation){n(p,x.sibling),x=i(x,_.children||[]),x.return=p,p=x;break e}else{n(p,x);break}else e(p,x);x=x.sibling}x=Dp(_,p.mode,w),x.return=p,p=x}return o(p);case ws:return T=_._init,g(p,x,T(_._payload),w)}if(vc(_))return m(p,x,_,w);if(Kl(_))return v(p,x,_,w);Xu(p,_)}return typeof _=="string"&&_!==""||typeof _=="number"?(_=""+_,x!==null&&x.tag===6?(n(p,x.sibling),x=i(x,_),x.return=p,p=x):(n(p,x),x=Np(_,p.mode,w),x.return=p,p=x),o(p)):n(p,x)}return g}var gl=Kb(!0),qb=Kb(!1),Rf=io(null),Pf=null,Ia=null,B0=null;function z0(){B0=Ia=Pf=null}function H0(t){var e=Rf.current;It(Rf),t._currentValue=e}function yg(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Ga(t,e){Pf=t,B0=Ia=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Zn=!0),t.firstContext=null)}function Dr(t){var e=t._currentValue;if(B0!==t)if(t={context:t,memoizedValue:e,next:null},Ia===null){if(Pf===null)throw Error(ce(308));Ia=t,Pf.dependencies={lanes:0,firstContext:t}}else Ia=Ia.next=t;return e}var Co=null;function j0(t){Co===null?Co=[t]:Co.push(t)}function Zb(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,j0(e)):(n.next=i.next,i.next=n),e.interleaved=n,Qi(t,r)}function Qi(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var Ss=!1;function V0(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Qb(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function $i(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function zs(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,mt&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Qi(t,n)}return i=r.interleaved,i===null?(e.next=e,j0(r)):(e.next=i.next,i.next=e),r.interleaved=e,Qi(t,n)}function Yd(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,C0(t,n)}}function f_(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Nf(t,e,n,r){var i=t.updateQueue;Ss=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,c=l.next;l.next=null,o===null?s=c:o.next=c,o=l;var f=t.alternate;f!==null&&(f=f.updateQueue,a=f.lastBaseUpdate,a!==o&&(a===null?f.firstBaseUpdate=c:a.next=c,f.lastBaseUpdate=l))}if(s!==null){var u=i.baseState;o=0,f=c=l=null,a=s;do{var d=a.lane,h=a.eventTime;if((r&d)===d){f!==null&&(f=f.next={eventTime:h,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var m=t,v=a;switch(d=e,h=n,v.tag){case 1:if(m=v.payload,typeof m=="function"){u=m.call(h,u,d);break e}u=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=v.payload,d=typeof m=="function"?m.call(h,u,d):m,d==null)break e;u=zt({},u,d);break e;case 2:Ss=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,d=i.effects,d===null?i.effects=[a]:d.push(a))}else h={eventTime:h,lane:d,tag:a.tag,payload:a.payload,callback:a.callback,next:null},f===null?(c=f=h,l=u):f=f.next=h,o|=d;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;d=a,a=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(f===null&&(l=u),i.baseState=l,i.firstBaseUpdate=c,i.lastBaseUpdate=f,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Ho|=o,t.lanes=o,t.memoizedState=u}}function h_(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var r=t[e],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(ce(191,i));i.call(r)}}}var Su={},xi=io(Su),$c=io(Su),Yc=io(Su);function Ro(t){if(t===Su)throw Error(ce(174));return t}function G0(t,e){switch(Ct(Yc,e),Ct($c,t),Ct(xi,Su),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Qm(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=Qm(e,t)}It(xi),Ct(xi,e)}function vl(){It(xi),It($c),It(Yc)}function Jb(t){Ro(Yc.current);var e=Ro(xi.current),n=Qm(e,t.type);e!==n&&(Ct($c,t),Ct(xi,n))}function W0(t){$c.current===t&&(It(xi),It($c))}var Ft=io(0);function Df(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var Ep=[];function X0(){for(var t=0;t<Ep.length;t++)Ep[t]._workInProgressVersionPrimary=null;Ep.length=0}var Kd=is.ReactCurrentDispatcher,Tp=is.ReactCurrentBatchConfig,zo=0,Bt=null,tn=null,un=null,Lf=!1,Rc=!1,Kc=0,K2=0;function Mn(){throw Error(ce(321))}function $0(t,e){if(e===null)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!ti(t[n],e[n]))return!1;return!0}function Y0(t,e,n,r,i,s){if(zo=s,Bt=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Kd.current=t===null||t.memoizedState===null?J2:eN,t=n(r,i),Rc){s=0;do{if(Rc=!1,Kc=0,25<=s)throw Error(ce(301));s+=1,un=tn=null,e.updateQueue=null,Kd.current=tN,t=n(r,i)}while(Rc)}if(Kd.current=If,e=tn!==null&&tn.next!==null,zo=0,un=tn=Bt=null,Lf=!1,e)throw Error(ce(300));return t}function K0(){var t=Kc!==0;return Kc=0,t}function li(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return un===null?Bt.memoizedState=un=t:un=un.next=t,un}function Lr(){if(tn===null){var t=Bt.alternate;t=t!==null?t.memoizedState:null}else t=tn.next;var e=un===null?Bt.memoizedState:un.next;if(e!==null)un=e,tn=t;else{if(t===null)throw Error(ce(310));tn=t,t={memoizedState:tn.memoizedState,baseState:tn.baseState,baseQueue:tn.baseQueue,queue:tn.queue,next:null},un===null?Bt.memoizedState=un=t:un=un.next=t}return un}function qc(t,e){return typeof e=="function"?e(t):e}function Ap(t){var e=Lr(),n=e.queue;if(n===null)throw Error(ce(311));n.lastRenderedReducer=t;var r=tn,i=r.baseQueue,s=n.pending;if(s!==null){if(i!==null){var o=i.next;i.next=s.next,s.next=o}r.baseQueue=i=s,n.pending=null}if(i!==null){s=i.next,r=r.baseState;var a=o=null,l=null,c=s;do{var f=c.lane;if((zo&f)===f)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:t(r,c.action);else{var u={lane:f,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=u,o=r):l=l.next=u,Bt.lanes|=f,Ho|=f}c=c.next}while(c!==null&&c!==s);l===null?o=r:l.next=a,ti(r,e.memoizedState)||(Zn=!0),e.memoizedState=r,e.baseState=o,e.baseQueue=l,n.lastRenderedState=r}if(t=n.interleaved,t!==null){i=t;do s=i.lane,Bt.lanes|=s,Ho|=s,i=i.next;while(i!==t)}else i===null&&(n.lanes=0);return[e.memoizedState,n.dispatch]}function Cp(t){var e=Lr(),n=e.queue;if(n===null)throw Error(ce(311));n.lastRenderedReducer=t;var r=n.dispatch,i=n.pending,s=e.memoizedState;if(i!==null){n.pending=null;var o=i=i.next;do s=t(s,o.action),o=o.next;while(o!==i);ti(s,e.memoizedState)||(Zn=!0),e.memoizedState=s,e.baseQueue===null&&(e.baseState=s),n.lastRenderedState=s}return[s,r]}function eE(){}function tE(t,e){var n=Bt,r=Lr(),i=e(),s=!ti(r.memoizedState,i);if(s&&(r.memoizedState=i,Zn=!0),r=r.queue,q0(iE.bind(null,n,r,t),[t]),r.getSnapshot!==e||s||un!==null&&un.memoizedState.tag&1){if(n.flags|=2048,Zc(9,rE.bind(null,n,r,i,e),void 0,null),fn===null)throw Error(ce(349));zo&30||nE(n,e,i)}return i}function nE(t,e,n){t.flags|=16384,t={getSnapshot:e,value:n},e=Bt.updateQueue,e===null?(e={lastEffect:null,stores:null},Bt.updateQueue=e,e.stores=[t]):(n=e.stores,n===null?e.stores=[t]:n.push(t))}function rE(t,e,n,r){e.value=n,e.getSnapshot=r,sE(e)&&oE(t)}function iE(t,e,n){return n(function(){sE(e)&&oE(t)})}function sE(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!ti(t,n)}catch{return!0}}function oE(t){var e=Qi(t,1);e!==null&&Jr(e,t,1,-1)}function p_(t){var e=li();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:qc,lastRenderedState:t},e.queue=t,t=t.dispatch=Q2.bind(null,Bt,t),[e.memoizedState,t]}function Zc(t,e,n,r){return t={tag:t,create:e,destroy:n,deps:r,next:null},e=Bt.updateQueue,e===null?(e={lastEffect:null,stores:null},Bt.updateQueue=e,e.lastEffect=t.next=t):(n=e.lastEffect,n===null?e.lastEffect=t.next=t:(r=n.next,n.next=t,t.next=r,e.lastEffect=t)),t}function aE(){return Lr().memoizedState}function qd(t,e,n,r){var i=li();Bt.flags|=t,i.memoizedState=Zc(1|e,n,void 0,r===void 0?null:r)}function hh(t,e,n,r){var i=Lr();r=r===void 0?null:r;var s=void 0;if(tn!==null){var o=tn.memoizedState;if(s=o.destroy,r!==null&&$0(r,o.deps)){i.memoizedState=Zc(e,n,s,r);return}}Bt.flags|=t,i.memoizedState=Zc(1|e,n,s,r)}function m_(t,e){return qd(8390656,8,t,e)}function q0(t,e){return hh(2048,8,t,e)}function lE(t,e){return hh(4,2,t,e)}function cE(t,e){return hh(4,4,t,e)}function uE(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function dE(t,e,n){return n=n!=null?n.concat([t]):null,hh(4,4,uE.bind(null,e,t),n)}function Z0(){}function fE(t,e){var n=Lr();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&$0(e,r[1])?r[0]:(n.memoizedState=[t,e],t)}function hE(t,e){var n=Lr();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&$0(e,r[1])?r[0]:(t=t(),n.memoizedState=[t,e],t)}function pE(t,e,n){return zo&21?(ti(n,e)||(n=xb(),Bt.lanes|=n,Ho|=n,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,Zn=!0),t.memoizedState=n)}function q2(t,e){var n=St;St=n!==0&&4>n?n:4,t(!0);var r=Tp.transition;Tp.transition={};try{t(!1),e()}finally{St=n,Tp.transition=r}}function mE(){return Lr().memoizedState}function Z2(t,e,n){var r=js(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},gE(t))vE(e,n);else if(n=Zb(t,e,n,r),n!==null){var i=zn();Jr(n,t,r,i),yE(n,e,r)}}function Q2(t,e,n){var r=js(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(gE(t))vE(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,ti(a,o)){var l=e.interleaved;l===null?(i.next=i,j0(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}finally{}n=Zb(t,e,i,r),n!==null&&(i=zn(),Jr(n,t,r,i),yE(n,e,r))}}function gE(t){var e=t.alternate;return t===Bt||e!==null&&e===Bt}function vE(t,e){Rc=Lf=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function yE(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,C0(t,n)}}var If={readContext:Dr,useCallback:Mn,useContext:Mn,useEffect:Mn,useImperativeHandle:Mn,useInsertionEffect:Mn,useLayoutEffect:Mn,useMemo:Mn,useReducer:Mn,useRef:Mn,useState:Mn,useDebugValue:Mn,useDeferredValue:Mn,useTransition:Mn,useMutableSource:Mn,useSyncExternalStore:Mn,useId:Mn,unstable_isNewReconciler:!1},J2={readContext:Dr,useCallback:function(t,e){return li().memoizedState=[t,e===void 0?null:e],t},useContext:Dr,useEffect:m_,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,qd(4194308,4,uE.bind(null,e,t),n)},useLayoutEffect:function(t,e){return qd(4194308,4,t,e)},useInsertionEffect:function(t,e){return qd(4,2,t,e)},useMemo:function(t,e){var n=li();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=li();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=Z2.bind(null,Bt,t),[r.memoizedState,t]},useRef:function(t){var e=li();return t={current:t},e.memoizedState=t},useState:p_,useDebugValue:Z0,useDeferredValue:function(t){return li().memoizedState=t},useTransition:function(){var t=p_(!1),e=t[0];return t=q2.bind(null,t[1]),li().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Bt,i=li();if(Ot){if(n===void 0)throw Error(ce(407));n=n()}else{if(n=e(),fn===null)throw Error(ce(349));zo&30||nE(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,m_(iE.bind(null,r,s,t),[t]),r.flags|=2048,Zc(9,rE.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=li(),e=fn.identifierPrefix;if(Ot){var n=Vi,r=ji;n=(r&~(1<<32-Qr(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Kc++,0<n&&(e+="H"+n.toString(32)),e+=":"}else n=K2++,e=":"+e+"r"+n.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},eN={readContext:Dr,useCallback:fE,useContext:Dr,useEffect:q0,useImperativeHandle:dE,useInsertionEffect:lE,useLayoutEffect:cE,useMemo:hE,useReducer:Ap,useRef:aE,useState:function(){return Ap(qc)},useDebugValue:Z0,useDeferredValue:function(t){var e=Lr();return pE(e,tn.memoizedState,t)},useTransition:function(){var t=Ap(qc)[0],e=Lr().memoizedState;return[t,e]},useMutableSource:eE,useSyncExternalStore:tE,useId:mE,unstable_isNewReconciler:!1},tN={readContext:Dr,useCallback:fE,useContext:Dr,useEffect:q0,useImperativeHandle:dE,useInsertionEffect:lE,useLayoutEffect:cE,useMemo:hE,useReducer:Cp,useRef:aE,useState:function(){return Cp(qc)},useDebugValue:Z0,useDeferredValue:function(t){var e=Lr();return tn===null?e.memoizedState=t:pE(e,tn.memoizedState,t)},useTransition:function(){var t=Cp(qc)[0],e=Lr().memoizedState;return[t,e]},useMutableSource:eE,useSyncExternalStore:tE,useId:mE,unstable_isNewReconciler:!1};function Vr(t,e){if(t&&t.defaultProps){e=zt({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function xg(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:zt({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var ph={isMounted:function(t){return(t=t._reactInternals)?Qo(t)===t:!1},enqueueSetState:function(t,e,n){t=t._reactInternals;var r=zn(),i=js(t),s=$i(r,i);s.payload=e,n!=null&&(s.callback=n),e=zs(t,s,i),e!==null&&(Jr(e,t,i,r),Yd(e,t,i))},enqueueReplaceState:function(t,e,n){t=t._reactInternals;var r=zn(),i=js(t),s=$i(r,i);s.tag=1,s.payload=e,n!=null&&(s.callback=n),e=zs(t,s,i),e!==null&&(Jr(e,t,i,r),Yd(e,t,i))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var n=zn(),r=js(t),i=$i(n,r);i.tag=2,e!=null&&(i.callback=e),e=zs(t,i,r),e!==null&&(Jr(e,t,r,n),Yd(e,t,r))}};function g_(t,e,n,r,i,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,s,o):e.prototype&&e.prototype.isPureReactComponent?!Vc(n,r)||!Vc(i,s):!0}function xE(t,e,n){var r=!1,i=$s,s=e.contextType;return typeof s=="object"&&s!==null?s=Dr(s):(i=Jn(e)?Uo:Dn.current,r=e.contextTypes,s=(r=r!=null)?pl(t,i):$s),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=ph,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=s),e}function v_(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&ph.enqueueReplaceState(e,e.state,null)}function _g(t,e,n,r){var i=t.stateNode;i.props=n,i.state=t.memoizedState,i.refs={},V0(t);var s=e.contextType;typeof s=="object"&&s!==null?i.context=Dr(s):(s=Jn(e)?Uo:Dn.current,i.context=pl(t,s)),i.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(xg(t,e,s,n),i.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(e=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),e!==i.state&&ph.enqueueReplaceState(i,i.state,null),Nf(t,n,i,r),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308)}function yl(t,e){try{var n="",r=e;do n+=RP(r),r=r.return;while(r);var i=n}catch(s){i=`
Error generating stack: `+s.message+`
`+s.stack}return{value:t,source:e,stack:i,digest:null}}function Rp(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function wg(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var nN=typeof WeakMap=="function"?WeakMap:Map;function _E(t,e,n){n=$i(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){Of||(Of=!0,Ng=r),wg(t,e)},n}function wE(t,e,n){n=$i(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){wg(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){wg(t,e),typeof r!="function"&&(Hs===null?Hs=new Set([this]):Hs.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function y_(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new nN;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=gN.bind(null,t,e,n),e.then(t,t))}function x_(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function __(t,e,n,r,i){return t.mode&1?(t.flags|=65536,t.lanes=i,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=$i(-1,1),e.tag=2,zs(n,e,1))),n.lanes|=1),t)}var rN=is.ReactCurrentOwner,Zn=!1;function Un(t,e,n,r){e.child=t===null?qb(e,null,n,r):gl(e,t.child,n,r)}function w_(t,e,n,r,i){n=n.render;var s=e.ref;return Ga(e,i),r=Y0(t,e,n,r,s,i),n=K0(),t!==null&&!Zn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Ji(t,e,i)):(Ot&&n&&O0(e),e.flags|=1,Un(t,e,r,i),e.child)}function S_(t,e,n,r,i){if(t===null){var s=n.type;return typeof s=="function"&&!sy(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,SE(t,e,s,r,i)):(t=ef(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,!(t.lanes&i)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:Vc,n(o,r)&&t.ref===e.ref)return Ji(t,e,i)}return e.flags|=1,t=Vs(s,r),t.ref=e.ref,t.return=e,e.child=t}function SE(t,e,n,r,i){if(t!==null){var s=t.memoizedProps;if(Vc(s,r)&&t.ref===e.ref)if(Zn=!1,e.pendingProps=r=s,(t.lanes&i)!==0)t.flags&131072&&(Zn=!0);else return e.lanes=t.lanes,Ji(t,e,i)}return Sg(t,e,n,r,i)}function ME(t,e,n){var r=e.pendingProps,i=r.children,s=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ct(Oa,ur),ur|=n;else{if(!(n&1073741824))return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,Ct(Oa,ur),ur|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,Ct(Oa,ur),ur|=r}else s!==null?(r=s.baseLanes|n,e.memoizedState=null):r=n,Ct(Oa,ur),ur|=r;return Un(t,e,i,n),e.child}function bE(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Sg(t,e,n,r,i){var s=Jn(n)?Uo:Dn.current;return s=pl(e,s),Ga(e,i),n=Y0(t,e,n,r,s,i),r=K0(),t!==null&&!Zn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Ji(t,e,i)):(Ot&&r&&O0(e),e.flags|=1,Un(t,e,n,i),e.child)}function M_(t,e,n,r,i){if(Jn(n)){var s=!0;Tf(e)}else s=!1;if(Ga(e,i),e.stateNode===null)Zd(t,e),xE(e,n,r),_g(e,n,r,i),r=!0;else if(t===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var l=o.context,c=n.contextType;typeof c=="object"&&c!==null?c=Dr(c):(c=Jn(n)?Uo:Dn.current,c=pl(e,c));var f=n.getDerivedStateFromProps,u=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";u||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==c)&&v_(e,o,r,c),Ss=!1;var d=e.memoizedState;o.state=d,Nf(e,r,o,i),l=e.memoizedState,a!==r||d!==l||Qn.current||Ss?(typeof f=="function"&&(xg(e,n,f,r),l=e.memoizedState),(a=Ss||g_(e,n,a,r,d,l,c))?(u||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),o.props=r,o.state=l,o.context=c,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,Qb(t,e),a=e.memoizedProps,c=e.type===e.elementType?a:Vr(e.type,a),o.props=c,u=e.pendingProps,d=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=Dr(l):(l=Jn(n)?Uo:Dn.current,l=pl(e,l));var h=n.getDerivedStateFromProps;(f=typeof h=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==u||d!==l)&&v_(e,o,r,l),Ss=!1,d=e.memoizedState,o.state=d,Nf(e,r,o,i);var m=e.memoizedState;a!==u||d!==m||Qn.current||Ss?(typeof h=="function"&&(xg(e,n,h,r),m=e.memoizedState),(c=Ss||g_(e,n,c,r,d,m,l)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,m,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,m,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=m),o.props=r,o.state=m,o.context=l,r=c):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),r=!1)}return Mg(t,e,n,r,s,i)}function Mg(t,e,n,r,i,s){bE(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&l_(e,n,!1),Ji(t,e,s);r=e.stateNode,rN.current=e;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=gl(e,t.child,null,s),e.child=gl(e,null,a,s)):Un(t,e,a,s),e.memoizedState=r.state,i&&l_(e,n,!0),e.child}function EE(t){var e=t.stateNode;e.pendingContext?a_(t,e.pendingContext,e.pendingContext!==e.context):e.context&&a_(t,e.context,!1),G0(t,e.containerInfo)}function b_(t,e,n,r,i){return ml(),U0(i),e.flags|=256,Un(t,e,n,r),e.child}var bg={dehydrated:null,treeContext:null,retryLane:0};function Eg(t){return{baseLanes:t,cachePool:null,transitions:null}}function TE(t,e,n){var r=e.pendingProps,i=Ft.current,s=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=t!==null&&t.memoizedState===null?!1:(i&2)!==0),a?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),Ct(Ft,i&1),t===null)return vg(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=r.children,t=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=vh(o,r,0,null),t=ko(t,r,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=Eg(n),e.memoizedState=bg,t):Q0(e,o));if(i=t.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return iN(t,e,o,r,a,i,n);if(s){s=r.fallback,o=e.mode,i=t.child,a=i.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=Vs(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=Vs(a,s):(s=ko(s,o,n,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=t.child.memoizedState,o=o===null?Eg(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=bg,r}return s=t.child,t=s.sibling,r=Vs(s,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function Q0(t,e){return e=vh({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function $u(t,e,n,r){return r!==null&&U0(r),gl(e,t.child,null,n),t=Q0(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function iN(t,e,n,r,i,s,o){if(n)return e.flags&256?(e.flags&=-257,r=Rp(Error(ce(422))),$u(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=vh({mode:"visible",children:r.children},i,0,null),s=ko(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,e.mode&1&&gl(e,t.child,null,o),e.child.memoizedState=Eg(o),e.memoizedState=bg,s);if(!(e.mode&1))return $u(t,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(ce(419)),r=Rp(s,r,void 0),$u(t,e,o,r)}if(a=(o&t.childLanes)!==0,Zn||a){if(r=fn,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,Qi(t,i),Jr(r,t,i,-1))}return iy(),r=Rp(Error(ce(421))),$u(t,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=vN.bind(null,t),i._reactRetry=e,null):(t=s.treeContext,fr=Bs(i.nextSibling),pr=e,Ot=!0,Yr=null,t!==null&&(Mr[br++]=ji,Mr[br++]=Vi,Mr[br++]=Bo,ji=t.id,Vi=t.overflow,Bo=e),e=Q0(e,r.children),e.flags|=4096,e)}function E_(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),yg(t.return,e,n)}function Pp(t,e,n,r,i){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function AE(t,e,n){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(Un(t,e,r.children,n),r=Ft.current,r&2)r=r&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&E_(t,n,e);else if(t.tag===19)E_(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(Ct(Ft,r),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(n=e.child,i=null;n!==null;)t=n.alternate,t!==null&&Df(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),Pp(e,!1,i,n,s);break;case"backwards":for(n=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&Df(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}Pp(e,!0,n,null,s);break;case"together":Pp(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Zd(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Ji(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Ho|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(ce(153));if(e.child!==null){for(t=e.child,n=Vs(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=Vs(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function sN(t,e,n){switch(e.tag){case 3:EE(e),ml();break;case 5:Jb(e);break;case 1:Jn(e.type)&&Tf(e);break;case 4:G0(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;Ct(Rf,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(Ct(Ft,Ft.current&1),e.flags|=128,null):n&e.child.childLanes?TE(t,e,n):(Ct(Ft,Ft.current&1),t=Ji(t,e,n),t!==null?t.sibling:null);Ct(Ft,Ft.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return AE(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ct(Ft,Ft.current),r)break;return null;case 22:case 23:return e.lanes=0,ME(t,e,n)}return Ji(t,e,n)}var CE,Tg,RE,PE;CE=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Tg=function(){};RE=function(t,e,n,r){var i=t.memoizedProps;if(i!==r){t=e.stateNode,Ro(xi.current);var s=null;switch(n){case"input":i=Ym(t,i),r=Ym(t,r),s=[];break;case"select":i=zt({},i,{value:void 0}),r=zt({},r,{value:void 0}),s=[];break;case"textarea":i=Zm(t,i),r=Zm(t,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=bf)}Jm(n,r);var o;n=null;for(c in i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&i[c]!=null)if(c==="style"){var a=i[c];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Oc.hasOwnProperty(c)?s||(s=[]):(s=s||[]).push(c,null));for(c in r){var l=r[c];if(a=i!=null?i[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(s||(s=[]),s.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(s=s||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(s=s||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Oc.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&Dt("scroll",t),s||a===l||(s=[])):(s=s||[]).push(c,l))}n&&(s=s||[]).push("style",n);var c=s;(e.updateQueue=c)&&(e.flags|=4)}};PE=function(t,e,n,r){n!==r&&(e.flags|=4)};function tc(t,e){if(!Ot)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function bn(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function oN(t,e,n){var r=e.pendingProps;switch(F0(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bn(e),null;case 1:return Jn(e.type)&&Ef(),bn(e),null;case 3:return r=e.stateNode,vl(),It(Qn),It(Dn),X0(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Wu(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Yr!==null&&(Ig(Yr),Yr=null))),Tg(t,e),bn(e),null;case 5:W0(e);var i=Ro(Yc.current);if(n=e.type,t!==null&&e.stateNode!=null)RE(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(ce(166));return bn(e),null}if(t=Ro(xi.current),Wu(e)){r=e.stateNode,n=e.type;var s=e.memoizedProps;switch(r[hi]=e,r[Xc]=s,t=(e.mode&1)!==0,n){case"dialog":Dt("cancel",r),Dt("close",r);break;case"iframe":case"object":case"embed":Dt("load",r);break;case"video":case"audio":for(i=0;i<xc.length;i++)Dt(xc[i],r);break;case"source":Dt("error",r);break;case"img":case"image":case"link":Dt("error",r),Dt("load",r);break;case"details":Dt("toggle",r);break;case"input":Ix(r,s),Dt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},Dt("invalid",r);break;case"textarea":Ox(r,s),Dt("invalid",r)}Jm(n,s),i=null;for(var o in s)if(s.hasOwnProperty(o)){var a=s[o];o==="children"?typeof a=="string"?r.textContent!==a&&(s.suppressHydrationWarning!==!0&&Gu(r.textContent,a,t),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(s.suppressHydrationWarning!==!0&&Gu(r.textContent,a,t),i=["children",""+a]):Oc.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&Dt("scroll",r)}switch(n){case"input":Ou(r),kx(r,s,!0);break;case"textarea":Ou(r),Fx(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=bf)}r=i,e.updateQueue=r,r!==null&&(e.flags|=4)}else{o=i.nodeType===9?i:i.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=ib(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=o.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[hi]=e,t[Xc]=r,CE(t,e,!1,!1),e.stateNode=t;e:{switch(o=eg(n,r),n){case"dialog":Dt("cancel",t),Dt("close",t),i=r;break;case"iframe":case"object":case"embed":Dt("load",t),i=r;break;case"video":case"audio":for(i=0;i<xc.length;i++)Dt(xc[i],t);i=r;break;case"source":Dt("error",t),i=r;break;case"img":case"image":case"link":Dt("error",t),Dt("load",t),i=r;break;case"details":Dt("toggle",t),i=r;break;case"input":Ix(t,r),i=Ym(t,r),Dt("invalid",t);break;case"option":i=r;break;case"select":t._wrapperState={wasMultiple:!!r.multiple},i=zt({},r,{value:void 0}),Dt("invalid",t);break;case"textarea":Ox(t,r),i=Zm(t,r),Dt("invalid",t);break;default:i=r}Jm(n,i),a=i;for(s in a)if(a.hasOwnProperty(s)){var l=a[s];s==="style"?ab(t,l):s==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&sb(t,l)):s==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&Fc(t,l):typeof l=="number"&&Fc(t,""+l):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Oc.hasOwnProperty(s)?l!=null&&s==="onScroll"&&Dt("scroll",t):l!=null&&S0(t,s,l,o))}switch(n){case"input":Ou(t),kx(t,r,!1);break;case"textarea":Ou(t),Fx(t);break;case"option":r.value!=null&&t.setAttribute("value",""+Xs(r.value));break;case"select":t.multiple=!!r.multiple,s=r.value,s!=null?za(t,!!r.multiple,s,!1):r.defaultValue!=null&&za(t,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(t.onclick=bf)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return bn(e),null;case 6:if(t&&e.stateNode!=null)PE(t,e,t.memoizedProps,r);else{if(typeof r!="string"&&e.stateNode===null)throw Error(ce(166));if(n=Ro(Yc.current),Ro(xi.current),Wu(e)){if(r=e.stateNode,n=e.memoizedProps,r[hi]=e,(s=r.nodeValue!==n)&&(t=pr,t!==null))switch(t.tag){case 3:Gu(r.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Gu(r.nodeValue,n,(t.mode&1)!==0)}s&&(e.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[hi]=e,e.stateNode=r}return bn(e),null;case 13:if(It(Ft),r=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Ot&&fr!==null&&e.mode&1&&!(e.flags&128))Yb(),ml(),e.flags|=98560,s=!1;else if(s=Wu(e),r!==null&&r.dehydrated!==null){if(t===null){if(!s)throw Error(ce(318));if(s=e.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(ce(317));s[hi]=e}else ml(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;bn(e),s=!1}else Yr!==null&&(Ig(Yr),Yr=null),s=!0;if(!s)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(r=r!==null,r!==(t!==null&&t.memoizedState!==null)&&r&&(e.child.flags|=8192,e.mode&1&&(t===null||Ft.current&1?sn===0&&(sn=3):iy())),e.updateQueue!==null&&(e.flags|=4),bn(e),null);case 4:return vl(),Tg(t,e),t===null&&Gc(e.stateNode.containerInfo),bn(e),null;case 10:return H0(e.type._context),bn(e),null;case 17:return Jn(e.type)&&Ef(),bn(e),null;case 19:if(It(Ft),s=e.memoizedState,s===null)return bn(e),null;if(r=(e.flags&128)!==0,o=s.rendering,o===null)if(r)tc(s,!1);else{if(sn!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(o=Df(t),o!==null){for(e.flags|=128,tc(s,!1),r=o.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),e.subtreeFlags=0,r=n,n=e.child;n!==null;)s=n,t=r,s.flags&=14680066,o=s.alternate,o===null?(s.childLanes=0,s.lanes=t,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=o.childLanes,s.lanes=o.lanes,s.child=o.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=o.memoizedProps,s.memoizedState=o.memoizedState,s.updateQueue=o.updateQueue,s.type=o.type,t=o.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return Ct(Ft,Ft.current&1|2),e.child}t=t.sibling}s.tail!==null&&Yt()>xl&&(e.flags|=128,r=!0,tc(s,!1),e.lanes=4194304)}else{if(!r)if(t=Df(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),tc(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Ot)return bn(e),null}else 2*Yt()-s.renderingStartTime>xl&&n!==1073741824&&(e.flags|=128,r=!0,tc(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Yt(),e.sibling=null,n=Ft.current,Ct(Ft,r?n&1|2:n&1),e):(bn(e),null);case 22:case 23:return ry(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?ur&1073741824&&(bn(e),e.subtreeFlags&6&&(e.flags|=8192)):bn(e),null;case 24:return null;case 25:return null}throw Error(ce(156,e.tag))}function aN(t,e){switch(F0(e),e.tag){case 1:return Jn(e.type)&&Ef(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return vl(),It(Qn),It(Dn),X0(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return W0(e),null;case 13:if(It(Ft),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(ce(340));ml()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return It(Ft),null;case 4:return vl(),null;case 10:return H0(e.type._context),null;case 22:case 23:return ry(),null;case 24:return null;default:return null}}var Yu=!1,Nn=!1,lN=typeof WeakSet=="function"?WeakSet:Set,Ae=null;function ka(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Vt(t,e,r)}else n.current=null}function Ag(t,e,n){try{n()}catch(r){Vt(t,e,r)}}var T_=!1;function cN(t,e){if(ug=wf,t=kb(),k0(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,c=0,f=0,u=t,d=null;t:for(;;){for(var h;u!==n||i!==0&&u.nodeType!==3||(a=o+i),u!==s||r!==0&&u.nodeType!==3||(l=o+r),u.nodeType===3&&(o+=u.nodeValue.length),(h=u.firstChild)!==null;)d=u,u=h;for(;;){if(u===t)break t;if(d===n&&++c===i&&(a=o),d===s&&++f===r&&(l=o),(h=u.nextSibling)!==null)break;u=d,d=u.parentNode}u=h}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(dg={focusedElem:t,selectionRange:n},wf=!1,Ae=e;Ae!==null;)if(e=Ae,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Ae=t;else for(;Ae!==null;){e=Ae;try{var m=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var v=m.memoizedProps,g=m.memoizedState,p=e.stateNode,x=p.getSnapshotBeforeUpdate(e.elementType===e.type?v:Vr(e.type,v),g);p.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var _=e.stateNode.containerInfo;_.nodeType===1?_.textContent="":_.nodeType===9&&_.documentElement&&_.removeChild(_.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ce(163))}}catch(w){Vt(e,e.return,w)}if(t=e.sibling,t!==null){t.return=e.return,Ae=t;break}Ae=e.return}return m=T_,T_=!1,m}function Pc(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&Ag(e,n,s)}i=i.next}while(i!==r)}}function mh(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function Cg(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function NE(t){var e=t.alternate;e!==null&&(t.alternate=null,NE(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[hi],delete e[Xc],delete e[pg],delete e[W2],delete e[X2])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function DE(t){return t.tag===5||t.tag===3||t.tag===4}function A_(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||DE(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.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 Rg(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=bf));else if(r!==4&&(t=t.child,t!==null))for(Rg(t,e,n),t=t.sibling;t!==null;)Rg(t,e,n),t=t.sibling}function Pg(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(Pg(t,e,n),t=t.sibling;t!==null;)Pg(t,e,n),t=t.sibling}var pn=null,$r=!1;function as(t,e,n){for(n=n.child;n!==null;)LE(t,e,n),n=n.sibling}function LE(t,e,n){if(yi&&typeof yi.onCommitFiberUnmount=="function")try{yi.onCommitFiberUnmount(ah,n)}catch{}switch(n.tag){case 5:Nn||ka(n,e);case 6:var r=pn,i=$r;pn=null,as(t,e,n),pn=r,$r=i,pn!==null&&($r?(t=pn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):pn.removeChild(n.stateNode));break;case 18:pn!==null&&($r?(t=pn,n=n.stateNode,t.nodeType===8?Mp(t.parentNode,n):t.nodeType===1&&Mp(t,n),Hc(t)):Mp(pn,n.stateNode));break;case 4:r=pn,i=$r,pn=n.stateNode.containerInfo,$r=!0,as(t,e,n),pn=r,$r=i;break;case 0:case 11:case 14:case 15:if(!Nn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Ag(n,e,o),i=i.next}while(i!==r)}as(t,e,n);break;case 1:if(!Nn&&(ka(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Vt(n,e,a)}as(t,e,n);break;case 21:as(t,e,n);break;case 22:n.mode&1?(Nn=(r=Nn)||n.memoizedState!==null,as(t,e,n),Nn=r):as(t,e,n);break;default:as(t,e,n)}}function C_(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new lN),e.forEach(function(r){var i=yN.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Fr(t,e){var n=e.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var s=t,o=e,a=o;e:for(;a!==null;){switch(a.tag){case 5:pn=a.stateNode,$r=!1;break e;case 3:pn=a.stateNode.containerInfo,$r=!0;break e;case 4:pn=a.stateNode.containerInfo,$r=!0;break e}a=a.return}if(pn===null)throw Error(ce(160));LE(s,o,i),pn=null,$r=!1;var l=i.alternate;l!==null&&(l.return=null),i.return=null}catch(c){Vt(i,e,c)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)IE(e,t),e=e.sibling}function IE(t,e){var n=t.alternate,r=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Fr(e,t),ai(t),r&4){try{Pc(3,t,t.return),mh(3,t)}catch(v){Vt(t,t.return,v)}try{Pc(5,t,t.return)}catch(v){Vt(t,t.return,v)}}break;case 1:Fr(e,t),ai(t),r&512&&n!==null&&ka(n,n.return);break;case 5:if(Fr(e,t),ai(t),r&512&&n!==null&&ka(n,n.return),t.flags&32){var i=t.stateNode;try{Fc(i,"")}catch(v){Vt(t,t.return,v)}}if(r&4&&(i=t.stateNode,i!=null)){var s=t.memoizedProps,o=n!==null?n.memoizedProps:s,a=t.type,l=t.updateQueue;if(t.updateQueue=null,l!==null)try{a==="input"&&s.type==="radio"&&s.name!=null&&nb(i,s),eg(a,o);var c=eg(a,s);for(o=0;o<l.length;o+=2){var f=l[o],u=l[o+1];f==="style"?ab(i,u):f==="dangerouslySetInnerHTML"?sb(i,u):f==="children"?Fc(i,u):S0(i,f,u,c)}switch(a){case"input":Km(i,s);break;case"textarea":rb(i,s);break;case"select":var d=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!s.multiple;var h=s.value;h!=null?za(i,!!s.multiple,h,!1):d!==!!s.multiple&&(s.defaultValue!=null?za(i,!!s.multiple,s.defaultValue,!0):za(i,!!s.multiple,s.multiple?[]:"",!1))}i[Xc]=s}catch(v){Vt(t,t.return,v)}}break;case 6:if(Fr(e,t),ai(t),r&4){if(t.stateNode===null)throw Error(ce(162));i=t.stateNode,s=t.memoizedProps;try{i.nodeValue=s}catch(v){Vt(t,t.return,v)}}break;case 3:if(Fr(e,t),ai(t),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Hc(e.containerInfo)}catch(v){Vt(t,t.return,v)}break;case 4:Fr(e,t),ai(t);break;case 13:Fr(e,t),ai(t),i=t.child,i.flags&8192&&(s=i.memoizedState!==null,i.stateNode.isHidden=s,!s||i.alternate!==null&&i.alternate.memoizedState!==null||(ty=Yt())),r&4&&C_(t);break;case 22:if(f=n!==null&&n.memoizedState!==null,t.mode&1?(Nn=(c=Nn)||f,Fr(e,t),Nn=c):Fr(e,t),ai(t),r&8192){if(c=t.memoizedState!==null,(t.stateNode.isHidden=c)&&!f&&t.mode&1)for(Ae=t,f=t.child;f!==null;){for(u=Ae=f;Ae!==null;){switch(d=Ae,h=d.child,d.tag){case 0:case 11:case 14:case 15:Pc(4,d,d.return);break;case 1:ka(d,d.return);var m=d.stateNode;if(typeof m.componentWillUnmount=="function"){r=d,n=d.return;try{e=r,m.props=e.memoizedProps,m.state=e.memoizedState,m.componentWillUnmount()}catch(v){Vt(r,n,v)}}break;case 5:ka(d,d.return);break;case 22:if(d.memoizedState!==null){P_(u);continue}}h!==null?(h.return=d,Ae=h):P_(u)}f=f.sibling}e:for(f=null,u=t;;){if(u.tag===5){if(f===null){f=u;try{i=u.stateNode,c?(s=i.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(a=u.stateNode,l=u.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=ob("display",o))}catch(v){Vt(t,t.return,v)}}}else if(u.tag===6){if(f===null)try{u.stateNode.nodeValue=c?"":u.memoizedProps}catch(v){Vt(t,t.return,v)}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===t)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===t)break e;for(;u.sibling===null;){if(u.return===null||u.return===t)break e;f===u&&(f=null),u=u.return}f===u&&(f=null),u.sibling.return=u.return,u=u.sibling}}break;case 19:Fr(e,t),ai(t),r&4&&C_(t);break;case 21:break;default:Fr(e,t),ai(t)}}function ai(t){var e=t.flags;if(e&2){try{e:{for(var n=t.return;n!==null;){if(DE(n)){var r=n;break e}n=n.return}throw Error(ce(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Fc(i,""),r.flags&=-33);var s=A_(t);Pg(t,s,i);break;case 3:case 4:var o=r.stateNode.containerInfo,a=A_(t);Rg(t,a,o);break;default:throw Error(ce(161))}}catch(l){Vt(t,t.return,l)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function uN(t,e,n){Ae=t,kE(t)}function kE(t,e,n){for(var r=(t.mode&1)!==0;Ae!==null;){var i=Ae,s=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||Yu;if(!o){var a=i.alternate,l=a!==null&&a.memoizedState!==null||Nn;a=Yu;var c=Nn;if(Yu=o,(Nn=l)&&!c)for(Ae=i;Ae!==null;)o=Ae,l=o.child,o.tag===22&&o.memoizedState!==null?N_(i):l!==null?(l.return=o,Ae=l):N_(i);for(;s!==null;)Ae=s,kE(s),s=s.sibling;Ae=i,Yu=a,Nn=c}R_(t)}else i.subtreeFlags&8772&&s!==null?(s.return=i,Ae=s):R_(t)}}function R_(t){for(;Ae!==null;){var e=Ae;if(e.flags&8772){var n=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Nn||mh(5,e);break;case 1:var r=e.stateNode;if(e.flags&4&&!Nn)if(n===null)r.componentDidMount();else{var i=e.elementType===e.type?n.memoizedProps:Vr(e.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=e.updateQueue;s!==null&&h_(e,s,r);break;case 3:var o=e.updateQueue;if(o!==null){if(n=null,e.child!==null)switch(e.child.tag){case 5:n=e.child.stateNode;break;case 1:n=e.child.stateNode}h_(e,o,n)}break;case 5:var a=e.stateNode;if(n===null&&e.flags&4){n=a;var l=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var c=e.alternate;if(c!==null){var f=c.memoizedState;if(f!==null){var u=f.dehydrated;u!==null&&Hc(u)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(ce(163))}Nn||e.flags&512&&Cg(e)}catch(d){Vt(e,e.return,d)}}if(e===t){Ae=null;break}if(n=e.sibling,n!==null){n.return=e.return,Ae=n;break}Ae=e.return}}function P_(t){for(;Ae!==null;){var e=Ae;if(e===t){Ae=null;break}var n=e.sibling;if(n!==null){n.return=e.return,Ae=n;break}Ae=e.return}}function N_(t){for(;Ae!==null;){var e=Ae;try{switch(e.tag){case 0:case 11:case 15:var n=e.return;try{mh(4,e)}catch(l){Vt(e,n,l)}break;case 1:var r=e.stateNode;if(typeof r.componentDidMount=="function"){var i=e.return;try{r.componentDidMount()}catch(l){Vt(e,i,l)}}var s=e.return;try{Cg(e)}catch(l){Vt(e,s,l)}break;case 5:var o=e.return;try{Cg(e)}catch(l){Vt(e,o,l)}}}catch(l){Vt(e,e.return,l)}if(e===t){Ae=null;break}var a=e.sibling;if(a!==null){a.return=e.return,Ae=a;break}Ae=e.return}}var dN=Math.ceil,kf=is.ReactCurrentDispatcher,J0=is.ReactCurrentOwner,Rr=is.ReactCurrentBatchConfig,mt=0,fn=null,Jt=null,yn=0,ur=0,Oa=io(0),sn=0,Qc=null,Ho=0,gh=0,ey=0,Nc=null,qn=null,ty=0,xl=1/0,Ui=null,Of=!1,Ng=null,Hs=null,Ku=!1,Ls=null,Ff=0,Dc=0,Dg=null,Qd=-1,Jd=0;function zn(){return mt&6?Yt():Qd!==-1?Qd:Qd=Yt()}function js(t){return t.mode&1?mt&2&&yn!==0?yn&-yn:Y2.transition!==null?(Jd===0&&(Jd=xb()),Jd):(t=St,t!==0||(t=window.event,t=t===void 0?16:Tb(t.type)),t):1}function Jr(t,e,n,r){if(50<Dc)throw Dc=0,Dg=null,Error(ce(185));xu(t,n,r),(!(mt&2)||t!==fn)&&(t===fn&&(!(mt&2)&&(gh|=n),sn===4&&Es(t,yn)),er(t,r),n===1&&mt===0&&!(e.mode&1)&&(xl=Yt()+500,fh&&so()))}function er(t,e){var n=t.callbackNode;YP(t,e);var r=_f(t,t===fn?yn:0);if(r===0)n!==null&&zx(n),t.callbackNode=null,t.callbackPriority=0;else if(e=r&-r,t.callbackPriority!==e){if(n!=null&&zx(n),e===1)t.tag===0?$2(D_.bind(null,t)):Wb(D_.bind(null,t)),V2(function(){!(mt&6)&&so()}),n=null;else{switch(_b(r)){case 1:n=A0;break;case 4:n=vb;break;case 16:n=xf;break;case 536870912:n=yb;break;default:n=xf}n=VE(n,OE.bind(null,t))}t.callbackPriority=e,t.callbackNode=n}}function OE(t,e){if(Qd=-1,Jd=0,mt&6)throw Error(ce(327));var n=t.callbackNode;if(Wa()&&t.callbackNode!==n)return null;var r=_f(t,t===fn?yn:0);if(r===0)return null;if(r&30||r&t.expiredLanes||e)e=Uf(t,r);else{e=r;var i=mt;mt|=2;var s=UE();(fn!==t||yn!==e)&&(Ui=null,xl=Yt()+500,Io(t,e));do try{pN();break}catch(a){FE(t,a)}while(!0);z0(),kf.current=s,mt=i,Jt!==null?e=0:(fn=null,yn=0,e=sn)}if(e!==0){if(e===2&&(i=sg(t),i!==0&&(r=i,e=Lg(t,i))),e===1)throw n=Qc,Io(t,0),Es(t,r),er(t,Yt()),n;if(e===6)Es(t,r);else{if(i=t.current.alternate,!(r&30)&&!fN(i)&&(e=Uf(t,r),e===2&&(s=sg(t),s!==0&&(r=s,e=Lg(t,s))),e===1))throw n=Qc,Io(t,0),Es(t,r),er(t,Yt()),n;switch(t.finishedWork=i,t.finishedLanes=r,e){case 0:case 1:throw Error(ce(345));case 2:_o(t,qn,Ui);break;case 3:if(Es(t,r),(r&130023424)===r&&(e=ty+500-Yt(),10<e)){if(_f(t,0)!==0)break;if(i=t.suspendedLanes,(i&r)!==r){zn(),t.pingedLanes|=t.suspendedLanes&i;break}t.timeoutHandle=hg(_o.bind(null,t,qn,Ui),e);break}_o(t,qn,Ui);break;case 4:if(Es(t,r),(r&4194240)===r)break;for(e=t.eventTimes,i=-1;0<r;){var o=31-Qr(r);s=1<<o,o=e[o],o>i&&(i=o),r&=~s}if(r=i,r=Yt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*dN(r/1960))-r,10<r){t.timeoutHandle=hg(_o.bind(null,t,qn,Ui),r);break}_o(t,qn,Ui);break;case 5:_o(t,qn,Ui);break;default:throw Error(ce(329))}}}return er(t,Yt()),t.callbackNode===n?OE.bind(null,t):null}function Lg(t,e){var n=Nc;return t.current.memoizedState.isDehydrated&&(Io(t,e).flags|=256),t=Uf(t,e),t!==2&&(e=qn,qn=n,e!==null&&Ig(e)),t}function Ig(t){qn===null?qn=t:qn.push.apply(qn,t)}function fN(t){for(var e=t;;){if(e.flags&16384){var n=e.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],s=i.getSnapshot;i=i.value;try{if(!ti(s(),i))return!1}catch{return!1}}}if(n=e.child,e.subtreeFlags&16384&&n!==null)n.return=e,e=n;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function Es(t,e){for(e&=~ey,e&=~gh,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var n=31-Qr(e),r=1<<n;t[n]=-1,e&=~r}}function D_(t){if(mt&6)throw Error(ce(327));Wa();var e=_f(t,0);if(!(e&1))return er(t,Yt()),null;var n=Uf(t,e);if(t.tag!==0&&n===2){var r=sg(t);r!==0&&(e=r,n=Lg(t,r))}if(n===1)throw n=Qc,Io(t,0),Es(t,e),er(t,Yt()),n;if(n===6)throw Error(ce(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,_o(t,qn,Ui),er(t,Yt()),null}function ny(t,e){var n=mt;mt|=1;try{return t(e)}finally{mt=n,mt===0&&(xl=Yt()+500,fh&&so())}}function jo(t){Ls!==null&&Ls.tag===0&&!(mt&6)&&Wa();var e=mt;mt|=1;var n=Rr.transition,r=St;try{if(Rr.transition=null,St=1,t)return t()}finally{St=r,Rr.transition=n,mt=e,!(mt&6)&&so()}}function ry(){ur=Oa.current,It(Oa)}function Io(t,e){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,j2(n)),Jt!==null)for(n=Jt.return;n!==null;){var r=n;switch(F0(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ef();break;case 3:vl(),It(Qn),It(Dn),X0();break;case 5:W0(r);break;case 4:vl();break;case 13:It(Ft);break;case 19:It(Ft);break;case 10:H0(r.type._context);break;case 22:case 23:ry()}n=n.return}if(fn=t,Jt=t=Vs(t.current,null),yn=ur=e,sn=0,Qc=null,ey=gh=Ho=0,qn=Nc=null,Co!==null){for(e=0;e<Co.length;e++)if(n=Co[e],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,s=n.pending;if(s!==null){var o=s.next;s.next=i,r.next=o}n.pending=r}Co=null}return t}function FE(t,e){do{var n=Jt;try{if(z0(),Kd.current=If,Lf){for(var r=Bt.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}Lf=!1}if(zo=0,un=tn=Bt=null,Rc=!1,Kc=0,J0.current=null,n===null||n.return===null){sn=1,Qc=e,Jt=null;break}e:{var s=t,o=n.return,a=n,l=e;if(e=yn,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,f=a,u=f.tag;if(!(f.mode&1)&&(u===0||u===11||u===15)){var d=f.alternate;d?(f.updateQueue=d.updateQueue,f.memoizedState=d.memoizedState,f.lanes=d.lanes):(f.updateQueue=null,f.memoizedState=null)}var h=x_(o);if(h!==null){h.flags&=-257,__(h,o,a,s,e),h.mode&1&&y_(s,c,e),e=h,l=c;var m=e.updateQueue;if(m===null){var v=new Set;v.add(l),e.updateQueue=v}else m.add(l);break e}else{if(!(e&1)){y_(s,c,e),iy();break e}l=Error(ce(426))}}else if(Ot&&a.mode&1){var g=x_(o);if(g!==null){!(g.flags&65536)&&(g.flags|=256),__(g,o,a,s,e),U0(yl(l,a));break e}}s=l=yl(l,a),sn!==4&&(sn=2),Nc===null?Nc=[s]:Nc.push(s),s=o;do{switch(s.tag){case 3:s.flags|=65536,e&=-e,s.lanes|=e;var p=_E(s,l,e);f_(s,p);break e;case 1:a=l;var x=s.type,_=s.stateNode;if(!(s.flags&128)&&(typeof x.getDerivedStateFromError=="function"||_!==null&&typeof _.componentDidCatch=="function"&&(Hs===null||!Hs.has(_)))){s.flags|=65536,e&=-e,s.lanes|=e;var w=wE(s,a,e);f_(s,w);break e}}s=s.return}while(s!==null)}zE(n)}catch(M){e=M,Jt===n&&n!==null&&(Jt=n=n.return);continue}break}while(!0)}function UE(){var t=kf.current;return kf.current=If,t===null?If:t}function iy(){(sn===0||sn===3||sn===2)&&(sn=4),fn===null||!(Ho&268435455)&&!(gh&268435455)||Es(fn,yn)}function Uf(t,e){var n=mt;mt|=2;var r=UE();(fn!==t||yn!==e)&&(Ui=null,Io(t,e));do try{hN();break}catch(i){FE(t,i)}while(!0);if(z0(),mt=n,kf.current=r,Jt!==null)throw Error(ce(261));return fn=null,yn=0,sn}function hN(){for(;Jt!==null;)BE(Jt)}function pN(){for(;Jt!==null&&!BP();)BE(Jt)}function BE(t){var e=jE(t.alternate,t,ur);t.memoizedProps=t.pendingProps,e===null?zE(t):Jt=e,J0.current=null}function zE(t){var e=t;do{var n=e.alternate;if(t=e.return,e.flags&32768){if(n=aN(n,e),n!==null){n.flags&=32767,Jt=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{sn=6,Jt=null;return}}else if(n=oN(n,e,ur),n!==null){Jt=n;return}if(e=e.sibling,e!==null){Jt=e;return}Jt=e=t}while(e!==null);sn===0&&(sn=5)}function _o(t,e,n){var r=St,i=Rr.transition;try{Rr.transition=null,St=1,mN(t,e,n,r)}finally{Rr.transition=i,St=r}return null}function mN(t,e,n,r){do Wa();while(Ls!==null);if(mt&6)throw Error(ce(327));n=t.finishedWork;var i=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(ce(177));t.callbackNode=null,t.callbackPriority=0;var s=n.lanes|n.childLanes;if(KP(t,s),t===fn&&(Jt=fn=null,yn=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ku||(Ku=!0,VE(xf,function(){return Wa(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=Rr.transition,Rr.transition=null;var o=St;St=1;var a=mt;mt|=4,J0.current=null,cN(t,n),IE(n,t),k2(dg),wf=!!ug,dg=ug=null,t.current=n,uN(n),zP(),mt=a,St=o,Rr.transition=s}else t.current=n;if(Ku&&(Ku=!1,Ls=t,Ff=i),s=t.pendingLanes,s===0&&(Hs=null),VP(n.stateNode),er(t,Yt()),e!==null)for(r=t.onRecoverableError,n=0;n<e.length;n++)i=e[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(Of)throw Of=!1,t=Ng,Ng=null,t;return Ff&1&&t.tag!==0&&Wa(),s=t.pendingLanes,s&1?t===Dg?Dc++:(Dc=0,Dg=t):Dc=0,so(),null}function Wa(){if(Ls!==null){var t=_b(Ff),e=Rr.transition,n=St;try{if(Rr.transition=null,St=16>t?16:t,Ls===null)var r=!1;else{if(t=Ls,Ls=null,Ff=0,mt&6)throw Error(ce(331));var i=mt;for(mt|=4,Ae=t.current;Ae!==null;){var s=Ae,o=s.child;if(Ae.flags&16){var a=s.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(Ae=c;Ae!==null;){var f=Ae;switch(f.tag){case 0:case 11:case 15:Pc(8,f,s)}var u=f.child;if(u!==null)u.return=f,Ae=u;else for(;Ae!==null;){f=Ae;var d=f.sibling,h=f.return;if(NE(f),f===c){Ae=null;break}if(d!==null){d.return=h,Ae=d;break}Ae=h}}}var m=s.alternate;if(m!==null){var v=m.child;if(v!==null){m.child=null;do{var g=v.sibling;v.sibling=null,v=g}while(v!==null)}}Ae=s}}if(s.subtreeFlags&2064&&o!==null)o.return=s,Ae=o;else e:for(;Ae!==null;){if(s=Ae,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Pc(9,s,s.return)}var p=s.sibling;if(p!==null){p.return=s.return,Ae=p;break e}Ae=s.return}}var x=t.current;for(Ae=x;Ae!==null;){o=Ae;var _=o.child;if(o.subtreeFlags&2064&&_!==null)_.return=o,Ae=_;else e:for(o=x;Ae!==null;){if(a=Ae,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:mh(9,a)}}catch(M){Vt(a,a.return,M)}if(a===o){Ae=null;break e}var w=a.sibling;if(w!==null){w.return=a.return,Ae=w;break e}Ae=a.return}}if(mt=i,so(),yi&&typeof yi.onPostCommitFiberRoot=="function")try{yi.onPostCommitFiberRoot(ah,t)}catch{}r=!0}return r}finally{St=n,Rr.transition=e}}return!1}function L_(t,e,n){e=yl(n,e),e=_E(t,e,1),t=zs(t,e,1),e=zn(),t!==null&&(xu(t,1,e),er(t,e))}function Vt(t,e,n){if(t.tag===3)L_(t,t,n);else for(;e!==null;){if(e.tag===3){L_(e,t,n);break}else if(e.tag===1){var r=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Hs===null||!Hs.has(r))){t=yl(n,t),t=wE(e,t,1),e=zs(e,t,1),t=zn(),e!==null&&(xu(e,1,t),er(e,t));break}}e=e.return}}function gN(t,e,n){var r=t.pingCache;r!==null&&r.delete(e),e=zn(),t.pingedLanes|=t.suspendedLanes&n,fn===t&&(yn&n)===n&&(sn===4||sn===3&&(yn&130023424)===yn&&500>Yt()-ty?Io(t,0):ey|=n),er(t,e)}function HE(t,e){e===0&&(t.mode&1?(e=Bu,Bu<<=1,!(Bu&130023424)&&(Bu=4194304)):e=1);var n=zn();t=Qi(t,e),t!==null&&(xu(t,e,n),er(t,n))}function vN(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),HE(t,n)}function yN(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(ce(314))}r!==null&&r.delete(e),HE(t,n)}var jE;jE=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Qn.current)Zn=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Zn=!1,sN(t,e,n);Zn=!!(t.flags&131072)}else Zn=!1,Ot&&e.flags&1048576&&Xb(e,Cf,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Zd(t,e),t=e.pendingProps;var i=pl(e,Dn.current);Ga(e,n),i=Y0(null,e,r,t,i,n);var s=K0();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Jn(r)?(s=!0,Tf(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,V0(e),i.updater=ph,e.stateNode=i,i._reactInternals=e,_g(e,r,t,n),e=Mg(null,e,r,!0,s,n)):(e.tag=0,Ot&&s&&O0(e),Un(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Zd(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=_N(r),t=Vr(r,t),i){case 0:e=Sg(null,e,r,t,n);break e;case 1:e=M_(null,e,r,t,n);break e;case 11:e=w_(null,e,r,t,n);break e;case 14:e=S_(null,e,r,Vr(r.type,t),n);break e}throw Error(ce(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Vr(r,i),Sg(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Vr(r,i),M_(t,e,r,i,n);case 3:e:{if(EE(e),t===null)throw Error(ce(387));r=e.pendingProps,s=e.memoizedState,i=s.element,Qb(t,e),Nf(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=yl(Error(ce(423)),e),e=b_(t,e,r,n,i);break e}else if(r!==i){i=yl(Error(ce(424)),e),e=b_(t,e,r,n,i);break e}else for(fr=Bs(e.stateNode.containerInfo.firstChild),pr=e,Ot=!0,Yr=null,n=qb(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ml(),r===i){e=Ji(t,e,n);break e}Un(t,e,r,n)}e=e.child}return e;case 5:return Jb(e),t===null&&vg(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,fg(r,i)?o=null:s!==null&&fg(r,s)&&(e.flags|=32),bE(t,e),Un(t,e,o,n),e.child;case 6:return t===null&&vg(e),null;case 13:return TE(t,e,n);case 4:return G0(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=gl(e,null,r,n):Un(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Vr(r,i),w_(t,e,r,i,n);case 7:return Un(t,e,e.pendingProps,n),e.child;case 8:return Un(t,e,e.pendingProps.children,n),e.child;case 12:return Un(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,Ct(Rf,r._currentValue),r._currentValue=o,s!==null)if(ti(s.value,o)){if(s.children===i.children&&!Qn.current){e=Ji(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=$i(-1,n&-n),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var f=c.pending;f===null?l.next=l:(l.next=f.next,f.next=l),c.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),yg(s.return,n,e),a.lanes|=n;break}l=l.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(ce(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),yg(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}Un(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Ga(e,n),i=Dr(i),r=r(i),e.flags|=1,Un(t,e,r,n),e.child;case 14:return r=e.type,i=Vr(r,e.pendingProps),i=Vr(r.type,i),S_(t,e,r,i,n);case 15:return SE(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Vr(r,i),Zd(t,e),e.tag=1,Jn(r)?(t=!0,Tf(e)):t=!1,Ga(e,n),xE(e,r,i),_g(e,r,i,n),Mg(null,e,r,!0,t,n);case 19:return AE(t,e,n);case 22:return ME(t,e,n)}throw Error(ce(156,e.tag))};function VE(t,e){return gb(t,e)}function xN(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ar(t,e,n,r){return new xN(t,e,n,r)}function sy(t){return t=t.prototype,!(!t||!t.isReactComponent)}function _N(t){if(typeof t=="function")return sy(t)?1:0;if(t!=null){if(t=t.$$typeof,t===b0)return 11;if(t===E0)return 14}return 2}function Vs(t,e){var n=t.alternate;return n===null?(n=Ar(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function ef(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")sy(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Ta:return ko(n.children,i,s,e);case M0:o=8,i|=8;break;case Gm:return t=Ar(12,n,e,i|2),t.elementType=Gm,t.lanes=s,t;case Wm:return t=Ar(13,n,e,i),t.elementType=Wm,t.lanes=s,t;case Xm:return t=Ar(19,n,e,i),t.elementType=Xm,t.lanes=s,t;case JM:return vh(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ZM:o=10;break e;case QM:o=9;break e;case b0:o=11;break e;case E0:o=14;break e;case ws:o=16,r=null;break e}throw Error(ce(130,t==null?t:typeof t,""))}return e=Ar(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function ko(t,e,n,r){return t=Ar(7,t,r,e),t.lanes=n,t}function vh(t,e,n,r){return t=Ar(22,t,r,e),t.elementType=JM,t.lanes=n,t.stateNode={isHidden:!1},t}function Np(t,e,n){return t=Ar(6,t,null,e),t.lanes=n,t}function Dp(t,e,n){return e=Ar(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function wN(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=fp(0),this.expirationTimes=fp(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fp(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function oy(t,e,n,r,i,s,o,a,l){return t=new wN(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Ar(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},V0(s),t}function SN(t,e,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ea,key:r==null?null:""+r,children:t,containerInfo:e,implementation:n}}function GE(t){if(!t)return $s;t=t._reactInternals;e:{if(Qo(t)!==t||t.tag!==1)throw Error(ce(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(Jn(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(ce(171))}if(t.tag===1){var n=t.type;if(Jn(n))return Gb(t,n,e)}return e}function WE(t,e,n,r,i,s,o,a,l){return t=oy(n,r,!0,t,i,s,o,a,l),t.context=GE(null),n=t.current,r=zn(),i=js(n),s=$i(r,i),s.callback=e??null,zs(n,s,i),t.current.lanes=i,xu(t,i,r),er(t,r),t}function yh(t,e,n,r){var i=e.current,s=zn(),o=js(i);return n=GE(n),e.context===null?e.context=n:e.pendingContext=n,e=$i(s,o),e.payload={element:t},r=r===void 0?null:r,r!==null&&(e.callback=r),t=zs(i,e,o),t!==null&&(Jr(t,i,o,s),Yd(t,i,o)),o}function Bf(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function I_(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<e?n:e}}function ay(t,e){I_(t,e),(t=t.alternate)&&I_(t,e)}function MN(){return null}var XE=typeof reportError=="function"?reportError:function(t){console.error(t)};function ly(t){this._internalRoot=t}xh.prototype.render=ly.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(ce(409));yh(t,e,null,null)};xh.prototype.unmount=ly.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;jo(function(){yh(null,t,null,null)}),e[Zi]=null}};function xh(t){this._internalRoot=t}xh.prototype.unstable_scheduleHydration=function(t){if(t){var e=Mb();t={blockedOn:null,target:t,priority:e};for(var n=0;n<bs.length&&e!==0&&e<bs[n].priority;n++);bs.splice(n,0,t),n===0&&Eb(t)}};function cy(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function _h(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function k_(){}function bN(t,e,n,r,i){if(i){if(typeof r=="function"){var s=r;r=function(){var c=Bf(o);s.call(c)}}var o=WE(e,r,t,0,null,!1,!1,"",k_);return t._reactRootContainer=o,t[Zi]=o.current,Gc(t.nodeType===8?t.parentNode:t),jo(),o}for(;i=t.lastChild;)t.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var c=Bf(l);a.call(c)}}var l=oy(t,0,!1,null,null,!1,!1,"",k_);return t._reactRootContainer=l,t[Zi]=l.current,Gc(t.nodeType===8?t.parentNode:t),jo(function(){yh(e,l,n,r)}),l}function wh(t,e,n,r,i){var s=n._reactRootContainer;if(s){var o=s;if(typeof i=="function"){var a=i;i=function(){var l=Bf(o);a.call(l)}}yh(e,o,t,i)}else o=bN(n,e,t,i,r);return Bf(o)}wb=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var n=yc(e.pendingLanes);n!==0&&(C0(e,n|1),er(e,Yt()),!(mt&6)&&(xl=Yt()+500,so()))}break;case 13:jo(function(){var r=Qi(t,1);if(r!==null){var i=zn();Jr(r,t,1,i)}}),ay(t,1)}};R0=function(t){if(t.tag===13){var e=Qi(t,134217728);if(e!==null){var n=zn();Jr(e,t,134217728,n)}ay(t,134217728)}};Sb=function(t){if(t.tag===13){var e=js(t),n=Qi(t,e);if(n!==null){var r=zn();Jr(n,t,e,r)}ay(t,e)}};Mb=function(){return St};bb=function(t,e){var n=St;try{return St=t,e()}finally{St=n}};ng=function(t,e,n){switch(e){case"input":if(Km(t,n),e=n.name,n.type==="radio"&&e!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<n.length;e++){var r=n[e];if(r!==t&&r.form===t.form){var i=dh(r);if(!i)throw Error(ce(90));tb(r),Km(r,i)}}}break;case"textarea":rb(t,n);break;case"select":e=n.value,e!=null&&za(t,!!n.multiple,e,!1)}};ub=ny;db=jo;var EN={usingClientEntryPoint:!1,Events:[wu,Pa,dh,lb,cb,ny]},nc={findFiberByHostInstance:Ao,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},TN={bundleType:nc.bundleType,version:nc.version,rendererPackageName:nc.rendererPackageName,rendererConfig:nc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:is.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=pb(t),t===null?null:t.stateNode},findFiberByHostInstance:nc.findFiberByHostInstance||MN,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var qu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!qu.isDisabled&&qu.supportsFiber)try{ah=qu.inject(TN),yi=qu}catch{}}vr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=EN;vr.createPortal=function(t,e){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!cy(e))throw Error(ce(200));return SN(t,e,null,n)};vr.createRoot=function(t,e){if(!cy(t))throw Error(ce(299));var n=!1,r="",i=XE;return e!=null&&(e.unstable_strictMode===!0&&(n=!0),e.identifierPrefix!==void 0&&(r=e.identifierPrefix),e.onRecoverableError!==void 0&&(i=e.onRecoverableError)),e=oy(t,1,!1,null,null,n,!1,r,i),t[Zi]=e.current,Gc(t.nodeType===8?t.parentNode:t),new ly(e)};vr.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(ce(188)):(t=Object.keys(t).join(","),Error(ce(268,t)));return t=pb(e),t=t===null?null:t.stateNode,t};vr.flushSync=function(t){return jo(t)};vr.hydrate=function(t,e,n){if(!_h(e))throw Error(ce(200));return wh(null,t,e,!0,n)};vr.hydrateRoot=function(t,e,n){if(!cy(t))throw Error(ce(405));var r=n!=null&&n.hydratedSources||null,i=!1,s="",o=XE;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),e=WE(e,null,t,1,n??null,i,!1,s,o),t[Zi]=e.current,Gc(t),r)for(t=0;t<r.length;t++)n=r[t],i=n._getVersion,i=i(n._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[n,i]:e.mutableSourceEagerHydrationData.push(n,i);return new xh(e)};vr.render=function(t,e,n){if(!_h(e))throw Error(ce(200));return wh(null,t,e,!1,n)};vr.unmountComponentAtNode=function(t){if(!_h(t))throw Error(ce(40));return t._reactRootContainer?(jo(function(){wh(null,null,t,!1,function(){t._reactRootContainer=null,t[Zi]=null})}),!0):!1};vr.unstable_batchedUpdates=ny;vr.unstable_renderSubtreeIntoContainer=function(t,e,n,r){if(!_h(n))throw Error(ce(200));if(t==null||t._reactInternals===void 0)throw Error(ce(38));return wh(t,e,n,!1,r)};vr.version="18.3.1-next-f1338f8080-20240426";function $E(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($E)}catch(t){console.error(t)}}$E(),$M.exports=vr;var Jo=$M.exports;const YE=IM(Jo);var KE,O_=Jo;KE=O_.createRoot,O_.hydrateRoot;const AN=1,CN=1e6;let Lp=0;function RN(){return Lp=(Lp+1)%Number.MAX_SAFE_INTEGER,Lp.toString()}const Ip=new Map,F_=t=>{if(Ip.has(t))return;const e=setTimeout(()=>{Ip.delete(t),Lc({type:"REMOVE_TOAST",toastId:t})},CN);Ip.set(t,e)},PN=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,AN)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===e.toast.id?{...n,...e.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=e;return n?F_(n):t.toasts.forEach(r=>{F_(r.id)}),{...t,toasts:t.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==e.toastId)}}},tf=[];let nf={toasts:[]};function Lc(t){nf=PN(nf,t),tf.forEach(e=>{e(nf)})}function NN({...t}){const e=RN(),n=i=>Lc({type:"UPDATE_TOAST",toast:{...i,id:e}}),r=()=>Lc({type:"DISMISS_TOAST",toastId:e});return Lc({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:i=>{i||r()}}}),{id:e,dismiss:r,update:n}}function uy(){const[t,e]=S.useState(nf);return S.useEffect(()=>(tf.push(e),()=>{const n=tf.indexOf(e);n>-1&&tf.splice(n,1)}),[t]),{...t,toast:NN,dismiss:n=>Lc({type:"DISMISS_TOAST",toastId:n})}}function Ne(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t==null||t(i),n===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function DN(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function qE(...t){return e=>t.forEach(n=>DN(n,e))}function dt(...t){return S.useCallback(qE(...t),t)}function LN(t,e=[]){let n=[];function r(s,o){const a=S.createContext(o),l=n.length;n=[...n,o];function c(u){const{scope:d,children:h,...m}=u,v=(d==null?void 0:d[t][l])||a,g=S.useMemo(()=>m,Object.values(m));return y.jsx(v.Provider,{value:g,children:h})}function f(u,d){const h=(d==null?void 0:d[t][l])||a,m=S.useContext(h);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${u}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,f]}const i=()=>{const s=n.map(o=>S.createContext(o));return function(a){const l=(a==null?void 0:a[t])||s;return S.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[r,IN(i,...e)]}function IN(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const u=l(s)[`__scope${c}`];return{...a,...u}},{});return S.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var _l=S.forwardRef((t,e)=>{const{children:n,...r}=t,i=S.Children.toArray(n),s=i.find(kN);if(s){const o=s.props.children,a=i.map(l=>l===s?S.Children.count(o)>1?S.Children.only(null):S.isValidElement(o)?o.props.children:null:l);return y.jsx(kg,{...r,ref:e,children:S.isValidElement(o)?S.cloneElement(o,void 0,a):null})}return y.jsx(kg,{...r,ref:e,children:n})});_l.displayName="Slot";var kg=S.forwardRef((t,e)=>{const{children:n,...r}=t;if(S.isValidElement(n)){const i=FN(n);return S.cloneElement(n,{...ON(r,n.props),ref:e?qE(e,i):i})}return S.Children.count(n)>1?S.Children.only(null):null});kg.displayName="SlotClone";var ZE=({children:t})=>y.jsx(y.Fragment,{children:t});function kN(t){return S.isValidElement(t)&&t.type===ZE}function ON(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{s(...a),i(...a)}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function FN(t){var r,i;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Sh(t){const e=t+"CollectionProvider",[n,r]=LN(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=h=>{const{scope:m,children:v}=h,g=he.useRef(null),p=he.useRef(new Map).current;return y.jsx(i,{scope:m,itemMap:p,collectionRef:g,children:v})};o.displayName=e;const a=t+"CollectionSlot",l=he.forwardRef((h,m)=>{const{scope:v,children:g}=h,p=s(a,v),x=dt(m,p.collectionRef);return y.jsx(_l,{ref:x,children:g})});l.displayName=a;const c=t+"CollectionItemSlot",f="data-radix-collection-item",u=he.forwardRef((h,m)=>{const{scope:v,children:g,...p}=h,x=he.useRef(null),_=dt(m,x),w=s(c,v);return he.useEffect(()=>(w.itemMap.set(x,{ref:x,...p}),()=>void w.itemMap.delete(x))),y.jsx(_l,{[f]:"",ref:_,children:g})});u.displayName=c;function d(h){const m=s(t+"CollectionConsumer",h);return he.useCallback(()=>{const g=m.collectionRef.current;if(!g)return[];const p=Array.from(g.querySelectorAll(`[${f}]`));return Array.from(m.itemMap.values()).sort((w,M)=>p.indexOf(w.ref.current)-p.indexOf(M.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:o,Slot:l,ItemSlot:u},d,r]}function ea(t,e=[]){let n=[];function r(s,o){const a=S.createContext(o),l=n.length;n=[...n,o];const c=u=>{var p;const{scope:d,children:h,...m}=u,v=((p=d==null?void 0:d[t])==null?void 0:p[l])||a,g=S.useMemo(()=>m,Object.values(m));return y.jsx(v.Provider,{value:g,children:h})};c.displayName=s+"Provider";function f(u,d){var v;const h=((v=d==null?void 0:d[t])==null?void 0:v[l])||a,m=S.useContext(h);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${u}\` must be used within \`${s}\``)}return[c,f]}const i=()=>{const s=n.map(o=>S.createContext(o));return function(a){const l=(a==null?void 0:a[t])||s;return S.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[r,UN(i,...e)]}function UN(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const u=l(s)[`__scope${c}`];return{...a,...u}},{});return S.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var BN=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],We=BN.reduce((t,e)=>{const n=S.forwardRef((r,i)=>{const{asChild:s,...o}=r,a=s?_l:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(a,{...o,ref:i})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function QE(t,e){t&&Jo.flushSync(()=>t.dispatchEvent(e))}function Kt(t){const e=S.useRef(t);return S.useEffect(()=>{e.current=t}),S.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function zN(t,e=globalThis==null?void 0:globalThis.document){const n=Kt(t);S.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var HN="DismissableLayer",Og="dismissableLayer.update",jN="dismissableLayer.pointerDownOutside",VN="dismissableLayer.focusOutside",U_,JE=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Mh=S.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=t,c=S.useContext(JE),[f,u]=S.useState(null),d=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=S.useState({}),m=dt(e,b=>u(b)),v=Array.from(c.layers),[g]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),p=v.indexOf(g),x=f?v.indexOf(f):-1,_=c.layersWithOutsidePointerEventsDisabled.size>0,w=x>=p,M=WN(b=>{const C=b.target,A=[...c.branches].some(E=>E.contains(C));!w||A||(i==null||i(b),o==null||o(b),b.defaultPrevented||a==null||a())},d),T=XN(b=>{const C=b.target;[...c.branches].some(E=>E.contains(C))||(s==null||s(b),o==null||o(b),b.defaultPrevented||a==null||a())},d);return zN(b=>{x===c.layers.size-1&&(r==null||r(b),!b.defaultPrevented&&a&&(b.preventDefault(),a()))},d),S.useEffect(()=>{if(f)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(U_=d.body.style.pointerEvents,d.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),B_(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(d.body.style.pointerEvents=U_)}},[f,d,n,c]),S.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),B_())},[f,c]),S.useEffect(()=>{const b=()=>h({});return document.addEventListener(Og,b),()=>document.removeEventListener(Og,b)},[]),y.jsx(We.div,{...l,ref:m,style:{pointerEvents:_?w?"auto":"none":void 0,...t.style},onFocusCapture:Ne(t.onFocusCapture,T.onFocusCapture),onBlurCapture:Ne(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ne(t.onPointerDownCapture,M.onPointerDownCapture)})});Mh.displayName=HN;var GN="DismissableLayerBranch",e1=S.forwardRef((t,e)=>{const n=S.useContext(JE),r=S.useRef(null),i=dt(e,r);return S.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),y.jsx(We.div,{...t,ref:i})});e1.displayName=GN;function WN(t,e=globalThis==null?void 0:globalThis.document){const n=Kt(t),r=S.useRef(!1),i=S.useRef(()=>{});return S.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){t1(jN,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=l,e.addEventListener("click",i.current,{once:!0})):l()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function XN(t,e=globalThis==null?void 0:globalThis.document){const n=Kt(t),r=S.useRef(!1);return S.useEffect(()=>{const i=s=>{s.target&&!r.current&&t1(VN,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function B_(){const t=new CustomEvent(Og);document.dispatchEvent(t)}function t1(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?QE(i,s):i.dispatchEvent(s)}var $N=Mh,YN=e1,_n=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},KN="Portal",dy=S.forwardRef((t,e)=>{var a;const{container:n,...r}=t,[i,s]=S.useState(!1);_n(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?YE.createPortal(y.jsx(We.div,{...r,ref:e}),o):null});dy.displayName=KN;function qN(t,e){return S.useReducer((n,r)=>e[n][r]??n,t)}var oo=t=>{const{present:e,children:n}=t,r=ZN(e),i=typeof n=="function"?n({present:r.isPresent}):S.Children.only(n),s=dt(r.ref,QN(i));return typeof n=="function"||r.isPresent?S.cloneElement(i,{ref:s}):null};oo.displayName="Presence";function ZN(t){const[e,n]=S.useState(),r=S.useRef({}),i=S.useRef(t),s=S.useRef("none"),o=t?"mounted":"unmounted",[a,l]=qN(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const c=Zu(r.current);s.current=a==="mounted"?c:"none"},[a]),_n(()=>{const c=r.current,f=i.current;if(f!==t){const d=s.current,h=Zu(c);t?l("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(f&&d!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,l]),_n(()=>{if(e){let c;const f=e.ownerDocument.defaultView??window,u=h=>{const v=Zu(r.current).includes(h.animationName);if(h.target===e&&v&&(l("ANIMATION_END"),!i.current)){const g=e.style.animationFillMode;e.style.animationFillMode="forwards",c=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=g)})}},d=h=>{h.target===e&&(s.current=Zu(r.current))};return e.addEventListener("animationstart",d),e.addEventListener("animationcancel",u),e.addEventListener("animationend",u),()=>{f.clearTimeout(c),e.removeEventListener("animationstart",d),e.removeEventListener("animationcancel",u),e.removeEventListener("animationend",u)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:S.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Zu(t){return(t==null?void 0:t.animationName)||"none"}function QN(t){var r,i;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Ys({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,i]=JN({defaultProp:e,onChange:n}),s=t!==void 0,o=s?t:r,a=Kt(n),l=S.useCallback(c=>{if(s){const u=typeof c=="function"?c(t):c;u!==t&&a(u)}else i(c)},[s,t,i,a]);return[o,l]}function JN({defaultProp:t,onChange:e}){const n=S.useState(t),[r]=n,i=S.useRef(r),s=Kt(e);return S.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),n}var eD="VisuallyHidden",Mu=S.forwardRef((t,e)=>y.jsx(We.span,{...t,ref:e,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...t.style}}));Mu.displayName=eD;var tD=Mu,fy="ToastProvider",[hy,nD,rD]=Sh("Toast"),[n1,w7]=ea("Toast",[rD]),[iD,bh]=n1(fy),r1=t=>{const{__scopeToast:e,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:s=50,children:o}=t,[a,l]=S.useState(null),[c,f]=S.useState(0),u=S.useRef(!1),d=S.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${fy}\`. Expected non-empty \`string\`.`),y.jsx(hy.Provider,{scope:e,children:y.jsx(iD,{scope:e,label:n,duration:r,swipeDirection:i,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:S.useCallback(()=>f(h=>h+1),[]),onToastRemove:S.useCallback(()=>f(h=>h-1),[]),isFocusedToastEscapeKeyDownRef:u,isClosePausedRef:d,children:o})})};r1.displayName=fy;var i1="ToastViewport",sD=["F8"],Fg="toast.viewportPause",Ug="toast.viewportResume",s1=S.forwardRef((t,e)=>{const{__scopeToast:n,hotkey:r=sD,label:i="Notifications ({hotkey})",...s}=t,o=bh(i1,n),a=nD(n),l=S.useRef(null),c=S.useRef(null),f=S.useRef(null),u=S.useRef(null),d=dt(e,u,o.onViewportChange),h=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),m=o.toastCount>0;S.useEffect(()=>{const g=p=>{var _;r.length!==0&&r.every(w=>p[w]||p.code===w)&&((_=u.current)==null||_.focus())};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[r]),S.useEffect(()=>{const g=l.current,p=u.current;if(m&&g&&p){const x=()=>{if(!o.isClosePausedRef.current){const T=new CustomEvent(Fg);p.dispatchEvent(T),o.isClosePausedRef.current=!0}},_=()=>{if(o.isClosePausedRef.current){const T=new CustomEvent(Ug);p.dispatchEvent(T),o.isClosePausedRef.current=!1}},w=T=>{!g.contains(T.relatedTarget)&&_()},M=()=>{g.contains(document.activeElement)||_()};return g.addEventListener("focusin",x),g.addEventListener("focusout",w),g.addEventListener("pointermove",x),g.addEventListener("pointerleave",M),window.addEventListener("blur",x),window.addEventListener("focus",_),()=>{g.removeEventListener("focusin",x),g.removeEventListener("focusout",w),g.removeEventListener("pointermove",x),g.removeEventListener("pointerleave",M),window.removeEventListener("blur",x),window.removeEventListener("focus",_)}}},[m,o.isClosePausedRef]);const v=S.useCallback(({tabbingDirection:g})=>{const x=a().map(_=>{const w=_.ref.current,M=[w,...yD(w)];return g==="forwards"?M:M.reverse()});return(g==="forwards"?x.reverse():x).flat()},[a]);return S.useEffect(()=>{const g=u.current;if(g){const p=x=>{var M,T,b;const _=x.altKey||x.ctrlKey||x.metaKey;if(x.key==="Tab"&&!_){const C=document.activeElement,A=x.shiftKey;if(x.target===g&&A){(M=c.current)==null||M.focus();return}const F=v({tabbingDirection:A?"backwards":"forwards"}),I=F.findIndex(U=>U===C);kp(F.slice(I+1))?x.preventDefault():A?(T=c.current)==null||T.focus():(b=f.current)==null||b.focus()}};return g.addEventListener("keydown",p),()=>g.removeEventListener("keydown",p)}},[a,v]),y.jsxs(YN,{ref:l,role:"region","aria-label":i.replace("{hotkey}",h),tabIndex:-1,style:{pointerEvents:m?void 0:"none"},children:[m&&y.jsx(Bg,{ref:c,onFocusFromOutsideViewport:()=>{const g=v({tabbingDirection:"forwards"});kp(g)}}),y.jsx(hy.Slot,{scope:n,children:y.jsx(We.ol,{tabIndex:-1,...s,ref:d})}),m&&y.jsx(Bg,{ref:f,onFocusFromOutsideViewport:()=>{const g=v({tabbingDirection:"backwards"});kp(g)}})]})});s1.displayName=i1;var o1="ToastFocusProxy",Bg=S.forwardRef((t,e)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=t,s=bh(o1,n);return y.jsx(Mu,{"aria-hidden":!0,tabIndex:0,...i,ref:e,style:{position:"fixed"},onFocus:o=>{var c;const a=o.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Bg.displayName=o1;var Eh="Toast",oD="toast.swipeStart",aD="toast.swipeMove",lD="toast.swipeCancel",cD="toast.swipeEnd",a1=S.forwardRef((t,e)=>{const{forceMount:n,open:r,defaultOpen:i,onOpenChange:s,...o}=t,[a=!0,l]=Ys({prop:r,defaultProp:i,onChange:s});return y.jsx(oo,{present:n||a,children:y.jsx(fD,{open:a,...o,ref:e,onClose:()=>l(!1),onPause:Kt(t.onPause),onResume:Kt(t.onResume),onSwipeStart:Ne(t.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ne(t.onSwipeMove,c=>{const{x:f,y:u}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${u}px`)}),onSwipeCancel:Ne(t.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Ne(t.onSwipeEnd,c=>{const{x:f,y:u}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${f}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${u}px`),l(!1)})})})});a1.displayName=Eh;var[uD,dD]=n1(Eh,{onClose(){}}),fD=S.forwardRef((t,e)=>{const{__scopeToast:n,type:r="foreground",duration:i,open:s,onClose:o,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:f,onSwipeMove:u,onSwipeCancel:d,onSwipeEnd:h,...m}=t,v=bh(Eh,n),[g,p]=S.useState(null),x=dt(e,U=>p(U)),_=S.useRef(null),w=S.useRef(null),M=i||v.duration,T=S.useRef(0),b=S.useRef(M),C=S.useRef(0),{onToastAdd:A,onToastRemove:E}=v,N=Kt(()=>{var z;(g==null?void 0:g.contains(document.activeElement))&&((z=v.viewport)==null||z.focus()),o()}),F=S.useCallback(U=>{!U||U===1/0||(window.clearTimeout(C.current),T.current=new Date().getTime(),C.current=window.setTimeout(N,U))},[N]);S.useEffect(()=>{const U=v.viewport;if(U){const z=()=>{F(b.current),c==null||c()},O=()=>{const j=new Date().getTime()-T.current;b.current=b.current-j,window.clearTimeout(C.current),l==null||l()};return U.addEventListener(Fg,O),U.addEventListener(Ug,z),()=>{U.removeEventListener(Fg,O),U.removeEventListener(Ug,z)}}},[v.viewport,M,l,c,F]),S.useEffect(()=>{s&&!v.isClosePausedRef.current&&F(M)},[s,M,v.isClosePausedRef,F]),S.useEffect(()=>(A(),()=>E()),[A,E]);const I=S.useMemo(()=>g?p1(g):null,[g]);return v.viewport?y.jsxs(y.Fragment,{children:[I&&y.jsx(hD,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:I}),y.jsx(uD,{scope:n,onClose:N,children:Jo.createPortal(y.jsx(hy.ItemSlot,{scope:n,children:y.jsx($N,{asChild:!0,onEscapeKeyDown:Ne(a,()=>{v.isFocusedToastEscapeKeyDownRef.current||N(),v.isFocusedToastEscapeKeyDownRef.current=!1}),children:y.jsx(We.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":v.swipeDirection,...m,ref:x,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Ne(t.onKeyDown,U=>{U.key==="Escape"&&(a==null||a(U.nativeEvent),U.nativeEvent.defaultPrevented||(v.isFocusedToastEscapeKeyDownRef.current=!0,N()))}),onPointerDown:Ne(t.onPointerDown,U=>{U.button===0&&(_.current={x:U.clientX,y:U.clientY})}),onPointerMove:Ne(t.onPointerMove,U=>{if(!_.current)return;const z=U.clientX-_.current.x,O=U.clientY-_.current.y,j=!!w.current,D=["left","right"].includes(v.swipeDirection),V=["left","up"].includes(v.swipeDirection)?Math.min:Math.max,Q=D?V(0,z):0,J=D?0:V(0,O),le=U.pointerType==="touch"?10:2,pe={x:Q,y:J},$={originalEvent:U,delta:pe};j?(w.current=pe,Qu(aD,u,$,{discrete:!1})):z_(pe,v.swipeDirection,le)?(w.current=pe,Qu(oD,f,$,{discrete:!1}),U.target.setPointerCapture(U.pointerId)):(Math.abs(z)>le||Math.abs(O)>le)&&(_.current=null)}),onPointerUp:Ne(t.onPointerUp,U=>{const z=w.current,O=U.target;if(O.hasPointerCapture(U.pointerId)&&O.releasePointerCapture(U.pointerId),w.current=null,_.current=null,z){const j=U.currentTarget,D={originalEvent:U,delta:z};z_(z,v.swipeDirection,v.swipeThreshold)?Qu(cD,h,D,{discrete:!0}):Qu(lD,d,D,{discrete:!0}),j.addEventListener("click",V=>V.preventDefault(),{once:!0})}})})})}),v.viewport)})]}):null}),hD=t=>{const{__scopeToast:e,children:n,...r}=t,i=bh(Eh,e),[s,o]=S.useState(!1),[a,l]=S.useState(!1);return gD(()=>o(!0)),S.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:y.jsx(dy,{asChild:!0,children:y.jsx(Mu,{...r,children:s&&y.jsxs(y.Fragment,{children:[i.label," ",n]})})})},pD="ToastTitle",l1=S.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t;return y.jsx(We.div,{...r,ref:e})});l1.displayName=pD;var mD="ToastDescription",c1=S.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t;return y.jsx(We.div,{...r,ref:e})});c1.displayName=mD;var u1="ToastAction",d1=S.forwardRef((t,e)=>{const{altText:n,...r}=t;return n.trim()?y.jsx(h1,{altText:n,asChild:!0,children:y.jsx(py,{...r,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${u1}\`. Expected non-empty \`string\`.`),null)});d1.displayName=u1;var f1="ToastClose",py=S.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t,i=dD(f1,n);return y.jsx(h1,{asChild:!0,children:y.jsx(We.button,{type:"button",...r,ref:e,onClick:Ne(t.onClick,i.onClose)})})});py.displayName=f1;var h1=S.forwardRef((t,e)=>{const{__scopeToast:n,altText:r,...i}=t;return y.jsx(We.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...i,ref:e})});function p1(t){const e=[];return Array.from(t.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&e.push(r.textContent),vD(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!i)if(s){const o=r.dataset.radixToastAnnounceAlt;o&&e.push(o)}else e.push(...p1(r))}}),e}function Qu(t,e,n,{discrete:r}){const i=n.originalEvent.currentTarget,s=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?QE(i,s):i.dispatchEvent(s)}var z_=(t,e,n=0)=>{const r=Math.abs(t.x),i=Math.abs(t.y),s=r>i;return e==="left"||e==="right"?s&&r>n:!s&&i>n};function gD(t=()=>{}){const e=Kt(t);_n(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[e])}function vD(t){return t.nodeType===t.ELEMENT_NODE}function yD(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function kp(t){const e=document.activeElement;return t.some(n=>n===e?!0:(n.focus(),document.activeElement!==e))}var xD=r1,m1=s1,g1=a1,v1=l1,y1=c1,x1=d1,_1=py;function w1(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=w1(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function S1(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=w1(t))&&(r&&(r+=" "),r+=e);return r}const H_=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,j_=S1,Th=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return j_(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=e,o=Object.keys(i).map(c=>{const f=n==null?void 0:n[c],u=s==null?void 0:s[c];if(f===null)return null;const d=H_(f)||H_(u);return i[c][d]}),a=n&&Object.entries(n).reduce((c,f)=>{let[u,d]=f;return d===void 0||(c[u]=d),c},{}),l=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((c,f)=>{let{class:u,className:d,...h}=f;return Object.entries(h).every(m=>{let[v,g]=m;return Array.isArray(g)?g.includes({...s,...a}[v]):{...s,...a}[v]===g})?[...c,u,d]:c},[]);return j_(t,o,l,n==null?void 0:n.class,n==null?void 0:n.className)};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _D=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),M1=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var wD={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const SD=S.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...a},l)=>S.createElement("svg",{ref:l,...wD,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:M1("lucide",i),...a},[...o.map(([c,f])=>S.createElement(c,f)),...Array.isArray(s)?s:[s]]));/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const He=(t,e)=>{const n=S.forwardRef(({className:r,...i},s)=>S.createElement(SD,{ref:s,iconNode:e,className:M1(`lucide-${_D(t)}`,r),...i}));return n.displayName=`${t}`,n};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const b1=He("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const E1=He("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const T1=He("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Pr=He("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const MD=He("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bD=He("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ED=He("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const TD=He("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const AD=He("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ah=He("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A1=He("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const my=He("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const CD=He("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const RD=He("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const PD=He("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C1=He("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ND=He("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ch=He("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gy=He("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const DD=He("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const LD=He("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ID=He("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const kD=He("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const vy=He("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const V_=He("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const OD=He("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zg=He("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const FD=He("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yy=He("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xy=He("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Rh=He("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const UD=He("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const BD=He("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zD=He("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const HD=He("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const jD=He("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const R1=He("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zf=He("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const VD=He("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xa=He("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const GD=He("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _y=He("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rf=He("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const P1=He("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const N1=He("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const D1=He("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const WD=He("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bu=He("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const XD=He("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Hf=He("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $D=He("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),wy="-",YD=t=>{const e=qD(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const a=o.split(wy);return a[0]===""&&a.length!==1&&a.shift(),L1(a,e)||KD(o)},getConflictingClassGroupIds:(o,a)=>{const l=n[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},L1=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?L1(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(wy);return(o=e.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},G_=/^\[(.+)\]$/,KD=t=>{if(G_.test(t)){const e=G_.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},qD=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return QD(Object.entries(t.classGroups),n).forEach(([s,o])=>{Hg(o,r,s,e)}),r},Hg=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:W_(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(ZD(i)){Hg(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{Hg(o,W_(e,s),n,r)})})},W_=(t,e)=>{let n=t;return e.split(wy).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},ZD=t=>t.isThemeGetter,QD=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[e+o,a])):s);return[n,i]}):t,JD=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},I1="!",eL=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=a=>{const l=[];let c=0,f=0,u;for(let g=0;g<a.length;g++){let p=a[g];if(c===0){if(p===i&&(r||a.slice(g,g+s)===e)){l.push(a.slice(f,g)),f=g+s;continue}if(p==="/"){u=g;continue}}p==="["?c++:p==="]"&&c--}const d=l.length===0?a:a.substring(f),h=d.startsWith(I1),m=h?d.substring(1):d,v=u&&u>f?u-f:void 0;return{modifiers:l,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:v}};return n?a=>n({className:a,parseClassName:o}):o},tL=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},nL=t=>({cache:JD(t.cacheSize),parseClassName:eL(t),...YD(t)}),rL=/\s+/,iL=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(rL);let a="";for(let l=o.length-1;l>=0;l-=1){const c=o[l],{modifiers:f,hasImportantModifier:u,baseClassName:d,maybePostfixModifierPosition:h}=n(c);let m=!!h,v=r(m?d.substring(0,h):d);if(!v){if(!m){a=c+(a.length>0?" "+a:a);continue}if(v=r(d),!v){a=c+(a.length>0?" "+a:a);continue}m=!1}const g=tL(f).join(":"),p=u?g+I1:g,x=p+v;if(s.includes(x))continue;s.push(x);const _=i(v,m);for(let w=0;w<_.length;++w){const M=_[w];s.push(p+M)}a=c+(a.length>0?" "+a:a)}return a};function sL(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=k1(e))&&(r&&(r+=" "),r+=n);return r}const k1=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=k1(t[r]))&&(n&&(n+=" "),n+=e);return n};function oL(t,...e){let n,r,i,s=o;function o(l){const c=e.reduce((f,u)=>u(f),t());return n=nL(c),r=n.cache.get,i=n.cache.set,s=a,a(l)}function a(l){const c=r(l);if(c)return c;const f=iL(l,n);return i(l,f),f}return function(){return s(sL.apply(null,arguments))}}const Nt=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},O1=/^\[(?:([a-z-]+):)?(.+)\]$/i,aL=/^\d+\/\d+$/,lL=new Set(["px","full","screen"]),cL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uL=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,fL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ri=t=>$a(t)||lL.has(t)||aL.test(t),ls=t=>Il(t,"length",wL),$a=t=>!!t&&!Number.isNaN(Number(t)),Op=t=>Il(t,"number",$a),rc=t=>!!t&&Number.isInteger(Number(t)),pL=t=>t.endsWith("%")&&$a(t.slice(0,-1)),tt=t=>O1.test(t),cs=t=>cL.test(t),mL=new Set(["length","size","percentage"]),gL=t=>Il(t,mL,F1),vL=t=>Il(t,"position",F1),yL=new Set(["image","url"]),xL=t=>Il(t,yL,ML),_L=t=>Il(t,"",SL),ic=()=>!0,Il=(t,e,n)=>{const r=O1.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},wL=t=>uL.test(t)&&!dL.test(t),F1=()=>!1,SL=t=>fL.test(t),ML=t=>hL.test(t),bL=()=>{const t=Nt("colors"),e=Nt("spacing"),n=Nt("blur"),r=Nt("brightness"),i=Nt("borderColor"),s=Nt("borderRadius"),o=Nt("borderSpacing"),a=Nt("borderWidth"),l=Nt("contrast"),c=Nt("grayscale"),f=Nt("hueRotate"),u=Nt("invert"),d=Nt("gap"),h=Nt("gradientColorStops"),m=Nt("gradientColorStopPositions"),v=Nt("inset"),g=Nt("margin"),p=Nt("opacity"),x=Nt("padding"),_=Nt("saturate"),w=Nt("scale"),M=Nt("sepia"),T=Nt("skew"),b=Nt("space"),C=Nt("translate"),A=()=>["auto","contain","none"],E=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto",tt,e],F=()=>[tt,e],I=()=>["",Ri,ls],U=()=>["auto",$a,tt],z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],O=()=>["solid","dashed","dotted","double","none"],j=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],D=()=>["start","end","center","between","around","evenly","stretch"],V=()=>["","0",tt],Q=()=>["auto","avoid","all","avoid-page","page","left","right","column"],J=()=>[$a,tt];return{cacheSize:500,separator:":",theme:{colors:[ic],spacing:[Ri,ls],blur:["none","",cs,tt],brightness:J(),borderColor:[t],borderRadius:["none","","full",cs,tt],borderSpacing:F(),borderWidth:I(),contrast:J(),grayscale:V(),hueRotate:J(),invert:V(),gap:F(),gradientColorStops:[t],gradientColorStopPositions:[pL,ls],inset:N(),margin:N(),opacity:J(),padding:F(),saturate:J(),scale:J(),sepia:V(),skew:J(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",tt]}],container:["container"],columns:[{columns:[cs]}],"break-after":[{"break-after":Q()}],"break-before":[{"break-before":Q()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...z(),tt]}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",rc,tt]}],basis:[{basis:N()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",tt]}],grow:[{grow:V()}],shrink:[{shrink:V()}],order:[{order:["first","last","none",rc,tt]}],"grid-cols":[{"grid-cols":[ic]}],"col-start-end":[{col:["auto",{span:["full",rc,tt]},tt]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[ic]}],"row-start-end":[{row:["auto",{span:[rc,tt]},tt]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",tt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",tt]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...D()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...D(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...D(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[x]}],px:[{px:[x]}],py:[{py:[x]}],ps:[{ps:[x]}],pe:[{pe:[x]}],pt:[{pt:[x]}],pr:[{pr:[x]}],pb:[{pb:[x]}],pl:[{pl:[x]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[b]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[b]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",tt,e]}],"min-w":[{"min-w":[tt,e,"min","max","fit"]}],"max-w":[{"max-w":[tt,e,"none","full","min","max","fit","prose",{screen:[cs]},cs]}],h:[{h:[tt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[tt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[tt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[tt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",cs,ls]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Op]}],"font-family":[{font:[ic]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",tt]}],"line-clamp":[{"line-clamp":["none",$a,Op]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ri,tt]}],"list-image":[{"list-image":["none",tt]}],"list-style-type":[{list:["none","disc","decimal",tt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[p]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[p]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...O(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ri,ls]}],"underline-offset":[{"underline-offset":["auto",Ri,tt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",tt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",tt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[p]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...z(),vL]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",gL]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},xL]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[p]}],"border-style":[{border:[...O(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[p]}],"divide-style":[{divide:O()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...O()]}],"outline-offset":[{"outline-offset":[Ri,tt]}],"outline-w":[{outline:[Ri,ls]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[p]}],"ring-offset-w":[{"ring-offset":[Ri,ls]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",cs,_L]}],"shadow-color":[{shadow:[ic]}],opacity:[{opacity:[p]}],"mix-blend":[{"mix-blend":[...j(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":j()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",cs,tt]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[u]}],saturate:[{saturate:[_]}],sepia:[{sepia:[M]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[p]}],"backdrop-saturate":[{"backdrop-saturate":[_]}],"backdrop-sepia":[{"backdrop-sepia":[M]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",tt]}],duration:[{duration:J()}],ease:[{ease:["linear","in","out","in-out",tt]}],delay:[{delay:J()}],animate:[{animate:["none","spin","ping","pulse","bounce",tt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[rc,tt]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",tt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",tt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",tt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Ri,ls,Op]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},EL=oL(bL);function ht(...t){return EL(S1(t))}const TL=xD,U1=S.forwardRef(({className:t,...e},n)=>y.jsx(m1,{ref:n,className:ht("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...e}));U1.displayName=m1.displayName;const AL=Th("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground",success:"border-green-500 bg-green-50 text-green-900 dark:bg-green-900/20 dark:text-green-100",warning:"border-yellow-500 bg-yellow-50 text-yellow-900 dark:bg-yellow-900/20 dark:text-yellow-100",info:"border-blue-500 bg-blue-50 text-blue-900 dark:bg-blue-900/20 dark:text-blue-100"}},defaultVariants:{variant:"default"}}),B1=S.forwardRef(({className:t,variant:e,...n},r)=>y.jsx(g1,{ref:r,className:ht(AL({variant:e}),t),...n}));B1.displayName=g1.displayName;const CL=S.forwardRef(({className:t,...e},n)=>y.jsx(x1,{ref:n,className:ht("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",t),...e}));CL.displayName=x1.displayName;const z1=S.forwardRef(({className:t,...e},n)=>y.jsx(_1,{ref:n,className:ht("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...e,children:y.jsx(bu,{className:"h-4 w-4"})}));z1.displayName=_1.displayName;const H1=S.forwardRef(({className:t,...e},n)=>y.jsx(v1,{ref:n,className:ht("text-sm font-semibold flex items-center gap-2",t),...e}));H1.displayName=v1.displayName;const j1=S.forwardRef(({className:t,...e},n)=>y.jsx(y1,{ref:n,className:ht("text-sm opacity-90",t),...e}));j1.displayName=y1.displayName;const RL=({variant:t})=>{switch(t){case"success":return y.jsx(CD,{className:"h-4 w-4 text-green-600"});case"destructive":return y.jsx(PD,{className:"h-4 w-4 text-red-600"});case"warning":return y.jsx(zg,{className:"h-4 w-4 text-yellow-600"});case"info":return y.jsx(zg,{className:"h-4 w-4 text-blue-600"});default:return y.jsx(Xa,{className:"h-4 w-4"})}};function PL(){const{toasts:t}=uy();return y.jsxs(TL,{children:[t.map(function({id:e,title:n,description:r,action:i,variant:s,...o}){return y.jsxs(B1,{variant:s,...o,children:[y.jsxs("div",{className:"grid gap-1",children:[n&&y.jsxs(H1,{className:"flex items-center gap-2",children:[y.jsx(RL,{variant:s}),n]}),r&&y.jsx(j1,{children:r})]}),i,y.jsx(z1,{})]},e)}),y.jsx(U1,{})]})}var X_=["light","dark"],NL="(prefers-color-scheme: dark)",DL=S.createContext(void 0),LL={setTheme:t=>{},themes:[]},IL=()=>{var t;return(t=S.useContext(DL))!=null?t:LL};S.memo(({forcedTheme:t,storageKey:e,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:s,value:o,attrs:a,nonce:l})=>{let c=s==="system",f=n==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${a.map(m=>`'${m}'`).join(",")})`};`:`var d=document.documentElement,n='${n}',s='setAttribute';`,u=i?X_.includes(s)&&s?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${s}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",d=(m,v=!1,g=!0)=>{let p=o?o[m]:m,x=v?m+"|| ''":`'${p}'`,_="";return i&&g&&!v&&X_.includes(m)&&(_+=`d.style.colorScheme = '${m}';`),n==="class"?v||p?_+=`c.add(${x})`:_+="null":p&&(_+=`d[s](n,${x})`),_},h=t?`!function(){${f}${d(t)}}()`:r?`!function(){try{${f}var e=localStorage.getItem('${e}');if('system'===e||(!e&&${c})){var t='${NL}',m=window.matchMedia(t);if(m.media!==t||m.matches){${d("dark")}}else{${d("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${d(o?"x[e]":"e",!0)}}${c?"":"else{"+d(s,!1,!1)+"}"}${u}}catch(e){}}()`:`!function(){try{${f}var e=localStorage.getItem('${e}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${d(o?"x[e]":"e",!0)}}else{${d(s,!1,!1)};}${u}}catch(t){}}();`;return S.createElement("script",{nonce:l,dangerouslySetInnerHTML:{__html:h}})});var kL=t=>{switch(t){case"success":return UL;case"info":return zL;case"warning":return BL;case"error":return HL;default:return null}},OL=Array(12).fill(0),FL=({visible:t})=>he.createElement("div",{className:"sonner-loading-wrapper","data-visible":t},he.createElement("div",{className:"sonner-spinner"},OL.map((e,n)=>he.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),UL=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},he.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),BL=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},he.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),zL=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},he.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),HL=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},he.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),jL=()=>{let[t,e]=he.useState(document.hidden);return he.useEffect(()=>{let n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},jg=1,VL=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:n,...r}=t,i=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:jg++,s=this.toasts.find(a=>a.id===i),o=t.dismissible===void 0?!0:t.dismissible;return s?this.toasts=this.toasts.map(a=>a.id===i?(this.publish({...a,...t,id:i,title:n}),{...a,...t,id:i,dismissible:o,title:n}):a):this.addToast({title:n,...r,dismissible:o,id:i}),i},this.dismiss=t=>(t||this.toasts.forEach(e=>{this.subscribers.forEach(n=>n({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let n;e.loading!==void 0&&(n=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let r=t instanceof Promise?t:t(),i=n!==void 0;return r.then(async s=>{if(WL(s)&&!s.ok){i=!1;let o=typeof e.error=="function"?await e.error(`HTTP error! status: ${s.status}`):e.error,a=typeof e.description=="function"?await e.description(`HTTP error! status: ${s.status}`):e.description;this.create({id:n,type:"error",message:o,description:a})}else if(e.success!==void 0){i=!1;let o=typeof e.success=="function"?await e.success(s):e.success,a=typeof e.description=="function"?await e.description(s):e.description;this.create({id:n,type:"success",message:o,description:a})}}).catch(async s=>{if(e.error!==void 0){i=!1;let o=typeof e.error=="function"?await e.error(s):e.error,a=typeof e.description=="function"?await e.description(s):e.description;this.create({id:n,type:"error",message:o,description:a})}}).finally(()=>{var s;i&&(this.dismiss(n),n=void 0),(s=e.finally)==null||s.call(e)}),n},this.custom=(t,e)=>{let n=(e==null?void 0:e.id)||jg++;return this.create({jsx:t(n),id:n,...e}),n},this.subscribers=[],this.toasts=[]}},cr=new VL,GL=(t,e)=>{let n=(e==null?void 0:e.id)||jg++;return cr.addToast({title:t,...e,id:n}),n},WL=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",XL=GL,$L=()=>cr.toasts;Object.assign(XL,{success:cr.success,info:cr.info,warning:cr.warning,error:cr.error,custom:cr.custom,message:cr.message,promise:cr.promise,dismiss:cr.dismiss,loading:cr.loading},{getHistory:$L});function YL(t,{insertAt:e}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",e==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}YL(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999}:where([data-sonner-toaster][data-x-position="right"]){right:max(var(--offset),env(safe-area-inset-right))}:where([data-sonner-toaster][data-x-position="left"]){left:max(var(--offset),env(safe-area-inset-left))}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:max(var(--offset),env(safe-area-inset-top))}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:max(var(--offset),env(safe-area-inset-bottom))}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;background:var(--gray1);color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:0;right:0;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount, 0px));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{0%{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;--mobile-offset: 16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
`);function Ju(t){return t.label!==void 0}var KL=3,qL="32px",ZL=4e3,QL=356,JL=14,eI=20,tI=200;function nI(...t){return t.filter(Boolean).join(" ")}var rI=t=>{var e,n,r,i,s,o,a,l,c,f;let{invert:u,toast:d,unstyled:h,interacting:m,setHeights:v,visibleToasts:g,heights:p,index:x,toasts:_,expanded:w,removeToast:M,defaultRichColors:T,closeButton:b,style:C,cancelButtonStyle:A,actionButtonStyle:E,className:N="",descriptionClassName:F="",duration:I,position:U,gap:z,loadingIcon:O,expandByDefault:j,classNames:D,icons:V,closeButtonAriaLabel:Q="Close toast",pauseWhenPageIsHidden:J,cn:le}=t,[pe,$]=he.useState(!1),[ee,se]=he.useState(!1),[Z,ue]=he.useState(!1),[Me,ye]=he.useState(!1),[ke,Se]=he.useState(0),[nt,H]=he.useState(0),Xt=he.useRef(null),Ve=he.useRef(null),qe=x===0,Ue=x+1<=g,Ye=d.type,Oe=d.dismissible!==!1,L=d.className||"",R=d.descriptionClassName||"",X=he.useMemo(()=>p.findIndex(be=>be.toastId===d.id)||0,[p,d.id]),ie=he.useMemo(()=>{var be;return(be=d.closeButton)!=null?be:b},[d.closeButton,b]),oe=he.useMemo(()=>d.duration||I||ZL,[d.duration,I]),ne=he.useRef(0),Re=he.useRef(0),ge=he.useRef(0),_e=he.useRef(null),[ct,de]=U.split("-"),Te=he.useMemo(()=>p.reduce((be,B,ae)=>ae>=X?be:be+B.height,0),[p,X]),Be=jL(),Ge=d.invert||u,Ee=Ye==="loading";Re.current=he.useMemo(()=>X*z+Te,[X,Te]),he.useEffect(()=>{$(!0)},[]),he.useLayoutEffect(()=>{if(!pe)return;let be=Ve.current,B=be.style.height;be.style.height="auto";let ae=be.getBoundingClientRect().height;be.style.height=B,H(ae),v(q=>q.find(te=>te.toastId===d.id)?q.map(te=>te.toastId===d.id?{...te,height:ae}:te):[{toastId:d.id,height:ae,position:d.position},...q])},[pe,d.title,d.description,v,d.id]);let Ke=he.useCallback(()=>{se(!0),Se(Re.current),v(be=>be.filter(B=>B.toastId!==d.id)),setTimeout(()=>{M(d)},tI)},[d,M,v,Re]);he.useEffect(()=>{if(d.promise&&Ye==="loading"||d.duration===1/0||d.type==="loading")return;let be,B=oe;return w||m||J&&Be?(()=>{if(ge.current<ne.current){let ae=new Date().getTime()-ne.current;B=B-ae}ge.current=new Date().getTime()})():B!==1/0&&(ne.current=new Date().getTime(),be=setTimeout(()=>{var ae;(ae=d.onAutoClose)==null||ae.call(d,d),Ke()},B)),()=>clearTimeout(be)},[w,m,j,d,oe,Ke,d.promise,Ye,J,Be]),he.useEffect(()=>{let be=Ve.current;if(be){let B=be.getBoundingClientRect().height;return H(B),v(ae=>[{toastId:d.id,height:B,position:d.position},...ae]),()=>v(ae=>ae.filter(q=>q.toastId!==d.id))}},[v,d.id]),he.useEffect(()=>{d.delete&&Ke()},[Ke,d.delete]);function Ze(){return V!=null&&V.loading?he.createElement("div",{className:"sonner-loader","data-visible":Ye==="loading"},V.loading):O?he.createElement("div",{className:"sonner-loader","data-visible":Ye==="loading"},O):he.createElement(FL,{visible:Ye==="loading"})}return he.createElement("li",{"aria-live":d.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:Ve,className:le(N,L,D==null?void 0:D.toast,(e=d==null?void 0:d.classNames)==null?void 0:e.toast,D==null?void 0:D.default,D==null?void 0:D[Ye],(n=d==null?void 0:d.classNames)==null?void 0:n[Ye]),"data-sonner-toast":"","data-rich-colors":(r=d.richColors)!=null?r:T,"data-styled":!(d.jsx||d.unstyled||h),"data-mounted":pe,"data-promise":!!d.promise,"data-removed":ee,"data-visible":Ue,"data-y-position":ct,"data-x-position":de,"data-index":x,"data-front":qe,"data-swiping":Z,"data-dismissible":Oe,"data-type":Ye,"data-invert":Ge,"data-swipe-out":Me,"data-expanded":!!(w||j&&pe),style:{"--index":x,"--toasts-before":x,"--z-index":_.length-x,"--offset":`${ee?ke:Re.current}px`,"--initial-height":j?"auto":`${nt}px`,...C,...d.style},onPointerDown:be=>{Ee||!Oe||(Xt.current=new Date,Se(Re.current),be.target.setPointerCapture(be.pointerId),be.target.tagName!=="BUTTON"&&(ue(!0),_e.current={x:be.clientX,y:be.clientY}))},onPointerUp:()=>{var be,B,ae,q;if(Me||!Oe)return;_e.current=null;let te=Number(((be=Ve.current)==null?void 0:be.style.getPropertyValue("--swipe-amount").replace("px",""))||0),ve=new Date().getTime()-((B=Xt.current)==null?void 0:B.getTime()),xe=Math.abs(te)/ve;if(Math.abs(te)>=eI||xe>.11){Se(Re.current),(ae=d.onDismiss)==null||ae.call(d,d),Ke(),ye(!0);return}(q=Ve.current)==null||q.style.setProperty("--swipe-amount","0px"),ue(!1)},onPointerMove:be=>{var B;if(!_e.current||!Oe)return;let ae=be.clientY-_e.current.y,q=be.clientX-_e.current.x,te=(ct==="top"?Math.min:Math.max)(0,ae),ve=be.pointerType==="touch"?10:2;Math.abs(te)>ve?(B=Ve.current)==null||B.style.setProperty("--swipe-amount",`${ae}px`):Math.abs(q)>ve&&(_e.current=null)}},ie&&!d.jsx?he.createElement("button",{"aria-label":Q,"data-disabled":Ee,"data-close-button":!0,onClick:Ee||!Oe?()=>{}:()=>{var be;Ke(),(be=d.onDismiss)==null||be.call(d,d)},className:le(D==null?void 0:D.closeButton,(i=d==null?void 0:d.classNames)==null?void 0:i.closeButton)},he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},he.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),he.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null,d.jsx||he.isValidElement(d.title)?d.jsx||d.title:he.createElement(he.Fragment,null,Ye||d.icon||d.promise?he.createElement("div",{"data-icon":"",className:le(D==null?void 0:D.icon,(s=d==null?void 0:d.classNames)==null?void 0:s.icon)},d.promise||d.type==="loading"&&!d.icon?d.icon||Ze():null,d.type!=="loading"?d.icon||(V==null?void 0:V[Ye])||kL(Ye):null):null,he.createElement("div",{"data-content":"",className:le(D==null?void 0:D.content,(o=d==null?void 0:d.classNames)==null?void 0:o.content)},he.createElement("div",{"data-title":"",className:le(D==null?void 0:D.title,(a=d==null?void 0:d.classNames)==null?void 0:a.title)},d.title),d.description?he.createElement("div",{"data-description":"",className:le(F,R,D==null?void 0:D.description,(l=d==null?void 0:d.classNames)==null?void 0:l.description)},d.description):null),he.isValidElement(d.cancel)?d.cancel:d.cancel&&Ju(d.cancel)?he.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||A,onClick:be=>{var B,ae;Ju(d.cancel)&&Oe&&((ae=(B=d.cancel).onClick)==null||ae.call(B,be),Ke())},className:le(D==null?void 0:D.cancelButton,(c=d==null?void 0:d.classNames)==null?void 0:c.cancelButton)},d.cancel.label):null,he.isValidElement(d.action)?d.action:d.action&&Ju(d.action)?he.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||E,onClick:be=>{var B,ae;Ju(d.action)&&(be.defaultPrevented||((ae=(B=d.action).onClick)==null||ae.call(B,be),Ke()))},className:le(D==null?void 0:D.actionButton,(f=d==null?void 0:d.classNames)==null?void 0:f.actionButton)},d.action.label):null))};function $_(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}var iI=t=>{let{invert:e,position:n="bottom-right",hotkey:r=["altKey","KeyT"],expand:i,closeButton:s,className:o,offset:a,theme:l="light",richColors:c,duration:f,style:u,visibleToasts:d=KL,toastOptions:h,dir:m=$_(),gap:v=JL,loadingIcon:g,icons:p,containerAriaLabel:x="Notifications",pauseWhenPageIsHidden:_,cn:w=nI}=t,[M,T]=he.useState([]),b=he.useMemo(()=>Array.from(new Set([n].concat(M.filter(J=>J.position).map(J=>J.position)))),[M,n]),[C,A]=he.useState([]),[E,N]=he.useState(!1),[F,I]=he.useState(!1),[U,z]=he.useState(l!=="system"?l:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=he.useRef(null),j=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=he.useRef(null),V=he.useRef(!1),Q=he.useCallback(J=>{var le;(le=M.find(pe=>pe.id===J.id))!=null&&le.delete||cr.dismiss(J.id),T(pe=>pe.filter(({id:$})=>$!==J.id))},[M]);return he.useEffect(()=>cr.subscribe(J=>{if(J.dismiss){T(le=>le.map(pe=>pe.id===J.id?{...pe,delete:!0}:pe));return}setTimeout(()=>{YE.flushSync(()=>{T(le=>{let pe=le.findIndex($=>$.id===J.id);return pe!==-1?[...le.slice(0,pe),{...le[pe],...J},...le.slice(pe+1)]:[J,...le]})})})}),[]),he.useEffect(()=>{if(l!=="system"){z(l);return}l==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?z("dark"):z("light")),typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:J})=>{z(J?"dark":"light")})},[l]),he.useEffect(()=>{M.length<=1&&N(!1)},[M]),he.useEffect(()=>{let J=le=>{var pe,$;r.every(ee=>le[ee]||le.code===ee)&&(N(!0),(pe=O.current)==null||pe.focus()),le.code==="Escape"&&(document.activeElement===O.current||($=O.current)!=null&&$.contains(document.activeElement))&&N(!1)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[r]),he.useEffect(()=>{if(O.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,V.current=!1)}},[O.current]),M.length?he.createElement("section",{"aria-label":`${x} ${j}`,tabIndex:-1},b.map((J,le)=>{var pe;let[$,ee]=J.split("-");return he.createElement("ol",{key:J,dir:m==="auto"?$_():m,tabIndex:-1,ref:O,className:o,"data-sonner-toaster":!0,"data-theme":U,"data-y-position":$,"data-x-position":ee,style:{"--front-toast-height":`${((pe=C[0])==null?void 0:pe.height)||0}px`,"--offset":typeof a=="number"?`${a}px`:a||qL,"--width":`${QL}px`,"--gap":`${v}px`,...u},onBlur:se=>{V.current&&!se.currentTarget.contains(se.relatedTarget)&&(V.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:se=>{se.target instanceof HTMLElement&&se.target.dataset.dismissible==="false"||V.current||(V.current=!0,D.current=se.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{F||N(!1)},onPointerDown:se=>{se.target instanceof HTMLElement&&se.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},M.filter(se=>!se.position&&le===0||se.position===J).map((se,Z)=>{var ue,Me;return he.createElement(rI,{key:se.id,icons:p,index:Z,toast:se,defaultRichColors:c,duration:(ue=h==null?void 0:h.duration)!=null?ue:f,className:h==null?void 0:h.className,descriptionClassName:h==null?void 0:h.descriptionClassName,invert:e,visibleToasts:d,closeButton:(Me=h==null?void 0:h.closeButton)!=null?Me:s,interacting:F,position:J,style:h==null?void 0:h.style,unstyled:h==null?void 0:h.unstyled,classNames:h==null?void 0:h.classNames,cancelButtonStyle:h==null?void 0:h.cancelButtonStyle,actionButtonStyle:h==null?void 0:h.actionButtonStyle,removeToast:Q,toasts:M.filter(ye=>ye.position==se.position),heights:C.filter(ye=>ye.position==se.position),setHeights:A,expandByDefault:i,gap:v,loadingIcon:g,expanded:E,pauseWhenPageIsHidden:_,cn:w})}))})):null};const sI=({...t})=>{const{theme:e="system"}=IL();return y.jsx(iI,{theme:e,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var oI=WM.useId||(()=>{}),aI=0;function kl(t){const[e,n]=S.useState(oI());return _n(()=>{n(r=>r??String(aI++))},[t]),e?`radix-${e}`:""}const lI=["top","right","bottom","left"],Ks=Math.min,dr=Math.max,jf=Math.round,ed=Math.floor,qs=t=>({x:t,y:t}),cI={left:"right",right:"left",bottom:"top",top:"bottom"},uI={start:"end",end:"start"};function Vg(t,e,n){return dr(t,Ks(e,n))}function es(t,e){return typeof t=="function"?t(e):t}function ts(t){return t.split("-")[0]}function Ol(t){return t.split("-")[1]}function Sy(t){return t==="x"?"y":"x"}function My(t){return t==="y"?"height":"width"}function Zs(t){return["top","bottom"].includes(ts(t))?"y":"x"}function by(t){return Sy(Zs(t))}function dI(t,e,n){n===void 0&&(n=!1);const r=Ol(t),i=by(t),s=My(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Vf(o)),[o,Vf(o)]}function fI(t){const e=Vf(t);return[Gg(t),e,Gg(e)]}function Gg(t){return t.replace(/start|end/g,e=>uI[e])}function hI(t,e,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function pI(t,e,n,r){const i=Ol(t);let s=hI(ts(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(Gg)))),s}function Vf(t){return t.replace(/left|right|bottom|top/g,e=>cI[e])}function mI(t){return{top:0,right:0,bottom:0,left:0,...t}}function V1(t){return typeof t!="number"?mI(t):{top:t,right:t,bottom:t,left:t}}function Gf(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function Y_(t,e,n){let{reference:r,floating:i}=t;const s=Zs(e),o=by(e),a=My(o),l=ts(e),c=s==="y",f=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,d=r[a]/2-i[a]/2;let h;switch(l){case"top":h={x:f,y:r.y-i.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:u};break;case"left":h={x:r.x-i.width,y:u};break;default:h={x:r.x,y:r.y}}switch(Ol(e)){case"start":h[o]-=d*(n&&c?-1:1);break;case"end":h[o]+=d*(n&&c?-1:1);break}return h}const gI=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=Y_(c,r,l),d=r,h={},m=0;for(let v=0;v<a.length;v++){const{name:g,fn:p}=a[v],{x,y:_,data:w,reset:M}=await p({x:f,y:u,initialPlacement:r,placement:d,strategy:i,middlewareData:h,rects:c,platform:o,elements:{reference:t,floating:e}});f=x??f,u=_??u,h={...h,[g]:{...h[g],...w}},M&&m<=50&&(m++,typeof M=="object"&&(M.placement&&(d=M.placement),M.rects&&(c=M.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):M.rects),{x:f,y:u}=Y_(c,d,l)),v=-1)}return{x:f,y:u,placement:d,strategy:i,middlewareData:h}};async function Jc(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:d=!1,padding:h=0}=es(e,t),m=V1(h),g=a[d?u==="floating"?"reference":"floating":u],p=Gf(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:l})),x=u==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,_=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),w=await(s.isElement==null?void 0:s.isElement(_))?await(s.getScale==null?void 0:s.getScale(_))||{x:1,y:1}:{x:1,y:1},M=Gf(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:_,strategy:l}):x);return{top:(p.top-M.top+m.top)/w.y,bottom:(M.bottom-p.bottom+m.bottom)/w.y,left:(p.left-M.left+m.left)/w.x,right:(M.right-p.right+m.right)/w.x}}const vI=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:f=0}=es(t,e)||{};if(c==null)return{};const u=V1(f),d={x:n,y:r},h=by(i),m=My(h),v=await o.getDimensions(c),g=h==="y",p=g?"top":"left",x=g?"bottom":"right",_=g?"clientHeight":"clientWidth",w=s.reference[m]+s.reference[h]-d[h]-s.floating[m],M=d[h]-s.reference[h],T=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let b=T?T[_]:0;(!b||!await(o.isElement==null?void 0:o.isElement(T)))&&(b=a.floating[_]||s.floating[m]);const C=w/2-M/2,A=b/2-v[m]/2-1,E=Ks(u[p],A),N=Ks(u[x],A),F=E,I=b-v[m]-N,U=b/2-v[m]/2+C,z=Vg(F,U,I),O=!l.arrow&&Ol(i)!=null&&U!==z&&s.reference[m]/2-(U<F?E:N)-v[m]/2<0,j=O?U<F?U-F:U-I:0;return{[h]:d[h]+j,data:{[h]:z,centerOffset:U-z-j,...O&&{alignmentOffset:j}},reset:O}}}),yI=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...g}=es(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const p=ts(i),x=Zs(a),_=ts(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),M=d||(_||!v?[Vf(a)]:fI(a)),T=m!=="none";!d&&T&&M.push(...pI(a,v,m,w));const b=[a,...M],C=await Jc(e,g),A=[];let E=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&A.push(C[p]),u){const U=dI(i,o,w);A.push(C[U[0]],C[U[1]])}if(E=[...E,{placement:i,overflows:A}],!A.every(U=>U<=0)){var N,F;const U=(((N=s.flip)==null?void 0:N.index)||0)+1,z=b[U];if(z)return{data:{index:U,overflows:E},reset:{placement:z}};let O=(F=E.filter(j=>j.overflows[0]<=0).sort((j,D)=>j.overflows[1]-D.overflows[1])[0])==null?void 0:F.placement;if(!O)switch(h){case"bestFit":{var I;const j=(I=E.filter(D=>{if(T){const V=Zs(D.placement);return V===x||V==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(V=>V>0).reduce((V,Q)=>V+Q,0)]).sort((D,V)=>D[1]-V[1])[0])==null?void 0:I[0];j&&(O=j);break}case"initialPlacement":O=a;break}if(i!==O)return{reset:{placement:O}}}return{}}}};function K_(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function q_(t){return lI.some(e=>t[e]>=0)}const xI=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=es(t,e);switch(r){case"referenceHidden":{const s=await Jc(e,{...i,elementContext:"reference"}),o=K_(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:q_(o)}}}case"escaped":{const s=await Jc(e,{...i,altBoundary:!0}),o=K_(s,n.floating);return{data:{escapedOffsets:o,escaped:q_(o)}}}default:return{}}}}};async function _I(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ts(n),a=Ol(n),l=Zs(n)==="y",c=["left","top"].includes(o)?-1:1,f=s&&l?-1:1,u=es(e,t);let{mainAxis:d,crossAxis:h,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof m=="number"&&(h=a==="end"?m*-1:m),l?{x:h*f,y:d*c}:{x:d*c,y:h*f}}const wI=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,l=await _I(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},SI=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:g=>{let{x:p,y:x}=g;return{x:p,y:x}}},...l}=es(t,e),c={x:n,y:r},f=await Jc(e,l),u=Zs(ts(i)),d=Sy(u);let h=c[d],m=c[u];if(s){const g=d==="y"?"top":"left",p=d==="y"?"bottom":"right",x=h+f[g],_=h-f[p];h=Vg(x,h,_)}if(o){const g=u==="y"?"top":"left",p=u==="y"?"bottom":"right",x=m+f[g],_=m-f[p];m=Vg(x,m,_)}const v=a.fn({...e,[d]:h,[u]:m});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[d]:s,[u]:o}}}}}},MI=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=es(t,e),f={x:n,y:r},u=Zs(i),d=Sy(u);let h=f[d],m=f[u];const v=es(a,e),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const _=d==="y"?"height":"width",w=s.reference[d]-s.floating[_]+g.mainAxis,M=s.reference[d]+s.reference[_]-g.mainAxis;h<w?h=w:h>M&&(h=M)}if(c){var p,x;const _=d==="y"?"width":"height",w=["top","left"].includes(ts(i)),M=s.reference[u]-s.floating[_]+(w&&((p=o.offset)==null?void 0:p[u])||0)+(w?0:g.crossAxis),T=s.reference[u]+s.reference[_]+(w?0:((x=o.offset)==null?void 0:x[u])||0)-(w?g.crossAxis:0);m<M?m=M:m>T&&(m=T)}return{[d]:h,[u]:m}}}},bI=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:l=()=>{},...c}=es(t,e),f=await Jc(e,c),u=ts(i),d=Ol(i),h=Zs(i)==="y",{width:m,height:v}=s.floating;let g,p;u==="top"||u==="bottom"?(g=u,p=d===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(p=u,g=d==="end"?"top":"bottom");const x=v-f.top-f.bottom,_=m-f.left-f.right,w=Ks(v-f[g],x),M=Ks(m-f[p],_),T=!e.middlewareData.shift;let b=w,C=M;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(C=_),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(b=x),T&&!d){const E=dr(f.left,0),N=dr(f.right,0),F=dr(f.top,0),I=dr(f.bottom,0);h?C=m-2*(E!==0||N!==0?E+N:dr(f.left,f.right)):b=v-2*(F!==0||I!==0?F+I:dr(f.top,f.bottom))}await l({...e,availableWidth:C,availableHeight:b});const A=await o.getDimensions(a.floating);return m!==A.width||v!==A.height?{reset:{rects:!0}}:{}}}};function Ph(){return typeof window<"u"}function Fl(t){return G1(t)?(t.nodeName||"").toLowerCase():"#document"}function mr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Mi(t){var e;return(e=(G1(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function G1(t){return Ph()?t instanceof Node||t instanceof mr(t).Node:!1}function ni(t){return Ph()?t instanceof Element||t instanceof mr(t).Element:!1}function _i(t){return Ph()?t instanceof HTMLElement||t instanceof mr(t).HTMLElement:!1}function Z_(t){return!Ph()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof mr(t).ShadowRoot}function Eu(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=ri(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(i)}function EI(t){return["table","td","th"].includes(Fl(t))}function Nh(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function Ey(t){const e=Ty(),n=ni(t)?ri(t):t;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function TI(t){let e=Qs(t);for(;_i(e)&&!wl(e);){if(Ey(e))return e;if(Nh(e))return null;e=Qs(e)}return null}function Ty(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function wl(t){return["html","body","#document"].includes(Fl(t))}function ri(t){return mr(t).getComputedStyle(t)}function Dh(t){return ni(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Qs(t){if(Fl(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Z_(t)&&t.host||Mi(t);return Z_(e)?e.host:e}function W1(t){const e=Qs(t);return wl(e)?t.ownerDocument?t.ownerDocument.body:t.body:_i(e)&&Eu(e)?e:W1(e)}function eu(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=W1(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=mr(i);if(s){const a=Wg(o);return e.concat(o,o.visualViewport||[],Eu(i)?i:[],a&&n?eu(a):[])}return e.concat(i,eu(i,[],n))}function Wg(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function X1(t){const e=ri(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=_i(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=jf(n)!==s||jf(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function Ay(t){return ni(t)?t:t.contextElement}function Ya(t){const e=Ay(t);if(!_i(e))return qs(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=X1(e);let o=(s?jf(n.width):n.width)/r,a=(s?jf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const AI=qs(0);function $1(t){const e=mr(t);return!Ty()||!e.visualViewport?AI:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function CI(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==mr(t)?!1:e}function Vo(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=Ay(t);let o=qs(1);e&&(r?ni(r)&&(o=Ya(r)):o=Ya(t));const a=CI(s,n,r)?$1(s):qs(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,f=i.width/o.x,u=i.height/o.y;if(s){const d=mr(s),h=r&&ni(r)?mr(r):r;let m=d,v=Wg(m);for(;v&&r&&h!==m;){const g=Ya(v),p=v.getBoundingClientRect(),x=ri(v),_=p.left+(v.clientLeft+parseFloat(x.paddingLeft))*g.x,w=p.top+(v.clientTop+parseFloat(x.paddingTop))*g.y;l*=g.x,c*=g.y,f*=g.x,u*=g.y,l+=_,c+=w,m=mr(v),v=Wg(m)}}return Gf({width:f,height:u,x:l,y:c})}function RI(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=Mi(r),a=e?Nh(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=qs(1);const f=qs(0),u=_i(r);if((u||!u&&!s)&&((Fl(r)!=="body"||Eu(o))&&(l=Dh(r)),_i(r))){const d=Vo(r);c=Ya(r),f.x=d.x+r.clientLeft,f.y=d.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+f.x,y:n.y*c.y-l.scrollTop*c.y+f.y}}function PI(t){return Array.from(t.getClientRects())}function Xg(t,e){const n=Dh(t).scrollLeft;return e?e.left+n:Vo(Mi(t)).left+n}function NI(t){const e=Mi(t),n=Dh(t),r=t.ownerDocument.body,i=dr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=dr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Xg(t);const a=-n.scrollTop;return ri(r).direction==="rtl"&&(o+=dr(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}function DI(t,e){const n=mr(t),r=Mi(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const c=Ty();(!c||c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a,y:l}}function LI(t,e){const n=Vo(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=_i(t)?Ya(t):qs(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function Q_(t,e,n){let r;if(e==="viewport")r=DI(t,n);else if(e==="document")r=NI(Mi(t));else if(ni(e))r=LI(e,n);else{const i=$1(t);r={...e,x:e.x-i.x,y:e.y-i.y}}return Gf(r)}function Y1(t,e){const n=Qs(t);return n===e||!ni(n)||wl(n)?!1:ri(n).position==="fixed"||Y1(n,e)}function II(t,e){const n=e.get(t);if(n)return n;let r=eu(t,[],!1).filter(a=>ni(a)&&Fl(a)!=="body"),i=null;const s=ri(t).position==="fixed";let o=s?Qs(t):t;for(;ni(o)&&!wl(o);){const a=ri(o),l=Ey(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Eu(o)&&!l&&Y1(t,o))?r=r.filter(f=>f!==o):i=a,o=Qs(o)}return e.set(t,r),r}function kI(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?Nh(e)?[]:II(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((c,f)=>{const u=Q_(e,f,i);return c.top=dr(u.top,c.top),c.right=Ks(u.right,c.right),c.bottom=Ks(u.bottom,c.bottom),c.left=dr(u.left,c.left),c},Q_(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function OI(t){const{width:e,height:n}=X1(t);return{width:e,height:n}}function FI(t,e,n){const r=_i(e),i=Mi(e),s=n==="fixed",o=Vo(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=qs(0);if(r||!r&&!s)if((Fl(e)!=="body"||Eu(i))&&(a=Dh(e)),r){const h=Vo(e,!0,s,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else i&&(l.x=Xg(i));let c=0,f=0;if(i&&!r&&!s){const h=i.getBoundingClientRect();f=h.top+a.scrollTop,c=h.left+a.scrollLeft-Xg(i,h)}const u=o.left+a.scrollLeft-l.x-c,d=o.top+a.scrollTop-l.y-f;return{x:u,y:d,width:o.width,height:o.height}}function Fp(t){return ri(t).position==="static"}function J_(t,e){if(!_i(t)||ri(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Mi(t)===n&&(n=n.ownerDocument.body),n}function K1(t,e){const n=mr(t);if(Nh(t))return n;if(!_i(t)){let i=Qs(t);for(;i&&!wl(i);){if(ni(i)&&!Fp(i))return i;i=Qs(i)}return n}let r=J_(t,e);for(;r&&EI(r)&&Fp(r);)r=J_(r,e);return r&&wl(r)&&Fp(r)&&!Ey(r)?n:r||TI(t)||n}const UI=async function(t){const e=this.getOffsetParent||K1,n=this.getDimensions,r=await n(t.floating);return{reference:FI(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function BI(t){return ri(t).direction==="rtl"}const zI={convertOffsetParentRelativeRectToViewportRelativeRect:RI,getDocumentElement:Mi,getClippingRect:kI,getOffsetParent:K1,getElementRects:UI,getClientRects:PI,getDimensions:OI,getScale:Ya,isElement:ni,isRTL:BI};function HI(t,e){let n=null,r;const i=Mi(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const{left:c,top:f,width:u,height:d}=t.getBoundingClientRect();if(a||e(),!u||!d)return;const h=ed(f),m=ed(i.clientWidth-(c+u)),v=ed(i.clientHeight-(f+d)),g=ed(c),x={rootMargin:-h+"px "+-m+"px "+-v+"px "+-g+"px",threshold:dr(0,Ks(1,l))||1};let _=!0;function w(M){const T=M[0].intersectionRatio;if(T!==l){if(!_)return o();T?o(!1,T):r=setTimeout(()=>{o(!1,1e-7)},1e3)}_=!1}try{n=new IntersectionObserver(w,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(w,x)}n.observe(t)}return o(!0),s}function jI(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Ay(t),f=i||s?[...c?eu(c):[],...eu(e)]:[];f.forEach(p=>{i&&p.addEventListener("scroll",n,{passive:!0}),s&&p.addEventListener("resize",n)});const u=c&&a?HI(c,n):null;let d=-1,h=null;o&&(h=new ResizeObserver(p=>{let[x]=p;x&&x.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var _;(_=h)==null||_.observe(e)})),n()}),c&&!l&&h.observe(c),h.observe(e));let m,v=l?Vo(t):null;l&&g();function g(){const p=Vo(t);v&&(p.x!==v.x||p.y!==v.y||p.width!==v.width||p.height!==v.height)&&n(),v=p,m=requestAnimationFrame(g)}return n(),()=>{var p;f.forEach(x=>{i&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),u==null||u(),(p=h)==null||p.disconnect(),h=null,l&&cancelAnimationFrame(m)}}const VI=wI,GI=SI,WI=yI,XI=bI,$I=xI,ew=vI,YI=MI,KI=(t,e,n)=>{const r=new Map,i={platform:zI,...n},s={...i.platform,_c:r};return gI(t,e,{...i,platform:s})};var sf=typeof document<"u"?S.useLayoutEffect:S.useEffect;function Wf(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Wf(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!Wf(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function q1(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function tw(t,e){const n=q1(t);return Math.round(e*n)/n}function Up(t){const e=S.useRef(t);return sf(()=>{e.current=t}),e}function qI(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[f,u]=S.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[d,h]=S.useState(r);Wf(d,r)||h(r);const[m,v]=S.useState(null),[g,p]=S.useState(null),x=S.useCallback(D=>{D!==T.current&&(T.current=D,v(D))},[]),_=S.useCallback(D=>{D!==b.current&&(b.current=D,p(D))},[]),w=s||m,M=o||g,T=S.useRef(null),b=S.useRef(null),C=S.useRef(f),A=l!=null,E=Up(l),N=Up(i),F=Up(c),I=S.useCallback(()=>{if(!T.current||!b.current)return;const D={placement:e,strategy:n,middleware:d};N.current&&(D.platform=N.current),KI(T.current,b.current,D).then(V=>{const Q={...V,isPositioned:F.current!==!1};U.current&&!Wf(C.current,Q)&&(C.current=Q,Jo.flushSync(()=>{u(Q)}))})},[d,e,n,N,F]);sf(()=>{c===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,u(D=>({...D,isPositioned:!1})))},[c]);const U=S.useRef(!1);sf(()=>(U.current=!0,()=>{U.current=!1}),[]),sf(()=>{if(w&&(T.current=w),M&&(b.current=M),w&&M){if(E.current)return E.current(w,M,I);I()}},[w,M,I,E,A]);const z=S.useMemo(()=>({reference:T,floating:b,setReference:x,setFloating:_}),[x,_]),O=S.useMemo(()=>({reference:w,floating:M}),[w,M]),j=S.useMemo(()=>{const D={position:n,left:0,top:0};if(!O.floating)return D;const V=tw(O.floating,f.x),Q=tw(O.floating,f.y);return a?{...D,transform:"translate("+V+"px, "+Q+"px)",...q1(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:Q}},[n,a,O.floating,f.x,f.y]);return S.useMemo(()=>({...f,update:I,refs:z,elements:O,floatingStyles:j}),[f,I,z,O,j])}const ZI=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?ew({element:r.current,padding:i}).fn(n):{}:r?ew({element:r,padding:i}).fn(n):{}}}},QI=(t,e)=>({...VI(t),options:[t,e]}),JI=(t,e)=>({...GI(t),options:[t,e]}),e3=(t,e)=>({...YI(t),options:[t,e]}),t3=(t,e)=>({...WI(t),options:[t,e]}),n3=(t,e)=>({...XI(t),options:[t,e]}),r3=(t,e)=>({...$I(t),options:[t,e]}),i3=(t,e)=>({...ZI(t),options:[t,e]});var s3="Arrow",Z1=S.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return y.jsx(We.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:y.jsx("polygon",{points:"0,0 30,0 15,10"})})});Z1.displayName=s3;var o3=Z1;function a3(t,e=[]){let n=[];function r(s,o){const a=S.createContext(o),l=n.length;n=[...n,o];function c(u){const{scope:d,children:h,...m}=u,v=(d==null?void 0:d[t][l])||a,g=S.useMemo(()=>m,Object.values(m));return y.jsx(v.Provider,{value:g,children:h})}function f(u,d){const h=(d==null?void 0:d[t][l])||a,m=S.useContext(h);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${u}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,f]}const i=()=>{const s=n.map(o=>S.createContext(o));return function(a){const l=(a==null?void 0:a[t])||s;return S.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[r,l3(i,...e)]}function l3(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const u=l(s)[`__scope${c}`];return{...a,...u}},{});return S.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}function Cy(t){const[e,n]=S.useState(void 0);return _n(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=t.offsetWidth,a=t.offsetHeight;n({width:o,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Ry="Popper",[Q1,Lh]=a3(Ry),[c3,J1]=Q1(Ry),eT=t=>{const{__scopePopper:e,children:n}=t,[r,i]=S.useState(null);return y.jsx(c3,{scope:e,anchor:r,onAnchorChange:i,children:n})};eT.displayName=Ry;var tT="PopperAnchor",nT=S.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=J1(tT,n),o=S.useRef(null),a=dt(e,o);return S.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:y.jsx(We.div,{...i,ref:a})});nT.displayName=tT;var Py="PopperContent",[u3,d3]=Q1(Py),rT=S.forwardRef((t,e)=>{var Z,ue,Me,ye,ke,Se;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:f=0,sticky:u="partial",hideWhenDetached:d=!1,updatePositionStrategy:h="optimized",onPlaced:m,...v}=t,g=J1(Py,n),[p,x]=S.useState(null),_=dt(e,nt=>x(nt)),[w,M]=S.useState(null),T=Cy(w),b=(T==null?void 0:T.width)??0,C=(T==null?void 0:T.height)??0,A=r+(s!=="center"?"-"+s:""),E=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},N=Array.isArray(c)?c:[c],F=N.length>0,I={padding:E,boundary:N.filter(h3),altBoundary:F},{refs:U,floatingStyles:z,placement:O,isPositioned:j,middlewareData:D}=qI({strategy:"fixed",placement:A,whileElementsMounted:(...nt)=>jI(...nt,{animationFrame:h==="always"}),elements:{reference:g.anchor},middleware:[QI({mainAxis:i+C,alignmentAxis:o}),l&&JI({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?e3():void 0,...I}),l&&t3({...I}),n3({...I,apply:({elements:nt,rects:H,availableWidth:Xt,availableHeight:Ve})=>{const{width:qe,height:Ue}=H.reference,Ye=nt.floating.style;Ye.setProperty("--radix-popper-available-width",`${Xt}px`),Ye.setProperty("--radix-popper-available-height",`${Ve}px`),Ye.setProperty("--radix-popper-anchor-width",`${qe}px`),Ye.setProperty("--radix-popper-anchor-height",`${Ue}px`)}}),w&&i3({element:w,padding:a}),p3({arrowWidth:b,arrowHeight:C}),d&&r3({strategy:"referenceHidden",...I})]}),[V,Q]=oT(O),J=Kt(m);_n(()=>{j&&(J==null||J())},[j,J]);const le=(Z=D.arrow)==null?void 0:Z.x,pe=(ue=D.arrow)==null?void 0:ue.y,$=((Me=D.arrow)==null?void 0:Me.centerOffset)!==0,[ee,se]=S.useState();return _n(()=>{p&&se(window.getComputedStyle(p).zIndex)},[p]),y.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:j?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(ye=D.transformOrigin)==null?void 0:ye.x,(ke=D.transformOrigin)==null?void 0:ke.y].join(" "),...((Se=D.hide)==null?void 0:Se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:y.jsx(u3,{scope:n,placedSide:V,onArrowChange:M,arrowX:le,arrowY:pe,shouldHideArrow:$,children:y.jsx(We.div,{"data-side":V,"data-align":Q,...v,ref:_,style:{...v.style,animation:j?void 0:"none"}})})})});rT.displayName=Py;var iT="PopperArrow",f3={top:"bottom",right:"left",bottom:"top",left:"right"},sT=S.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=d3(iT,r),o=f3[s.placedSide];return y.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:y.jsx(o3,{...i,ref:n,style:{...i.style,display:"block"}})})});sT.displayName=iT;function h3(t){return t!==null}var p3=t=>({name:"transformOrigin",options:t,fn(e){var g,p,x;const{placement:n,rects:r,middlewareData:i}=e,o=((g=i.arrow)==null?void 0:g.centerOffset)!==0,a=o?0:t.arrowWidth,l=o?0:t.arrowHeight,[c,f]=oT(n),u={start:"0%",center:"50%",end:"100%"}[f],d=(((p=i.arrow)==null?void 0:p.x)??0)+a/2,h=(((x=i.arrow)==null?void 0:x.y)??0)+l/2;let m="",v="";return c==="bottom"?(m=o?u:`${d}px`,v=`${-l}px`):c==="top"?(m=o?u:`${d}px`,v=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,v=o?u:`${h}px`):c==="left"&&(m=`${r.floating.width+l}px`,v=o?u:`${h}px`),{data:{x:m,y:v}}}});function oT(t){const[e,n="center"]=t.split("-");return[e,n]}var aT=eT,lT=nT,cT=rT,uT=sT,[Ih,S7]=ea("Tooltip",[Lh]),kh=Lh(),dT="TooltipProvider",m3=700,$g="tooltip.open",[g3,Ny]=Ih(dT),fT=t=>{const{__scopeTooltip:e,delayDuration:n=m3,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,[o,a]=S.useState(!0),l=S.useRef(!1),c=S.useRef(0);return S.useEffect(()=>{const f=c.current;return()=>window.clearTimeout(f)},[]),y.jsx(g3,{scope:e,isOpenDelayed:o,delayDuration:n,onOpen:S.useCallback(()=>{window.clearTimeout(c.current),a(!1)},[]),onClose:S.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:S.useCallback(f=>{l.current=f},[]),disableHoverableContent:i,children:s})};fT.displayName=dT;var Oh="Tooltip",[v3,Fh]=Ih(Oh),hT=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i=!1,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,l=Ny(Oh,t.__scopeTooltip),c=kh(e),[f,u]=S.useState(null),d=kl(),h=S.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,g=S.useRef(!1),[p=!1,x]=Ys({prop:r,defaultProp:i,onChange:b=>{b?(l.onOpen(),document.dispatchEvent(new CustomEvent($g))):l.onClose(),s==null||s(b)}}),_=S.useMemo(()=>p?g.current?"delayed-open":"instant-open":"closed",[p]),w=S.useCallback(()=>{window.clearTimeout(h.current),h.current=0,g.current=!1,x(!0)},[x]),M=S.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x(!1)},[x]),T=S.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{g.current=!0,x(!0),h.current=0},v)},[v,x]);return S.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),y.jsx(aT,{...c,children:y.jsx(v3,{scope:e,contentId:d,open:p,stateAttribute:_,trigger:f,onTriggerChange:u,onTriggerEnter:S.useCallback(()=>{l.isOpenDelayed?T():w()},[l.isOpenDelayed,T,w]),onTriggerLeave:S.useCallback(()=>{m?M():(window.clearTimeout(h.current),h.current=0)},[M,m]),onOpen:w,onClose:M,disableHoverableContent:m,children:n})})};hT.displayName=Oh;var Yg="TooltipTrigger",pT=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Fh(Yg,n),s=Ny(Yg,n),o=kh(n),a=S.useRef(null),l=dt(e,a,i.onTriggerChange),c=S.useRef(!1),f=S.useRef(!1),u=S.useCallback(()=>c.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",u),[u]),y.jsx(lT,{asChild:!0,...o,children:y.jsx(We.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Ne(t.onPointerMove,d=>{d.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:Ne(t.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:Ne(t.onPointerDown,()=>{c.current=!0,document.addEventListener("pointerup",u,{once:!0})}),onFocus:Ne(t.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ne(t.onBlur,i.onClose),onClick:Ne(t.onClick,i.onClose)})})});pT.displayName=Yg;var y3="TooltipPortal",[M7,x3]=Ih(y3,{forceMount:void 0}),Sl="TooltipContent",mT=S.forwardRef((t,e)=>{const n=x3(Sl,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=Fh(Sl,t.__scopeTooltip);return y.jsx(oo,{present:r||o.open,children:o.disableHoverableContent?y.jsx(gT,{side:i,...s,ref:e}):y.jsx(_3,{side:i,...s,ref:e})})}),_3=S.forwardRef((t,e)=>{const n=Fh(Sl,t.__scopeTooltip),r=Ny(Sl,t.__scopeTooltip),i=S.useRef(null),s=dt(e,i),[o,a]=S.useState(null),{trigger:l,onClose:c}=n,f=i.current,{onPointerInTransitChange:u}=r,d=S.useCallback(()=>{a(null),u(!1)},[u]),h=S.useCallback((m,v)=>{const g=m.currentTarget,p={x:m.clientX,y:m.clientY},x=b3(p,g.getBoundingClientRect()),_=E3(p,x),w=T3(v.getBoundingClientRect()),M=C3([..._,...w]);a(M),u(!0)},[u]);return S.useEffect(()=>()=>d(),[d]),S.useEffect(()=>{if(l&&f){const m=g=>h(g,f),v=g=>h(g,l);return l.addEventListener("pointerleave",m),f.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),f.removeEventListener("pointerleave",v)}}},[l,f,h,d]),S.useEffect(()=>{if(o){const m=v=>{const g=v.target,p={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(g))||(f==null?void 0:f.contains(g)),_=!A3(p,o);x?d():_&&(d(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,f,o,c,d]),y.jsx(gT,{...t,ref:s})}),[w3,S3]=Ih(Oh,{isInside:!1}),gT=S.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,l=Fh(Sl,n),c=kh(n),{onClose:f}=l;return S.useEffect(()=>(document.addEventListener($g,f),()=>document.removeEventListener($g,f)),[f]),S.useEffect(()=>{if(l.trigger){const u=d=>{const h=d.target;h!=null&&h.contains(l.trigger)&&f()};return window.addEventListener("scroll",u,{capture:!0}),()=>window.removeEventListener("scroll",u,{capture:!0})}},[l.trigger,f]),y.jsx(Mh,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:u=>u.preventDefault(),onDismiss:f,children:y.jsxs(cT,{"data-state":l.stateAttribute,...c,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[y.jsx(ZE,{children:r}),y.jsx(w3,{scope:n,isInside:!0,children:y.jsx(tD,{id:l.contentId,role:"tooltip",children:i||r})})]})})});mT.displayName=Sl;var vT="TooltipArrow",M3=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=kh(n);return S3(vT,n).isInside?null:y.jsx(uT,{...i,...r,ref:e})});M3.displayName=vT;function b3(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function E3(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function T3(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function A3(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s].x,l=e[s].y,c=e[o].x,f=e[o].y;l>r!=f>r&&n<(c-a)*(r-l)/(f-l)+a&&(i=!i)}return i}function C3(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),R3(e)}function R3(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var P3=fT,N3=hT,D3=pT,yT=mT;const Ul=P3,Cn=N3,Rn=D3,mn=S.forwardRef(({className:t,sideOffset:e=4,...n},r)=>y.jsx(yT,{ref:r,sideOffset:e,className:ht("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));mn.displayName=yT.displayName;var Uh=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Bh=typeof window>"u"||"Deno"in globalThis;function Gr(){}function L3(t,e){return typeof t=="function"?t(e):t}function I3(t){return typeof t=="number"&&t>=0&&t!==1/0}function k3(t,e){return Math.max(t+(e||0)-Date.now(),0)}function nw(t,e){return typeof t=="function"?t(e):t}function O3(t,e){return typeof t=="function"?t(e):t}function rw(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:a}=t;if(o){if(r){if(e.queryHash!==Dy(o,e.options))return!1}else if(!nu(e.queryKey,o))return!1}if(n!=="all"){const l=e.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||i&&i!==e.state.fetchStatus||s&&!s(e))}function iw(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(tu(e.options.mutationKey)!==tu(s))return!1}else if(!nu(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function Dy(t,e){return((e==null?void 0:e.queryKeyHashFn)||tu)(t)}function tu(t){return JSON.stringify(t,(e,n)=>Kg(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function nu(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(n=>!nu(t[n],e[n])):!1}function xT(t,e){if(t===e)return t;const n=sw(t)&&sw(e);if(n||Kg(t)&&Kg(e)){const r=n?t:Object.keys(t),i=r.length,s=n?e:Object.keys(e),o=s.length,a=n?[]:{};let l=0;for(let c=0;c<o;c++){const f=n?c:s[c];(!n&&r.includes(f)||n)&&t[f]===void 0&&e[f]===void 0?(a[f]=void 0,l++):(a[f]=xT(t[f],e[f]),a[f]===t[f]&&t[f]!==void 0&&l++)}return i===o&&l===i?t:a}return e}function sw(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Kg(t){if(!ow(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!ow(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function ow(t){return Object.prototype.toString.call(t)==="[object Object]"}function F3(t){return new Promise(e=>{setTimeout(e,t)})}function U3(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?xT(t,e):e}function B3(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function z3(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var Ly=Symbol();function _T(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===Ly?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var Po,As,il,TM,H3=(TM=class extends Uh{constructor(){super();xt(this,Po);xt(this,As);xt(this,il);rt(this,il,e=>{if(!Bh&&window.addEventListener){const n=()=>e();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){re(this,As)||this.setEventListener(re(this,il))}onUnsubscribe(){var e;this.hasListeners()||((e=re(this,As))==null||e.call(this),rt(this,As,void 0))}setEventListener(e){var n;rt(this,il,e),(n=re(this,As))==null||n.call(this),rt(this,As,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){re(this,Po)!==e&&(rt(this,Po,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(n=>{n(e)})}isFocused(){var e;return typeof re(this,Po)=="boolean"?re(this,Po):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},Po=new WeakMap,As=new WeakMap,il=new WeakMap,TM),wT=new H3,sl,Cs,ol,AM,j3=(AM=class extends Uh{constructor(){super();xt(this,sl,!0);xt(this,Cs);xt(this,ol);rt(this,ol,e=>{if(!Bh&&window.addEventListener){const n=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){re(this,Cs)||this.setEventListener(re(this,ol))}onUnsubscribe(){var e;this.hasListeners()||((e=re(this,Cs))==null||e.call(this),rt(this,Cs,void 0))}setEventListener(e){var n;rt(this,ol,e),(n=re(this,Cs))==null||n.call(this),rt(this,Cs,e(this.setOnline.bind(this)))}setOnline(e){re(this,sl)!==e&&(rt(this,sl,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return re(this,sl)}},sl=new WeakMap,Cs=new WeakMap,ol=new WeakMap,AM),Xf=new j3;function V3(){let t,e;const n=new Promise((i,s)=>{t=i,e=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}function G3(t){return Math.min(1e3*2**t,3e4)}function ST(t){return(t??"online")==="online"?Xf.isOnline():!0}var MT=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Bp(t){return t instanceof MT}function bT(t){let e=!1,n=0,r=!1,i;const s=V3(),o=v=>{var g;r||(d(new MT(v)),(g=t.abort)==null||g.call(t))},a=()=>{e=!0},l=()=>{e=!1},c=()=>wT.isFocused()&&(t.networkMode==="always"||Xf.isOnline())&&t.canRun(),f=()=>ST(t.networkMode)&&t.canRun(),u=v=>{var g;r||(r=!0,(g=t.onSuccess)==null||g.call(t,v),i==null||i(),s.resolve(v))},d=v=>{var g;r||(r=!0,(g=t.onError)==null||g.call(t,v),i==null||i(),s.reject(v))},h=()=>new Promise(v=>{var g;i=p=>{(r||c())&&v(p)},(g=t.onPause)==null||g.call(t)}).then(()=>{var v;i=void 0,r||(v=t.onContinue)==null||v.call(t)}),m=()=>{if(r)return;let v;const g=n===0?t.initialPromise:void 0;try{v=g??t.fn()}catch(p){v=Promise.reject(p)}Promise.resolve(v).then(u).catch(p=>{var T;if(r)return;const x=t.retry??(Bh?0:3),_=t.retryDelay??G3,w=typeof _=="function"?_(n,p):_,M=x===!0||typeof x=="number"&&n<x||typeof x=="function"&&x(n,p);if(e||!M){d(p);return}n++,(T=t.onFail)==null||T.call(t,n,p),F3(w).then(()=>c()?void 0:h()).then(()=>{e?d(p):m()})})};return{promise:s,cancel:o,continue:()=>(i==null||i(),s),cancelRetry:a,continueRetry:l,canStart:f,start:()=>(f()?m():h().then(m),s)}}function W3(){let t=[],e=0,n=a=>{a()},r=a=>{a()},i=a=>setTimeout(a,0);const s=a=>{e?t.push(a):i(()=>{n(a)})},o=()=>{const a=t;t=[],a.length&&i(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||o()}return l},batchCalls:a=>(...l)=>{s(()=>{a(...l)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}var Bn=W3(),No,CM,ET=(CM=class{constructor(){xt(this,No)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),I3(this.gcTime)&&rt(this,No,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Bh?1/0:5*60*1e3))}clearGcTimeout(){re(this,No)&&(clearTimeout(re(this,No)),rt(this,No,void 0))}},No=new WeakMap,CM),al,ll,Sr,An,gu,Do,Xr,Oi,RM,X3=(RM=class extends ET{constructor(e){super();xt(this,Xr);xt(this,al);xt(this,ll);xt(this,Sr);xt(this,An);xt(this,gu);xt(this,Do);rt(this,Do,!1),rt(this,gu,e.defaultOptions),this.setOptions(e.options),this.observers=[],rt(this,Sr,e.cache),this.queryKey=e.queryKey,this.queryHash=e.queryHash,rt(this,al,Y3(this.options)),this.state=e.state??re(this,al),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=re(this,An))==null?void 0:e.promise}setOptions(e){this.options={...re(this,gu),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&re(this,Sr).remove(this)}setData(e,n){const r=U3(this.state.data,e,this.options);return Sn(this,Xr,Oi).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(e,n){Sn(this,Xr,Oi).call(this,{type:"setState",state:e,setStateOptions:n})}cancel(e){var r,i;const n=(r=re(this,An))==null?void 0:r.promise;return(i=re(this,An))==null||i.cancel(e),n?n.then(Gr).catch(Gr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(re(this,al))}isActive(){return this.observers.some(e=>O3(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ly||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!k3(this.state.dataUpdatedAt,e)}onFocus(){var n;const e=this.observers.find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(n=re(this,An))==null||n.continue()}onOnline(){var n;const e=this.observers.find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(n=re(this,An))==null||n.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),re(this,Sr).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(n=>n!==e),this.observers.length||(re(this,An)&&(re(this,Do)?re(this,An).cancel({revert:!0}):re(this,An).cancelRetry()),this.scheduleGc()),re(this,Sr).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Sn(this,Xr,Oi).call(this,{type:"invalidate"})}fetch(e,n){var l,c,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(re(this,An))return re(this,An).continueRetry(),re(this,An).promise}if(e&&this.setOptions(e),!this.options.queryFn){const u=this.observers.find(d=>d.options.queryFn);u&&this.setOptions(u.options)}const r=new AbortController,i=u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:()=>(rt(this,Do,!0),r.signal)})},s=()=>{const u=_T(this.options,n),d={queryKey:this.queryKey,meta:this.meta};return i(d),rt(this,Do,!1),this.options.persister?this.options.persister(u,d,this):u(d)},o={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};i(o),(l=this.options.behavior)==null||l.onFetch(o,this),rt(this,ll,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((c=o.fetchOptions)==null?void 0:c.meta))&&Sn(this,Xr,Oi).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta});const a=u=>{var d,h,m,v;Bp(u)&&u.silent||Sn(this,Xr,Oi).call(this,{type:"error",error:u}),Bp(u)||((h=(d=re(this,Sr).config).onError)==null||h.call(d,u,this),(v=(m=re(this,Sr).config).onSettled)==null||v.call(m,this.state.data,u,this)),this.scheduleGc()};return rt(this,An,bT({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,abort:r.abort.bind(r),onSuccess:u=>{var d,h,m,v;if(u===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(u)}catch(g){a(g);return}(h=(d=re(this,Sr).config).onSuccess)==null||h.call(d,u,this),(v=(m=re(this,Sr).config).onSettled)==null||v.call(m,u,this.state.error,this),this.scheduleGc()},onError:a,onFail:(u,d)=>{Sn(this,Xr,Oi).call(this,{type:"failed",failureCount:u,error:d})},onPause:()=>{Sn(this,Xr,Oi).call(this,{type:"pause"})},onContinue:()=>{Sn(this,Xr,Oi).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0})),re(this,An).start()}},al=new WeakMap,ll=new WeakMap,Sr=new WeakMap,An=new WeakMap,gu=new WeakMap,Do=new WeakMap,Xr=new WeakSet,Oi=function(e){const n=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...$3(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const i=e.error;return Bp(i)&&i.revert&&re(this,ll)?{...re(this,ll),fetchStatus:"idle"}:{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=n(this.state),Bn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),re(this,Sr).notify({query:this,type:"updated",action:e})})},RM);function $3(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ST(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Y3(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var ci,PM,K3=(PM=class extends Uh{constructor(e={}){super();xt(this,ci);this.config=e,rt(this,ci,new Map)}build(e,n,r){const i=n.queryKey,s=n.queryHash??Dy(i,n);let o=this.get(s);return o||(o=new X3({cache:this,queryKey:i,queryHash:s,options:e.defaultQueryOptions(n),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(o)),o}add(e){re(this,ci).has(e.queryHash)||(re(this,ci).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const n=re(this,ci).get(e.queryHash);n&&(e.destroy(),n===e&&re(this,ci).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Bn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return re(this,ci).get(e)}getAll(){return[...re(this,ci).values()]}find(e){const n={exact:!0,...e};return this.getAll().find(r=>rw(n,r))}findAll(e={}){const n=this.getAll();return Object.keys(e).length>0?n.filter(r=>rw(e,r)):n}notify(e){Bn.batch(()=>{this.listeners.forEach(n=>{n(e)})})}onFocus(){Bn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Bn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ci=new WeakMap,PM),ui,Fn,Lo,di,xs,NM,q3=(NM=class extends ET{constructor(e){super();xt(this,di);xt(this,ui);xt(this,Fn);xt(this,Lo);this.mutationId=e.mutationId,rt(this,Fn,e.mutationCache),rt(this,ui,[]),this.state=e.state||Z3(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){re(this,ui).includes(e)||(re(this,ui).push(e),this.clearGcTimeout(),re(this,Fn).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){rt(this,ui,re(this,ui).filter(n=>n!==e)),this.scheduleGc(),re(this,Fn).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){re(this,ui).length||(this.state.status==="pending"?this.scheduleGc():re(this,Fn).remove(this))}continue(){var e;return((e=re(this,Lo))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var i,s,o,a,l,c,f,u,d,h,m,v,g,p,x,_,w,M,T,b;rt(this,Lo,bT({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(C,A)=>{Sn(this,di,xs).call(this,{type:"failed",failureCount:C,error:A})},onPause:()=>{Sn(this,di,xs).call(this,{type:"pause"})},onContinue:()=>{Sn(this,di,xs).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>re(this,Fn).canRun(this)}));const n=this.state.status==="pending",r=!re(this,Lo).canStart();try{if(!n){Sn(this,di,xs).call(this,{type:"pending",variables:e,isPaused:r}),await((s=(i=re(this,Fn).config).onMutate)==null?void 0:s.call(i,e,this));const A=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,e));A!==this.state.context&&Sn(this,di,xs).call(this,{type:"pending",context:A,variables:e,isPaused:r})}const C=await re(this,Lo).start();return await((c=(l=re(this,Fn).config).onSuccess)==null?void 0:c.call(l,C,e,this.state.context,this)),await((u=(f=this.options).onSuccess)==null?void 0:u.call(f,C,e,this.state.context)),await((h=(d=re(this,Fn).config).onSettled)==null?void 0:h.call(d,C,null,this.state.variables,this.state.context,this)),await((v=(m=this.options).onSettled)==null?void 0:v.call(m,C,null,e,this.state.context)),Sn(this,di,xs).call(this,{type:"success",data:C}),C}catch(C){try{throw await((p=(g=re(this,Fn).config).onError)==null?void 0:p.call(g,C,e,this.state.context,this)),await((_=(x=this.options).onError)==null?void 0:_.call(x,C,e,this.state.context)),await((M=(w=re(this,Fn).config).onSettled)==null?void 0:M.call(w,void 0,C,this.state.variables,this.state.context,this)),await((b=(T=this.options).onSettled)==null?void 0:b.call(T,void 0,C,e,this.state.context)),C}finally{Sn(this,di,xs).call(this,{type:"error",error:C})}}finally{re(this,Fn).runNext(this)}}},ui=new WeakMap,Fn=new WeakMap,Lo=new WeakMap,di=new WeakSet,xs=function(e){const n=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Bn.batch(()=>{re(this,ui).forEach(r=>{r.onMutationUpdate(e)}),re(this,Fn).notify({mutation:this,type:"updated",action:e})})},NM);function Z3(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var lr,vu,DM,Q3=(DM=class extends Uh{constructor(e={}){super();xt(this,lr);xt(this,vu);this.config=e,rt(this,lr,new Map),rt(this,vu,Date.now())}build(e,n,r){const i=new q3({mutationCache:this,mutationId:++Lu(this,vu)._,options:e.defaultMutationOptions(n),state:r});return this.add(i),i}add(e){const n=td(e),r=re(this,lr).get(n)??[];r.push(e),re(this,lr).set(n,r),this.notify({type:"added",mutation:e})}remove(e){var r;const n=td(e);if(re(this,lr).has(n)){const i=(r=re(this,lr).get(n))==null?void 0:r.filter(s=>s!==e);i&&(i.length===0?re(this,lr).delete(n):re(this,lr).set(n,i))}this.notify({type:"removed",mutation:e})}canRun(e){var r;const n=(r=re(this,lr).get(td(e)))==null?void 0:r.find(i=>i.state.status==="pending");return!n||n===e}runNext(e){var r;const n=(r=re(this,lr).get(td(e)))==null?void 0:r.find(i=>i!==e&&i.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}clear(){Bn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}getAll(){return[...re(this,lr).values()].flat()}find(e){const n={exact:!0,...e};return this.getAll().find(r=>iw(n,r))}findAll(e={}){return this.getAll().filter(n=>iw(e,n))}notify(e){Bn.batch(()=>{this.listeners.forEach(n=>{n(e)})})}resumePausedMutations(){const e=this.getAll().filter(n=>n.state.isPaused);return Bn.batch(()=>Promise.all(e.map(n=>n.continue().catch(Gr))))}},lr=new WeakMap,vu=new WeakMap,DM);function td(t){var e;return((e=t.options.scope)==null?void 0:e.id)??String(t.mutationId)}function aw(t){return{onFetch:(e,n)=>{var f,u,d,h,m;const r=e.options,i=(d=(u=(f=e.fetchOptions)==null?void 0:f.meta)==null?void 0:u.fetchMore)==null?void 0:d.direction,s=((h=e.state.data)==null?void 0:h.pages)||[],o=((m=e.state.data)==null?void 0:m.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const c=async()=>{let v=!1;const g=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(e.signal.aborted?v=!0:e.signal.addEventListener("abort",()=>{v=!0}),e.signal)})},p=_T(e.options,e.fetchOptions),x=async(_,w,M)=>{if(v)return Promise.reject();if(w==null&&_.pages.length)return Promise.resolve(_);const T={queryKey:e.queryKey,pageParam:w,direction:M?"backward":"forward",meta:e.options.meta};g(T);const b=await p(T),{maxPages:C}=e.options,A=M?z3:B3;return{pages:A(_.pages,b,C),pageParams:A(_.pageParams,w,C)}};if(i&&s.length){const _=i==="backward",w=_?J3:lw,M={pages:s,pageParams:o},T=w(r,M);a=await x(M,T,_)}else{const _=t??s.length;do{const w=l===0?o[0]??r.initialPageParam:lw(r,a);if(l>0&&w==null)break;a=await x(a,w),l++}while(l<_)}return a};e.options.persister?e.fetchFn=()=>{var v,g;return(g=(v=e.options).persister)==null?void 0:g.call(v,c,{queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n)}:e.fetchFn=c}}}function lw(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function J3(t,{pages:e,pageParams:n}){var r;return e.length>0?(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,n[0],n):void 0}var jt,Rs,Ps,cl,ul,Ns,dl,fl,LM,ek=(LM=class{constructor(t={}){xt(this,jt);xt(this,Rs);xt(this,Ps);xt(this,cl);xt(this,ul);xt(this,Ns);xt(this,dl);xt(this,fl);rt(this,jt,t.queryCache||new K3),rt(this,Rs,t.mutationCache||new Q3),rt(this,Ps,t.defaultOptions||{}),rt(this,cl,new Map),rt(this,ul,new Map),rt(this,Ns,0)}mount(){Lu(this,Ns)._++,re(this,Ns)===1&&(rt(this,dl,wT.subscribe(async t=>{t&&(await this.resumePausedMutations(),re(this,jt).onFocus())})),rt(this,fl,Xf.subscribe(async t=>{t&&(await this.resumePausedMutations(),re(this,jt).onOnline())})))}unmount(){var t,e;Lu(this,Ns)._--,re(this,Ns)===0&&((t=re(this,dl))==null||t.call(this),rt(this,dl,void 0),(e=re(this,fl))==null||e.call(this),rt(this,fl,void 0))}isFetching(t){return re(this,jt).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return re(this,Rs).findAll({...t,status:"pending"}).length}getQueryData(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=re(this,jt).get(e.queryHash))==null?void 0:n.state.data}ensureQueryData(t){const e=this.getQueryData(t.queryKey);if(e===void 0)return this.fetchQuery(t);{const n=this.defaultQueryOptions(t),r=re(this,jt).build(this,n);return t.revalidateIfStale&&r.isStaleByTime(nw(n.staleTime,r))&&this.prefetchQuery(n),Promise.resolve(e)}}getQueriesData(t){return re(this,jt).findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),i=re(this,jt).get(r.queryHash),s=i==null?void 0:i.state.data,o=L3(e,s);if(o!==void 0)return re(this,jt).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Bn.batch(()=>re(this,jt).findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=re(this,jt).get(e.queryHash))==null?void 0:n.state}removeQueries(t){const e=re(this,jt);Bn.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=re(this,jt),r={type:"active",...t};return Bn.batch(()=>(n.findAll(t).forEach(i=>{i.reset()}),this.refetchQueries(r,e)))}cancelQueries(t={},e={}){const n={revert:!0,...e},r=Bn.batch(()=>re(this,jt).findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Gr).catch(Gr)}invalidateQueries(t={},e={}){return Bn.batch(()=>{if(re(this,jt).findAll(t).forEach(r=>{r.invalidate()}),t.refetchType==="none")return Promise.resolve();const n={...t,type:t.refetchType??t.type??"active"};return this.refetchQueries(n,e)})}refetchQueries(t={},e){const n={...e,cancelRefetch:(e==null?void 0:e.cancelRefetch)??!0},r=Bn.batch(()=>re(this,jt).findAll(t).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(Gr)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Gr)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=re(this,jt).build(this,e);return n.isStaleByTime(nw(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Gr).catch(Gr)}fetchInfiniteQuery(t){return t.behavior=aw(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Gr).catch(Gr)}ensureInfiniteQueryData(t){return t.behavior=aw(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Xf.isOnline()?re(this,Rs).resumePausedMutations():Promise.resolve()}getQueryCache(){return re(this,jt)}getMutationCache(){return re(this,Rs)}getDefaultOptions(){return re(this,Ps)}setDefaultOptions(t){rt(this,Ps,t)}setQueryDefaults(t,e){re(this,cl).set(tu(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...re(this,cl).values()];let n={};return e.forEach(r=>{nu(t,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(t,e){re(this,ul).set(tu(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...re(this,ul).values()];let n={};return e.forEach(r=>{nu(t,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...re(this,Ps).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Dy(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.enabled!==!0&&e.queryFn===Ly&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...re(this,Ps).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){re(this,jt).clear(),re(this,Rs).clear()}},jt=new WeakMap,Rs=new WeakMap,Ps=new WeakMap,cl=new WeakMap,ul=new WeakMap,Ns=new WeakMap,dl=new WeakMap,fl=new WeakMap,LM),tk=S.createContext(void 0),nk=({client:t,children:e})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),y.jsx(tk.Provider,{value:t,children:e}));/**
* @remix-run/router v1.20.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function $f(){return $f=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$f.apply(this,arguments)}var Is;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Is||(Is={}));const cw="popstate";function rk(t){t===void 0&&(t={});function e(r,i){let{pathname:s,search:o,hash:a}=r.location;return qg("",{pathname:s,search:o,hash:a},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:AT(i)}return sk(e,n,null,t)}function nr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function TT(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function ik(){return Math.random().toString(36).substr(2,8)}function uw(t,e){return{usr:t.state,key:t.key,idx:e}}function qg(t,e,n,r){return n===void 0&&(n=null),$f({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?zh(e):e,{state:n,key:e&&e.key||r||ik()})}function AT(t){let{pathname:e="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function zh(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function sk(t,e,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:s=!1}=r,o=i.history,a=Is.Pop,l=null,c=f();c==null&&(c=0,o.replaceState($f({},o.state,{idx:c}),""));function f(){return(o.state||{idx:null}).idx}function u(){a=Is.Pop;let g=f(),p=g==null?null:g-c;c=g,l&&l({action:a,location:v.location,delta:p})}function d(g,p){a=Is.Push;let x=qg(v.location,g,p);c=f()+1;let _=uw(x,c),w=v.createHref(x);try{o.pushState(_,"",w)}catch(M){if(M instanceof DOMException&&M.name==="DataCloneError")throw M;i.location.assign(w)}s&&l&&l({action:a,location:v.location,delta:1})}function h(g,p){a=Is.Replace;let x=qg(v.location,g,p);c=f();let _=uw(x,c),w=v.createHref(x);o.replaceState(_,"",w),s&&l&&l({action:a,location:v.location,delta:0})}function m(g){let p=i.location.origin!=="null"?i.location.origin:i.location.href,x=typeof g=="string"?g:AT(g);return x=x.replace(/ $/,"%20"),nr(p,"No window.location.(origin|href) available to create URL for href: "+x),new URL(x,p)}let v={get action(){return a},get location(){return t(i,o)},listen(g){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(cw,u),l=g,()=>{i.removeEventListener(cw,u),l=null}},createHref(g){return e(i,g)},createURL:m,encodeLocation(g){let p=m(g);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:d,replace:h,go(g){return o.go(g)}};return v}var dw;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(dw||(dw={}));function ok(t,e,n){return n===void 0&&(n="/"),ak(t,e,n,!1)}function ak(t,e,n,r){let i=typeof e=="string"?zh(e):e,s=PT(i.pathname||"/",n);if(s==null)return null;let o=CT(t);lk(o);let a=null;for(let l=0;a==null&&l<o.length;++l){let c=xk(s);a=vk(o[l],c,r)}return a}function CT(t,e,n,r){e===void 0&&(e=[]),n===void 0&&(n=[]),r===void 0&&(r="");let i=(s,o,a)=>{let l={relativePath:a===void 0?s.path||"":a,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};l.relativePath.startsWith("/")&&(nr(l.relativePath.startsWith(r),'Absolute route path "'+l.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),l.relativePath=l.relativePath.slice(r.length));let c=Ka([r,l.relativePath]),f=n.concat(l);s.children&&s.children.length>0&&(nr(s.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),CT(s.children,e,f,c)),!(s.path==null&&!s.index)&&e.push({path:c,score:mk(c,s.index),routesMeta:f})};return t.forEach((s,o)=>{var a;if(s.path===""||!((a=s.path)!=null&&a.includes("?")))i(s,o);else for(let l of RT(s.path))i(s,o,l)}),e}function RT(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let o=RT(r.join("/")),a=[];return a.push(...o.map(l=>l===""?s:[s,l].join("/"))),i&&a.push(...o),a.map(l=>t.startsWith("/")&&l===""?"/":l)}function lk(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:gk(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const ck=/^:[\w-]+$/,uk=3,dk=2,fk=1,hk=10,pk=-2,fw=t=>t==="*";function mk(t,e){let n=t.split("/"),r=n.length;return n.some(fw)&&(r+=pk),e&&(r+=dk),n.filter(i=>!fw(i)).reduce((i,s)=>i+(ck.test(s)?uk:s===""?fk:hk),r)}function gk(t,e){return t.length===e.length&&t.slice(0,-1).every((r,i)=>r===e[i])?t[t.length-1]-e[e.length-1]:0}function vk(t,e,n){let{routesMeta:r}=t,i={},s="/",o=[];for(let a=0;a<r.length;++a){let l=r[a],c=a===r.length-1,f=s==="/"?e:e.slice(s.length)||"/",u=hw({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},f),d=l.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=hw({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},f)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:Ka([s,u.pathname]),pathnameBase:_k(Ka([s,u.pathnameBase])),route:d}),u.pathnameBase!=="/"&&(s=Ka([s,u.pathnameBase]))}return o}function hw(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=yk(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],o=s.replace(/(.)\/+$/,"$1"),a=i.slice(1);return{params:r.reduce((c,f,u)=>{let{paramName:d,isOptional:h}=f;if(d==="*"){let v=a[u]||"";o=s.slice(0,s.length-v.length).replace(/(.)\/+$/,"$1")}const m=a[u];return h&&!m?c[d]=void 0:c[d]=(m||"").replace(/%2F/g,"/"),c},{}),pathname:s,pathnameBase:o,pattern:t}}function yk(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),TT(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,a,l)=>(r.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function xk(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return TT(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function PT(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const Ka=t=>t.join("/").replace(/\/\/+/g,"/"),_k=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/");function wk(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const NT=["post","put","patch","delete"];new Set(NT);const Sk=["get",...NT];new Set(Sk);/**
* React Router v6.27.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function Yf(){return Yf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Yf.apply(this,arguments)}const Mk=S.createContext(null),bk=S.createContext(null),DT=S.createContext(null),Hh=S.createContext(null),jh=S.createContext({outlet:null,matches:[],isDataRoute:!1}),LT=S.createContext(null);function Iy(){return S.useContext(Hh)!=null}function IT(){return Iy()||nr(!1),S.useContext(Hh).location}function Ek(t,e){return Tk(t,e)}function Tk(t,e,n,r){Iy()||nr(!1);let{navigator:i}=S.useContext(DT),{matches:s}=S.useContext(jh),o=s[s.length-1],a=o?o.params:{};o&&o.pathname;let l=o?o.pathnameBase:"/";o&&o.route;let c=IT(),f;if(e){var u;let g=typeof e=="string"?zh(e):e;l==="/"||(u=g.pathname)!=null&&u.startsWith(l)||nr(!1),f=g}else f=c;let d=f.pathname||"/",h=d;if(l!=="/"){let g=l.replace(/^\//,"").split("/");h="/"+d.replace(/^\//,"").split("/").slice(g.length).join("/")}let m=ok(t,{pathname:h}),v=Nk(m&&m.map(g=>Object.assign({},g,{params:Object.assign({},a,g.params),pathname:Ka([l,i.encodeLocation?i.encodeLocation(g.pathname).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?l:Ka([l,i.encodeLocation?i.encodeLocation(g.pathnameBase).pathname:g.pathnameBase])})),s,n,r);return e&&v?S.createElement(Hh.Provider,{value:{location:Yf({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:Is.Pop}},v):v}function Ak(){let t=kk(),e=wk(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},e),n?S.createElement("pre",{style:i},n):null,null)}const Ck=S.createElement(Ak,null);class Rk extends S.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?S.createElement(jh.Provider,{value:this.props.routeContext},S.createElement(LT.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Pk(t){let{routeContext:e,match:n,children:r}=t,i=S.useContext(Mk);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),S.createElement(jh.Provider,{value:e},r)}function Nk(t,e,n,r){var i;if(e===void 0&&(e=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var s;if(!n)return null;if(n.errors)t=n.matches;else if((s=r)!=null&&s.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,a=(i=n)==null?void 0:i.errors;if(a!=null){let f=o.findIndex(u=>u.route.id&&(a==null?void 0:a[u.route.id])!==void 0);f>=0||nr(!1),o=o.slice(0,Math.min(o.length,f+1))}let l=!1,c=-1;if(n&&r&&r.v7_partialHydration)for(let f=0;f<o.length;f++){let u=o[f];if((u.route.HydrateFallback||u.route.hydrateFallbackElement)&&(c=f),u.route.id){let{loaderData:d,errors:h}=n,m=u.route.loader&&d[u.route.id]===void 0&&(!h||h[u.route.id]===void 0);if(u.route.lazy||m){l=!0,c>=0?o=o.slice(0,c+1):o=[o[0]];break}}}return o.reduceRight((f,u,d)=>{let h,m=!1,v=null,g=null;n&&(h=a&&u.route.id?a[u.route.id]:void 0,v=u.route.errorElement||Ck,l&&(c<0&&d===0?(m=!0,g=null):c===d&&(m=!0,g=u.route.hydrateFallbackElement||null)));let p=e.concat(o.slice(0,d+1)),x=()=>{let _;return h?_=v:m?_=g:u.route.Component?_=S.createElement(u.route.Component,null):u.route.element?_=u.route.element:_=f,S.createElement(Pk,{match:u,routeContext:{outlet:f,matches:p,isDataRoute:n!=null},children:_})};return n&&(u.route.ErrorBoundary||u.route.errorElement||d===0)?S.createElement(Rk,{location:n.location,revalidation:n.revalidation,component:v,error:h,children:x(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):x()},null)}var Zg=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(Zg||{});function Dk(t){let e=S.useContext(bk);return e||nr(!1),e}function Lk(t){let e=S.useContext(jh);return e||nr(!1),e}function Ik(t){let e=Lk(),n=e.matches[e.matches.length-1];return n.route.id||nr(!1),n.route.id}function kk(){var t;let e=S.useContext(LT),n=Dk(Zg.UseRouteError),r=Ik(Zg.UseRouteError);return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function Qg(t){nr(!1)}function Ok(t){let{basename:e="/",children:n=null,location:r,navigationType:i=Is.Pop,navigator:s,static:o=!1,future:a}=t;Iy()&&nr(!1);let l=e.replace(/^\/*/,"/"),c=S.useMemo(()=>({basename:l,navigator:s,static:o,future:Yf({v7_relativeSplatPath:!1},a)}),[l,a,s,o]);typeof r=="string"&&(r=zh(r));let{pathname:f="/",search:u="",hash:d="",state:h=null,key:m="default"}=r,v=S.useMemo(()=>{let g=PT(f,l);return g==null?null:{location:{pathname:g,search:u,hash:d,state:h,key:m},navigationType:i}},[l,f,u,d,h,m,i]);return v==null?null:S.createElement(DT.Provider,{value:c},S.createElement(Hh.Provider,{children:n,value:v}))}function Fk(t){let{children:e,location:n}=t;return Ek(Jg(e),n)}new Promise(()=>{});function Jg(t,e){e===void 0&&(e=[]);let n=[];return S.Children.forEach(t,(r,i)=>{if(!S.isValidElement(r))return;let s=[...e,i];if(r.type===S.Fragment){n.push.apply(n,Jg(r.props.children,s));return}r.type!==Qg&&nr(!1),!r.props.index||!r.props.children||nr(!1);let o={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Jg(r.props.children,s)),n.push(o)}),n}/**
* React Router DOM v6.27.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/const Uk="6";try{window.__reactRouterVersion=Uk}catch{}const Bk="startTransition",pw=WM[Bk];function zk(t){let{basename:e,children:n,future:r,window:i}=t,s=S.useRef();s.current==null&&(s.current=rk({window:i,v5Compat:!0}));let o=s.current,[a,l]=S.useState({action:o.action,location:o.location}),{v7_startTransition:c}=r||{},f=S.useCallback(u=>{c&&pw?pw(()=>l(u)):l(u)},[l,c]);return S.useLayoutEffect(()=>o.listen(f),[o,f]),S.createElement(Ok,{basename:e,children:n,location:a.location,navigationType:a.action,navigator:o,future:r})}var mw;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(mw||(mw={}));var gw;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(gw||(gw={}));const Hk=S.createContext(void 0),jk=({children:t})=>{const[e,n]=S.useState(()=>localStorage.getItem("theme")||"dark");S.useEffect(()=>{localStorage.setItem("theme",e),document.documentElement.classList.toggle("dark",e==="dark")},[e]);const r=()=>{n(i=>i==="light"?"dark":"light")};return y.jsx(Hk.Provider,{value:{theme:e,setTheme:n,toggleTheme:r},children:t})},kT=S.createContext(void 0),Vk=()=>{const t=S.useContext(kT);if(t===void 0)throw new Error("useUnits must be used within a UnitsProvider");return t},vw={meters:1,feet:3.28084,inches:39.3701,centimeters:100},Gk=({children:t})=>{const[e,n]=S.useState(()=>localStorage.getItem("units")||"meters");S.useEffect(()=>{localStorage.setItem("units",e)},[e]);const r=(s,o="meters")=>s/vw[o]*vw[e],i=(s,o=2)=>{const a={meters:"m",feet:"ft",inches:"in",centimeters:"cm"};return`${s.toFixed(o)}${a[e]}`};return y.jsx(kT.Provider,{value:{unit:e,setUnit:n,convertValue:r,formatValue:i},children:t})},OT=S.createContext(void 0),ky=()=>{const t=S.useContext(OT);if(!t)throw new Error("useNotifications must be used within a NotificationProvider");return t},Wk=({children:t})=>{const[e,n]=S.useState([]),r=l=>{const c={...l,id:Date.now().toString(),timestamp:new Date,read:!1};n(f=>[c,...f])},i=l=>{n(c=>c.map(f=>f.id===l?{...f,read:!0}:f))},s=()=>{n(l=>l.map(c=>({...c,read:!0})))},o=()=>{n([])},a=e.filter(l=>!l.read).length;return y.jsx(OT.Provider,{value:{messages:e,unreadCount:a,addMessage:r,markAsRead:i,markAllAsRead:s,clearAllMessages:o},children:t})},FT=S.createContext(null),Xk=({children:t})=>{const[e,n]=S.useState([]),r=S.useCallback(u=>{n(u?[u]:[])},[]),i=S.useCallback(u=>{n(u)},[]),s=S.useCallback(u=>{n(d=>d.find(h=>h.id===u.id)?d:[...d,u])},[]),o=S.useCallback(u=>{n(d=>d.filter(h=>h.id!==u.id))},[]),a=S.useCallback(u=>{n(d=>d.find(m=>m.id===u.id)?d.filter(m=>m.id!==u.id):[...d,u])},[]),l=S.useCallback(()=>{n([])},[]),c=S.useCallback(u=>e.some(d=>d.id===u.id),[e]),f=e.length>0?e[0]:null;return y.jsx(FT.Provider,{value:{selectedObjects:e,selectedObject:f,selectObject:r,selectMultipleObjects:i,addToSelection:s,removeFromSelection:o,toggleSelection:a,clearSelection:l,isSelected:c},children:t})},Bl=()=>{const t=S.useContext(FT);if(!t)throw new Error("useSelectionContext must be used within a SelectionProvider");return t},$k=({children:t})=>y.jsx(Xk,{children:y.jsx("div",{className:"min-h-screen bg-background text-foreground overflow-hidden transition-colors",children:t})}),Yk=({onToggleControlPanel:t,onZoomAll:e,onZoomToSelected:n,onResetView:r})=>{S.useEffect(()=>{const i=s=>{if(!(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement))switch(s.key.toLowerCase()){case"tab":t&&(t(),s.preventDefault());break;case"a":e&&(e(),s.preventDefault());break;case"f":n&&(n(),s.preventDefault());break;case"r":r&&(r(),s.preventDefault());break}};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[t,e,n,r])},UT=()=>{const[t,e]=S.useState([]);return{measurements:t,addMeasurement:(o,a)=>{const l=o.distanceTo(a),c={id:`measure_${Date.now()}`,startPoint:{x:o.x,y:o.y,z:o.z},endPoint:{x:a.x,y:a.y,z:a.z},distance:l,label:`Measurement ${t.length+1}`};return e(f=>[...f,c]),c},removeMeasurement:o=>{e(a=>a.filter(l=>l.id!==o))},clearAllMeasurements:()=>{e([])},updateMeasurementLabel:(o,a)=>{e(l=>l.map(c=>c.id===o?{...c,label:a}:c))}}},yw=t=>{let e;const n=new Set,r=(c,f)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const d=e;e=f??(typeof u!="object"||u===null)?u:Object.assign({},e,u),n.forEach(h=>h(e,d))}},i=()=>e,a={setState:r,getState:i,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=e=t(r,i,a);return a},Kk=t=>t?yw(t):yw,qk=t=>t;function Zk(t,e=qk){const n=he.useSyncExternalStore(t.subscribe,()=>e(t.getState()),()=>e(t.getInitialState()));return he.useDebugValue(n),n}const Qk=t=>{const e=Kk(t),n=r=>Zk(e,r);return Object.assign(n,e),n},Jk=t=>Qk,xw={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},ru=new Map,nd=t=>{const e=ru.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,r])=>[n,r.getState()])):{}},eO=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const r=ru.get(n.name);if(r)return{type:"tracked",store:t,...r};const i={connection:e.connect(n),stores:{}};return ru.set(n.name,i),{type:"tracked",store:t,...i}},tO=(t,e)=>{if(e===void 0)return;const n=ru.get(t);n&&(delete n.stores[e],Object.keys(n.stores).length===0&&ru.delete(t))},nO=t=>{var e,n;if(!t)return;const r=t.split(`
`),i=r.findIndex(o=>o.includes("api.setState"));if(i<0)return;const s=((e=r[i+1])==null?void 0:e.trim())||"";return(n=/.+ (.+) .+/.exec(s))==null?void 0:n[1]},rO=(t,e={})=>(n,r,i)=>{const{enabled:s,anonymousActionType:o,store:a,...l}=e;let c;try{c=(s??(xw?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return t(n,r,i);const{connection:f,...u}=eO(a,c,l);let d=!0;i.setState=(v,g,p)=>{const x=n(v,g);if(!d)return x;const _=p===void 0?{type:o||nO(new Error().stack)||"anonymous"}:typeof p=="string"?{type:p}:p;return a===void 0?(f==null||f.send(_,r()),x):(f==null||f.send({..._,type:`${a}/${_.type}`},{...nd(l.name),[a]:i.getState()}),x)},i.devtools={cleanup:()=>{f&&typeof f.unsubscribe=="function"&&f.unsubscribe(),tO(l.name,a)}};const h=(...v)=>{const g=d;d=!1,n(...v),d=g},m=t(i.setState,r,i);if(u.type==="untracked"?f==null||f.init(m):(u.stores[u.store]=i,f==null||f.init(Object.fromEntries(Object.entries(u.stores).map(([v,g])=>[v,v===u.store?m:g.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let v=!1;const g=i.dispatch;i.dispatch=(...p)=>{(xw?"production":void 0)!=="production"&&p[0].type==="__setState"&&!v&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),v=!0),g(...p)}}return f.subscribe(v=>{var g;switch(v.type){case"ACTION":if(typeof v.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return zp(v.payload,p=>{if(p.type==="__setState"){if(a===void 0){h(p.state);return}Object.keys(p.state).length!==1&&console.error(`
[zustand devtools middleware] Unsupported __setState action format.
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
`);const x=p.state[a];if(x==null)return;JSON.stringify(i.getState())!==JSON.stringify(x)&&h(x);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(p)});case"DISPATCH":switch(v.payload.type){case"RESET":return h(m),a===void 0?f==null?void 0:f.init(i.getState()):f==null?void 0:f.init(nd(l.name));case"COMMIT":if(a===void 0){f==null||f.init(i.getState());return}return f==null?void 0:f.init(nd(l.name));case"ROLLBACK":return zp(v.state,p=>{if(a===void 0){h(p),f==null||f.init(i.getState());return}h(p[a]),f==null||f.init(nd(l.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return zp(v.state,p=>{if(a===void 0){h(p);return}JSON.stringify(i.getState())!==JSON.stringify(p[a])&&h(p[a])});case"IMPORT_STATE":{const{nextLiftedState:p}=v.payload,x=(g=p.computedStates.slice(-1)[0])==null?void 0:g.state;if(!x)return;h(a===void 0?x:x[a]),f==null||f.send(null,p);return}case"PAUSE_RECORDING":return d=!d}return}}),m},iO=rO,zp=(t,e)=>{let n;try{n=JSON.parse(t)}catch(r){console.error("[zustand devtools middleware] Could not parse the received json",r)}n!==void 0&&e(n)},_w=t=>Symbol.iterator in t,ww=t=>"entries"in t,Sw=(t,e)=>{const n=t instanceof Map?t:new Map(t.entries()),r=e instanceof Map?e:new Map(e.entries());if(n.size!==r.size)return!1;for(const[i,s]of n)if(!Object.is(s,r.get(i)))return!1;return!0},sO=(t,e)=>{const n=t[Symbol.iterator](),r=e[Symbol.iterator]();let i=n.next(),s=r.next();for(;!i.done&&!s.done;){if(!Object.is(i.value,s.value))return!1;i=n.next(),s=r.next()}return!!i.done&&!!s.done};function oO(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:_w(t)&&_w(e)?ww(t)&&ww(e)?Sw(t,e):sO(t,e):Sw({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function Oy(t){const e=he.useRef(void 0);return n=>{const r=t(n);return oO(e.current,r)?e.current:e.current=r}}const Fy=Jk()(iO(t=>({scene:null,isInitialized:!1,setScene:e=>t({scene:e},!1,"setScene"),setInitialized:e=>t({isInitialized:e},!1,"setInitialized"),showControlPanel:!1,showMeasurePanel:!1,activeControlTab:"scene",activeTool:"select",isOrthographic:!1,gridEnabled:!0,groundPlaneEnabled:!1,setShowControlPanel:e=>t({showControlPanel:e},!1,"setShowControlPanel"),setShowMeasurePanel:e=>t({showMeasurePanel:e},!1,"setShowMeasurePanel"),setActiveControlTab:e=>t({activeControlTab:e},!1,"setActiveControlTab"),setActiveTool:e=>t({activeTool:e},!1,"setActiveTool"),setIsOrthographic:e=>t({isOrthographic:e},!1,"setIsOrthographic"),setGridEnabled:e=>t({gridEnabled:e},!1,"setGridEnabled"),setGroundPlaneEnabled:e=>t({groundPlaneEnabled:e},!1,"setGroundPlaneEnabled"),loadedModels:[],currentModel:null,sunlight:{intensity:1,azimuth:45,elevation:45,color:"#ffffff",castShadow:!0},ambientLight:{intensity:.4,color:"#ffffff"},shadowQuality:"medium",environment:{showGrid:!0,groundColor:"#ffffff",skyColor:"#87CEEB",showGround:!0,preset:"default"},isUploading:!1,uploadError:null,setLoadedModels:e=>t({loadedModels:e},!1,"setLoadedModels"),setCurrentModel:e=>t({currentModel:e},!1,"setCurrentModel"),setSunlight:e=>t({sunlight:e},!1,"setSunlight"),setAmbientLight:e=>t({ambientLight:e},!1,"setAmbientLight"),setShadowQuality:e=>t({shadowQuality:e},!1,"setShadowQuality"),setEnvironment:e=>t({environment:e},!1,"setEnvironment"),setUploading:e=>t({isUploading:e},!1,"setUploading"),setUploadError:e=>t({uploadError:e},!1,"setUploadError")}),{name:"app-store"})),BT=()=>Fy(Oy(t=>({scene:t.scene,isInitialized:t.isInitialized,setScene:t.setScene,setInitialized:t.setInitialized}))),iu=()=>Fy(Oy(t=>({showControlPanel:t.showControlPanel,showMeasurePanel:t.showMeasurePanel,activeControlTab:t.activeControlTab,activeTool:t.activeTool,isOrthographic:t.isOrthographic,gridEnabled:t.gridEnabled,groundPlaneEnabled:t.groundPlaneEnabled,setShowControlPanel:t.setShowControlPanel,setShowMeasurePanel:t.setShowMeasurePanel,setActiveControlTab:t.setActiveControlTab,setActiveTool:t.setActiveTool,setIsOrthographic:t.setIsOrthographic,setGridEnabled:t.setGridEnabled,setGroundPlaneEnabled:t.setGroundPlaneEnabled}))),Uy=()=>Fy(Oy(t=>({loadedModels:t.loadedModels,currentModel:t.currentModel,sunlight:t.sunlight,ambientLight:t.ambientLight,shadowQuality:t.shadowQuality,environment:t.environment,isUploading:t.isUploading,uploadError:t.uploadError,setLoadedModels:t.setLoadedModels,setCurrentModel:t.setCurrentModel,setSunlight:t.setSunlight,setAmbientLight:t.setAmbientLight,setShadowQuality:t.setShadowQuality,setEnvironment:t.setEnvironment,setUploading:t.setUploading,setUploadError:t.setUploadError}))),zT=(t,e,n)=>{uy();const{addMessage:r}=ky();return{handleToolSelect:a=>{t(a),a==="measure"&&e(!0),r({type:"info",title:"Tool Selected",description:`${a.charAt(0).toUpperCase()+a.slice(1)} tool activated`})},handlePointCreate:a=>{console.log("Point created:",a),r({type:"success",title:"Point added",description:`Position: (${a.x.toFixed(2)}, ${a.y.toFixed(2)}, ${a.z.toFixed(2)})`})},handleMeasureCreate:(a,l)=>{const c=n(a,l);r({type:"success",title:"Measurement added",description:`Distance: ${c.distance.toFixed(3)} units`})}}},HT=()=>({handleZoomAll:()=>{console.log("useZoomHandlers: handleZoomAll called");const s=window.__zoomControls;s?(console.log("useZoomHandlers: executing zoomAll"),s.zoomAll()):console.log("useZoomHandlers: zoom controls not available")},handleZoomToSelected:()=>{console.log("useZoomHandlers: handleZoomToSelected called");const s=window.__zoomControls;s?(console.log("useZoomHandlers: executing zoomToSelected"),s.zoomToSelected()):console.log("useZoomHandlers: zoom controls not available")},handleZoomIn:()=>{console.log("useZoomHandlers: handleZoomIn called");const s=window.__zoomControls;s&&s.zoomIn?(console.log("useZoomHandlers: executing zoomIn"),s.zoomIn()):console.log("useZoomHandlers: zoom controls not available")},handleZoomOut:()=>{console.log("useZoomHandlers: handleZoomOut called");const s=window.__zoomControls;s&&s.zoomOut?(console.log("useZoomHandlers: executing zoomOut"),s.zoomOut()):console.log("useZoomHandlers: zoom controls not available")},handleResetView:()=>{console.log("useZoomHandlers: handleResetView called");const s=window.__zoomControls;s?(console.log("useZoomHandlers: executing resetView"),s.resetView()):console.log("useZoomHandlers: zoom controls not available")}}),bo=class bo{constructor(){kt(this,"geometries",new Map);kt(this,"materials",new Map);kt(this,"textures",new Map)}static getInstance(){return bo.instance||(bo.instance=new bo),bo.instance}getGeometry(e,n){return this.geometries.has(e)||this.geometries.set(e,n()),this.geometries.get(e)}getMaterial(e,n){return this.materials.has(e)||this.materials.set(e,n()),this.materials.get(e)}getTexture(e,n){return this.textures.has(e)||this.textures.set(e,n()),this.textures.get(e)}disposeAll(){this.geometries.forEach(e=>e.dispose()),this.materials.forEach(e=>e.dispose()),this.textures.forEach(e=>e.dispose()),this.geometries.clear(),this.materials.clear(),this.textures.clear()}dispose(e,n){switch(e){case"geometry":const r=this.geometries.get(n);r&&(r.dispose(),this.geometries.delete(n));break;case"material":const i=this.materials.get(n);i&&(i.dispose(),this.materials.delete(n));break;case"texture":const s=this.textures.get(n);s&&(s.dispose(),this.textures.delete(n));break}}};kt(bo,"instance");let Kf=bo;const aO=t=>{const e=S.useRef({fps:60,frameTime:16.67,memoryUsage:0,renderCalls:0}),n=S.useRef(0),r=S.useRef(performance.now()),i=S.useRef(0),s=S.useCallback(()=>{const a=performance.now(),l=a-r.current;if(n.current++,l>=1e3&&(e.current.fps=Math.round(n.current*1e3/l),e.current.frameTime=l/n.current,n.current=0,r.current=a),"memory"in performance){const c=performance.memory;e.current.memoryUsage=c.usedJSHeapSize/1048576}e.current.renderCalls=i.current,i.current=0},[]),o=S.useCallback(()=>{i.current++},[]);return S.useEffect(()=>{if(!t)return;const a=t.render.bind(t);t.render=(c,f)=>(o(),a(c,f));const l=setInterval(s,100);return()=>{clearInterval(l),t.render=a}},[t,s,o]),{metrics:e.current,updateMetrics:s}};/**
* @license
* Copyright 2010-2024 Three.js Authors
* SPDX-License-Identifier: MIT
*/const By="170",Yi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},gi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},lO=0,Mw=1,cO=2,uO=0,jT=1,zy=2,Fi=3,ns=0,tr=1,pi=2,Gs=0,qa=1,bw=2,Ew=3,Tw=4,dO=5,So=100,fO=101,hO=102,pO=103,mO=104,gO=200,vO=201,yO=202,xO=203,ev=204,tv=205,_O=206,wO=207,SO=208,MO=209,bO=210,EO=211,TO=212,AO=213,CO=214,nv=0,rv=1,iv=2,Ml=3,sv=4,ov=5,av=6,lv=7,Vh=0,RO=1,PO=2,Ws=0,NO=1,DO=2,LO=3,Hy=4,IO=5,kO=6,OO=7,Aw="attached",FO="detached",VT=300,bl=301,El=302,qf=303,cv=304,Gh=306,Js=1e3,vi=1001,Zf=1002,Hn=1003,GT=1004,_c=1005,hr=1006,of=1007,Gi=1008,rs=1009,WT=1010,XT=1011,su=1012,jy=1013,Go=1014,qr=1015,Tu=1016,Vy=1017,Gy=1018,Tl=1020,$T=35902,YT=1021,KT=1022,Cr=1023,qT=1024,ZT=1025,Za=1026,Al=1027,Wy=1028,Xy=1029,QT=1030,$y=1031,Yy=1033,af=33776,lf=33777,cf=33778,uf=33779,uv=35840,dv=35841,fv=35842,hv=35843,pv=36196,mv=37492,gv=37496,vv=37808,yv=37809,xv=37810,_v=37811,wv=37812,Sv=37813,Mv=37814,bv=37815,Ev=37816,Tv=37817,Av=37818,Cv=37819,Rv=37820,Pv=37821,df=36492,Nv=36494,Dv=36495,JT=36283,Lv=36284,Iv=36285,kv=36286,ou=2300,au=2301,Hp=2302,Cw=2400,Rw=2401,Pw=2402,UO=2500,BO=0,eA=1,Ov=2,zO=3200,HO=3201,Wh=0,jO=1,Ts="",ft="srgb",Ln="srgb-linear",Xh="linear",Mt="srgb",ia=7680,Nw=519,VO=512,GO=513,WO=514,tA=515,XO=516,$O=517,YO=518,KO=519,Fv=35044,Dw="300 es",Wi=2e3,Qf=2001;class ta{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}}const En=["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"];let Lw=1234567;const Qa=Math.PI/180,Cl=180/Math.PI;function ei(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(En[t&255]+En[t>>8&255]+En[t>>16&255]+En[t>>24&255]+"-"+En[e&255]+En[e>>8&255]+"-"+En[e>>16&15|64]+En[e>>24&255]+"-"+En[n&63|128]+En[n>>8&255]+"-"+En[n>>16&255]+En[n>>24&255]+En[r&255]+En[r>>8&255]+En[r>>16&255]+En[r>>24&255]).toLowerCase()}function rn(t,e,n){return Math.max(e,Math.min(n,t))}function Ky(t,e){return(t%e+e)%e}function qO(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function ZO(t,e,n){return t!==e?(n-t)/(e-t):0}function Ic(t,e,n){return(1-n)*t+n*e}function QO(t,e,n,r){return Ic(t,e,1-Math.exp(-n*r))}function JO(t,e=1){return e-Math.abs(Ky(t,e*2)-e)}function eF(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function tF(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function nF(t,e){return t+Math.floor(Math.random()*(e-t+1))}function rF(t,e){return t+Math.random()*(e-t)}function iF(t){return t*(.5-Math.random())}function sF(t){t!==void 0&&(Lw=t);let e=Lw+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function oF(t){return t*Qa}function aF(t){return t*Cl}function lF(t){return(t&t-1)===0&&t!==0}function cF(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function uF(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function dF(t,e,n,r,i){const s=Math.cos,o=Math.sin,a=s(n/2),l=o(n/2),c=s((e+r)/2),f=o((e+r)/2),u=s((e-r)/2),d=o((e-r)/2),h=s((r-e)/2),m=o((r-e)/2);switch(i){case"XYX":t.set(a*f,l*u,l*d,a*c);break;case"YZY":t.set(l*d,a*f,l*u,a*c);break;case"ZXZ":t.set(l*u,l*d,a*f,a*c);break;case"XZX":t.set(a*f,l*m,l*h,a*c);break;case"YXY":t.set(l*h,a*f,l*m,a*c);break;case"ZYZ":t.set(l*m,l*h,a*f,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Kr(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function wt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const gn={DEG2RAD:Qa,RAD2DEG:Cl,generateUUID:ei,clamp:rn,euclideanModulo:Ky,mapLinear:qO,inverseLerp:ZO,lerp:Ic,damp:QO,pingpong:JO,smoothstep:eF,smootherstep:tF,randInt:nF,randFloat:rF,randFloatSpread:iF,seededRandom:sF,degToRad:oF,radToDeg:aF,isPowerOfTwo:lF,ceilPowerOfTwo:cF,floorPowerOfTwo:uF,setQuaternionFromProperEuler:dF,normalize:wt,denormalize:Kr};class ze{constructor(e=0,n=0){ze.prototype.isVector2=!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("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,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,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[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=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}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 r=this.dot(e)/n;return Math.acos(rn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,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 r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qe{constructor(e,n,r,i,s,o,a,l,c){Qe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,a,l,c)}set(e,n,r,i,s,o,a,l,c){const f=this.elements;return f[0]=e,f[1]=i,f[2]=a,f[3]=n,f[4]=s,f[5]=l,f[6]=r,f[7]=o,f[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.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 r=e.elements,i=n.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],f=r[4],u=r[7],d=r[2],h=r[5],m=r[8],v=i[0],g=i[3],p=i[6],x=i[1],_=i[4],w=i[7],M=i[2],T=i[5],b=i[8];return s[0]=o*v+a*x+l*M,s[3]=o*g+a*_+l*T,s[6]=o*p+a*w+l*b,s[1]=c*v+f*x+u*M,s[4]=c*g+f*_+u*T,s[7]=c*p+f*w+u*b,s[2]=d*v+h*x+m*M,s[5]=d*g+h*_+m*T,s[8]=d*p+h*w+m*b,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],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],f=e[8];return n*o*f-n*a*c-r*s*f+r*a*l+i*s*c-i*o*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],f=e[8],u=f*o-a*c,d=a*l-f*s,h=c*s-o*l,m=n*u+r*d+i*h;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=u*v,e[1]=(i*c-f*r)*v,e[2]=(a*r-i*o)*v,e[3]=d*v,e[4]=(f*n-i*l)*v,e[5]=(i*s-a*n)*v,e[6]=h*v,e[7]=(r*l-c*n)*v,e[8]=(o*n-r*s)*v,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,r,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+n,0,0,1),this}scale(e,n){return this.premultiply(jp.makeScale(e,n)),this}rotate(e){return this.premultiply(jp.makeRotation(-e)),this}translate(e,n){return this.premultiply(jp.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),r=Math.sin(e);return this.set(n,-r,0,r,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,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const jp=new Qe;function nA(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function lu(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function fF(){const t=lu("canvas");return t.style.display="block",t}const Iw={};function wc(t){t in Iw||(Iw[t]=!0,console.warn(t))}function hF(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}function pF(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function mF(t){const e=t.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const $e={enabled:!0,workingColorSpace:Ln,spaces:{},convert:function(t,e,n){return this.enabled===!1||e===n||!e||!n||(this.spaces[e].transfer===Mt&&(t.r=Ki(t.r),t.g=Ki(t.g),t.b=Ki(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Mt&&(t.r=Ja(t.r),t.g=Ja(t.g),t.b=Ja(t.b))),t},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===Ts?Xh:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}};function Ki(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Ja(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}const kw=[.64,.33,.3,.6,.15,.06],Ow=[.2126,.7152,.0722],Fw=[.3127,.329],Uw=new Qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Bw=new Qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);$e.define({[Ln]:{primaries:kw,whitePoint:Fw,transfer:Xh,toXYZ:Uw,fromXYZ:Bw,luminanceCoefficients:Ow,workingColorSpaceConfig:{unpackColorSpace:ft},outputColorSpaceConfig:{drawingBufferColorSpace:ft}},[ft]:{primaries:kw,whitePoint:Fw,transfer:Mt,toXYZ:Uw,fromXYZ:Bw,luminanceCoefficients:Ow,outputColorSpaceConfig:{drawingBufferColorSpace:ft}}});let sa;class gF{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{sa===void 0&&(sa=lu("canvas")),sa.width=e.width,sa.height=e.height;const r=sa.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=sa}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=lu("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Ki(s[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Ki(n[r]/255)*255):n[r]=Ki(n[r]);return{data:n,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let vF=0;class rA{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:vF++}),this.uuid=ei(),this.data=e,this.dataReady=!0,this.version=0}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 r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Vp(i[o].image)):s.push(Vp(i[o]))}else s=Vp(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function Vp(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?gF.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let yF=0;class on extends ta{constructor(e=on.DEFAULT_IMAGE,n=on.DEFAULT_MAPPING,r=vi,i=vi,s=hr,o=Gi,a=Cr,l=rs,c=on.DEFAULT_ANISOTROPY,f=Ts){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:yF++}),this.uuid=ei(),this.name="",this.source=new rA(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new ze(0,0),this.repeat=new ze(1,1),this.center=new ze(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Qe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){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)}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.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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.6,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,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&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==VT)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Js:e.x=e.x-Math.floor(e.x);break;case vi:e.x=e.x<0?0:1;break;case Zf: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 Js:e.y=e.y-Math.floor(e.y);break;case vi:e.y=e.y<0?0:1;break;case Zf: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++}}on.DEFAULT_IMAGE=null;on.DEFAULT_MAPPING=VT;on.DEFAULT_ANISOTROPY=1;class ut{constructor(e=0,n=0,r=0,i=1){ut.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}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,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,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("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,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,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,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,r,i,s;const l=e.elements,c=l[0],f=l[4],u=l[8],d=l[1],h=l[5],m=l[9],v=l[2],g=l[6],p=l[10];if(Math.abs(f-d)<.01&&Math.abs(u-v)<.01&&Math.abs(m-g)<.01){if(Math.abs(f+d)<.1&&Math.abs(u+v)<.1&&Math.abs(m+g)<.1&&Math.abs(c+h+p-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const _=(c+1)/2,w=(h+1)/2,M=(p+1)/2,T=(f+d)/4,b=(u+v)/4,C=(m+g)/4;return _>w&&_>M?_<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(_),i=T/r,s=b/r):w>M?w<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(w),r=T/i,s=C/i):M<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),r=b/s,i=C/s),this.set(r,i,s,n),this}let x=Math.sqrt((g-m)*(g-m)+(u-v)*(u-v)+(d-f)*(d-f));return Math.abs(x)<.001&&(x=1),this.x=(g-m)/x,this.y=(u-v)/x,this.z=(d-f)/x,this.w=Math.acos((c+h+p-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=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,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}}class xF extends ta{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new ut(0,0,e,n),this.scissorTest=!1,this.viewport=new ut(0,0,e,n);const i={width:e,height:n,depth:1};r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:hr,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},r);const s=new on(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace);s.flipY=!1,s.generateMipmaps=r.generateMipmaps,s.internalFormat=r.internalFormat,this.textures=[];const o=r.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this.depthTexture=r.depthTexture,this.samples=r.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r;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 r=0,i=e.textures.length;r<i;r++)this.textures[r]=e.textures[r].clone(),this.textures[r].isRenderTargetTexture=!0;const n=Object.assign({},e.texture.image);return this.texture.source=new rA(n),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}dispose(){this.dispatchEvent({type:"dispose"})}}class Wo extends xF{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class iA extends on{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Hn,this.minFilter=Hn,this.wrapR=vi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class _F extends on{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Hn,this.minFilter=Hn,this.wrapR=vi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class nn{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,o,a){let l=r[i+0],c=r[i+1],f=r[i+2],u=r[i+3];const d=s[o+0],h=s[o+1],m=s[o+2],v=s[o+3];if(a===0){e[n+0]=l,e[n+1]=c,e[n+2]=f,e[n+3]=u;return}if(a===1){e[n+0]=d,e[n+1]=h,e[n+2]=m,e[n+3]=v;return}if(u!==v||l!==d||c!==h||f!==m){let g=1-a;const p=l*d+c*h+f*m+u*v,x=p>=0?1:-1,_=1-p*p;if(_>Number.EPSILON){const M=Math.sqrt(_),T=Math.atan2(M,p*x);g=Math.sin(g*T)/M,a=Math.sin(a*T)/M}const w=a*x;if(l=l*g+d*w,c=c*g+h*w,f=f*g+m*w,u=u*g+v*w,g===1-a){const M=1/Math.sqrt(l*l+c*c+f*f+u*u);l*=M,c*=M,f*=M,u*=M}}e[n]=l,e[n+1]=c,e[n+2]=f,e[n+3]=u}static multiplyQuaternionsFlat(e,n,r,i,s,o){const a=r[i],l=r[i+1],c=r[i+2],f=r[i+3],u=s[o],d=s[o+1],h=s[o+2],m=s[o+3];return e[n]=a*m+f*u+l*h-c*d,e[n+1]=l*m+f*d+c*u-a*h,e[n+2]=c*m+f*h+a*d-l*u,e[n+3]=f*m-a*u-l*d-c*h,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,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,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 r=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(r/2),f=a(i/2),u=a(s/2),d=l(r/2),h=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=d*f*u+c*h*m,this._y=c*h*u-d*f*m,this._z=c*f*m+d*h*u,this._w=c*f*u-d*h*m;break;case"YXZ":this._x=d*f*u+c*h*m,this._y=c*h*u-d*f*m,this._z=c*f*m-d*h*u,this._w=c*f*u+d*h*m;break;case"ZXY":this._x=d*f*u-c*h*m,this._y=c*h*u+d*f*m,this._z=c*f*m+d*h*u,this._w=c*f*u-d*h*m;break;case"ZYX":this._x=d*f*u-c*h*m,this._y=c*h*u+d*f*m,this._z=c*f*m-d*h*u,this._w=c*f*u+d*h*m;break;case"YZX":this._x=d*f*u+c*h*m,this._y=c*h*u+d*f*m,this._z=c*f*m-d*h*u,this._w=c*f*u-d*h*m;break;case"XZY":this._x=d*f*u-c*h*m,this._y=c*h*u-d*f*m,this._z=c*f*m+d*h*u,this._w=c*f*u+d*h*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],o=n[1],a=n[5],l=n[9],c=n[2],f=n[6],u=n[10],d=r+a+u;if(d>0){const h=.5/Math.sqrt(d+1);this._w=.25/h,this._x=(f-l)*h,this._y=(s-c)*h,this._z=(o-i)*h}else if(r>a&&r>u){const h=2*Math.sqrt(1+r-a-u);this._w=(f-l)/h,this._x=.25*h,this._y=(i+o)/h,this._z=(s+c)/h}else if(a>u){const h=2*Math.sqrt(1+a-r-u);this._w=(s-c)/h,this._x=(i+o)/h,this._y=.25*h,this._z=(l+f)/h}else{const h=2*Math.sqrt(1+u-r-a);this._w=(o-i)/h,this._x=(s+c)/h,this._y=(l+f)/h,this._z=.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(rn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),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 r=e._x,i=e._y,s=e._z,o=e._w,a=n._x,l=n._y,c=n._z,f=n._w;return this._x=r*f+o*a+i*c-s*l,this._y=i*f+o*l+s*a-r*c,this._z=s*f+o*c+r*l-i*a,this._w=o*f-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+r*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const h=1-n;return this._w=h*o+n*this._w,this._x=h*r+n*this._x,this._y=h*i+n*this._y,this._z=h*s+n*this._z,this.normalize(),this}const c=Math.sqrt(l),f=Math.atan2(c,a),u=Math.sin((1-n)*f)/c,d=Math.sin(n*f)/c;return this._w=o*u+this._w*d,this._x=r*u+this._x*d,this._y=i*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*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}}class k{constructor(e=0,n=0,r=0){k.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,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("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,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(zw.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(zw.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*r),f=2*(a*n-s*i),u=2*(s*r-o*n);return this.x=n+l*c+o*u-a*f,this.y=r+l*f+a*c-s*u,this.z=i+l*u+s*f-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,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=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,o=n.x,a=n.y,l=n.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return Gp.copy(this).projectOnVector(e),this.sub(Gp)}reflect(e){return this.sub(Gp.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 r=this.dot(e)/n;return Math.acos(rn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}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,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,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,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Gp=new k,zw=new nn;class Gt{constructor(e=new k(1/0,1/0,1/0),n=new k(-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,r=e.length;n<r;n+=3)this.expandByPoint(Ur.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ur.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Ur.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),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 r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Ur):Ur.fromBufferAttribute(s,o),Ur.applyMatrix4(e.matrixWorld),this.expandByPoint(Ur);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),rd.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),rd.copy(r.boundingBox)),rd.applyMatrix4(e.matrixWorld),this.union(rd)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],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,Ur),Ur.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(sc),id.subVectors(this.max,sc),oa.subVectors(e.a,sc),aa.subVectors(e.b,sc),la.subVectors(e.c,sc),us.subVectors(aa,oa),ds.subVectors(la,aa),fo.subVectors(oa,la);let n=[0,-us.z,us.y,0,-ds.z,ds.y,0,-fo.z,fo.y,us.z,0,-us.x,ds.z,0,-ds.x,fo.z,0,-fo.x,-us.y,us.x,0,-ds.y,ds.x,0,-fo.y,fo.x,0];return!Wp(n,oa,aa,la,id)||(n=[1,0,0,0,1,0,0,0,1],!Wp(n,oa,aa,la,id))?!1:(sd.crossVectors(us,ds),n=[sd.x,sd.y,sd.z],Wp(n,oa,aa,la,id))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ur).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ur).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:(Pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Pi=[new k,new k,new k,new k,new k,new k,new k,new k],Ur=new k,rd=new Gt,oa=new k,aa=new k,la=new k,us=new k,ds=new k,fo=new k,sc=new k,id=new k,sd=new k,ho=new k;function Wp(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){ho.fromArray(t,s);const a=i.x*Math.abs(ho.x)+i.y*Math.abs(ho.y)+i.z*Math.abs(ho.z),l=e.dot(ho),c=n.dot(ho),f=r.dot(ho);if(Math.max(-Math.max(l,c,f),Math.min(l,c,f))>a)return!1}return!0}const wF=new Gt,oc=new k,Xp=new k;class bi{constructor(e=new k,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 r=this.center;n!==void 0?r.copy(n):wF.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),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 r=this.center.distanceToSquared(e);return n.copy(e),r>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;oc.subVectors(e,this.center);const n=oc.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(oc,i/r),this.radius+=i}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):(Xp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oc.copy(e.center).add(Xp)),this.expandByPoint(oc.copy(e.center).sub(Xp))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ni=new k,$p=new k,od=new k,fs=new k,Yp=new k,ad=new k,Kp=new k;class zl{constructor(e=new k,n=new k(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,Ni)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Ni.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Ni.copy(this.origin).addScaledVector(this.direction,n),Ni.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){$p.copy(e).add(n).multiplyScalar(.5),od.copy(n).sub(e).normalize(),fs.copy(this.origin).sub($p);const s=e.distanceTo(n)*.5,o=-this.direction.dot(od),a=fs.dot(this.direction),l=-fs.dot(od),c=fs.lengthSq(),f=Math.abs(1-o*o);let u,d,h,m;if(f>0)if(u=o*l-a,d=o*a-l,m=s*f,u>=0)if(d>=-m)if(d<=m){const v=1/f;u*=v,d*=v,h=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=s,u=Math.max(0,-(o*d+a)),h=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(o*d+a)),h=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-l),s),h=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-s,-l),s),h=d*(d+2*l)+c):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-l),s),h=-u*u+d*(d+2*l)+c);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),h=-u*u+d*(d+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy($p).addScaledVector(od,d),h}intersectSphere(e,n){Ni.subVectors(e.center,this.origin);const r=Ni.dot(this.direction),i=Ni.dot(Ni)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return l<0?null:a<0?this.at(l,n):this.at(a,n)}intersectsSphere(e){return 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 r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,o,a,l;const c=1/this.direction.x,f=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(r=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(r=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),f>=0?(s=(e.min.y-d.y)*f,o=(e.max.y-d.y)*f):(s=(e.max.y-d.y)*f,o=(e.min.y-d.y)*f),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),u>=0?(a=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),r>l||a>i)||((a>r||r!==r)&&(r=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Ni)!==null}intersectTriangle(e,n,r,i,s){Yp.subVectors(n,e),ad.subVectors(r,e),Kp.crossVectors(Yp,ad);let o=this.direction.dot(Kp),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;fs.subVectors(this.origin,e);const l=a*this.direction.dot(ad.crossVectors(fs,ad));if(l<0)return null;const c=a*this.direction.dot(Yp.cross(fs));if(c<0||l+c>o)return null;const f=-a*fs.dot(Kp);return f<0?null:this.at(f/o,s)}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 Ce{constructor(e,n,r,i,s,o,a,l,c,f,u,d,h,m,v,g){Ce.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,a,l,c,f,u,d,h,m,v,g)}set(e,n,r,i,s,o,a,l,c,f,u,d,h,m,v,g){const p=this.elements;return p[0]=e,p[4]=n,p[8]=r,p[12]=i,p[1]=s,p[5]=o,p[9]=a,p[13]=l,p[2]=c,p[6]=f,p[10]=u,p[14]=d,p[3]=h,p[7]=m,p[11]=v,p[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ce().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[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,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/ca.setFromMatrixColumn(e,0).length(),s=1/ca.setFromMatrixColumn(e,1).length(),o=1/ca.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),f=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const d=o*f,h=o*u,m=a*f,v=a*u;n[0]=l*f,n[4]=-l*u,n[8]=c,n[1]=h+m*c,n[5]=d-v*c,n[9]=-a*l,n[2]=v-d*c,n[6]=m+h*c,n[10]=o*l}else if(e.order==="YXZ"){const d=l*f,h=l*u,m=c*f,v=c*u;n[0]=d+v*a,n[4]=m*a-h,n[8]=o*c,n[1]=o*u,n[5]=o*f,n[9]=-a,n[2]=h*a-m,n[6]=v+d*a,n[10]=o*l}else if(e.order==="ZXY"){const d=l*f,h=l*u,m=c*f,v=c*u;n[0]=d-v*a,n[4]=-o*u,n[8]=m+h*a,n[1]=h+m*a,n[5]=o*f,n[9]=v-d*a,n[2]=-o*c,n[6]=a,n[10]=o*l}else if(e.order==="ZYX"){const d=o*f,h=o*u,m=a*f,v=a*u;n[0]=l*f,n[4]=m*c-h,n[8]=d*c+v,n[1]=l*u,n[5]=v*c+d,n[9]=h*c-m,n[2]=-c,n[6]=a*l,n[10]=o*l}else if(e.order==="YZX"){const d=o*l,h=o*c,m=a*l,v=a*c;n[0]=l*f,n[4]=v-d*u,n[8]=m*u+h,n[1]=u,n[5]=o*f,n[9]=-a*f,n[2]=-c*f,n[6]=h*u+m,n[10]=d-v*u}else if(e.order==="XZY"){const d=o*l,h=o*c,m=a*l,v=a*c;n[0]=l*f,n[4]=-u,n[8]=c*f,n[1]=d*u+v,n[5]=o*f,n[9]=h*u-m,n[2]=m*u-h,n[6]=a*f,n[10]=v*u+d}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(SF,e,MF)}lookAt(e,n,r){const i=this.elements;return ir.subVectors(e,n),ir.lengthSq()===0&&(ir.z=1),ir.normalize(),hs.crossVectors(r,ir),hs.lengthSq()===0&&(Math.abs(r.z)===1?ir.x+=1e-4:ir.z+=1e-4,ir.normalize(),hs.crossVectors(r,ir)),hs.normalize(),ld.crossVectors(ir,hs),i[0]=hs.x,i[4]=ld.x,i[8]=ir.x,i[1]=hs.y,i[5]=ld.y,i[9]=ir.y,i[2]=hs.z,i[6]=ld.z,i[10]=ir.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],f=r[1],u=r[5],d=r[9],h=r[13],m=r[2],v=r[6],g=r[10],p=r[14],x=r[3],_=r[7],w=r[11],M=r[15],T=i[0],b=i[4],C=i[8],A=i[12],E=i[1],N=i[5],F=i[9],I=i[13],U=i[2],z=i[6],O=i[10],j=i[14],D=i[3],V=i[7],Q=i[11],J=i[15];return s[0]=o*T+a*E+l*U+c*D,s[4]=o*b+a*N+l*z+c*V,s[8]=o*C+a*F+l*O+c*Q,s[12]=o*A+a*I+l*j+c*J,s[1]=f*T+u*E+d*U+h*D,s[5]=f*b+u*N+d*z+h*V,s[9]=f*C+u*F+d*O+h*Q,s[13]=f*A+u*I+d*j+h*J,s[2]=m*T+v*E+g*U+p*D,s[6]=m*b+v*N+g*z+p*V,s[10]=m*C+v*F+g*O+p*Q,s[14]=m*A+v*I+g*j+p*J,s[3]=x*T+_*E+w*U+M*D,s[7]=x*b+_*N+w*z+M*V,s[11]=x*C+_*F+w*O+M*Q,s[15]=x*A+_*I+w*j+M*J,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],r=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],f=e[2],u=e[6],d=e[10],h=e[14],m=e[3],v=e[7],g=e[11],p=e[15];return m*(+s*l*u-i*c*u-s*a*d+r*c*d+i*a*h-r*l*h)+v*(+n*l*h-n*c*d+s*o*d-i*o*h+i*c*f-s*l*f)+g*(+n*c*u-n*a*h-s*o*u+r*o*h+s*a*f-r*c*f)+p*(-i*a*f-n*l*u+n*a*d+i*o*u-r*o*d+r*l*f)}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,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],f=e[8],u=e[9],d=e[10],h=e[11],m=e[12],v=e[13],g=e[14],p=e[15],x=u*g*c-v*d*c+v*l*h-a*g*h-u*l*p+a*d*p,_=m*d*c-f*g*c-m*l*h+o*g*h+f*l*p-o*d*p,w=f*v*c-m*u*c+m*a*h-o*v*h-f*a*p+o*u*p,M=m*u*l-f*v*l-m*a*d+o*v*d+f*a*g-o*u*g,T=n*x+r*_+i*w+s*M;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/T;return e[0]=x*b,e[1]=(v*d*s-u*g*s-v*i*h+r*g*h+u*i*p-r*d*p)*b,e[2]=(a*g*s-v*l*s+v*i*c-r*g*c-a*i*p+r*l*p)*b,e[3]=(u*l*s-a*d*s-u*i*c+r*d*c+a*i*h-r*l*h)*b,e[4]=_*b,e[5]=(f*g*s-m*d*s+m*i*h-n*g*h-f*i*p+n*d*p)*b,e[6]=(m*l*s-o*g*s-m*i*c+n*g*c+o*i*p-n*l*p)*b,e[7]=(o*d*s-f*l*s+f*i*c-n*d*c-o*i*h+n*l*h)*b,e[8]=w*b,e[9]=(m*u*s-f*v*s-m*r*h+n*v*h+f*r*p-n*u*p)*b,e[10]=(o*v*s-m*a*s+m*r*c-n*v*c-o*r*p+n*a*p)*b,e[11]=(f*a*s-o*u*s-f*r*c+n*u*c+o*r*h-n*a*h)*b,e[12]=M*b,e[13]=(f*v*i-m*u*i+m*r*d-n*v*d-f*r*g+n*u*g)*b,e[14]=(m*a*i-o*v*i-m*r*l+n*v*l+o*r*g-n*a*g)*b,e[15]=(o*u*i-f*a*i+f*r*l-n*u*l-o*r*d+n*a*d)*b,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){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,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,o=e.x,a=e.y,l=e.z,c=s*o,f=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,f*a+r,f*l-i*o,0,c*l-i*a,f*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,a=n._z,l=n._w,c=s+s,f=o+o,u=a+a,d=s*c,h=s*f,m=s*u,v=o*f,g=o*u,p=a*u,x=l*c,_=l*f,w=l*u,M=r.x,T=r.y,b=r.z;return i[0]=(1-(v+p))*M,i[1]=(h+w)*M,i[2]=(m-_)*M,i[3]=0,i[4]=(h-w)*T,i[5]=(1-(d+p))*T,i[6]=(g+x)*T,i[7]=0,i[8]=(m+_)*b,i[9]=(g-x)*b,i[10]=(1-(d+v))*b,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=ca.set(i[0],i[1],i[2]).length();const o=ca.set(i[4],i[5],i[6]).length(),a=ca.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Br.copy(this);const c=1/s,f=1/o,u=1/a;return Br.elements[0]*=c,Br.elements[1]*=c,Br.elements[2]*=c,Br.elements[4]*=f,Br.elements[5]*=f,Br.elements[6]*=f,Br.elements[8]*=u,Br.elements[9]*=u,Br.elements[10]*=u,n.setFromRotationMatrix(Br),r.x=s,r.y=o,r.z=a,this}makePerspective(e,n,r,i,s,o,a=Wi){const l=this.elements,c=2*s/(n-e),f=2*s/(r-i),u=(n+e)/(n-e),d=(r+i)/(r-i);let h,m;if(a===Wi)h=-(o+s)/(o-s),m=-2*o*s/(o-s);else if(a===Qf)h=-o/(o-s),m=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=f,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=h,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,i,s,o,a=Wi){const l=this.elements,c=1/(n-e),f=1/(r-i),u=1/(o-s),d=(n+e)*c,h=(r+i)*f;let m,v;if(a===Wi)m=(o+s)*u,v=-2*u;else if(a===Qf)m=s*u,v=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*f,l[9]=0,l[13]=-h,l[2]=0,l[6]=0,l[10]=v,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const ca=new k,Br=new Ce,SF=new k(0,0,0),MF=new k(1,1,1),hs=new k,ld=new k,ir=new k,Hw=new Ce,jw=new nn;class Qt{constructor(e=0,n=0,r=0,i=Qt.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}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,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,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,r=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],f=i[9],u=i[2],d=i[6],h=i[10];switch(n){case"XYZ":this._y=Math.asin(rn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-f,h),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-rn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(a,h),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(rn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-rn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,h),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(rn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-f,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,h));break;case"XZY":this._z=Math.asin(-rn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-f,h),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return Hw.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Hw,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return jw.setFromEuler(this),this.setFromQuaternion(jw,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}}Qt.DEFAULT_ORDER="XYZ";class qy{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 bF=0;const Vw=new k,ua=new nn,Di=new Ce,cd=new k,ac=new k,EF=new k,TF=new nn,Gw=new k(1,0,0),Ww=new k(0,1,0),Xw=new k(0,0,1),$w={type:"added"},AF={type:"removed"},da={type:"childadded",child:null},qp={type:"childremoved",child:null};class Et extends ta{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:bF++}),this.uuid=ei(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Et.DEFAULT_UP.clone();const e=new k,n=new Qt,r=new nn,i=new k(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ce},normalMatrix:{value:new Qe}}),this.matrix=new Ce,this.matrixWorld=new Ce,this.matrixAutoUpdate=Et.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qy,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 ua.setFromAxisAngle(e,n),this.quaternion.multiply(ua),this}rotateOnWorldAxis(e,n){return ua.setFromAxisAngle(e,n),this.quaternion.premultiply(ua),this}rotateX(e){return this.rotateOnAxis(Gw,e)}rotateY(e){return this.rotateOnAxis(Ww,e)}rotateZ(e){return this.rotateOnAxis(Xw,e)}translateOnAxis(e,n){return Vw.copy(e).applyQuaternion(this.quaternion),this.position.add(Vw.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(Gw,e)}translateY(e){return this.translateOnAxis(Ww,e)}translateZ(e){return this.translateOnAxis(Xw,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Di.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?cd.copy(e):cd.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),ac.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Di.lookAt(ac,cd,this.up):Di.lookAt(cd,ac,this.up),this.quaternion.setFromRotationMatrix(Di),i&&(Di.extractRotation(i.matrixWorld),ua.setFromRotationMatrix(Di),this.quaternion.premultiply(ua.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(console.error("THREE.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($w),da.child=e,this.dispatchEvent(da),da.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(AF),qp.child=e,this.dispatchEvent(qp),qp.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),Di.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Di.multiply(e.parent.matrixWorld)),e.applyMatrix4(Di),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent($w),da.child=e,this.dispatchEvent(da),da.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 r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ac,e,EF),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ac,TF,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 r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].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),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 r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,f=l.length;c<f;c++){const u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(e.animations,l))}}if(n){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),f=o(e.images),u=o(e.shapes),d=o(e.skeletons),h=o(e.animations),m=o(e.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),f.length>0&&(r.images=f),u.length>0&&(r.shapes=u),d.length>0&&(r.skeletons=d),h.length>0&&(r.animations=h),m.length>0&&(r.nodes=m)}return r.object=i,r;function o(a){const l=[];for(const c in a){const f=a[c];delete f.metadata,l.push(f)}return l}}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.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Et.DEFAULT_UP=new k(0,1,0);Et.DEFAULT_MATRIX_AUTO_UPDATE=!0;Et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zr=new k,Li=new k,Zp=new k,Ii=new k,fa=new k,ha=new k,Yw=new k,Qp=new k,Jp=new k,em=new k,tm=new ut,nm=new ut,rm=new ut;class Er{constructor(e=new k,n=new k,r=new k){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),zr.subVectors(e,n),i.cross(zr);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){zr.subVectors(i,n),Li.subVectors(r,n),Zp.subVectors(e,n);const o=zr.dot(zr),a=zr.dot(Li),l=zr.dot(Zp),c=Li.dot(Li),f=Li.dot(Zp),u=o*c-a*a;if(u===0)return s.set(0,0,0),null;const d=1/u,h=(c*l-a*f)*d,m=(o*f-a*l)*d;return s.set(1-h-m,m,h)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Ii)===null?!1:Ii.x>=0&&Ii.y>=0&&Ii.x+Ii.y<=1}static getInterpolation(e,n,r,i,s,o,a,l){return this.getBarycoord(e,n,r,i,Ii)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Ii.x),l.addScaledVector(o,Ii.y),l.addScaledVector(a,Ii.z),l)}static getInterpolatedAttribute(e,n,r,i,s,o){return tm.setScalar(0),nm.setScalar(0),rm.setScalar(0),tm.fromBufferAttribute(e,n),nm.fromBufferAttribute(e,r),rm.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(tm,s.x),o.addScaledVector(nm,s.y),o.addScaledVector(rm,s.z),o}static isFrontFacing(e,n,r,i){return zr.subVectors(r,n),Li.subVectors(e,n),zr.cross(Li).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),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 zr.subVectors(this.c,this.b),Li.subVectors(this.a,this.b),zr.cross(Li).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Er.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Er.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return Er.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Er.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Er.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let o,a;fa.subVectors(i,r),ha.subVectors(s,r),Qp.subVectors(e,r);const l=fa.dot(Qp),c=ha.dot(Qp);if(l<=0&&c<=0)return n.copy(r);Jp.subVectors(e,i);const f=fa.dot(Jp),u=ha.dot(Jp);if(f>=0&&u<=f)return n.copy(i);const d=l*u-f*c;if(d<=0&&l>=0&&f<=0)return o=l/(l-f),n.copy(r).addScaledVector(fa,o);em.subVectors(e,s);const h=fa.dot(em),m=ha.dot(em);if(m>=0&&h<=m)return n.copy(s);const v=h*c-l*m;if(v<=0&&c>=0&&m<=0)return a=c/(c-m),n.copy(r).addScaledVector(ha,a);const g=f*m-h*u;if(g<=0&&u-f>=0&&h-m>=0)return Yw.subVectors(s,i),a=(u-f)/(u-f+(h-m)),n.copy(i).addScaledVector(Yw,a);const p=1/(g+v+d);return o=v*p,a=d*p,n.copy(r).addScaledVector(fa,o).addScaledVector(ha,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const sA={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},ps={h:0,s:0,l:0},ud={h:0,s:0,l:0};function im(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}class Pe{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=ft){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=$e.workingColorSpace){return this.r=e,this.g=n,this.b=r,$e.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=$e.workingColorSpace){if(e=Ky(e,1),n=rn(n,0,1),r=rn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=im(o,s,e+1/3),this.g=im(o,s,e),this.b=im(o,s,e-1/3)}return $e.toWorkingColorSpace(this,i),this}setStyle(e,n=ft){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=ft){const r=sA[e.toLowerCase()];return r!==void 0?this.setHex(r,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ki(e.r),this.g=Ki(e.g),this.b=Ki(e.b),this}copyLinearToSRGB(e){return this.r=Ja(e.r),this.g=Ja(e.g),this.b=Ja(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ft){return $e.fromWorkingColorSpace(Tn.copy(this),e),Math.round(rn(Tn.r*255,0,255))*65536+Math.round(rn(Tn.g*255,0,255))*256+Math.round(rn(Tn.b*255,0,255))}getHexString(e=ft){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=$e.workingColorSpace){$e.fromWorkingColorSpace(Tn.copy(this),n);const r=Tn.r,i=Tn.g,s=Tn.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,c;const f=(a+o)/2;if(a===o)l=0,c=0;else{const u=o-a;switch(c=f<=.5?u/(o+a):u/(2-o-a),o){case r:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-r)/u+2;break;case s:l=(r-i)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=f,e}getRGB(e,n=$e.workingColorSpace){return $e.fromWorkingColorSpace(Tn.copy(this),n),e.r=Tn.r,e.g=Tn.g,e.b=Tn.b,e}getStyle(e=ft){$e.fromWorkingColorSpace(Tn.copy(this),e);const n=Tn.r,r=Tn.g,i=Tn.b;return e!==ft?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(ps),this.setHSL(ps.h+e,ps.s+n,ps.l+r)}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,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(ps),e.getHSL(ud);const r=Ic(ps.h,ud.h,n),i=Ic(ps.s,ud.s,n),s=Ic(ps.l,ud.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,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 Tn=new Pe;Pe.NAMES=sA;let CF=0;class Nr extends ta{static get type(){return"Material"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:CF++}),this.uuid=ei(),this.name="",this.blending=qa,this.side=ns,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ev,this.blendDst=tv,this.blendEquation=So,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Pe(0,0,0),this.blendAlpha=0,this.depthFunc=Ml,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Nw,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ia,this.stencilZFail=ia,this.stencilZPass=ia,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.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 r=e[n];if(r===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==qa&&(r.blending=this.blending),this.side!==ns&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==ev&&(r.blendSrc=this.blendSrc),this.blendDst!==tv&&(r.blendDst=this.blendDst),this.blendEquation!==So&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Ml&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Nw&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ia&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ia&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ia&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}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 r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Xi extends Nr{static get type(){return"MeshBasicMaterial"}constructor(e){super(),this.isMeshBasicMaterial=!0,this.color=new Pe(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 Qt,this.combine=Vh,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 Zt=new k,dd=new ze;class hn{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=Fv,this.updateRanges=[],this.gpuType=qr,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,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)dd.fromBufferAttribute(this,n),dd.applyMatrix3(e),this.setXY(n,dd.x,dd.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Zt.fromBufferAttribute(this,n),Zt.applyMatrix3(e),this.setXYZ(n,Zt.x,Zt.y,Zt.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Zt.fromBufferAttribute(this,n),Zt.applyMatrix4(e),this.setXYZ(n,Zt.x,Zt.y,Zt.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Zt.fromBufferAttribute(this,n),Zt.applyNormalMatrix(e),this.setXYZ(n,Zt.x,Zt.y,Zt.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Zt.fromBufferAttribute(this,n),Zt.transformDirection(e),this.setXYZ(n,Zt.x,Zt.y,Zt.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=Kr(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=wt(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Kr(n,this.array)),n}setX(e,n){return this.normalized&&(n=wt(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Kr(n,this.array)),n}setY(e,n){return this.normalized&&(n=wt(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=Kr(n,this.array)),n}setZ(e,n){return this.normalized&&(n=wt(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=Kr(n,this.array)),n}setW(e,n){return this.normalized&&(n=wt(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=wt(n,this.array),r=wt(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=wt(n,this.array),r=wt(r,this.array),i=wt(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=wt(n,this.array),r=wt(r,this.array),i=wt(i,this.array),s=wt(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,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!==Fv&&(e.usage=this.usage),e}}class Zy extends hn{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class oA extends hn{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class At extends hn{constructor(e,n,r){super(new Float32Array(e),n,r)}}let RF=0;const _r=new Ce,sm=new Et,pa=new k,sr=new Gt,lc=new Gt,cn=new k;class Wt extends ta{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:RF++}),this.uuid=ei(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(nA(e)?oA:Zy)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,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,r=0){this.groups.push({start:e,count:n,materialIndex:r})}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 r=this.attributes.normal;if(r!==void 0){const s=new Qe().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return _r.makeRotationFromQuaternion(e),this.applyMatrix4(_r),this}rotateX(e){return _r.makeRotationX(e),this.applyMatrix4(_r),this}rotateY(e){return _r.makeRotationY(e),this.applyMatrix4(_r),this}rotateZ(e){return _r.makeRotationZ(e),this.applyMatrix4(_r),this}translate(e,n,r){return _r.makeTranslation(e,n,r),this.applyMatrix4(_r),this}scale(e,n,r){return _r.makeScale(e,n,r),this.applyMatrix4(_r),this}lookAt(e){return sm.lookAt(e),sm.updateMatrix(),this.applyMatrix4(sm.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pa).negate(),this.translate(pa.x,pa.y,pa.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new At(r,3))}else{for(let r=0,i=n.count;r<i;r++){const s=e[r];n.setXYZ(r,s.x,s.y,s.z||0)}e.length>n.count&&console.warn("THREE.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 Gt);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];sr.setFromBufferAttribute(s),this.morphTargetsRelative?(cn.addVectors(this.boundingBox.min,sr.min),this.boundingBox.expandByPoint(cn),cn.addVectors(this.boundingBox.max,sr.max),this.boundingBox.expandByPoint(cn)):(this.boundingBox.expandByPoint(sr.min),this.boundingBox.expandByPoint(sr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 bi);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(e){const r=this.boundingSphere.center;if(sr.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const a=n[s];lc.setFromBufferAttribute(a),this.morphTargetsRelative?(cn.addVectors(sr.min,lc.min),sr.expandByPoint(cn),cn.addVectors(sr.max,lc.max),sr.expandByPoint(cn)):(sr.expandByPoint(lc.min),sr.expandByPoint(lc.max))}sr.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)cn.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(cn));if(n)for(let s=0,o=n.length;s<o;s++){const a=n[s],l=this.morphTargetsRelative;for(let c=0,f=a.count;c<f;c++)cn.fromBufferAttribute(a,c),l&&(pa.fromBufferAttribute(e,c),cn.add(pa)),i=Math.max(i,r.distanceToSquared(cn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.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){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new hn(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let C=0;C<r.count;C++)a[C]=new k,l[C]=new k;const c=new k,f=new k,u=new k,d=new ze,h=new ze,m=new ze,v=new k,g=new k;function p(C,A,E){c.fromBufferAttribute(r,C),f.fromBufferAttribute(r,A),u.fromBufferAttribute(r,E),d.fromBufferAttribute(s,C),h.fromBufferAttribute(s,A),m.fromBufferAttribute(s,E),f.sub(c),u.sub(c),h.sub(d),m.sub(d);const N=1/(h.x*m.y-m.x*h.y);isFinite(N)&&(v.copy(f).multiplyScalar(m.y).addScaledVector(u,-h.y).multiplyScalar(N),g.copy(u).multiplyScalar(h.x).addScaledVector(f,-m.x).multiplyScalar(N),a[C].add(v),a[A].add(v),a[E].add(v),l[C].add(g),l[A].add(g),l[E].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let C=0,A=x.length;C<A;++C){const E=x[C],N=E.start,F=E.count;for(let I=N,U=N+F;I<U;I+=3)p(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const _=new k,w=new k,M=new k,T=new k;function b(C){M.fromBufferAttribute(i,C),T.copy(M);const A=a[C];_.copy(A),_.sub(M.multiplyScalar(M.dot(A))).normalize(),w.crossVectors(T,A);const N=w.dot(l[C])<0?-1:1;o.setXYZW(C,_.x,_.y,_.z,N)}for(let C=0,A=x.length;C<A;++C){const E=x[C],N=E.start,F=E.count;for(let I=N,U=N+F;I<U;I+=3)b(e.getX(I+0)),b(e.getX(I+1)),b(e.getX(I+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new hn(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let d=0,h=r.count;d<h;d++)r.setXYZ(d,0,0,0);const i=new k,s=new k,o=new k,a=new k,l=new k,c=new k,f=new k,u=new k;if(e)for(let d=0,h=e.count;d<h;d+=3){const m=e.getX(d+0),v=e.getX(d+1),g=e.getX(d+2);i.fromBufferAttribute(n,m),s.fromBufferAttribute(n,v),o.fromBufferAttribute(n,g),f.subVectors(o,s),u.subVectors(i,s),f.cross(u),a.fromBufferAttribute(r,m),l.fromBufferAttribute(r,v),c.fromBufferAttribute(r,g),a.add(f),l.add(f),c.add(f),r.setXYZ(m,a.x,a.y,a.z),r.setXYZ(v,l.x,l.y,l.z),r.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,h=n.count;d<h;d+=3)i.fromBufferAttribute(n,d+0),s.fromBufferAttribute(n,d+1),o.fromBufferAttribute(n,d+2),f.subVectors(o,s),u.subVectors(i,s),f.cross(u),r.setXYZ(d+0,f.x,f.y,f.z),r.setXYZ(d+1,f.x,f.y,f.z),r.setXYZ(d+2,f.x,f.y,f.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)cn.fromBufferAttribute(e,n),cn.normalize(),e.setXYZ(n,cn.x,cn.y,cn.z)}toNonIndexed(){function e(a,l){const c=a.array,f=a.itemSize,u=a.normalized,d=new c.constructor(l.length*f);let h=0,m=0;for(let v=0,g=l.length;v<g;v++){a.isInterleavedBufferAttribute?h=l[v]*a.data.stride+a.offset:h=l[v]*f;for(let p=0;p<f;p++)d[m++]=c[h++]}return new hn(d,f,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Wt,r=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=e(l,r);n.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let f=0,u=c.length;f<u;f++){const d=c[f],h=e(d,r);l.push(h)}n.morphAttributes[a]=l}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];n.addGroup(c.start,c.count,c.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],f=[];for(let u=0,d=c.length;u<d;u++){const h=c[u];f.push(h.toJSON(e.data))}f.length>0&&(i[l]=f,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const c in i){const f=i[c];this.setAttribute(c,f.clone(n))}const s=e.morphAttributes;for(const c in s){const f=[],u=s[c];for(let d=0,h=u.length;d<h;d++)f.push(u[d].clone(n));this.morphAttributes[c]=f}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,f=o.length;c<f;c++){const u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Kw=new Ce,po=new zl,fd=new bi,qw=new k,hd=new k,pd=new k,md=new k,om=new k,gd=new k,Zw=new k,vd=new k;class je extends Et{constructor(e=new Wt,n=new Xi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,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,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(s&&a){gd.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const f=a[l],u=s[l];f!==0&&(om.fromBufferAttribute(u,e),o?gd.addScaledVector(om,f):gd.addScaledVector(om.sub(n),f))}n.add(gd)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),fd.copy(r.boundingSphere),fd.applyMatrix4(s),po.copy(e.ray).recast(e.near),!(fd.containsPoint(po.origin)===!1&&(po.intersectSphere(fd,qw)===null||po.origin.distanceToSquared(qw)>(e.far-e.near)**2))&&(Kw.copy(s).invert(),po.copy(e.ray).applyMatrix4(Kw),!(r.boundingBox!==null&&po.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,po)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,f=s.attributes.uv1,u=s.attributes.normal,d=s.groups,h=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,v=d.length;m<v;m++){const g=d[m],p=o[g.materialIndex],x=Math.max(g.start,h.start),_=Math.min(a.count,Math.min(g.start+g.count,h.start+h.count));for(let w=x,M=_;w<M;w+=3){const T=a.getX(w),b=a.getX(w+1),C=a.getX(w+2);i=yd(this,p,e,r,c,f,u,T,b,C),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=g.materialIndex,n.push(i))}}else{const m=Math.max(0,h.start),v=Math.min(a.count,h.start+h.count);for(let g=m,p=v;g<p;g+=3){const x=a.getX(g),_=a.getX(g+1),w=a.getX(g+2);i=yd(this,o,e,r,c,f,u,x,_,w),i&&(i.faceIndex=Math.floor(g/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,v=d.length;m<v;m++){const g=d[m],p=o[g.materialIndex],x=Math.max(g.start,h.start),_=Math.min(l.count,Math.min(g.start+g.count,h.start+h.count));for(let w=x,M=_;w<M;w+=3){const T=w,b=w+1,C=w+2;i=yd(this,p,e,r,c,f,u,T,b,C),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=g.materialIndex,n.push(i))}}else{const m=Math.max(0,h.start),v=Math.min(l.count,h.start+h.count);for(let g=m,p=v;g<p;g+=3){const x=g,_=g+1,w=g+2;i=yd(this,o,e,r,c,f,u,x,_,w),i&&(i.faceIndex=Math.floor(g/3),n.push(i))}}}}function PF(t,e,n,r,i,s,o,a){let l;if(e.side===tr?l=r.intersectTriangle(o,s,i,!0,a):l=r.intersectTriangle(i,s,o,e.side===ns,a),l===null)return null;vd.copy(a),vd.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(vd);return c<n.near||c>n.far?null:{distance:c,point:vd.clone(),object:t}}function yd(t,e,n,r,i,s,o,a,l,c){t.getVertexPosition(a,hd),t.getVertexPosition(l,pd),t.getVertexPosition(c,md);const f=PF(t,e,n,r,hd,pd,md,Zw);if(f){const u=new k;Er.getBarycoord(Zw,hd,pd,md,u),i&&(f.uv=Er.getInterpolatedAttribute(i,a,l,c,u,new ze)),s&&(f.uv1=Er.getInterpolatedAttribute(s,a,l,c,u,new ze)),o&&(f.normal=Er.getInterpolatedAttribute(o,a,l,c,u,new k),f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new k,materialIndex:0};Er.getNormal(hd,pd,md,d.normal),f.face=d,f.barycoord=u}return f}class Hl extends Wt{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],f=[],u=[];let d=0,h=0;m("z","y","x",-1,-1,r,n,e,o,s,0),m("z","y","x",1,-1,r,n,-e,o,s,1),m("x","z","y",1,1,e,r,n,i,o,2),m("x","z","y",1,-1,e,r,-n,i,o,3),m("x","y","z",1,-1,e,n,r,i,s,4),m("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new At(c,3)),this.setAttribute("normal",new At(f,3)),this.setAttribute("uv",new At(u,2));function m(v,g,p,x,_,w,M,T,b,C,A){const E=w/b,N=M/C,F=w/2,I=M/2,U=T/2,z=b+1,O=C+1;let j=0,D=0;const V=new k;for(let Q=0;Q<O;Q++){const J=Q*N-I;for(let le=0;le<z;le++){const pe=le*E-F;V[v]=pe*x,V[g]=J*_,V[p]=U,c.push(V.x,V.y,V.z),V[v]=0,V[g]=0,V[p]=T>0?1:-1,f.push(V.x,V.y,V.z),u.push(le/b),u.push(1-Q/C),j+=1}}for(let Q=0;Q<C;Q++)for(let J=0;J<b;J++){const le=d+J+z*Q,pe=d+J+z*(Q+1),$=d+(J+1)+z*(Q+1),ee=d+(J+1)+z*Q;l.push(le,pe,ee),l.push(pe,$,ee),D+=6}a.addGroup(h,D,A),h+=D,d+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hl(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Rl(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function kn(t){const e={};for(let n=0;n<t.length;n++){const r=Rl(t[n]);for(const i in r)e[i]=r[i]}return e}function NF(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function aA(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:$e.workingColorSpace}const DF={clone:Rl,merge:kn};var LF=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,IF=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class eo extends Nr{static get type(){return"ShaderMaterial"}constructor(e){super(),this.isShaderMaterial=!0,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=LF,this.fragmentShader=IF,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=Rl(e.uniforms),this.uniformsGroups=NF(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}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}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 r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class lA extends Et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ce,this.projectionMatrix=new Ce,this.projectionMatrixInverse=new Ce,this.coordinateSystem=Wi}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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const ms=new k,Qw=new ze,Jw=new ze;class dn extends lA{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,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=Cl*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Qa*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Cl*2*Math.atan(Math.tan(Qa*.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,r){ms.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ms.x,ms.y).multiplyScalar(-e/ms.z),ms.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(ms.x,ms.y).multiplyScalar(-e/ms.z)}getViewSize(e,n){return this.getViewBounds(e,Qw,Jw),n.subVectors(Jw,Qw)}setViewOffset(e,n,r,i,s,o){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=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Qa*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,n-=o.offsetY*r/c,i*=o.width/l,r*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem),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}}const ma=-90,ga=1;class kF extends Et{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new dn(ma,ga,e,n);i.layers=this.layers,this.add(i);const s=new dn(ma,ga,e,n);s.layers=this.layers,this.add(s);const o=new dn(ma,ga,e,n);o.layers=this.layers,this.add(o);const a=new dn(ma,ga,e,n);a.layers=this.layers,this.add(a);const l=new dn(ma,ga,e,n);l.layers=this.layers,this.add(l);const c=new dn(ma,ga,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,a,l]=n;for(const c of n)this.remove(c);if(e===Wi)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Qf)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,f]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,a),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,c),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,f),e.setRenderTarget(u,d,h),e.xr.enabled=m,r.texture.needsPMREMUpdate=!0}}class cA extends on{constructor(e,n,r,i,s,o,a,l,c,f){e=e!==void 0?e:[],n=n!==void 0?n:bl,super(e,n,r,i,s,o,a,l,c,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class OF extends Wo{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new cA(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:hr}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 r={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 );
}
`},i=new Hl(5,5,5),s=new eo({name:"CubemapFromEquirect",uniforms:Rl(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:tr,blending:Gs});s.uniforms.tEquirect.value=n;const o=new je(i,s),a=n.minFilter;return n.minFilter===Gi&&(n.minFilter=hr),new kF(1,10,this).update(e,o),n.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}}const am=new k,FF=new k,UF=new Qe;class Ms{constructor(e=new k(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,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=am.subVectors(r,n).cross(FF.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,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){const r=e.delta(am),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<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 r=n||UF.getNormalMatrix(e),i=this.coplanarPoint(am).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),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 mo=new bi,xd=new k;class Qy{constructor(e=new Ms,n=new Ms,r=new Ms,i=new Ms,s=new Ms,o=new Ms){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(n),a[2].copy(r),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Wi){const r=this.planes,i=e.elements,s=i[0],o=i[1],a=i[2],l=i[3],c=i[4],f=i[5],u=i[6],d=i[7],h=i[8],m=i[9],v=i[10],g=i[11],p=i[12],x=i[13],_=i[14],w=i[15];if(r[0].setComponents(l-s,d-c,g-h,w-p).normalize(),r[1].setComponents(l+s,d+c,g+h,w+p).normalize(),r[2].setComponents(l+o,d+f,g+m,w+x).normalize(),r[3].setComponents(l-o,d-f,g-m,w-x).normalize(),r[4].setComponents(l-a,d-u,g-v,w-_).normalize(),n===Wi)r[5].setComponents(l+a,d+u,g+v,w+_).normalize();else if(n===Qf)r[5].setComponents(a,u,v,_).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(),mo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),mo.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(mo)}intersectsSprite(e){return mo.center.set(0,0,0),mo.radius=.7071067811865476,mo.applyMatrix4(e.matrixWorld),this.intersectsSphere(mo)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(xd.x=i.normal.x>0?e.max.x:e.min.x,xd.y=i.normal.y>0?e.max.y:e.min.y,xd.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(xd)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function uA(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function BF(t){const e=new WeakMap;function n(a,l){const c=a.array,f=a.usage,u=c.byteLength,d=t.createBuffer();t.bindBuffer(l,d),t.bufferData(l,c,f),a.onUploadCallback();let h;if(c instanceof Float32Array)h=t.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?h=t.HALF_FLOAT:h=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)h=t.SHORT;else if(c instanceof Uint32Array)h=t.UNSIGNED_INT;else if(c instanceof Int32Array)h=t.INT;else if(c instanceof Int8Array)h=t.BYTE;else if(c instanceof Uint8Array)h=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)h=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:h,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:u}}function r(a,l,c){const f=l.array,u=l.updateRanges;if(t.bindBuffer(c,a),u.length===0)t.bufferSubData(c,0,f);else{u.sort((h,m)=>h.start-m.start);let d=0;for(let h=1;h<u.length;h++){const m=u[d],v=u[h];v.start<=m.start+m.count+1?m.count=Math.max(m.count,v.start+v.count-m.start):(++d,u[d]=v)}u.length=d+1;for(let h=0,m=u.length;h<m;h++){const v=u[h];t.bufferSubData(c,v.start*f.BYTES_PER_ELEMENT,f,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=e.get(a);l&&(t.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const f=e.get(a);(!f||f.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const c=e.get(a);if(c===void 0)e.set(a,n(a,l));else if(c.version<a.version){if(c.size!==a.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.");r(c.buffer,a,l),c.version=a.version}}return{get:i,remove:s,update:o}}class $h extends Wt{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,o=n/2,a=Math.floor(r),l=Math.floor(i),c=a+1,f=l+1,u=e/a,d=n/l,h=[],m=[],v=[],g=[];for(let p=0;p<f;p++){const x=p*d-o;for(let _=0;_<c;_++){const w=_*u-s;m.push(w,-x,0),v.push(0,0,1),g.push(_/a),g.push(1-p/l)}}for(let p=0;p<l;p++)for(let x=0;x<a;x++){const _=x+c*p,w=x+c*(p+1),M=x+1+c*(p+1),T=x+1+c*p;h.push(_,w,T),h.push(w,M,T)}this.setIndex(h),this.setAttribute("position",new At(m,3)),this.setAttribute("normal",new At(v,3)),this.setAttribute("uv",new At(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $h(e.width,e.height,e.widthSegments,e.heightSegments)}}var zF=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,HF=`#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`,jF=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,VF=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,GF=`#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`,WF=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,XF=`#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`,$F=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,YF=`#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;
vec3 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 ).rgb;
}
#endif`,KF=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,qF=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,ZF=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,QF=`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`,JF=`#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`,eU=`#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`,tU=`#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`,nU=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,rU=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,iU=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,sU=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,oU=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,aU=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,lU=`#if defined( USE_COLOR_ALPHA )
vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
vColor.xyz *= batchingColor.xyz;
#endif`,cU=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
mat3 tmp;
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,uU=`#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`,dU=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
mat3 bm = mat3( batchingMatrix );
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
transformedNormal = bm * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = bm * transformedTangent;
#endif
#endif
#ifdef USE_INSTANCING
mat3 im = mat3( instanceMatrix );
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
transformedNormal = im * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = im * transformedTangent;
#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
#ifdef FLIP_SIDED
transformedTangent = - transformedTangent;
#endif
#endif`,fU=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,hU=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,pU=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,mU=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,gU="gl_FragColor = linearToOutputTexel( gl_FragColor );",vU=`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 );
}`,yU=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
#else
vec4 envColor = vec4( 0.0 );
#endif
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif`,xU=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,_U=`#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`,wU=`#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`,SU=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,MU=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,bU=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,EU=`#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`,TU=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,AU=`#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
}`,CU=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,RU=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,PU=`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`,NU=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometryPosition;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometryPosition;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif`,DU=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#ifdef USE_ANISOTROPY
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 bentNormal = cross( bitangent, viewDir );
bentNormal = normalize( cross( bentNormal, bitangent ) );
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
return getIBLRadiance( viewDir, bentNormal, roughness );
#else
return vec3( 0.0 );
#endif
}
#endif
#endif`,LU=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,IU=`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`,kU=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,OU=`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`,FU=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
material.ior = ior;
#ifdef USE_SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULAR_COLORMAP
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
#ifdef USE_IRIDESCENCEMAP
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
#else
material.iridescenceThickness = iridescenceThicknessMaximum;
#endif
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEEN_COLORMAP
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
#ifdef USE_SHEEN_ROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
#endif
#endif
#ifdef USE_ANISOTROPY
#ifdef USE_ANISOTROPYMAP
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
#else
vec2 anisotropyV = anisotropyVector;
#endif
material.anisotropy = length( anisotropyV );
if( material.anisotropy == 0.0 ) {
anisotropyV = vec2( 1.0, 0.0 );
} else {
anisotropyV /= material.anisotropy;
material.anisotropy = saturate( material.anisotropy );
}
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,UU=`struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
float specularF90;
float dispersion;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_IRIDESCENCE
float iridescence;
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
vec3 iridescenceF0;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
#ifdef IOR
float ior;
#endif
#ifdef USE_TRANSMISSION
float transmission;
float transmissionAlpha;
float thickness;
float attenuationDistance;
vec3 attenuationColor;
#endif
#ifdef USE_ANISOTROPY
float anisotropy;
float alphaT;
vec3 anisotropyT;
vec3 anisotropyB;
#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
float x2 = x * x;
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
float v = 0.5 / ( gv + gl );
return saturate(v);
}
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
float a2 = alphaT * alphaB;
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
highp float v2 = dot( v, v );
float w2 = a2 / v2;
return RECIPROCAL_PI * a2 * pow2 ( w2 );
}
#endif
#ifdef USE_CLEARCOAT
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
vec3 f0 = material.clearcoatF0;
float f90 = material.clearcoatF90;
float roughness = material.clearcoatRoughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 f0 = material.specularColor;
float f90 = material.specularF90;
float roughness = material.roughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
#ifdef USE_IRIDESCENCE
F = mix( F, material.iridescenceFresnel, material.iridescence );
#endif
#ifdef USE_ANISOTROPY
float dotTL = dot( material.anisotropyT, lightDir );
float dotTV = dot( material.anisotropyT, viewDir );
float dotTH = dot( material.anisotropyT, halfDir );
float dotBL = dot( material.anisotropyB, lightDir );
float dotBV = dot( material.anisotropyB, viewDir );
float dotBH = dot( material.anisotropyB, halfDir );
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
#else
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
#endif
return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
vec4 r = roughness * c0 + c1;
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
vec2 fab = DFGApprox( normal, viewDir, roughness );
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
vec2 fab = DFGApprox( normal, viewDir, roughness );
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
vec3 Fr = specularColor;
#endif
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometryNormal;
vec3 viewDir = geometryViewDir;
vec3 position = geometryPosition;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
#endif
#ifdef USE_SHEEN
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
#endif
vec3 singleScattering = vec3( 0.0 );
vec3 multiScattering = vec3( 0.0 );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
#endif
vec3 totalScattering = singleScattering + multiScattering;
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
reflectedLight.indirectSpecular += radiance * singleScattering;
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,BU=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometryViewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
material.iridescence = 0.0;
} else {
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometryPosition, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
vec4 spotColor;
vec3 spotLightCoord;
bool inSpotLightMap;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
getSpotLightInfo( spotLight, geometryPosition, directLight );
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
#else
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#endif
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
#endif
#undef SPOT_LIGHT_MAP_INDEX
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
getDirectionalLightInfo( directionalLight, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
#if defined( USE_LIGHT_PROBES )
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
#endif
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
}
#pragma unroll_loop_end
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,zU=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
iblIrradiance += getIBLIrradiance( geometryNormal );
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
#ifdef USE_ANISOTROPY
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
#else
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
#endif
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
#endif`,HU=`#if defined( RE_IndirectDiffuse )
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,jU=`#if defined( USE_LOGDEPTHBUF )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,VU=`#if defined( USE_LOGDEPTHBUF )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,GU=`#ifdef USE_LOGDEPTHBUF
varying float vFragDepth;
varying float vIsPerspective;
#endif`,WU=`#ifdef USE_LOGDEPTHBUF
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,XU=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,$U=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,YU=`#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`,KU=`#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`,qU=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,ZU=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,QU=`#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`,JU=`#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`,eB=`#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`,tB=`#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`,nB=`#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`,rB=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal *= faceDirection;
#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
#ifdef USE_TANGENT
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn = getTangentFrame( - vViewPosition, normal,
#if defined( USE_NORMALMAP )
vNormalMapUv
#elif defined( USE_CLEARCOAT_NORMALMAP )
vClearcoatNormalMapUv
#else
vUv
#endif
);
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#ifdef USE_TANGENT
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
vec3 nonPerturbedNormal = normal;`,iB=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,sB=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,oB=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,aB=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,lB=`#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`,cB=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,uB=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,dB=`#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`,fB=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,hB=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,pB=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
if( v <= 0.0 )
return vec4( 0., 0., 0., 0. );
if( v >= 1.0 )
return vec4( 1., 1., 1., 1. );
float vuf;
float af = modf( v * PackFactors.a, vuf );
float bf = modf( vuf * ShiftRight8, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
if( v <= 0.0 )
return vec3( 0., 0., 0. );
if( v >= 1.0 )
return vec3( 1., 1., 1. );
float vuf;
float bf = modf( v * PackFactors.b, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
if( v <= 0.0 )
return vec2( 0., 0. );
if( v >= 1.0 )
return vec2( 1., 1. );
float vuf;
float gf = modf( v * 256., vuf );
return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
return ( near * far ) / ( ( far - near ) * depth - far );
}`,mB=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,gB=`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;`,vB=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,yB=`#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`,xB=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,_B=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,wB=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
}
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
return unpackRGBATo2Half( texture2D( shadow, uv ) );
}
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
float occlusion = 1.0;
vec2 distribution = texture2DDistribution( shadow, uv );
float hard_shadow = step( compare , distribution.x );
if (hard_shadow != 1.0 ) {
float distance = compare - distribution.x ;
float variance = max( 0.00000, distribution.y * distribution.y );
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
}
return occlusion;
}
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
#if defined( SHADOWMAP_TYPE_PCF )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx0 = - texelSize.x * shadowRadius;
float dy0 = - texelSize.y * shadowRadius;
float dx1 = + texelSize.x * shadowRadius;
float dy1 = + texelSize.y * shadowRadius;
float dx2 = dx0 / 2.0;
float dy2 = dy0 / 2.0;
float dx3 = dx1 / 2.0;
float dy3 = dy1 / 2.0;
shadow = (
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
) * ( 1.0 / 17.0 );
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx = texelSize.x;
float dy = texelSize.y;
vec2 uv = shadowCoord.xy;
vec2 f = fract( uv * shadowMapSize + 0.5 );
uv -= f * texelSize;
shadow = (
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
f.x ),
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
f.x ),
f.y )
) * ( 1.0 / 9.0 );
#elif defined( SHADOWMAP_TYPE_VSM )
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
#else
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
vec2 cubeToUV( vec3 v, float texelSizeY ) {
vec3 absV = abs( v );
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
absV *= scaleToCube;
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
vec2 planar = v.xy;
float almostATexel = 1.5 * texelSizeY;
float almostOne = 1.0 - almostATexel;
if ( absV.z >= almostOne ) {
if ( v.z > 0.0 )
planar.x = 4.0 - v.x;
} else if ( absV.x >= almostOne ) {
float signX = sign( v.x );
planar.x = v.z * signX + 2.0 * signX;
} else if ( absV.y >= almostOne ) {
float signY = sign( v.y );
planar.x = v.x + 2.0 * signY + 2.0;
planar.y = v.z * signY - 2.0;
}
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
}
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
float lightToPositionLength = length( lightToPosition );
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
shadow = (
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
) * ( 1.0 / 9.0 );
#else
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif`,SB=`#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`,MB=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
shadowWorldPosition = worldPosition;
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif`,bB=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
}`,EB=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,TB=`#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`,AB=`#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`,CB=`#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`,RB=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,PB=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,NB=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,DB=`#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; }`,LB=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
material.attenuationDistance = attenuationDistance;
material.attenuationColor = attenuationColor;
#ifdef USE_TRANSMISSIONMAP
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
#endif
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = inverseTransformDirection( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,IB=`#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`,kB=`#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`,OB=`#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`,FB=`#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`,UB=`#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 BB=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,zB=`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>
}`,HB=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,jB=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,VB=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,GB=`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>
}`,WB=`#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;
}`,XB=`#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>
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
#if DEPTH_PACKING == 3200
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
#elif DEPTH_PACKING == 3202
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
}`,$B=`#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;
}`,YB=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#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 <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 = packDepthToRGBA( dist );
}`,KB=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,qB=`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>
}`,ZB=`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>
}`,QB=`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>
}`,JB=`#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>
}`,ez=`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>
}`,tz=`#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>
}`,nz=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#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 <envmap_common_pars_fragment>
#include <envmap_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>
}`,rz=`#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;
}`,iz=`#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>
}`,sz=`#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
}`,oz=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <packing>
#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( packNormalToRGB( normal ), diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,az=`#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>
}`,lz=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#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 <envmap_common_pars_fragment>
#include <envmap_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>
}`,cz=`#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
}`,uz=`#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 <packing>
#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
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
#endif
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,dz=`#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>
}`,fz=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#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>
}`,hz=`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>
}`,pz=`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>
}`,mz=`#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>
}`,gz=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#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>
}`,vz=`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>
}`,yz=`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>
}`,it={alphahash_fragment:zF,alphahash_pars_fragment:HF,alphamap_fragment:jF,alphamap_pars_fragment:VF,alphatest_fragment:GF,alphatest_pars_fragment:WF,aomap_fragment:XF,aomap_pars_fragment:$F,batching_pars_vertex:YF,batching_vertex:KF,begin_vertex:qF,beginnormal_vertex:ZF,bsdfs:QF,iridescence_fragment:JF,bumpmap_pars_fragment:eU,clipping_planes_fragment:tU,clipping_planes_pars_fragment:nU,clipping_planes_pars_vertex:rU,clipping_planes_vertex:iU,color_fragment:sU,color_pars_fragment:oU,color_pars_vertex:aU,color_vertex:lU,common:cU,cube_uv_reflection_fragment:uU,defaultnormal_vertex:dU,displacementmap_pars_vertex:fU,displacementmap_vertex:hU,emissivemap_fragment:pU,emissivemap_pars_fragment:mU,colorspace_fragment:gU,colorspace_pars_fragment:vU,envmap_fragment:yU,envmap_common_pars_fragment:xU,envmap_pars_fragment:_U,envmap_pars_vertex:wU,envmap_physical_pars_fragment:DU,envmap_vertex:SU,fog_vertex:MU,fog_pars_vertex:bU,fog_fragment:EU,fog_pars_fragment:TU,gradientmap_pars_fragment:AU,lightmap_pars_fragment:CU,lights_lambert_fragment:RU,lights_lambert_pars_fragment:PU,lights_pars_begin:NU,lights_toon_fragment:LU,lights_toon_pars_fragment:IU,lights_phong_fragment:kU,lights_phong_pars_fragment:OU,lights_physical_fragment:FU,lights_physical_pars_fragment:UU,lights_fragment_begin:BU,lights_fragment_maps:zU,lights_fragment_end:HU,logdepthbuf_fragment:jU,logdepthbuf_pars_fragment:VU,logdepthbuf_pars_vertex:GU,logdepthbuf_vertex:WU,map_fragment:XU,map_pars_fragment:$U,map_particle_fragment:YU,map_particle_pars_fragment:KU,metalnessmap_fragment:qU,metalnessmap_pars_fragment:ZU,morphinstance_vertex:QU,morphcolor_vertex:JU,morphnormal_vertex:eB,morphtarget_pars_vertex:tB,morphtarget_vertex:nB,normal_fragment_begin:rB,normal_fragment_maps:iB,normal_pars_fragment:sB,normal_pars_vertex:oB,normal_vertex:aB,normalmap_pars_fragment:lB,clearcoat_normal_fragment_begin:cB,clearcoat_normal_fragment_maps:uB,clearcoat_pars_fragment:dB,iridescence_pars_fragment:fB,opaque_fragment:hB,packing:pB,premultiplied_alpha_fragment:mB,project_vertex:gB,dithering_fragment:vB,dithering_pars_fragment:yB,roughnessmap_fragment:xB,roughnessmap_pars_fragment:_B,shadowmap_pars_fragment:wB,shadowmap_pars_vertex:SB,shadowmap_vertex:MB,shadowmask_pars_fragment:bB,skinbase_vertex:EB,skinning_pars_vertex:TB,skinning_vertex:AB,skinnormal_vertex:CB,specularmap_fragment:RB,specularmap_pars_fragment:PB,tonemapping_fragment:NB,tonemapping_pars_fragment:DB,transmission_fragment:LB,transmission_pars_fragment:IB,uv_pars_fragment:kB,uv_pars_vertex:OB,uv_vertex:FB,worldpos_vertex:UB,background_vert:BB,background_frag:zB,backgroundCube_vert:HB,backgroundCube_frag:jB,cube_vert:VB,cube_frag:GB,depth_vert:WB,depth_frag:XB,distanceRGBA_vert:$B,distanceRGBA_frag:YB,equirect_vert:KB,equirect_frag:qB,linedashed_vert:ZB,linedashed_frag:QB,meshbasic_vert:JB,meshbasic_frag:ez,meshlambert_vert:tz,meshlambert_frag:nz,meshmatcap_vert:rz,meshmatcap_frag:iz,meshnormal_vert:sz,meshnormal_frag:oz,meshphong_vert:az,meshphong_frag:lz,meshphysical_vert:cz,meshphysical_frag:uz,meshtoon_vert:dz,meshtoon_frag:fz,points_vert:hz,points_frag:pz,shadow_vert:mz,shadow_frag:gz,sprite_vert:vz,sprite_frag:yz},me={common:{diffuse:{value:new Pe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Qe},alphaMap:{value:null},alphaMapTransform:{value:new Qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Qe}},envmap:{envMap:{value:null},envMapRotation:{value:new Qe},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Qe},normalScale:{value:new ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Pe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Pe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Qe},alphaTest:{value:0},uvTransform:{value:new Qe}},sprite:{diffuse:{value:new Pe(16777215)},opacity:{value:1},center:{value:new ze(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Qe},alphaMap:{value:null},alphaMapTransform:{value:new Qe},alphaTest:{value:0}}},fi={basic:{uniforms:kn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:it.meshbasic_vert,fragmentShader:it.meshbasic_frag},lambert:{uniforms:kn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Pe(0)}}]),vertexShader:it.meshlambert_vert,fragmentShader:it.meshlambert_frag},phong:{uniforms:kn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Pe(0)},specular:{value:new Pe(1118481)},shininess:{value:30}}]),vertexShader:it.meshphong_vert,fragmentShader:it.meshphong_frag},standard:{uniforms:kn([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new Pe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag},toon:{uniforms:kn([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new Pe(0)}}]),vertexShader:it.meshtoon_vert,fragmentShader:it.meshtoon_frag},matcap:{uniforms:kn([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:it.meshmatcap_vert,fragmentShader:it.meshmatcap_frag},points:{uniforms:kn([me.points,me.fog]),vertexShader:it.points_vert,fragmentShader:it.points_frag},dashed:{uniforms:kn([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:it.linedashed_vert,fragmentShader:it.linedashed_frag},depth:{uniforms:kn([me.common,me.displacementmap]),vertexShader:it.depth_vert,fragmentShader:it.depth_frag},normal:{uniforms:kn([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:it.meshnormal_vert,fragmentShader:it.meshnormal_frag},sprite:{uniforms:kn([me.sprite,me.fog]),vertexShader:it.sprite_vert,fragmentShader:it.sprite_frag},background:{uniforms:{uvTransform:{value:new Qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:it.background_vert,fragmentShader:it.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Qe}},vertexShader:it.backgroundCube_vert,fragmentShader:it.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:it.cube_vert,fragmentShader:it.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:it.equirect_vert,fragmentShader:it.equirect_frag},distanceRGBA:{uniforms:kn([me.common,me.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:it.distanceRGBA_vert,fragmentShader:it.distanceRGBA_frag},shadow:{uniforms:kn([me.lights,me.fog,{color:{value:new Pe(0)},opacity:{value:1}}]),vertexShader:it.shadow_vert,fragmentShader:it.shadow_frag}};fi.physical={uniforms:kn([fi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Qe},clearcoatNormalScale:{value:new ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Qe},sheen:{value:0},sheenColor:{value:new Pe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Qe},transmissionSamplerSize:{value:new ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Qe},attenuationDistance:{value:0},attenuationColor:{value:new Pe(0)},specularColor:{value:new Pe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Qe},anisotropyVector:{value:new ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Qe}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag};const _d={r:0,b:0,g:0},go=new Qt,xz=new Ce;function _z(t,e,n,r,i,s,o){const a=new Pe(0);let l=s===!0?0:1,c,f,u=null,d=0,h=null;function m(x){let _=x.isScene===!0?x.background:null;return _&&_.isTexture&&(_=(x.backgroundBlurriness>0?n:e).get(_)),_}function v(x){let _=!1;const w=m(x);w===null?p(a,l):w&&w.isColor&&(p(w,1),_=!0);const M=t.xr.getEnvironmentBlendMode();M==="additive"?r.buffers.color.setClear(0,0,0,1,o):M==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||_)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function g(x,_){const w=m(_);w&&(w.isCubeTexture||w.mapping===Gh)?(f===void 0&&(f=new je(new Hl(1,1,1),new eo({name:"BackgroundCubeMaterial",uniforms:Rl(fi.backgroundCube.uniforms),vertexShader:fi.backgroundCube.vertexShader,fragmentShader:fi.backgroundCube.fragmentShader,side:tr,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),f.geometry.deleteAttribute("uv"),f.onBeforeRender=function(M,T,b){this.matrixWorld.copyPosition(b.matrixWorld)},Object.defineProperty(f.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(f)),go.copy(_.backgroundRotation),go.x*=-1,go.y*=-1,go.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(go.y*=-1,go.z*=-1),f.material.uniforms.envMap.value=w,f.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,f.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,f.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,f.material.uniforms.backgroundRotation.value.setFromMatrix4(xz.makeRotationFromEuler(go)),f.material.toneMapped=$e.getTransfer(w.colorSpace)!==Mt,(u!==w||d!==w.version||h!==t.toneMapping)&&(f.material.needsUpdate=!0,u=w,d=w.version,h=t.toneMapping),f.layers.enableAll(),x.unshift(f,f.geometry,f.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new je(new $h(2,2),new eo({name:"BackgroundMaterial",uniforms:Rl(fi.background.uniforms),vertexShader:fi.background.vertexShader,fragmentShader:fi.background.fragmentShader,side:ns,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=$e.getTransfer(w.colorSpace)!==Mt,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(u!==w||d!==w.version||h!==t.toneMapping)&&(c.material.needsUpdate=!0,u=w,d=w.version,h=t.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function p(x,_){x.getRGB(_d,aA(t)),r.buffers.color.setClear(_d.r,_d.g,_d.b,_,o)}return{getClearColor:function(){return a},setClearColor:function(x,_=1){a.set(x),l=_,p(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,p(a,l)},render:v,addToRenderList:g}}function wz(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=d(null);let s=i,o=!1;function a(E,N,F,I,U){let z=!1;const O=u(I,F,N);s!==O&&(s=O,c(s.object)),z=h(E,I,F,U),z&&m(E,I,F,U),U!==null&&e.update(U,t.ELEMENT_ARRAY_BUFFER),(z||o)&&(o=!1,w(E,N,F,I),U!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(U).buffer))}function l(){return t.createVertexArray()}function c(E){return t.bindVertexArray(E)}function f(E){return t.deleteVertexArray(E)}function u(E,N,F){const I=F.wireframe===!0;let U=r[E.id];U===void 0&&(U={},r[E.id]=U);let z=U[N.id];z===void 0&&(z={},U[N.id]=z);let O=z[I];return O===void 0&&(O=d(l()),z[I]=O),O}function d(E){const N=[],F=[],I=[];for(let U=0;U<n;U++)N[U]=0,F[U]=0,I[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:F,attributeDivisors:I,object:E,attributes:{},index:null}}function h(E,N,F,I){const U=s.attributes,z=N.attributes;let O=0;const j=F.getAttributes();for(const D in j)if(j[D].location>=0){const Q=U[D];let J=z[D];if(J===void 0&&(D==="instanceMatrix"&&E.instanceMatrix&&(J=E.instanceMatrix),D==="instanceColor"&&E.instanceColor&&(J=E.instanceColor)),Q===void 0||Q.attribute!==J||J&&Q.data!==J.data)return!0;O++}return s.attributesNum!==O||s.index!==I}function m(E,N,F,I){const U={},z=N.attributes;let O=0;const j=F.getAttributes();for(const D in j)if(j[D].location>=0){let Q=z[D];Q===void 0&&(D==="instanceMatrix"&&E.instanceMatrix&&(Q=E.instanceMatrix),D==="instanceColor"&&E.instanceColor&&(Q=E.instanceColor));const J={};J.attribute=Q,Q&&Q.data&&(J.data=Q.data),U[D]=J,O++}s.attributes=U,s.attributesNum=O,s.index=I}function v(){const E=s.newAttributes;for(let N=0,F=E.length;N<F;N++)E[N]=0}function g(E){p(E,0)}function p(E,N){const F=s.newAttributes,I=s.enabledAttributes,U=s.attributeDivisors;F[E]=1,I[E]===0&&(t.enableVertexAttribArray(E),I[E]=1),U[E]!==N&&(t.vertexAttribDivisor(E,N),U[E]=N)}function x(){const E=s.newAttributes,N=s.enabledAttributes;for(let F=0,I=N.length;F<I;F++)N[F]!==E[F]&&(t.disableVertexAttribArray(F),N[F]=0)}function _(E,N,F,I,U,z,O){O===!0?t.vertexAttribIPointer(E,N,F,U,z):t.vertexAttribPointer(E,N,F,I,U,z)}function w(E,N,F,I){v();const U=I.attributes,z=F.getAttributes(),O=N.defaultAttributeValues;for(const j in z){const D=z[j];if(D.location>=0){let V=U[j];if(V===void 0&&(j==="instanceMatrix"&&E.instanceMatrix&&(V=E.instanceMatrix),j==="instanceColor"&&E.instanceColor&&(V=E.instanceColor)),V!==void 0){const Q=V.normalized,J=V.itemSize,le=e.get(V);if(le===void 0)continue;const pe=le.buffer,$=le.type,ee=le.bytesPerElement,se=$===t.INT||$===t.UNSIGNED_INT||V.gpuType===jy;if(V.isInterleavedBufferAttribute){const Z=V.data,ue=Z.stride,Me=V.offset;if(Z.isInstancedInterleavedBuffer){for(let ye=0;ye<D.locationSize;ye++)p(D.location+ye,Z.meshPerAttribute);E.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ye=0;ye<D.locationSize;ye++)g(D.location+ye);t.bindBuffer(t.ARRAY_BUFFER,pe);for(let ye=0;ye<D.locationSize;ye++)_(D.location+ye,J/D.locationSize,$,Q,ue*ee,(Me+J/D.locationSize*ye)*ee,se)}else{if(V.isInstancedBufferAttribute){for(let Z=0;Z<D.locationSize;Z++)p(D.location+Z,V.meshPerAttribute);E.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=V.meshPerAttribute*V.count)}else for(let Z=0;Z<D.locationSize;Z++)g(D.location+Z);t.bindBuffer(t.ARRAY_BUFFER,pe);for(let Z=0;Z<D.locationSize;Z++)_(D.location+Z,J/D.locationSize,$,Q,J*ee,J/D.locationSize*Z*ee,se)}}else if(O!==void 0){const Q=O[j];if(Q!==void 0)switch(Q.length){case 2:t.vertexAttrib2fv(D.location,Q);break;case 3:t.vertexAttrib3fv(D.location,Q);break;case 4:t.vertexAttrib4fv(D.location,Q);break;default:t.vertexAttrib1fv(D.location,Q)}}}}x()}function M(){C();for(const E in r){const N=r[E];for(const F in N){const I=N[F];for(const U in I)f(I[U].object),delete I[U];delete N[F]}delete r[E]}}function T(E){if(r[E.id]===void 0)return;const N=r[E.id];for(const F in N){const I=N[F];for(const U in I)f(I[U].object),delete I[U];delete N[F]}delete r[E.id]}function b(E){for(const N in r){const F=r[N];if(F[E.id]===void 0)continue;const I=F[E.id];for(const U in I)f(I[U].object),delete I[U];delete F[E.id]}}function C(){A(),o=!0,s!==i&&(s=i,c(s.object))}function A(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:C,resetDefaultState:A,dispose:M,releaseStatesOfGeometry:T,releaseStatesOfProgram:b,initAttributes:v,enableAttribute:g,disableUnusedAttributes:x}}function Sz(t,e,n){let r;function i(c){r=c}function s(c,f){t.drawArrays(r,c,f),n.update(f,r,1)}function o(c,f,u){u!==0&&(t.drawArraysInstanced(r,c,f,u),n.update(f,r,u))}function a(c,f,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,f,0,u);let h=0;for(let m=0;m<u;m++)h+=f[m];n.update(h,r,1)}function l(c,f,u,d){if(u===0)return;const h=e.get("WEBGL_multi_draw");if(h===null)for(let m=0;m<c.length;m++)o(c[m],f[m],d[m]);else{h.multiDrawArraysInstancedWEBGL(r,c,0,f,0,d,0,u);let m=0;for(let v=0;v<u;v++)m+=f[v]*d[v];n.update(m,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function Mz(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const b=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(b){return!(b!==Cr&&r.convert(b)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(b){const C=b===Tu&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(b!==rs&&r.convert(b)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&b!==qr&&!C)}function l(b){if(b==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";b="mediump"}return b==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=n.precision!==void 0?n.precision:"highp";const f=l(c);f!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",f,"instead."),c=f);const u=n.logarithmicDepthBuffer===!0,d=n.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),g=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),x=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),_=t.getParameter(t.MAX_VARYING_VECTORS),w=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),M=m>0,T=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:h,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:x,maxVaryings:_,maxFragmentUniforms:w,vertexTextures:M,maxSamples:T}}function bz(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new Ms,a=new Qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const h=u.length!==0||d||r!==0||i;return i=d,r=u.length,h},this.beginShadows=function(){s=!0,f(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){n=f(u,d,0)},this.setState=function(u,d,h){const m=u.clippingPlanes,v=u.clipIntersection,g=u.clipShadows,p=t.get(u);if(!i||m===null||m.length===0||s&&!g)s?f(null):c();else{const x=s?0:r,_=x*4;let w=p.clippingState||null;l.value=w,w=f(m,d,_,h);for(let M=0;M!==_;++M)w[M]=n[M];p.clippingState=w,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function f(u,d,h,m){const v=u!==null?u.length:0;let g=null;if(v!==0){if(g=l.value,m!==!0||g===null){const p=h+v*4,x=d.matrixWorldInverse;a.getNormalMatrix(x),(g===null||g.length<p)&&(g=new Float32Array(p));for(let _=0,w=h;_!==v;++_,w+=4)o.copy(u[_]).applyMatrix4(x,a),o.normal.toArray(g,w),g[w+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,g}}function Ez(t){let e=new WeakMap;function n(o,a){return a===qf?o.mapping=bl:a===cv&&(o.mapping=El),o}function r(o){if(o&&o.isTexture){const a=o.mapping;if(a===qf||a===cv)if(e.has(o)){const l=e.get(o).texture;return n(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new OF(l.height);return c.fromEquirectangularTexture(t,o),e.set(o,c),o.addEventListener("dispose",i),n(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class Hi extends lA{constructor(e=-1,n=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=o,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,r,i,s,o){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=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,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),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,a=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=f*this.view.offsetY,l=a-f*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),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}}const Fa=4,eS=[.125,.215,.35,.446,.526,.582],Mo=20,lm=new Hi,tS=new Pe;let cm=null,um=0,dm=0,fm=!1;const wo=(1+Math.sqrt(5))/2,va=1/wo,nS=[new k(-wo,va,0),new k(wo,va,0),new k(-va,0,wo),new k(va,0,wo),new k(0,wo,-va),new k(0,wo,va),new k(-1,1,-1),new k(1,1,-1),new k(-1,1,1),new k(1,1,1)];class rS{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,r=.1,i=100){cm=this._renderer.getRenderTarget(),um=this._renderer.getActiveCubeFace(),dm=this._renderer.getActiveMipmapLevel(),fm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),n>0&&this._blur(s,0,0,n),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=oS(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=sS(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(cm,um,dm),this._renderer.xr.enabled=fm,e.scissorTest=!1,wd(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===bl||e.mapping===El?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),cm=this._renderer.getRenderTarget(),um=this._renderer.getActiveCubeFace(),dm=this._renderer.getActiveMipmapLevel(),fm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:hr,minFilter:hr,generateMipmaps:!1,type:Tu,format:Cr,colorSpace:Ln,depthBuffer:!1},i=iS(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=iS(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Tz(s)),this._blurMaterial=Az(s,e,n)}return i}_compileMaterial(e){const n=new je(this._lodPlanes[0],e);this._renderer.compile(n,lm)}_sceneToCubeUV(e,n,r,i){const a=new dn(90,1,n,r),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],f=this._renderer,u=f.autoClear,d=f.toneMapping;f.getClearColor(tS),f.toneMapping=Ws,f.autoClear=!1;const h=new Xi({name:"PMREM.Background",side:tr,depthWrite:!1,depthTest:!1}),m=new je(new Hl,h);let v=!1;const g=e.background;g?g.isColor&&(h.color.copy(g),e.background=null,v=!0):(h.color.copy(tS),v=!0);for(let p=0;p<6;p++){const x=p%3;x===0?(a.up.set(0,l[p],0),a.lookAt(c[p],0,0)):x===1?(a.up.set(0,0,l[p]),a.lookAt(0,c[p],0)):(a.up.set(0,l[p],0),a.lookAt(0,0,c[p]));const _=this._cubeSize;wd(i,x*_,p>2?_:0,_,_),f.setRenderTarget(i),v&&f.render(m,a),f.render(e,a)}m.geometry.dispose(),m.material.dispose(),f.toneMapping=d,f.autoClear=u,e.background=g}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===bl||e.mapping===El;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=oS()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=sS());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new je(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;wd(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(o,lm)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;s<i;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=nS[(i-s-1)%nS.length];this._blur(e,s-1,s,o,a)}n.autoClear=r}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const f=3,u=new je(this._lodPlanes[i],c),d=c.uniforms,h=this._sizeLods[r]-1,m=isFinite(s)?Math.PI/(2*h):2*Math.PI/(2*Mo-1),v=s/m,g=isFinite(s)?1+Math.floor(f*v):Mo;g>Mo&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Mo}`);const p=[];let x=0;for(let b=0;b<Mo;++b){const C=b/v,A=Math.exp(-C*C/2);p.push(A),b===0?x+=A:b<g&&(x+=2*A)}for(let b=0;b<p.length;b++)p[b]=p[b]/x;d.envMap.value=e.texture,d.samples.value=g,d.weights.value=p,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:_}=this;d.dTheta.value=m,d.mipInt.value=_-r;const w=this._sizeLods[i],M=3*w*(i>_-Fa?i-_+Fa:0),T=4*(this._cubeSize-w);wd(n,M,T,3*w,2*w),l.setRenderTarget(n),l.render(u,lm)}}function Tz(t){const e=[],n=[],r=[];let i=t;const s=t-Fa+1+eS.length;for(let o=0;o<s;o++){const a=Math.pow(2,i);n.push(a);let l=1/a;o>t-Fa?l=eS[o-t+Fa-1]:o===0&&(l=0),r.push(l);const c=1/(a-2),f=-c,u=1+c,d=[f,f,u,f,u,u,f,f,u,u,f,u],h=6,m=6,v=3,g=2,p=1,x=new Float32Array(v*m*h),_=new Float32Array(g*m*h),w=new Float32Array(p*m*h);for(let T=0;T<h;T++){const b=T%3*2/3-1,C=T>2?0:-1,A=[b,C,0,b+2/3,C,0,b+2/3,C+1,0,b,C,0,b+2/3,C+1,0,b,C+1,0];x.set(A,v*m*T),_.set(d,g*m*T);const E=[T,T,T,T,T,T];w.set(E,p*m*T)}const M=new Wt;M.setAttribute("position",new hn(x,v)),M.setAttribute("uv",new hn(_,g)),M.setAttribute("faceIndex",new hn(w,p)),e.push(M),i>Fa&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function iS(t,e,n){const r=new Wo(t,e,n);return r.texture.mapping=Gh,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function wd(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Az(t,e,n){const r=new Float32Array(Mo),i=new k(0,1,0);return new eo({name:"SphericalGaussianBlur",defines:{n:Mo,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Jy(),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:Gs,depthTest:!1,depthWrite:!1})}function sS(){return new eo({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Jy(),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:Gs,depthTest:!1,depthWrite:!1})}function oS(){return new eo({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Jy(),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:Gs,depthTest:!1,depthWrite:!1})}function Jy(){return`
precision mediump float;
precision mediump int;
attribute float faceIndex;
varying vec3 vOutputDirection;
// RH coordinate system; PMREM face-indexing convention
vec3 getDirection( vec2 uv, float face ) {
uv = 2.0 * uv - 1.0;
vec3 direction = vec3( uv, 1.0 );
if ( face == 0.0 ) {
direction = direction.zyx; // ( 1, v, u ) pos x
} else if ( face == 1.0 ) {
direction = direction.xzy;
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
} else if ( face == 2.0 ) {
direction.x *= -1.0; // ( -u, v, 1 ) pos z
} else if ( face == 3.0 ) {
direction = direction.zyx;
direction.xz *= -1.0; // ( -1, v, -u ) neg x
} else if ( face == 4.0 ) {
direction = direction.xzy;
direction.xy *= -1.0; // ( -u, -1, v ) neg y
} else if ( face == 5.0 ) {
direction.z *= -1.0; // ( u, v, -1 ) neg z
}
return direction;
}
void main() {
vOutputDirection = getDirection( uv, faceIndex );
gl_Position = vec4( position, 1.0 );
}
`}function Cz(t){let e=new WeakMap,n=null;function r(a){if(a&&a.isTexture){const l=a.mapping,c=l===qf||l===cv,f=l===bl||l===El;if(c||f){let u=e.get(a);const d=u!==void 0?u.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return n===null&&(n=new rS(t)),u=c?n.fromEquirectangular(a,u):n.fromCubemap(a,u),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),u.texture;if(u!==void 0)return u.texture;{const h=a.image;return c&&h&&h.height>0||f&&h&&i(h)?(n===null&&(n=new rS(t)),u=c?n.fromEquirectangular(a):n.fromCubemap(a),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),a.addEventListener("dispose",s),u.texture):null}}}return a}function i(a){let l=0;const c=6;for(let f=0;f<c;f++)a[f]!==void 0&&l++;return l===c}function s(a){const l=a.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function Rz(t){const e={};function n(r){if(e[r]!==void 0)return e[r];let i;switch(r){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(r)}return e[r]=i,i}return{has:function(r){return n(r)!==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(r){const i=n(r);return i===null&&wc("THREE.WebGLRenderer: "+r+" extension not supported."),i}}}function Pz(t,e,n,r){const i={},s=new WeakMap;function o(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const m in d.attributes)e.remove(d.attributes[m]);for(const m in d.morphAttributes){const v=d.morphAttributes[m];for(let g=0,p=v.length;g<p;g++)e.remove(v[g])}d.removeEventListener("dispose",o),delete i[d.id];const h=s.get(d);h&&(e.remove(h),s.delete(d)),r.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,n.memory.geometries--}function a(u,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,n.memory.geometries++),d}function l(u){const d=u.attributes;for(const m in d)e.update(d[m],t.ARRAY_BUFFER);const h=u.morphAttributes;for(const m in h){const v=h[m];for(let g=0,p=v.length;g<p;g++)e.update(v[g],t.ARRAY_BUFFER)}}function c(u){const d=[],h=u.index,m=u.attributes.position;let v=0;if(h!==null){const x=h.array;v=h.version;for(let _=0,w=x.length;_<w;_+=3){const M=x[_+0],T=x[_+1],b=x[_+2];d.push(M,T,T,b,b,M)}}else if(m!==void 0){const x=m.array;v=m.version;for(let _=0,w=x.length/3-1;_<w;_+=3){const M=_+0,T=_+1,b=_+2;d.push(M,T,T,b,b,M)}}else return;const g=new(nA(d)?oA:Zy)(d,1);g.version=v;const p=s.get(u);p&&e.remove(p),s.set(u,g)}function f(u){const d=s.get(u);if(d){const h=u.index;h!==null&&d.version<h.version&&c(u)}else c(u);return s.get(u)}return{get:a,update:l,getWireframeAttribute:f}}function Nz(t,e,n){let r;function i(d){r=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function l(d,h){t.drawElements(r,h,s,d*o),n.update(h,r,1)}function c(d,h,m){m!==0&&(t.drawElementsInstanced(r,h,s,d*o,m),n.update(h,r,m))}function f(d,h,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,h,0,s,d,0,m);let g=0;for(let p=0;p<m;p++)g+=h[p];n.update(g,r,1)}function u(d,h,m,v){if(m===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let p=0;p<d.length;p++)c(d[p]/o,h[p],v[p]);else{g.multiDrawElementsInstancedWEBGL(r,h,0,s,d,0,v,0,m);let p=0;for(let x=0;x<m;x++)p+=h[x]*v[x];n.update(p,r,1)}}this.setMode=i,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=f,this.renderMultiDrawInstances=u}function Dz(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,a){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=a*(s/3);break;case t.LINES:n.lines+=a*(s/2);break;case t.LINE_STRIP:n.lines+=a*(s-1);break;case t.LINE_LOOP:n.lines+=a*s;break;case t.POINTS:n.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function Lz(t,e,n){const r=new WeakMap,i=new ut;function s(o,a,l){const c=o.morphTargetInfluences,f=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=f!==void 0?f.length:0;let d=r.get(a);if(d===void 0||d.count!==u){let E=function(){C.dispose(),r.delete(a),a.removeEventListener("dispose",E)};var h=E;d!==void 0&&d.texture.dispose();const m=a.morphAttributes.position!==void 0,v=a.morphAttributes.normal!==void 0,g=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],x=a.morphAttributes.normal||[],_=a.morphAttributes.color||[];let w=0;m===!0&&(w=1),v===!0&&(w=2),g===!0&&(w=3);let M=a.attributes.position.count*w,T=1;M>e.maxTextureSize&&(T=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const b=new Float32Array(M*T*4*u),C=new iA(b,M,T,u);C.type=qr,C.needsUpdate=!0;const A=w*4;for(let N=0;N<u;N++){const F=p[N],I=x[N],U=_[N],z=M*T*4*N;for(let O=0;O<F.count;O++){const j=O*A;m===!0&&(i.fromBufferAttribute(F,O),b[z+j+0]=i.x,b[z+j+1]=i.y,b[z+j+2]=i.z,b[z+j+3]=0),v===!0&&(i.fromBufferAttribute(I,O),b[z+j+4]=i.x,b[z+j+5]=i.y,b[z+j+6]=i.z,b[z+j+7]=0),g===!0&&(i.fromBufferAttribute(U,O),b[z+j+8]=i.x,b[z+j+9]=i.y,b[z+j+10]=i.z,b[z+j+11]=U.itemSize===4?i.w:1)}}d={count:u,texture:C,size:new ze(M,T)},r.set(a,d),a.addEventListener("dispose",E)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let m=0;for(let g=0;g<c.length;g++)m+=c[g];const v=a.morphTargetsRelative?1:1-m;l.getUniforms().setValue(t,"morphTargetBaseInfluence",v),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",d.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}return{update:s}}function Iz(t,e,n,r){let i=new WeakMap;function s(l){const c=r.render.frame,f=l.geometry,u=e.get(l,f);if(i.get(u)!==c&&(e.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),i.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;i.get(d)!==c&&(d.update(),i.set(d,c))}return u}function o(){i=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:s,dispose:o}}class dA extends on{constructor(e,n,r,i,s,o,a,l,c,f=Za){if(f!==Za&&f!==Al)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&f===Za&&(r=Go),r===void 0&&f===Al&&(r=Tl),super(null,i,s,o,a,l,f,r,c),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=a!==void 0?a:Hn,this.minFilter=l!==void 0?l:Hn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}const fA=new on,aS=new dA(1,1),hA=new iA,pA=new _F,mA=new cA,lS=[],cS=[],uS=new Float32Array(16),dS=new Float32Array(9),fS=new Float32Array(4);function jl(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=lS[i];if(s===void 0&&(s=new Float32Array(i),lS[i]=s),e!==0){r.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=n,t[o].toArray(s,a)}return s}function an(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function ln(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function Yh(t,e){let n=cS[e];n===void 0&&(n=new Int32Array(e),cS[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function kz(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Oz(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(an(n,e))return;t.uniform2fv(this.addr,e),ln(n,e)}}function Fz(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.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)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(an(n,e))return;t.uniform3fv(this.addr,e),ln(n,e)}}function Uz(t,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)&&(t.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(an(n,e))return;t.uniform4fv(this.addr,e),ln(n,e)}}function Bz(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(an(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ln(n,e)}else{if(an(n,r))return;fS.set(r),t.uniformMatrix2fv(this.addr,!1,fS),ln(n,r)}}function zz(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(an(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ln(n,e)}else{if(an(n,r))return;dS.set(r),t.uniformMatrix3fv(this.addr,!1,dS),ln(n,r)}}function Hz(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(an(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ln(n,e)}else{if(an(n,r))return;uS.set(r),t.uniformMatrix4fv(this.addr,!1,uS),ln(n,r)}}function jz(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Vz(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(an(n,e))return;t.uniform2iv(this.addr,e),ln(n,e)}}function Gz(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(an(n,e))return;t.uniform3iv(this.addr,e),ln(n,e)}}function Wz(t,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)&&(t.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(an(n,e))return;t.uniform4iv(this.addr,e),ln(n,e)}}function Xz(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function $z(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(an(n,e))return;t.uniform2uiv(this.addr,e),ln(n,e)}}function Yz(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(an(n,e))return;t.uniform3uiv(this.addr,e),ln(n,e)}}function Kz(t,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)&&(t.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(an(n,e))return;t.uniform4uiv(this.addr,e),ln(n,e)}}function qz(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let s;this.type===t.SAMPLER_2D_SHADOW?(aS.compareFunction=tA,s=aS):s=fA,n.setTexture2D(e||s,i)}function Zz(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||pA,i)}function Qz(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||mA,i)}function Jz(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||hA,i)}function e4(t){switch(t){case 5126:return kz;case 35664:return Oz;case 35665:return Fz;case 35666:return Uz;case 35674:return Bz;case 35675:return zz;case 35676:return Hz;case 5124:case 35670:return jz;case 35667:case 35671:return Vz;case 35668:case 35672:return Gz;case 35669:case 35673:return Wz;case 5125:return Xz;case 36294:return $z;case 36295:return Yz;case 36296:return Kz;case 35678:case 36198:case 36298:case 36306:case 35682:return qz;case 35679:case 36299:case 36307:return Zz;case 35680:case 36300:case 36308:case 36293:return Qz;case 36289:case 36303:case 36311:case 36292:return Jz}}function t4(t,e){t.uniform1fv(this.addr,e)}function n4(t,e){const n=jl(e,this.size,2);t.uniform2fv(this.addr,n)}function r4(t,e){const n=jl(e,this.size,3);t.uniform3fv(this.addr,n)}function i4(t,e){const n=jl(e,this.size,4);t.uniform4fv(this.addr,n)}function s4(t,e){const n=jl(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function o4(t,e){const n=jl(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function a4(t,e){const n=jl(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function l4(t,e){t.uniform1iv(this.addr,e)}function c4(t,e){t.uniform2iv(this.addr,e)}function u4(t,e){t.uniform3iv(this.addr,e)}function d4(t,e){t.uniform4iv(this.addr,e)}function f4(t,e){t.uniform1uiv(this.addr,e)}function h4(t,e){t.uniform2uiv(this.addr,e)}function p4(t,e){t.uniform3uiv(this.addr,e)}function m4(t,e){t.uniform4uiv(this.addr,e)}function g4(t,e,n){const r=this.cache,i=e.length,s=Yh(n,i);an(r,s)||(t.uniform1iv(this.addr,s),ln(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||fA,s[o])}function v4(t,e,n){const r=this.cache,i=e.length,s=Yh(n,i);an(r,s)||(t.uniform1iv(this.addr,s),ln(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||pA,s[o])}function y4(t,e,n){const r=this.cache,i=e.length,s=Yh(n,i);an(r,s)||(t.uniform1iv(this.addr,s),ln(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||mA,s[o])}function x4(t,e,n){const r=this.cache,i=e.length,s=Yh(n,i);an(r,s)||(t.uniform1iv(this.addr,s),ln(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||hA,s[o])}function _4(t){switch(t){case 5126:return t4;case 35664:return n4;case 35665:return r4;case 35666:return i4;case 35674:return s4;case 35675:return o4;case 35676:return a4;case 5124:case 35670:return l4;case 35667:case 35671:return c4;case 35668:case 35672:return u4;case 35669:case 35673:return d4;case 5125:return f4;case 36294:return h4;case 36295:return p4;case 36296:return m4;case 35678:case 36198:case 36298:case 36306:case 35682:return g4;case 35679:case 36299:case 36307:return v4;case 35680:case 36300:case 36308:case 36293:return y4;case 36289:case 36303:case 36311:case 36292:return x4}}class w4{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=e4(n.type)}}class S4{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=_4(n.type)}}class M4{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const a=i[s];a.setValue(e,n[a.id],r)}}}const hm=/(\w+)(\])?(\[|\.)?/g;function hS(t,e){t.seq.push(e),t.map[e.id]=e}function b4(t,e,n){const r=t.name,i=r.length;for(hm.lastIndex=0;;){const s=hm.exec(r),o=hm.lastIndex;let a=s[1];const l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){hS(n,c===void 0?new w4(a,t,e):new S4(a,t,e));break}else{let u=n.map[a];u===void 0&&(u=new M4(a),hS(n,u)),n=u}}}class ff{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),o=e.getUniformLocation(n,s.name);b4(s,o,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,o=n.length;s!==o;++s){const a=n[s],l=r[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function pS(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const E4=37297;let T4=0;function A4(t,e){const n=t.split(`
`),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const a=o+1;r.push(`${a===e?">":" "} ${a}: ${n[o]}`)}return r.join(`
`)}const mS=new Qe;function C4(t){$e._getMatrix(mS,$e.workingColorSpace,t);const e=`mat3( ${mS.elements.map(n=>n.toFixed(4))} )`;switch($e.getTransfer(t)){case Xh:return[e,"LinearTransferOETF"];case Mt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function gS(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
`+i+`
`+A4(t.getShaderSource(e),o)}else return i}function R4(t,e){const n=C4(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
`)}function P4(t,e){let n;switch(e){case NO:n="Linear";break;case DO:n="Reinhard";break;case LO:n="Cineon";break;case Hy:n="ACESFilmic";break;case kO:n="AgX";break;case OO:n="Neutral";break;case IO:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Sd=new k;function N4(){$e.getLuminanceCoefficients(Sd);const t=Sd.x.toFixed(4),e=Sd.y.toFixed(4),n=Sd.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
`)}function D4(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Sc).join(`
`)}function L4(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
`)}function I4(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let a=1;s.type===t.FLOAT_MAT2&&(a=2),s.type===t.FLOAT_MAT3&&(a=3),s.type===t.FLOAT_MAT4&&(a=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:a}}return n}function Sc(t){return t!==""}function vS(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.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 yS(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const k4=/^[ \t]*#include +<([\w\d./]+)>/gm;function Uv(t){return t.replace(k4,F4)}const O4=new Map;function F4(t,e){let n=it[e];if(n===void 0){const r=O4.get(e);if(r!==void 0)n=it[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return Uv(n)}const U4=/#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 xS(t){return t.replace(U4,B4)}function B4(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function _S(t){let e=`precision ${t.precision} float;
precision ${t.precision} int;
precision ${t.precision} sampler2D;
precision ${t.precision} samplerCube;
precision ${t.precision} sampler3D;
precision ${t.precision} sampler2DArray;
precision ${t.precision} sampler2DShadow;
precision ${t.precision} samplerCubeShadow;
precision ${t.precision} sampler2DArrayShadow;
precision ${t.precision} isampler2D;
precision ${t.precision} isampler3D;
precision ${t.precision} isamplerCube;
precision ${t.precision} isampler2DArray;
precision ${t.precision} usampler2D;
precision ${t.precision} usampler3D;
precision ${t.precision} usamplerCube;
precision ${t.precision} usampler2DArray;
`;return t.precision==="highp"?e+=`
#define HIGH_PRECISION`:t.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function z4(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===jT?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===zy?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Fi&&(e="SHADOWMAP_TYPE_VSM"),e}function H4(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case bl:case El:e="ENVMAP_TYPE_CUBE";break;case Gh:e="ENVMAP_TYPE_CUBE_UV";break}return e}function j4(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case El:e="ENVMAP_MODE_REFRACTION";break}return e}function V4(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case Vh:e="ENVMAP_BLENDING_MULTIPLY";break;case RO:e="ENVMAP_BLENDING_MIX";break;case PO:e="ENVMAP_BLENDING_ADD";break}return e}function G4(t){const e=t.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),7*16)),texelHeight:r,maxMip:n}}function W4(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,a=n.fragmentShader;const l=z4(n),c=H4(n),f=j4(n),u=V4(n),d=G4(n),h=D4(n),m=L4(s),v=i.createProgram();let g,p,x=n.glslVersion?"#version "+n.glslVersion+`
`:"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Sc).join(`
`),g.length>0&&(g+=`
`),p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Sc).join(`
`),p.length>0&&(p+=`
`)):(g=[_S(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,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 "+f:"",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.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 "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(Sc).join(`
`),p=[_S(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,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 "+c:"",n.envMap?"#define "+f:"",n.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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.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||n.batchingColor?"#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.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 "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Ws?"#define TONE_MAPPING":"",n.toneMapping!==Ws?it.tonemapping_pars_fragment:"",n.toneMapping!==Ws?P4("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",it.colorspace_pars_fragment,R4("linearToOutputTexel",n.outputColorSpace),N4(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
`].filter(Sc).join(`
`)),o=Uv(o),o=vS(o,n),o=yS(o,n),a=Uv(a),a=vS(a,n),a=yS(a,n),o=xS(o),a=xS(a),n.isRawShaderMaterial!==!0&&(x=`#version 300 es
`,g=[h,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+g,p=["#define varying in",n.glslVersion===Dw?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Dw?"":"#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(`
`)+`
`+p);const _=x+g+o,w=x+p+a,M=pS(i,i.VERTEX_SHADER,_),T=pS(i,i.FRAGMENT_SHADER,w);i.attachShader(v,M),i.attachShader(v,T),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function b(N){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(v).trim(),I=i.getShaderInfoLog(M).trim(),U=i.getShaderInfoLog(T).trim();let z=!0,O=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(z=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,M,T);else{const j=gS(i,M,"vertex"),D=gS(i,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
Material Name: `+N.name+`
Material Type: `+N.type+`
Program Info Log: `+F+`
`+j+`
`+D)}else F!==""?console.warn("THREE.WebGLProgram: Program Info Log:",F):(I===""||U==="")&&(O=!1);O&&(N.diagnostics={runnable:z,programLog:F,vertexShader:{log:I,prefix:g},fragmentShader:{log:U,prefix:p}})}i.deleteShader(M),i.deleteShader(T),C=new ff(i,v),A=I4(i,v)}let C;this.getUniforms=function(){return C===void 0&&b(this),C};let A;this.getAttributes=function(){return A===void 0&&b(this),A};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(v,E4)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=T4++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=M,this.fragmentShader=T,this}let X4=0;class $4{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new Y4(e),n.set(e,r)),r}}class Y4{constructor(e){this.id=X4++,this.code=e,this.usedTimes=0}}function K4(t,e,n,r,i,s,o){const a=new qy,l=new $4,c=new Set,f=[],u=i.logarithmicDepthBuffer,d=i.vertexTextures;let h=i.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(A){return c.add(A),A===0?"uv":`uv${A}`}function g(A,E,N,F,I){const U=F.fog,z=I.geometry,O=A.isMeshStandardMaterial?F.environment:null,j=(A.isMeshStandardMaterial?n:e).get(A.envMap||O),D=j&&j.mapping===Gh?j.image.height:null,V=m[A.type];A.precision!==null&&(h=i.getMaxPrecision(A.precision),h!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",h,"instead."));const Q=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,J=Q!==void 0?Q.length:0;let le=0;z.morphAttributes.position!==void 0&&(le=1),z.morphAttributes.normal!==void 0&&(le=2),z.morphAttributes.color!==void 0&&(le=3);let pe,$,ee,se;if(V){const _t=fi[V];pe=_t.vertexShader,$=_t.fragmentShader}else pe=A.vertexShader,$=A.fragmentShader,l.update(A),ee=l.getVertexShaderID(A),se=l.getFragmentShaderID(A);const Z=t.getRenderTarget(),ue=t.state.buffers.depth.getReversed(),Me=I.isInstancedMesh===!0,ye=I.isBatchedMesh===!0,ke=!!A.map,Se=!!A.matcap,nt=!!j,H=!!A.aoMap,Xt=!!A.lightMap,Ve=!!A.bumpMap,qe=!!A.normalMap,Ue=!!A.displacementMap,Ye=!!A.emissiveMap,Oe=!!A.metalnessMap,L=!!A.roughnessMap,R=A.anisotropy>0,X=A.clearcoat>0,ie=A.dispersion>0,oe=A.iridescence>0,ne=A.sheen>0,Re=A.transmission>0,ge=R&&!!A.anisotropyMap,_e=X&&!!A.clearcoatMap,ct=X&&!!A.clearcoatNormalMap,de=X&&!!A.clearcoatRoughnessMap,Te=oe&&!!A.iridescenceMap,Be=oe&&!!A.iridescenceThicknessMap,Ge=ne&&!!A.sheenColorMap,Ee=ne&&!!A.sheenRoughnessMap,Ke=!!A.specularMap,Ze=!!A.specularColorMap,be=!!A.specularIntensityMap,B=Re&&!!A.transmissionMap,ae=Re&&!!A.thicknessMap,q=!!A.gradientMap,te=!!A.alphaMap,ve=A.alphaTest>0,xe=!!A.alphaHash,Je=!!A.extensions;let Ht=Ws;A.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Ht=t.toneMapping);const wn={shaderID:V,shaderType:A.type,shaderName:A.name,vertexShader:pe,fragmentShader:$,defines:A.defines,customVertexShaderID:ee,customFragmentShaderID:se,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:h,batching:ye,batchingColor:ye&&I._colorsTexture!==null,instancing:Me,instancingColor:Me&&I.instanceColor!==null,instancingMorph:Me&&I.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:Z===null?t.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Ln,alphaToCoverage:!!A.alphaToCoverage,map:ke,matcap:Se,envMap:nt,envMapMode:nt&&j.mapping,envMapCubeUVHeight:D,aoMap:H,lightMap:Xt,bumpMap:Ve,normalMap:qe,displacementMap:d&&Ue,emissiveMap:Ye,normalMapObjectSpace:qe&&A.normalMapType===jO,normalMapTangentSpace:qe&&A.normalMapType===Wh,metalnessMap:Oe,roughnessMap:L,anisotropy:R,anisotropyMap:ge,clearcoat:X,clearcoatMap:_e,clearcoatNormalMap:ct,clearcoatRoughnessMap:de,dispersion:ie,iridescence:oe,iridescenceMap:Te,iridescenceThicknessMap:Be,sheen:ne,sheenColorMap:Ge,sheenRoughnessMap:Ee,specularMap:Ke,specularColorMap:Ze,specularIntensityMap:be,transmission:Re,transmissionMap:B,thicknessMap:ae,gradientMap:q,opaque:A.transparent===!1&&A.blending===qa&&A.alphaToCoverage===!1,alphaMap:te,alphaTest:ve,alphaHash:xe,combine:A.combine,mapUv:ke&&v(A.map.channel),aoMapUv:H&&v(A.aoMap.channel),lightMapUv:Xt&&v(A.lightMap.channel),bumpMapUv:Ve&&v(A.bumpMap.channel),normalMapUv:qe&&v(A.normalMap.channel),displacementMapUv:Ue&&v(A.displacementMap.channel),emissiveMapUv:Ye&&v(A.emissiveMap.channel),metalnessMapUv:Oe&&v(A.metalnessMap.channel),roughnessMapUv:L&&v(A.roughnessMap.channel),anisotropyMapUv:ge&&v(A.anisotropyMap.channel),clearcoatMapUv:_e&&v(A.clearcoatMap.channel),clearcoatNormalMapUv:ct&&v(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:de&&v(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Te&&v(A.iridescenceMap.channel),iridescenceThicknessMapUv:Be&&v(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ge&&v(A.sheenColorMap.channel),sheenRoughnessMapUv:Ee&&v(A.sheenRoughnessMap.channel),specularMapUv:Ke&&v(A.specularMap.channel),specularColorMapUv:Ze&&v(A.specularColorMap.channel),specularIntensityMapUv:be&&v(A.specularIntensityMap.channel),transmissionMapUv:B&&v(A.transmissionMap.channel),thicknessMapUv:ae&&v(A.thicknessMap.channel),alphaMapUv:te&&v(A.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(qe||R),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!z.attributes.uv&&(ke||te),fog:!!U,useFog:A.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:ue,skinning:I.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:J,morphTextureStride:le,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&N.length>0,shadowMapType:t.shadowMap.type,toneMapping:Ht,decodeVideoTexture:ke&&A.map.isVideoTexture===!0&&$e.getTransfer(A.map.colorSpace)===Mt,decodeVideoTextureEmissive:Ye&&A.emissiveMap.isVideoTexture===!0&&$e.getTransfer(A.emissiveMap.colorSpace)===Mt,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===pi,flipSided:A.side===tr,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:Je&&A.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Je&&A.extensions.multiDraw===!0||ye)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return wn.vertexUv1s=c.has(1),wn.vertexUv2s=c.has(2),wn.vertexUv3s=c.has(3),c.clear(),wn}function p(A){const E=[];if(A.shaderID?E.push(A.shaderID):(E.push(A.customVertexShaderID),E.push(A.customFragmentShaderID)),A.defines!==void 0)for(const N in A.defines)E.push(N),E.push(A.defines[N]);return A.isRawShaderMaterial===!1&&(x(E,A),_(E,A),E.push(t.outputColorSpace)),E.push(A.customProgramCacheKey),E.join()}function x(A,E){A.push(E.precision),A.push(E.outputColorSpace),A.push(E.envMapMode),A.push(E.envMapCubeUVHeight),A.push(E.mapUv),A.push(E.alphaMapUv),A.push(E.lightMapUv),A.push(E.aoMapUv),A.push(E.bumpMapUv),A.push(E.normalMapUv),A.push(E.displacementMapUv),A.push(E.emissiveMapUv),A.push(E.metalnessMapUv),A.push(E.roughnessMapUv),A.push(E.anisotropyMapUv),A.push(E.clearcoatMapUv),A.push(E.clearcoatNormalMapUv),A.push(E.clearcoatRoughnessMapUv),A.push(E.iridescenceMapUv),A.push(E.iridescenceThicknessMapUv),A.push(E.sheenColorMapUv),A.push(E.sheenRoughnessMapUv),A.push(E.specularMapUv),A.push(E.specularColorMapUv),A.push(E.specularIntensityMapUv),A.push(E.transmissionMapUv),A.push(E.thicknessMapUv),A.push(E.combine),A.push(E.fogExp2),A.push(E.sizeAttenuation),A.push(E.morphTargetsCount),A.push(E.morphAttributeCount),A.push(E.numDirLights),A.push(E.numPointLights),A.push(E.numSpotLights),A.push(E.numSpotLightMaps),A.push(E.numHemiLights),A.push(E.numRectAreaLights),A.push(E.numDirLightShadows),A.push(E.numPointLightShadows),A.push(E.numSpotLightShadows),A.push(E.numSpotLightShadowsWithMaps),A.push(E.numLightProbes),A.push(E.shadowMapType),A.push(E.toneMapping),A.push(E.numClippingPlanes),A.push(E.numClipIntersection),A.push(E.depthPacking)}function _(A,E){a.disableAll(),E.supportsVertexTextures&&a.enable(0),E.instancing&&a.enable(1),E.instancingColor&&a.enable(2),E.instancingMorph&&a.enable(3),E.matcap&&a.enable(4),E.envMap&&a.enable(5),E.normalMapObjectSpace&&a.enable(6),E.normalMapTangentSpace&&a.enable(7),E.clearcoat&&a.enable(8),E.iridescence&&a.enable(9),E.alphaTest&&a.enable(10),E.vertexColors&&a.enable(11),E.vertexAlphas&&a.enable(12),E.vertexUv1s&&a.enable(13),E.vertexUv2s&&a.enable(14),E.vertexUv3s&&a.enable(15),E.vertexTangents&&a.enable(16),E.anisotropy&&a.enable(17),E.alphaHash&&a.enable(18),E.batching&&a.enable(19),E.dispersion&&a.enable(20),E.batchingColor&&a.enable(21),A.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.reverseDepthBuffer&&a.enable(4),E.skinning&&a.enable(5),E.morphTargets&&a.enable(6),E.morphNormals&&a.enable(7),E.morphColors&&a.enable(8),E.premultipliedAlpha&&a.enable(9),E.shadowMapEnabled&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),E.decodeVideoTexture&&a.enable(19),E.decodeVideoTextureEmissive&&a.enable(20),E.alphaToCoverage&&a.enable(21),A.push(a.mask)}function w(A){const E=m[A.type];let N;if(E){const F=fi[E];N=DF.clone(F.uniforms)}else N=A.uniforms;return N}function M(A,E){let N;for(let F=0,I=f.length;F<I;F++){const U=f[F];if(U.cacheKey===E){N=U,++N.usedTimes;break}}return N===void 0&&(N=new W4(t,E,A,s),f.push(N)),N}function T(A){if(--A.usedTimes===0){const E=f.indexOf(A);f[E]=f[f.length-1],f.pop(),A.destroy()}}function b(A){l.remove(A)}function C(){l.dispose()}return{getParameters:g,getProgramCacheKey:p,getUniforms:w,acquireProgram:M,releaseProgram:T,releaseShaderCache:b,programs:f,dispose:C}}function q4(){let t=new WeakMap;function e(o){return t.has(o)}function n(o){let a=t.get(o);return a===void 0&&(a={},t.set(o,a)),a}function r(o){t.delete(o)}function i(o,a,l){t.get(o)[a]=l}function s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function Z4(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function wS(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function SS(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(u,d,h,m,v,g){let p=t[e];return p===void 0?(p={id:u.id,object:u,geometry:d,material:h,groupOrder:m,renderOrder:u.renderOrder,z:v,group:g},t[e]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=h,p.groupOrder=m,p.renderOrder=u.renderOrder,p.z=v,p.group=g),e++,p}function a(u,d,h,m,v,g){const p=o(u,d,h,m,v,g);h.transmission>0?r.push(p):h.transparent===!0?i.push(p):n.push(p)}function l(u,d,h,m,v,g){const p=o(u,d,h,m,v,g);h.transmission>0?r.unshift(p):h.transparent===!0?i.unshift(p):n.unshift(p)}function c(u,d){n.length>1&&n.sort(u||Z4),r.length>1&&r.sort(d||wS),i.length>1&&i.sort(d||wS)}function f(){for(let u=e,d=t.length;u<d;u++){const h=t[u];if(h.id===null)break;h.id=null,h.object=null,h.geometry=null,h.material=null,h.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:a,unshift:l,finish:f,sort:c}}function Q4(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new SS,t.set(r,[o])):i>=s.length?(o=new SS,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function J4(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new k,color:new Pe};break;case"SpotLight":n={position:new k,direction:new k,color:new Pe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new k,color:new Pe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new k,skyColor:new Pe,groundColor:new Pe};break;case"RectAreaLight":n={color:new Pe,position:new k,halfWidth:new k,halfHeight:new k};break}return t[e.id]=n,n}}}function eH(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let tH=0;function nH(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function rH(t){const e=new J4,n=eH(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)r.probe.push(new k);const i=new k,s=new Ce,o=new Ce;function a(c){let f=0,u=0,d=0;for(let A=0;A<9;A++)r.probe[A].set(0,0,0);let h=0,m=0,v=0,g=0,p=0,x=0,_=0,w=0,M=0,T=0,b=0;c.sort(nH);for(let A=0,E=c.length;A<E;A++){const N=c[A],F=N.color,I=N.intensity,U=N.distance,z=N.shadow&&N.shadow.map?N.shadow.map.texture:null;if(N.isAmbientLight)f+=F.r*I,u+=F.g*I,d+=F.b*I;else if(N.isLightProbe){for(let O=0;O<9;O++)r.probe[O].addScaledVector(N.sh.coefficients[O],I);b++}else if(N.isDirectionalLight){const O=e.get(N);if(O.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){const j=N.shadow,D=n.get(N);D.shadowIntensity=j.intensity,D.shadowBias=j.bias,D.shadowNormalBias=j.normalBias,D.shadowRadius=j.radius,D.shadowMapSize=j.mapSize,r.directionalShadow[h]=D,r.directionalShadowMap[h]=z,r.directionalShadowMatrix[h]=N.shadow.matrix,x++}r.directional[h]=O,h++}else if(N.isSpotLight){const O=e.get(N);O.position.setFromMatrixPosition(N.matrixWorld),O.color.copy(F).multiplyScalar(I),O.distance=U,O.coneCos=Math.cos(N.angle),O.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),O.decay=N.decay,r.spot[v]=O;const j=N.shadow;if(N.map&&(r.spotLightMap[M]=N.map,M++,j.updateMatrices(N),N.castShadow&&T++),r.spotLightMatrix[v]=j.matrix,N.castShadow){const D=n.get(N);D.shadowIntensity=j.intensity,D.shadowBias=j.bias,D.shadowNormalBias=j.normalBias,D.shadowRadius=j.radius,D.shadowMapSize=j.mapSize,r.spotShadow[v]=D,r.spotShadowMap[v]=z,w++}v++}else if(N.isRectAreaLight){const O=e.get(N);O.color.copy(F).multiplyScalar(I),O.halfWidth.set(N.width*.5,0,0),O.halfHeight.set(0,N.height*.5,0),r.rectArea[g]=O,g++}else if(N.isPointLight){const O=e.get(N);if(O.color.copy(N.color).multiplyScalar(N.intensity),O.distance=N.distance,O.decay=N.decay,N.castShadow){const j=N.shadow,D=n.get(N);D.shadowIntensity=j.intensity,D.shadowBias=j.bias,D.shadowNormalBias=j.normalBias,D.shadowRadius=j.radius,D.shadowMapSize=j.mapSize,D.shadowCameraNear=j.camera.near,D.shadowCameraFar=j.camera.far,r.pointShadow[m]=D,r.pointShadowMap[m]=z,r.pointShadowMatrix[m]=N.shadow.matrix,_++}r.point[m]=O,m++}else if(N.isHemisphereLight){const O=e.get(N);O.skyColor.copy(N.color).multiplyScalar(I),O.groundColor.copy(N.groundColor).multiplyScalar(I),r.hemi[p]=O,p++}}g>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=me.LTC_FLOAT_1,r.rectAreaLTC2=me.LTC_FLOAT_2):(r.rectAreaLTC1=me.LTC_HALF_1,r.rectAreaLTC2=me.LTC_HALF_2)),r.ambient[0]=f,r.ambient[1]=u,r.ambient[2]=d;const C=r.hash;(C.directionalLength!==h||C.pointLength!==m||C.spotLength!==v||C.rectAreaLength!==g||C.hemiLength!==p||C.numDirectionalShadows!==x||C.numPointShadows!==_||C.numSpotShadows!==w||C.numSpotMaps!==M||C.numLightProbes!==b)&&(r.directional.length=h,r.spot.length=v,r.rectArea.length=g,r.point.length=m,r.hemi.length=p,r.directionalShadow.length=x,r.directionalShadowMap.length=x,r.pointShadow.length=_,r.pointShadowMap.length=_,r.spotShadow.length=w,r.spotShadowMap.length=w,r.directionalShadowMatrix.length=x,r.pointShadowMatrix.length=_,r.spotLightMatrix.length=w+M-T,r.spotLightMap.length=M,r.numSpotLightShadowsWithMaps=T,r.numLightProbes=b,C.directionalLength=h,C.pointLength=m,C.spotLength=v,C.rectAreaLength=g,C.hemiLength=p,C.numDirectionalShadows=x,C.numPointShadows=_,C.numSpotShadows=w,C.numSpotMaps=M,C.numLightProbes=b,r.version=tH++)}function l(c,f){let u=0,d=0,h=0,m=0,v=0;const g=f.matrixWorldInverse;for(let p=0,x=c.length;p<x;p++){const _=c[p];if(_.isDirectionalLight){const w=r.directional[u];w.direction.setFromMatrixPosition(_.matrixWorld),i.setFromMatrixPosition(_.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(g),u++}else if(_.isSpotLight){const w=r.spot[h];w.position.setFromMatrixPosition(_.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(_.matrixWorld),i.setFromMatrixPosition(_.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(g),h++}else if(_.isRectAreaLight){const w=r.rectArea[m];w.position.setFromMatrixPosition(_.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(_.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(_.width*.5,0,0),w.halfHeight.set(0,_.height*.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),m++}else if(_.isPointLight){const w=r.point[d];w.position.setFromMatrixPosition(_.matrixWorld),w.position.applyMatrix4(g),d++}else if(_.isHemisphereLight){const w=r.hemi[v];w.direction.setFromMatrixPosition(_.matrixWorld),w.direction.transformDirection(g),v++}}}return{setup:a,setupView:l,state:r}}function MS(t){const e=new rH(t),n=[],r=[];function i(f){c.camera=f,n.length=0,r.length=0}function s(f){n.push(f)}function o(f){r.push(f)}function a(){e.setup(n)}function l(f){e.setupView(n,f)}const c={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function iH(t){let e=new WeakMap;function n(i,s=0){const o=e.get(i);let a;return o===void 0?(a=new MS(t),e.set(i,[a])):s>=o.length?(a=new MS(t),o.push(a)):a=o[s],a}function r(){e=new WeakMap}return{get:n,dispose:r}}class sH extends Nr{static get type(){return"MeshDepthMaterial"}constructor(e){super(),this.isMeshDepthMaterial=!0,this.depthPacking=zO,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 oH extends Nr{static get type(){return"MeshDistanceMaterial"}constructor(e){super(),this.isMeshDistanceMaterial=!0,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}}const aH=`void main() {
gl_Position = vec4( position, 1.0 );
}`,lH=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
const float samples = float( VSM_SAMPLES );
float mean = 0.0;
float squared_mean = 0.0;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
for ( float i = 0.0; i < samples; i ++ ) {
float uvOffset = uvStart + i * uvStride;
#ifdef HORIZONTAL_PASS
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( squared_mean - mean * mean );
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function cH(t,e,n){let r=new Qy;const i=new ze,s=new ze,o=new ut,a=new sH({depthPacking:HO}),l=new oH,c={},f=n.maxTextureSize,u={[ns]:tr,[tr]:ns,[pi]:pi},d=new eo({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ze},radius:{value:4}},vertexShader:aH,fragmentShader:lH}),h=d.clone();h.defines.HORIZONTAL_PASS=1;const m=new Wt;m.setAttribute("position",new hn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new je(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=jT;let p=this.type;this.render=function(T,b,C){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;const A=t.getRenderTarget(),E=t.getActiveCubeFace(),N=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Gs),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const I=p!==Fi&&this.type===Fi,U=p===Fi&&this.type!==Fi;for(let z=0,O=T.length;z<O;z++){const j=T[z],D=j.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",j,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;i.copy(D.mapSize);const V=D.getFrameExtents();if(i.multiply(V),s.copy(D.mapSize),(i.x>f||i.y>f)&&(i.x>f&&(s.x=Math.floor(f/V.x),i.x=s.x*V.x,D.mapSize.x=s.x),i.y>f&&(s.y=Math.floor(f/V.y),i.y=s.y*V.y,D.mapSize.y=s.y)),D.map===null||I===!0||U===!0){const J=this.type!==Fi?{minFilter:Hn,magFilter:Hn}:{};D.map!==null&&D.map.dispose(),D.map=new Wo(i.x,i.y,J),D.map.texture.name=j.name+".shadowMap",D.camera.updateProjectionMatrix()}t.setRenderTarget(D.map),t.clear();const Q=D.getViewportCount();for(let J=0;J<Q;J++){const le=D.getViewport(J);o.set(s.x*le.x,s.y*le.y,s.x*le.z,s.y*le.w),F.viewport(o),D.updateMatrices(j,J),r=D.getFrustum(),w(b,C,D.camera,j,this.type)}D.isPointLightShadow!==!0&&this.type===Fi&&x(D,C),D.needsUpdate=!1}p=this.type,g.needsUpdate=!1,t.setRenderTarget(A,E,N)};function x(T,b){const C=e.update(v);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,h.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,h.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Wo(i.x,i.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(b,null,C,d,v,null),h.uniforms.shadow_pass.value=T.mapPass.texture,h.uniforms.resolution.value=T.mapSize,h.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(b,null,C,h,v,null)}function _(T,b,C,A){let E=null;const N=C.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(N!==void 0)E=N;else if(E=C.isPointLight===!0?l:a,t.localClippingEnabled&&b.clipShadows===!0&&Array.isArray(b.clippingPlanes)&&b.clippingPlanes.length!==0||b.displacementMap&&b.displacementScale!==0||b.alphaMap&&b.alphaTest>0||b.map&&b.alphaTest>0){const F=E.uuid,I=b.uuid;let U=c[F];U===void 0&&(U={},c[F]=U);let z=U[I];z===void 0&&(z=E.clone(),U[I]=z,b.addEventListener("dispose",M)),E=z}if(E.visible=b.visible,E.wireframe=b.wireframe,A===Fi?E.side=b.shadowSide!==null?b.shadowSide:b.side:E.side=b.shadowSide!==null?b.shadowSide:u[b.side],E.alphaMap=b.alphaMap,E.alphaTest=b.alphaTest,E.map=b.map,E.clipShadows=b.clipShadows,E.clippingPlanes=b.clippingPlanes,E.clipIntersection=b.clipIntersection,E.displacementMap=b.displacementMap,E.displacementScale=b.displacementScale,E.displacementBias=b.displacementBias,E.wireframeLinewidth=b.wireframeLinewidth,E.linewidth=b.linewidth,C.isPointLight===!0&&E.isMeshDistanceMaterial===!0){const F=t.properties.get(E);F.light=C}return E}function w(T,b,C,A,E){if(T.visible===!1)return;if(T.layers.test(b.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&E===Fi)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,T.matrixWorld);const I=e.update(T),U=T.material;if(Array.isArray(U)){const z=I.groups;for(let O=0,j=z.length;O<j;O++){const D=z[O],V=U[D.materialIndex];if(V&&V.visible){const Q=_(T,V,A,E);T.onBeforeShadow(t,T,b,C,I,Q,D),t.renderBufferDirect(C,null,I,Q,T,D),T.onAfterShadow(t,T,b,C,I,Q,D)}}}else if(U.visible){const z=_(T,U,A,E);T.onBeforeShadow(t,T,b,C,I,z,null),t.renderBufferDirect(C,null,I,z,T,null),T.onAfterShadow(t,T,b,C,I,z,null)}}const F=T.children;for(let I=0,U=F.length;I<U;I++)w(F[I],b,C,A,E)}function M(T){T.target.removeEventListener("dispose",M);for(const C in c){const A=c[C],E=T.target.uuid;E in A&&(A[E].dispose(),delete A[E])}}}const uH={[nv]:rv,[iv]:av,[sv]:lv,[Ml]:ov,[rv]:nv,[av]:iv,[lv]:sv,[ov]:Ml};function dH(t,e){function n(){let B=!1;const ae=new ut;let q=null;const te=new ut(0,0,0,0);return{setMask:function(ve){q!==ve&&!B&&(t.colorMask(ve,ve,ve,ve),q=ve)},setLocked:function(ve){B=ve},setClear:function(ve,xe,Je,Ht,wn){wn===!0&&(ve*=Ht,xe*=Ht,Je*=Ht),ae.set(ve,xe,Je,Ht),te.equals(ae)===!1&&(t.clearColor(ve,xe,Je,Ht),te.copy(ae))},reset:function(){B=!1,q=null,te.set(-1,0,0,0)}}}function r(){let B=!1,ae=!1,q=null,te=null,ve=null;return{setReversed:function(xe){if(ae!==xe){const Je=e.get("EXT_clip_control");ae?Je.clipControlEXT(Je.LOWER_LEFT_EXT,Je.ZERO_TO_ONE_EXT):Je.clipControlEXT(Je.LOWER_LEFT_EXT,Je.NEGATIVE_ONE_TO_ONE_EXT);const Ht=ve;ve=null,this.setClear(Ht)}ae=xe},getReversed:function(){return ae},setTest:function(xe){xe?Z(t.DEPTH_TEST):ue(t.DEPTH_TEST)},setMask:function(xe){q!==xe&&!B&&(t.depthMask(xe),q=xe)},setFunc:function(xe){if(ae&&(xe=uH[xe]),te!==xe){switch(xe){case nv:t.depthFunc(t.NEVER);break;case rv:t.depthFunc(t.ALWAYS);break;case iv:t.depthFunc(t.LESS);break;case Ml:t.depthFunc(t.LEQUAL);break;case sv:t.depthFunc(t.EQUAL);break;case ov:t.depthFunc(t.GEQUAL);break;case av:t.depthFunc(t.GREATER);break;case lv:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}te=xe}},setLocked:function(xe){B=xe},setClear:function(xe){ve!==xe&&(ae&&(xe=1-xe),t.clearDepth(xe),ve=xe)},reset:function(){B=!1,q=null,te=null,ve=null,ae=!1}}}function i(){let B=!1,ae=null,q=null,te=null,ve=null,xe=null,Je=null,Ht=null,wn=null;return{setTest:function(_t){B||(_t?Z(t.STENCIL_TEST):ue(t.STENCIL_TEST))},setMask:function(_t){ae!==_t&&!B&&(t.stencilMask(_t),ae=_t)},setFunc:function(_t,kr,Ai){(q!==_t||te!==kr||ve!==Ai)&&(t.stencilFunc(_t,kr,Ai),q=_t,te=kr,ve=Ai)},setOp:function(_t,kr,Ai){(xe!==_t||Je!==kr||Ht!==Ai)&&(t.stencilOp(_t,kr,Ai),xe=_t,Je=kr,Ht=Ai)},setLocked:function(_t){B=_t},setClear:function(_t){wn!==_t&&(t.clearStencil(_t),wn=_t)},reset:function(){B=!1,ae=null,q=null,te=null,ve=null,xe=null,Je=null,Ht=null,wn=null}}}const s=new n,o=new r,a=new i,l=new WeakMap,c=new WeakMap;let f={},u={},d=new WeakMap,h=[],m=null,v=!1,g=null,p=null,x=null,_=null,w=null,M=null,T=null,b=new Pe(0,0,0),C=0,A=!1,E=null,N=null,F=null,I=null,U=null;const z=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let O=!1,j=0;const D=t.getParameter(t.VERSION);D.indexOf("WebGL")!==-1?(j=parseFloat(/^WebGL (\d)/.exec(D)[1]),O=j>=1):D.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),O=j>=2);let V=null,Q={};const J=t.getParameter(t.SCISSOR_BOX),le=t.getParameter(t.VIEWPORT),pe=new ut().fromArray(J),$=new ut().fromArray(le);function ee(B,ae,q,te){const ve=new Uint8Array(4),xe=t.createTexture();t.bindTexture(B,xe),t.texParameteri(B,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(B,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Je=0;Je<q;Je++)B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY?t.texImage3D(ae,0,t.RGBA,1,1,te,0,t.RGBA,t.UNSIGNED_BYTE,ve):t.texImage2D(ae+Je,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ve);return xe}const se={};se[t.TEXTURE_2D]=ee(t.TEXTURE_2D,t.TEXTURE_2D,1),se[t.TEXTURE_CUBE_MAP]=ee(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),se[t.TEXTURE_2D_ARRAY]=ee(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),se[t.TEXTURE_3D]=ee(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),Z(t.DEPTH_TEST),o.setFunc(Ml),Ve(!1),qe(Mw),Z(t.CULL_FACE),H(Gs);function Z(B){f[B]!==!0&&(t.enable(B),f[B]=!0)}function ue(B){f[B]!==!1&&(t.disable(B),f[B]=!1)}function Me(B,ae){return u[B]!==ae?(t.bindFramebuffer(B,ae),u[B]=ae,B===t.DRAW_FRAMEBUFFER&&(u[t.FRAMEBUFFER]=ae),B===t.FRAMEBUFFER&&(u[t.DRAW_FRAMEBUFFER]=ae),!0):!1}function ye(B,ae){let q=h,te=!1;if(B){q=d.get(ae),q===void 0&&(q=[],d.set(ae,q));const ve=B.textures;if(q.length!==ve.length||q[0]!==t.COLOR_ATTACHMENT0){for(let xe=0,Je=ve.length;xe<Je;xe++)q[xe]=t.COLOR_ATTACHMENT0+xe;q.length=ve.length,te=!0}}else q[0]!==t.BACK&&(q[0]=t.BACK,te=!0);te&&t.drawBuffers(q)}function ke(B){return m!==B?(t.useProgram(B),m=B,!0):!1}const Se={[So]:t.FUNC_ADD,[fO]:t.FUNC_SUBTRACT,[hO]:t.FUNC_REVERSE_SUBTRACT};Se[pO]=t.MIN,Se[mO]=t.MAX;const nt={[gO]:t.ZERO,[vO]:t.ONE,[yO]:t.SRC_COLOR,[ev]:t.SRC_ALPHA,[bO]:t.SRC_ALPHA_SATURATE,[SO]:t.DST_COLOR,[_O]:t.DST_ALPHA,[xO]:t.ONE_MINUS_SRC_COLOR,[tv]:t.ONE_MINUS_SRC_ALPHA,[MO]:t.ONE_MINUS_DST_COLOR,[wO]:t.ONE_MINUS_DST_ALPHA,[EO]:t.CONSTANT_COLOR,[TO]:t.ONE_MINUS_CONSTANT_COLOR,[AO]:t.CONSTANT_ALPHA,[CO]:t.ONE_MINUS_CONSTANT_ALPHA};function H(B,ae,q,te,ve,xe,Je,Ht,wn,_t){if(B===Gs){v===!0&&(ue(t.BLEND),v=!1);return}if(v===!1&&(Z(t.BLEND),v=!0),B!==dO){if(B!==g||_t!==A){if((p!==So||w!==So)&&(t.blendEquation(t.FUNC_ADD),p=So,w=So),_t)switch(B){case qa:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case bw:t.blendFunc(t.ONE,t.ONE);break;case Ew:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case Tw:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}else switch(B){case qa:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case bw:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case Ew:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case Tw:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}x=null,_=null,M=null,T=null,b.set(0,0,0),C=0,g=B,A=_t}return}ve=ve||ae,xe=xe||q,Je=Je||te,(ae!==p||ve!==w)&&(t.blendEquationSeparate(Se[ae],Se[ve]),p=ae,w=ve),(q!==x||te!==_||xe!==M||Je!==T)&&(t.blendFuncSeparate(nt[q],nt[te],nt[xe],nt[Je]),x=q,_=te,M=xe,T=Je),(Ht.equals(b)===!1||wn!==C)&&(t.blendColor(Ht.r,Ht.g,Ht.b,wn),b.copy(Ht),C=wn),g=B,A=!1}function Xt(B,ae){B.side===pi?ue(t.CULL_FACE):Z(t.CULL_FACE);let q=B.side===tr;ae&&(q=!q),Ve(q),B.blending===qa&&B.transparent===!1?H(Gs):H(B.blending,B.blendEquation,B.blendSrc,B.blendDst,B.blendEquationAlpha,B.blendSrcAlpha,B.blendDstAlpha,B.blendColor,B.blendAlpha,B.premultipliedAlpha),o.setFunc(B.depthFunc),o.setTest(B.depthTest),o.setMask(B.depthWrite),s.setMask(B.colorWrite);const te=B.stencilWrite;a.setTest(te),te&&(a.setMask(B.stencilWriteMask),a.setFunc(B.stencilFunc,B.stencilRef,B.stencilFuncMask),a.setOp(B.stencilFail,B.stencilZFail,B.stencilZPass)),Ye(B.polygonOffset,B.polygonOffsetFactor,B.polygonOffsetUnits),B.alphaToCoverage===!0?Z(t.SAMPLE_ALPHA_TO_COVERAGE):ue(t.SAMPLE_ALPHA_TO_COVERAGE)}function Ve(B){E!==B&&(B?t.frontFace(t.CW):t.frontFace(t.CCW),E=B)}function qe(B){B!==lO?(Z(t.CULL_FACE),B!==N&&(B===Mw?t.cullFace(t.BACK):B===cO?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ue(t.CULL_FACE),N=B}function Ue(B){B!==F&&(O&&t.lineWidth(B),F=B)}function Ye(B,ae,q){B?(Z(t.POLYGON_OFFSET_FILL),(I!==ae||U!==q)&&(t.polygonOffset(ae,q),I=ae,U=q)):ue(t.POLYGON_OFFSET_FILL)}function Oe(B){B?Z(t.SCISSOR_TEST):ue(t.SCISSOR_TEST)}function L(B){B===void 0&&(B=t.TEXTURE0+z-1),V!==B&&(t.activeTexture(B),V=B)}function R(B,ae,q){q===void 0&&(V===null?q=t.TEXTURE0+z-1:q=V);let te=Q[q];te===void 0&&(te={type:void 0,texture:void 0},Q[q]=te),(te.type!==B||te.texture!==ae)&&(V!==q&&(t.activeTexture(q),V=q),t.bindTexture(B,ae||se[B]),te.type=B,te.texture=ae)}function X(){const B=Q[V];B!==void 0&&B.type!==void 0&&(t.bindTexture(B.type,null),B.type=void 0,B.texture=void 0)}function ie(){try{t.compressedTexImage2D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function oe(){try{t.compressedTexImage3D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ne(){try{t.texSubImage2D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Re(){try{t.texSubImage3D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ge(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function _e(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ct(){try{t.texStorage2D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function de(){try{t.texStorage3D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Te(){try{t.texImage2D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Be(){try{t.texImage3D.apply(t,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Ge(B){pe.equals(B)===!1&&(t.scissor(B.x,B.y,B.z,B.w),pe.copy(B))}function Ee(B){$.equals(B)===!1&&(t.viewport(B.x,B.y,B.z,B.w),$.copy(B))}function Ke(B,ae){let q=c.get(ae);q===void 0&&(q=new WeakMap,c.set(ae,q));let te=q.get(B);te===void 0&&(te=t.getUniformBlockIndex(ae,B.name),q.set(B,te))}function Ze(B,ae){const te=c.get(ae).get(B);l.get(ae)!==te&&(t.uniformBlockBinding(ae,te,B.__bindingPointIndex),l.set(ae,te))}function be(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),o.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),f={},V=null,Q={},u={},d=new WeakMap,h=[],m=null,v=!1,g=null,p=null,x=null,_=null,w=null,M=null,T=null,b=new Pe(0,0,0),C=0,A=!1,E=null,N=null,F=null,I=null,U=null,pe.set(0,0,t.canvas.width,t.canvas.height),$.set(0,0,t.canvas.width,t.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:Z,disable:ue,bindFramebuffer:Me,drawBuffers:ye,useProgram:ke,setBlending:H,setMaterial:Xt,setFlipSided:Ve,setCullFace:qe,setLineWidth:Ue,setPolygonOffset:Ye,setScissorTest:Oe,activeTexture:L,bindTexture:R,unbindTexture:X,compressedTexImage2D:ie,compressedTexImage3D:oe,texImage2D:Te,texImage3D:Be,updateUBOMapping:Ke,uniformBlockBinding:Ze,texStorage2D:ct,texStorage3D:de,texSubImage2D:ne,texSubImage3D:Re,compressedTexSubImage2D:ge,compressedTexSubImage3D:_e,scissor:Ge,viewport:Ee,reset:be}}function bS(t,e,n,r){const i=fH(r);switch(n){case YT:return t*e;case qT:return t*e;case ZT:return t*e*2;case Wy:return t*e/i.components*i.byteLength;case Xy:return t*e/i.components*i.byteLength;case QT:return t*e*2/i.components*i.byteLength;case $y:return t*e*2/i.components*i.byteLength;case KT:return t*e*3/i.components*i.byteLength;case Cr:return t*e*4/i.components*i.byteLength;case Yy:return t*e*4/i.components*i.byteLength;case af:case lf:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case cf:case uf:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case dv:case hv:return Math.max(t,16)*Math.max(e,8)/4;case uv:case fv:return Math.max(t,8)*Math.max(e,8)/2;case pv:case mv:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case gv:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case vv:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case yv:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case xv:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case _v:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case wv:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case Sv:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case Mv:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case bv:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Ev:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case Tv:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case Av:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case Cv:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case Rv:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case Pv:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case df:case Nv:case Dv:return Math.ceil(t/4)*Math.ceil(e/4)*16;case JT:case Lv:return Math.ceil(t/4)*Math.ceil(e/4)*8;case Iv:case kv:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function fH(t){switch(t){case rs:case WT:return{byteLength:1,components:1};case su:case XT:case Tu:return{byteLength:2,components:1};case Vy:case Gy:return{byteLength:2,components:4};case Go:case jy:case qr:return{byteLength:4,components:1};case $T:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}function hH(t,e,n,r,i,s,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ze,f=new WeakMap;let u;const d=new WeakMap;let h=!1;try{h=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(L,R){return h?new OffscreenCanvas(L,R):lu("canvas")}function v(L,R,X){let ie=1;const oe=Oe(L);if((oe.width>X||oe.height>X)&&(ie=X/Math.max(oe.width,oe.height)),ie<1)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap||typeof VideoFrame<"u"&&L instanceof VideoFrame){const ne=Math.floor(ie*oe.width),Re=Math.floor(ie*oe.height);u===void 0&&(u=m(ne,Re));const ge=R?m(ne,Re):u;return ge.width=ne,ge.height=Re,ge.getContext("2d").drawImage(L,0,0,ne,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+oe.width+"x"+oe.height+") to ("+ne+"x"+Re+")."),ge}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+oe.width+"x"+oe.height+")."),L;return L}function g(L){return L.generateMipmaps}function p(L){t.generateMipmap(L)}function x(L){return L.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:L.isWebGL3DRenderTarget?t.TEXTURE_3D:L.isWebGLArrayRenderTarget||L.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function _(L,R,X,ie,oe=!1){if(L!==null){if(t[L]!==void 0)return t[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let ne=R;if(R===t.RED&&(X===t.FLOAT&&(ne=t.R32F),X===t.HALF_FLOAT&&(ne=t.R16F),X===t.UNSIGNED_BYTE&&(ne=t.R8)),R===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(ne=t.R8UI),X===t.UNSIGNED_SHORT&&(ne=t.R16UI),X===t.UNSIGNED_INT&&(ne=t.R32UI),X===t.BYTE&&(ne=t.R8I),X===t.SHORT&&(ne=t.R16I),X===t.INT&&(ne=t.R32I)),R===t.RG&&(X===t.FLOAT&&(ne=t.RG32F),X===t.HALF_FLOAT&&(ne=t.RG16F),X===t.UNSIGNED_BYTE&&(ne=t.RG8)),R===t.RG_INTEGER&&(X===t.UNSIGNED_BYTE&&(ne=t.RG8UI),X===t.UNSIGNED_SHORT&&(ne=t.RG16UI),X===t.UNSIGNED_INT&&(ne=t.RG32UI),X===t.BYTE&&(ne=t.RG8I),X===t.SHORT&&(ne=t.RG16I),X===t.INT&&(ne=t.RG32I)),R===t.RGB_INTEGER&&(X===t.UNSIGNED_BYTE&&(ne=t.RGB8UI),X===t.UNSIGNED_SHORT&&(ne=t.RGB16UI),X===t.UNSIGNED_INT&&(ne=t.RGB32UI),X===t.BYTE&&(ne=t.RGB8I),X===t.SHORT&&(ne=t.RGB16I),X===t.INT&&(ne=t.RGB32I)),R===t.RGBA_INTEGER&&(X===t.UNSIGNED_BYTE&&(ne=t.RGBA8UI),X===t.UNSIGNED_SHORT&&(ne=t.RGBA16UI),X===t.UNSIGNED_INT&&(ne=t.RGBA32UI),X===t.BYTE&&(ne=t.RGBA8I),X===t.SHORT&&(ne=t.RGBA16I),X===t.INT&&(ne=t.RGBA32I)),R===t.RGB&&X===t.UNSIGNED_INT_5_9_9_9_REV&&(ne=t.RGB9_E5),R===t.RGBA){const Re=oe?Xh:$e.getTransfer(ie);X===t.FLOAT&&(ne=t.RGBA32F),X===t.HALF_FLOAT&&(ne=t.RGBA16F),X===t.UNSIGNED_BYTE&&(ne=Re===Mt?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(ne=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(ne=t.RGB5_A1)}return(ne===t.R16F||ne===t.R32F||ne===t.RG16F||ne===t.RG32F||ne===t.RGBA16F||ne===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ne}function w(L,R){let X;return L?R===null||R===Go||R===Tl?X=t.DEPTH24_STENCIL8:R===qr?X=t.DEPTH32F_STENCIL8:R===su&&(X=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):R===null||R===Go||R===Tl?X=t.DEPTH_COMPONENT24:R===qr?X=t.DEPTH_COMPONENT32F:R===su&&(X=t.DEPTH_COMPONENT16),X}function M(L,R){return g(L)===!0||L.isFramebufferTexture&&L.minFilter!==Hn&&L.minFilter!==hr?Math.log2(Math.max(R.width,R.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?R.mipmaps.length:1}function T(L){const R=L.target;R.removeEventListener("dispose",T),C(R),R.isVideoTexture&&f.delete(R)}function b(L){const R=L.target;R.removeEventListener("dispose",b),E(R)}function C(L){const R=r.get(L);if(R.__webglInit===void 0)return;const X=L.source,ie=d.get(X);if(ie){const oe=ie[R.__cacheKey];oe.usedTimes--,oe.usedTimes===0&&A(L),Object.keys(ie).length===0&&d.delete(X)}r.remove(L)}function A(L){const R=r.get(L);t.deleteTexture(R.__webglTexture);const X=L.source,ie=d.get(X);delete ie[R.__cacheKey],o.memory.textures--}function E(L){const R=r.get(L);if(L.depthTexture&&(L.depthTexture.dispose(),r.remove(L.depthTexture)),L.isWebGLCubeRenderTarget)for(let ie=0;ie<6;ie++){if(Array.isArray(R.__webglFramebuffer[ie]))for(let oe=0;oe<R.__webglFramebuffer[ie].length;oe++)t.deleteFramebuffer(R.__webglFramebuffer[ie][oe]);else t.deleteFramebuffer(R.__webglFramebuffer[ie]);R.__webglDepthbuffer&&t.deleteRenderbuffer(R.__webglDepthbuffer[ie])}else{if(Array.isArray(R.__webglFramebuffer))for(let ie=0;ie<R.__webglFramebuffer.length;ie++)t.deleteFramebuffer(R.__webglFramebuffer[ie]);else t.deleteFramebuffer(R.__webglFramebuffer);if(R.__webglDepthbuffer&&t.deleteRenderbuffer(R.__webglDepthbuffer),R.__webglMultisampledFramebuffer&&t.deleteFramebuffer(R.__webglMultisampledFramebuffer),R.__webglColorRenderbuffer)for(let ie=0;ie<R.__webglColorRenderbuffer.length;ie++)R.__webglColorRenderbuffer[ie]&&t.deleteRenderbuffer(R.__webglColorRenderbuffer[ie]);R.__webglDepthRenderbuffer&&t.deleteRenderbuffer(R.__webglDepthRenderbuffer)}const X=L.textures;for(let ie=0,oe=X.length;ie<oe;ie++){const ne=r.get(X[ie]);ne.__webglTexture&&(t.deleteTexture(ne.__webglTexture),o.memory.textures--),r.remove(X[ie])}r.remove(L)}let N=0;function F(){N=0}function I(){const L=N;return L>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+i.maxTextures),N+=1,L}function U(L){const R=[];return R.push(L.wrapS),R.push(L.wrapT),R.push(L.wrapR||0),R.push(L.magFilter),R.push(L.minFilter),R.push(L.anisotropy),R.push(L.internalFormat),R.push(L.format),R.push(L.type),R.push(L.generateMipmaps),R.push(L.premultiplyAlpha),R.push(L.flipY),R.push(L.unpackAlignment),R.push(L.colorSpace),R.join()}function z(L,R){const X=r.get(L);if(L.isVideoTexture&&Ue(L),L.isRenderTargetTexture===!1&&L.version>0&&X.__version!==L.version){const ie=L.image;if(ie===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ie.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{$(X,L,R);return}}n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+R)}function O(L,R){const X=r.get(L);if(L.version>0&&X.__version!==L.version){$(X,L,R);return}n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+R)}function j(L,R){const X=r.get(L);if(L.version>0&&X.__version!==L.version){$(X,L,R);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+R)}function D(L,R){const X=r.get(L);if(L.version>0&&X.__version!==L.version){ee(X,L,R);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+R)}const V={[Js]:t.REPEAT,[vi]:t.CLAMP_TO_EDGE,[Zf]:t.MIRRORED_REPEAT},Q={[Hn]:t.NEAREST,[GT]:t.NEAREST_MIPMAP_NEAREST,[_c]:t.NEAREST_MIPMAP_LINEAR,[hr]:t.LINEAR,[of]:t.LINEAR_MIPMAP_NEAREST,[Gi]:t.LINEAR_MIPMAP_LINEAR},J={[VO]:t.NEVER,[KO]:t.ALWAYS,[GO]:t.LESS,[tA]:t.LEQUAL,[WO]:t.EQUAL,[YO]:t.GEQUAL,[XO]:t.GREATER,[$O]:t.NOTEQUAL};function le(L,R){if(R.type===qr&&e.has("OES_texture_float_linear")===!1&&(R.magFilter===hr||R.magFilter===of||R.magFilter===_c||R.magFilter===Gi||R.minFilter===hr||R.minFilter===of||R.minFilter===_c||R.minFilter===Gi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(L,t.TEXTURE_WRAP_S,V[R.wrapS]),t.texParameteri(L,t.TEXTURE_WRAP_T,V[R.wrapT]),(L===t.TEXTURE_3D||L===t.TEXTURE_2D_ARRAY)&&t.texParameteri(L,t.TEXTURE_WRAP_R,V[R.wrapR]),t.texParameteri(L,t.TEXTURE_MAG_FILTER,Q[R.magFilter]),t.texParameteri(L,t.TEXTURE_MIN_FILTER,Q[R.minFilter]),R.compareFunction&&(t.texParameteri(L,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(L,t.TEXTURE_COMPARE_FUNC,J[R.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(R.magFilter===Hn||R.minFilter!==_c&&R.minFilter!==Gi||R.type===qr&&e.has("OES_texture_float_linear")===!1)return;if(R.anisotropy>1||r.get(R).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");t.texParameterf(L,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(R.anisotropy,i.getMaxAnisotropy())),r.get(R).__currentAnisotropy=R.anisotropy}}}function pe(L,R){let X=!1;L.__webglInit===void 0&&(L.__webglInit=!0,R.addEventListener("dispose",T));const ie=R.source;let oe=d.get(ie);oe===void 0&&(oe={},d.set(ie,oe));const ne=U(R);if(ne!==L.__cacheKey){oe[ne]===void 0&&(oe[ne]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,X=!0),oe[ne].usedTimes++;const Re=oe[L.__cacheKey];Re!==void 0&&(oe[L.__cacheKey].usedTimes--,Re.usedTimes===0&&A(R)),L.__cacheKey=ne,L.__webglTexture=oe[ne].texture}return X}function $(L,R,X){let ie=t.TEXTURE_2D;(R.isDataArrayTexture||R.isCompressedArrayTexture)&&(ie=t.TEXTURE_2D_ARRAY),R.isData3DTexture&&(ie=t.TEXTURE_3D);const oe=pe(L,R),ne=R.source;n.bindTexture(ie,L.__webglTexture,t.TEXTURE0+X);const Re=r.get(ne);if(ne.version!==Re.__version||oe===!0){n.activeTexture(t.TEXTURE0+X);const ge=$e.getPrimaries($e.workingColorSpace),_e=R.colorSpace===Ts?null:$e.getPrimaries(R.colorSpace),ct=R.colorSpace===Ts||ge===_e?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,R.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,R.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ct);let de=v(R.image,!1,i.maxTextureSize);de=Ye(R,de);const Te=s.convert(R.format,R.colorSpace),Be=s.convert(R.type);let Ge=_(R.internalFormat,Te,Be,R.colorSpace,R.isVideoTexture);le(ie,R);let Ee;const Ke=R.mipmaps,Ze=R.isVideoTexture!==!0,be=Re.__version===void 0||oe===!0,B=ne.dataReady,ae=M(R,de);if(R.isDepthTexture)Ge=w(R.format===Al,R.type),be&&(Ze?n.texStorage2D(t.TEXTURE_2D,1,Ge,de.width,de.height):n.texImage2D(t.TEXTURE_2D,0,Ge,de.width,de.height,0,Te,Be,null));else if(R.isDataTexture)if(Ke.length>0){Ze&&be&&n.texStorage2D(t.TEXTURE_2D,ae,Ge,Ke[0].width,Ke[0].height);for(let q=0,te=Ke.length;q<te;q++)Ee=Ke[q],Ze?B&&n.texSubImage2D(t.TEXTURE_2D,q,0,0,Ee.width,Ee.height,Te,Be,Ee.data):n.texImage2D(t.TEXTURE_2D,q,Ge,Ee.width,Ee.height,0,Te,Be,Ee.data);R.generateMipmaps=!1}else Ze?(be&&n.texStorage2D(t.TEXTURE_2D,ae,Ge,de.width,de.height),B&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,de.width,de.height,Te,Be,de.data)):n.texImage2D(t.TEXTURE_2D,0,Ge,de.width,de.height,0,Te,Be,de.data);else if(R.isCompressedTexture)if(R.isCompressedArrayTexture){Ze&&be&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ae,Ge,Ke[0].width,Ke[0].height,de.depth);for(let q=0,te=Ke.length;q<te;q++)if(Ee=Ke[q],R.format!==Cr)if(Te!==null)if(Ze){if(B)if(R.layerUpdates.size>0){const ve=bS(Ee.width,Ee.height,R.format,R.type);for(const xe of R.layerUpdates){const Je=Ee.data.subarray(xe*ve/Ee.data.BYTES_PER_ELEMENT,(xe+1)*ve/Ee.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,q,0,0,xe,Ee.width,Ee.height,1,Te,Je)}R.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,q,0,0,0,Ee.width,Ee.height,de.depth,Te,Ee.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,q,Ge,Ee.width,Ee.height,de.depth,0,Ee.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ze?B&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,q,0,0,0,Ee.width,Ee.height,de.depth,Te,Be,Ee.data):n.texImage3D(t.TEXTURE_2D_ARRAY,q,Ge,Ee.width,Ee.height,de.depth,0,Te,Be,Ee.data)}else{Ze&&be&&n.texStorage2D(t.TEXTURE_2D,ae,Ge,Ke[0].width,Ke[0].height);for(let q=0,te=Ke.length;q<te;q++)Ee=Ke[q],R.format!==Cr?Te!==null?Ze?B&&n.compressedTexSubImage2D(t.TEXTURE_2D,q,0,0,Ee.width,Ee.height,Te,Ee.data):n.compressedTexImage2D(t.TEXTURE_2D,q,Ge,Ee.width,Ee.height,0,Ee.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ze?B&&n.texSubImage2D(t.TEXTURE_2D,q,0,0,Ee.width,Ee.height,Te,Be,Ee.data):n.texImage2D(t.TEXTURE_2D,q,Ge,Ee.width,Ee.height,0,Te,Be,Ee.data)}else if(R.isDataArrayTexture)if(Ze){if(be&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ae,Ge,de.width,de.height,de.depth),B)if(R.layerUpdates.size>0){const q=bS(de.width,de.height,R.format,R.type);for(const te of R.layerUpdates){const ve=de.data.subarray(te*q/de.data.BYTES_PER_ELEMENT,(te+1)*q/de.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,te,de.width,de.height,1,Te,Be,ve)}R.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,de.width,de.height,de.depth,Te,Be,de.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ge,de.width,de.height,de.depth,0,Te,Be,de.data);else if(R.isData3DTexture)Ze?(be&&n.texStorage3D(t.TEXTURE_3D,ae,Ge,de.width,de.height,de.depth),B&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,de.width,de.height,de.depth,Te,Be,de.data)):n.texImage3D(t.TEXTURE_3D,0,Ge,de.width,de.height,de.depth,0,Te,Be,de.data);else if(R.isFramebufferTexture){if(be)if(Ze)n.texStorage2D(t.TEXTURE_2D,ae,Ge,de.width,de.height);else{let q=de.width,te=de.height;for(let ve=0;ve<ae;ve++)n.texImage2D(t.TEXTURE_2D,ve,Ge,q,te,0,Te,Be,null),q>>=1,te>>=1}}else if(Ke.length>0){if(Ze&&be){const q=Oe(Ke[0]);n.texStorage2D(t.TEXTURE_2D,ae,Ge,q.width,q.height)}for(let q=0,te=Ke.length;q<te;q++)Ee=Ke[q],Ze?B&&n.texSubImage2D(t.TEXTURE_2D,q,0,0,Te,Be,Ee):n.texImage2D(t.TEXTURE_2D,q,Ge,Te,Be,Ee);R.generateMipmaps=!1}else if(Ze){if(be){const q=Oe(de);n.texStorage2D(t.TEXTURE_2D,ae,Ge,q.width,q.height)}B&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,Te,Be,de)}else n.texImage2D(t.TEXTURE_2D,0,Ge,Te,Be,de);g(R)&&p(ie),Re.__version=ne.version,R.onUpdate&&R.onUpdate(R)}L.__version=R.version}function ee(L,R,X){if(R.image.length!==6)return;const ie=pe(L,R),oe=R.source;n.bindTexture(t.TEXTURE_CUBE_MAP,L.__webglTexture,t.TEXTURE0+X);const ne=r.get(oe);if(oe.version!==ne.__version||ie===!0){n.activeTexture(t.TEXTURE0+X);const Re=$e.getPrimaries($e.workingColorSpace),ge=R.colorSpace===Ts?null:$e.getPrimaries(R.colorSpace),_e=R.colorSpace===Ts||Re===ge?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,R.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,R.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,_e);const ct=R.isCompressedTexture||R.image[0].isCompressedTexture,de=R.image[0]&&R.image[0].isDataTexture,Te=[];for(let te=0;te<6;te++)!ct&&!de?Te[te]=v(R.image[te],!0,i.maxCubemapSize):Te[te]=de?R.image[te].image:R.image[te],Te[te]=Ye(R,Te[te]);const Be=Te[0],Ge=s.convert(R.format,R.colorSpace),Ee=s.convert(R.type),Ke=_(R.internalFormat,Ge,Ee,R.colorSpace),Ze=R.isVideoTexture!==!0,be=ne.__version===void 0||ie===!0,B=oe.dataReady;let ae=M(R,Be);le(t.TEXTURE_CUBE_MAP,R);let q;if(ct){Ze&&be&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ae,Ke,Be.width,Be.height);for(let te=0;te<6;te++){q=Te[te].mipmaps;for(let ve=0;ve<q.length;ve++){const xe=q[ve];R.format!==Cr?Ge!==null?Ze?B&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,ve,0,0,xe.width,xe.height,Ge,xe.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,ve,Ke,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ze?B&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,ve,0,0,xe.width,xe.height,Ge,Ee,xe.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,ve,Ke,xe.width,xe.height,0,Ge,Ee,xe.data)}}}else{if(q=R.mipmaps,Ze&&be){q.length>0&&ae++;const te=Oe(Te[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,ae,Ke,te.width,te.height)}for(let te=0;te<6;te++)if(de){Ze?B&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Te[te].width,Te[te].height,Ge,Ee,Te[te].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Ke,Te[te].width,Te[te].height,0,Ge,Ee,Te[te].data);for(let ve=0;ve<q.length;ve++){const Je=q[ve].image[te].image;Ze?B&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,ve+1,0,0,Je.width,Je.height,Ge,Ee,Je.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,ve+1,Ke,Je.width,Je.height,0,Ge,Ee,Je.data)}}else{Ze?B&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Ge,Ee,Te[te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Ke,Ge,Ee,Te[te]);for(let ve=0;ve<q.length;ve++){const xe=q[ve];Ze?B&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,ve+1,0,0,Ge,Ee,xe.image[te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,ve+1,Ke,Ge,Ee,xe.image[te])}}}g(R)&&p(t.TEXTURE_CUBE_MAP),ne.__version=oe.version,R.onUpdate&&R.onUpdate(R)}L.__version=R.version}function se(L,R,X,ie,oe,ne){const Re=s.convert(X.format,X.colorSpace),ge=s.convert(X.type),_e=_(X.internalFormat,Re,ge,X.colorSpace),ct=r.get(R),de=r.get(X);if(de.__renderTarget=R,!ct.__hasExternalTextures){const Te=Math.max(1,R.width>>ne),Be=Math.max(1,R.height>>ne);oe===t.TEXTURE_3D||oe===t.TEXTURE_2D_ARRAY?n.texImage3D(oe,ne,_e,Te,Be,R.depth,0,Re,ge,null):n.texImage2D(oe,ne,_e,Te,Be,0,Re,ge,null)}n.bindFramebuffer(t.FRAMEBUFFER,L),qe(R)?a.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ie,oe,de.__webglTexture,0,Ve(R)):(oe===t.TEXTURE_2D||oe>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&oe<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ie,oe,de.__webglTexture,ne),n.bindFramebuffer(t.FRAMEBUFFER,null)}function Z(L,R,X){if(t.bindRenderbuffer(t.RENDERBUFFER,L),R.depthBuffer){const ie=R.depthTexture,oe=ie&&ie.isDepthTexture?ie.type:null,ne=w(R.stencilBuffer,oe),Re=R.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=Ve(R);qe(R)?a.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,ne,R.width,R.height):X?t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,ne,R.width,R.height):t.renderbufferStorage(t.RENDERBUFFER,ne,R.width,R.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Re,t.RENDERBUFFER,L)}else{const ie=R.textures;for(let oe=0;oe<ie.length;oe++){const ne=ie[oe],Re=s.convert(ne.format,ne.colorSpace),ge=s.convert(ne.type),_e=_(ne.internalFormat,Re,ge,ne.colorSpace),ct=Ve(R);X&&qe(R)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ct,_e,R.width,R.height):qe(R)?a.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ct,_e,R.width,R.height):t.renderbufferStorage(t.RENDERBUFFER,_e,R.width,R.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ue(L,R){if(R&&R.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,L),!(R.depthTexture&&R.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ie=r.get(R.depthTexture);ie.__renderTarget=R,(!ie.__webglTexture||R.depthTexture.image.width!==R.width||R.depthTexture.image.height!==R.height)&&(R.depthTexture.image.width=R.width,R.depthTexture.image.height=R.height,R.depthTexture.needsUpdate=!0),z(R.depthTexture,0);const oe=ie.__webglTexture,ne=Ve(R);if(R.depthTexture.format===Za)qe(R)?a.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,oe,0,ne):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,oe,0);else if(R.depthTexture.format===Al)qe(R)?a.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,oe,0,ne):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,oe,0);else throw new Error("Unknown depthTexture format")}function Me(L){const R=r.get(L),X=L.isWebGLCubeRenderTarget===!0;if(R.__boundDepthTexture!==L.depthTexture){const ie=L.depthTexture;if(R.__depthDisposeCallback&&R.__depthDisposeCallback(),ie){const oe=()=>{delete R.__boundDepthTexture,delete R.__depthDisposeCallback,ie.removeEventListener("dispose",oe)};ie.addEventListener("dispose",oe),R.__depthDisposeCallback=oe}R.__boundDepthTexture=ie}if(L.depthTexture&&!R.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");ue(R.__webglFramebuffer,L)}else if(X){R.__webglDepthbuffer=[];for(let ie=0;ie<6;ie++)if(n.bindFramebuffer(t.FRAMEBUFFER,R.__webglFramebuffer[ie]),R.__webglDepthbuffer[ie]===void 0)R.__webglDepthbuffer[ie]=t.createRenderbuffer(),Z(R.__webglDepthbuffer[ie],L,!1);else{const oe=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ne=R.__webglDepthbuffer[ie];t.bindRenderbuffer(t.RENDERBUFFER,ne),t.framebufferRenderbuffer(t.FRAMEBUFFER,oe,t.RENDERBUFFER,ne)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,R.__webglFramebuffer),R.__webglDepthbuffer===void 0)R.__webglDepthbuffer=t.createRenderbuffer(),Z(R.__webglDepthbuffer,L,!1);else{const ie=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,oe=R.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,oe),t.framebufferRenderbuffer(t.FRAMEBUFFER,ie,t.RENDERBUFFER,oe)}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ye(L,R,X){const ie=r.get(L);R!==void 0&&se(ie.__webglFramebuffer,L,L.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&Me(L)}function ke(L){const R=L.texture,X=r.get(L),ie=r.get(R);L.addEventListener("dispose",b);const oe=L.textures,ne=L.isWebGLCubeRenderTarget===!0,Re=oe.length>1;if(Re||(ie.__webglTexture===void 0&&(ie.__webglTexture=t.createTexture()),ie.__version=R.version,o.memory.textures++),ne){X.__webglFramebuffer=[];for(let ge=0;ge<6;ge++)if(R.mipmaps&&R.mipmaps.length>0){X.__webglFramebuffer[ge]=[];for(let _e=0;_e<R.mipmaps.length;_e++)X.__webglFramebuffer[ge][_e]=t.createFramebuffer()}else X.__webglFramebuffer[ge]=t.createFramebuffer()}else{if(R.mipmaps&&R.mipmaps.length>0){X.__webglFramebuffer=[];for(let ge=0;ge<R.mipmaps.length;ge++)X.__webglFramebuffer[ge]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if(Re)for(let ge=0,_e=oe.length;ge<_e;ge++){const ct=r.get(oe[ge]);ct.__webglTexture===void 0&&(ct.__webglTexture=t.createTexture(),o.memory.textures++)}if(L.samples>0&&qe(L)===!1){X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let ge=0;ge<oe.length;ge++){const _e=oe[ge];X.__webglColorRenderbuffer[ge]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[ge]);const ct=s.convert(_e.format,_e.colorSpace),de=s.convert(_e.type),Te=_(_e.internalFormat,ct,de,_e.colorSpace,L.isXRRenderTarget===!0),Be=Ve(L);t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,Te,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ge,t.RENDERBUFFER,X.__webglColorRenderbuffer[ge])}t.bindRenderbuffer(t.RENDERBUFFER,null),L.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),Z(X.__webglDepthRenderbuffer,L,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ne){n.bindTexture(t.TEXTURE_CUBE_MAP,ie.__webglTexture),le(t.TEXTURE_CUBE_MAP,R);for(let ge=0;ge<6;ge++)if(R.mipmaps&&R.mipmaps.length>0)for(let _e=0;_e<R.mipmaps.length;_e++)se(X.__webglFramebuffer[ge][_e],L,R,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,_e);else se(X.__webglFramebuffer[ge],L,R,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0);g(R)&&p(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Re){for(let ge=0,_e=oe.length;ge<_e;ge++){const ct=oe[ge],de=r.get(ct);n.bindTexture(t.TEXTURE_2D,de.__webglTexture),le(t.TEXTURE_2D,ct),se(X.__webglFramebuffer,L,ct,t.COLOR_ATTACHMENT0+ge,t.TEXTURE_2D,0),g(ct)&&p(t.TEXTURE_2D)}n.unbindTexture()}else{let ge=t.TEXTURE_2D;if((L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(ge=L.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ge,ie.__webglTexture),le(ge,R),R.mipmaps&&R.mipmaps.length>0)for(let _e=0;_e<R.mipmaps.length;_e++)se(X.__webglFramebuffer[_e],L,R,t.COLOR_ATTACHMENT0,ge,_e);else se(X.__webglFramebuffer,L,R,t.COLOR_ATTACHMENT0,ge,0);g(R)&&p(ge),n.unbindTexture()}L.depthBuffer&&Me(L)}function Se(L){const R=L.textures;for(let X=0,ie=R.length;X<ie;X++){const oe=R[X];if(g(oe)){const ne=x(L),Re=r.get(oe).__webglTexture;n.bindTexture(ne,Re),p(ne),n.unbindTexture()}}}const nt=[],H=[];function Xt(L){if(L.samples>0){if(qe(L)===!1){const R=L.textures,X=L.width,ie=L.height;let oe=t.COLOR_BUFFER_BIT;const ne=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Re=r.get(L),ge=R.length>1;if(ge)for(let _e=0;_e<R.length;_e++)n.bindFramebuffer(t.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+_e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Re.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+_e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Re.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Re.__webglFramebuffer);for(let _e=0;_e<R.length;_e++){if(L.resolveDepthBuffer&&(L.depthBuffer&&(oe|=t.DEPTH_BUFFER_BIT),L.stencilBuffer&&L.resolveStencilBuffer&&(oe|=t.STENCIL_BUFFER_BIT)),ge){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Re.__webglColorRenderbuffer[_e]);const ct=r.get(R[_e]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ct,0)}t.blitFramebuffer(0,0,X,ie,0,0,X,ie,oe,t.NEAREST),l===!0&&(nt.length=0,H.length=0,nt.push(t.COLOR_ATTACHMENT0+_e),L.depthBuffer&&L.resolveDepthBuffer===!1&&(nt.push(ne),H.push(ne),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,H)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,nt))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ge)for(let _e=0;_e<R.length;_e++){n.bindFramebuffer(t.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+_e,t.RENDERBUFFER,Re.__webglColorRenderbuffer[_e]);const ct=r.get(R[_e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Re.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+_e,t.TEXTURE_2D,ct,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Re.__webglMultisampledFramebuffer)}else if(L.depthBuffer&&L.resolveDepthBuffer===!1&&l){const R=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[R])}}}function Ve(L){return Math.min(i.maxSamples,L.samples)}function qe(L){const R=r.get(L);return L.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&R.__useRenderToTexture!==!1}function Ue(L){const R=o.render.frame;f.get(L)!==R&&(f.set(L,R),L.update())}function Ye(L,R){const X=L.colorSpace,ie=L.format,oe=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||X!==Ln&&X!==Ts&&($e.getTransfer(X)===Mt?(ie!==Cr||oe!==rs)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),R}function Oe(L){return typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement?(c.width=L.naturalWidth||L.width,c.height=L.naturalHeight||L.height):typeof VideoFrame<"u"&&L instanceof VideoFrame?(c.width=L.displayWidth,c.height=L.displayHeight):(c.width=L.width,c.height=L.height),c}this.allocateTextureUnit=I,this.resetTextureUnits=F,this.setTexture2D=z,this.setTexture2DArray=O,this.setTexture3D=j,this.setTextureCube=D,this.rebindTextures=ye,this.setupRenderTarget=ke,this.updateRenderTargetMipmap=Se,this.updateMultisampleRenderTarget=Xt,this.setupDepthRenderbuffer=Me,this.setupFrameBufferTexture=se,this.useMultisampledRTT=qe}function pH(t,e){function n(r,i=Ts){let s;const o=$e.getTransfer(i);if(r===rs)return t.UNSIGNED_BYTE;if(r===Vy)return t.UNSIGNED_SHORT_4_4_4_4;if(r===Gy)return t.UNSIGNED_SHORT_5_5_5_1;if(r===$T)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===WT)return t.BYTE;if(r===XT)return t.SHORT;if(r===su)return t.UNSIGNED_SHORT;if(r===jy)return t.INT;if(r===Go)return t.UNSIGNED_INT;if(r===qr)return t.FLOAT;if(r===Tu)return t.HALF_FLOAT;if(r===YT)return t.ALPHA;if(r===KT)return t.RGB;if(r===Cr)return t.RGBA;if(r===qT)return t.LUMINANCE;if(r===ZT)return t.LUMINANCE_ALPHA;if(r===Za)return t.DEPTH_COMPONENT;if(r===Al)return t.DEPTH_STENCIL;if(r===Wy)return t.RED;if(r===Xy)return t.RED_INTEGER;if(r===QT)return t.RG;if(r===$y)return t.RG_INTEGER;if(r===Yy)return t.RGBA_INTEGER;if(r===af||r===lf||r===cf||r===uf)if(o===Mt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===af)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===lf)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===cf)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===uf)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===af)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===lf)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===cf)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===uf)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===uv||r===dv||r===fv||r===hv)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===uv)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===dv)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===fv)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===hv)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===pv||r===mv||r===gv)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===pv||r===mv)return o===Mt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===gv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===vv||r===yv||r===xv||r===_v||r===wv||r===Sv||r===Mv||r===bv||r===Ev||r===Tv||r===Av||r===Cv||r===Rv||r===Pv)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===vv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===yv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===xv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===_v)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===wv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Sv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Mv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===bv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Ev)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Tv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Av)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===Cv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Rv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===Pv)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===df||r===Nv||r===Dv)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===df)return o===Mt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Nv)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Dv)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===JT||r===Lv||r===Iv||r===kv)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===df)return s.COMPRESSED_RED_RGTC1_EXT;if(r===Lv)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===Iv)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===kv)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Tl?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}class mH extends dn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class qt extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}}const gH={type:"move"};class pm{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qt,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 qt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k),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 r of e.hand.values())this._getHandJoint(n,r)}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,r){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const v of e.hand.values()){const g=n.getJointPose(v,r),p=this._getHandJoint(c,v);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}const f=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=f.position.distanceTo(u.position),h=.02,m=.005;c.inputState.pinching&&d>h+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=h-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(gH)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new qt;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}const vH=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,yH=`
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 xH{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n,r){if(this.texture===null){const i=new on,s=e.properties.get(i);s.__webglTexture=n.texture,(n.depthNear!=r.depthNear||n.depthFar!=r.depthFar)&&(this.depthNear=n.depthNear,this.depthFar=n.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const n=e.cameras[0].viewport,r=new eo({vertexShader:vH,fragmentShader:yH,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new je(new $h(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class _H extends ta{constructor(e,n){super();const r=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,f=null,u=null,d=null,h=null,m=null;const v=new xH,g=n.getContextAttributes();let p=null,x=null;const _=[],w=[],M=new ze;let T=null;const b=new dn;b.viewport=new ut;const C=new dn;C.viewport=new ut;const A=[b,C],E=new mH;let N=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let ee=_[$];return ee===void 0&&(ee=new pm,_[$]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function($){let ee=_[$];return ee===void 0&&(ee=new pm,_[$]=ee),ee.getGripSpace()},this.getHand=function($){let ee=_[$];return ee===void 0&&(ee=new pm,_[$]=ee),ee.getHandSpace()};function I($){const ee=w.indexOf($.inputSource);if(ee===-1)return;const se=_[ee];se!==void 0&&(se.update($.inputSource,$.frame,c||o),se.dispatchEvent({type:$.type,data:$.inputSource}))}function U(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",U),i.removeEventListener("inputsourceschange",z);for(let $=0;$<_.length;$++){const ee=w[$];ee!==null&&(w[$]=null,_[$].disconnect(ee))}N=null,F=null,v.reset(),e.setRenderTarget(p),h=null,d=null,u=null,i=null,x=null,pe.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(M.width,M.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){s=$,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){a=$,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function($){if(i=$,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",U),i.addEventListener("inputsourceschange",z),g.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(M),i.renderState.layers===void 0){const ee={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};h=new XRWebGLLayer(i,n,ee),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),x=new Wo(h.framebufferWidth,h.framebufferHeight,{format:Cr,type:rs,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let ee=null,se=null,Z=null;g.depth&&(Z=g.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ee=g.stencil?Al:Za,se=g.stencil?Tl:Go);const ue={colorFormat:n.RGBA8,depthFormat:Z,scaleFactor:s};u=new XRWebGLBinding(i,n),d=u.createProjectionLayer(ue),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new Wo(d.textureWidth,d.textureHeight,{format:Cr,type:rs,depthTexture:new dA(d.textureWidth,d.textureHeight,se,void 0,void 0,void 0,void 0,void 0,void 0,ee),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),pe.setContext(i),pe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function z($){for(let ee=0;ee<$.removed.length;ee++){const se=$.removed[ee],Z=w.indexOf(se);Z>=0&&(w[Z]=null,_[Z].disconnect(se))}for(let ee=0;ee<$.added.length;ee++){const se=$.added[ee];let Z=w.indexOf(se);if(Z===-1){for(let Me=0;Me<_.length;Me++)if(Me>=w.length){w.push(se),Z=Me;break}else if(w[Me]===null){w[Me]=se,Z=Me;break}if(Z===-1)break}const ue=_[Z];ue&&ue.connect(se)}}const O=new k,j=new k;function D($,ee,se){O.setFromMatrixPosition(ee.matrixWorld),j.setFromMatrixPosition(se.matrixWorld);const Z=O.distanceTo(j),ue=ee.projectionMatrix.elements,Me=se.projectionMatrix.elements,ye=ue[14]/(ue[10]-1),ke=ue[14]/(ue[10]+1),Se=(ue[9]+1)/ue[5],nt=(ue[9]-1)/ue[5],H=(ue[8]-1)/ue[0],Xt=(Me[8]+1)/Me[0],Ve=ye*H,qe=ye*Xt,Ue=Z/(-H+Xt),Ye=Ue*-H;if(ee.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(Ye),$.translateZ(Ue),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),ue[10]===-1)$.projectionMatrix.copy(ee.projectionMatrix),$.projectionMatrixInverse.copy(ee.projectionMatrixInverse);else{const Oe=ye+Ue,L=ke+Ue,R=Ve-Ye,X=qe+(Z-Ye),ie=Se*ke/L*Oe,oe=nt*ke/L*Oe;$.projectionMatrix.makePerspective(R,X,ie,oe,Oe,L),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function V($,ee){ee===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(ee.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(i===null)return;let ee=$.near,se=$.far;v.texture!==null&&(v.depthNear>0&&(ee=v.depthNear),v.depthFar>0&&(se=v.depthFar)),E.near=C.near=b.near=ee,E.far=C.far=b.far=se,(N!==E.near||F!==E.far)&&(i.updateRenderState({depthNear:E.near,depthFar:E.far}),N=E.near,F=E.far),b.layers.mask=$.layers.mask|2,C.layers.mask=$.layers.mask|4,E.layers.mask=b.layers.mask|C.layers.mask;const Z=$.parent,ue=E.cameras;V(E,Z);for(let Me=0;Me<ue.length;Me++)V(ue[Me],Z);ue.length===2?D(E,b,C):E.projectionMatrix.copy(b.projectionMatrix),Q($,E,Z)};function Q($,ee,se){se===null?$.matrix.copy(ee.matrixWorld):($.matrix.copy(se.matrixWorld),$.matrix.invert(),$.matrix.multiply(ee.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(ee.projectionMatrix),$.projectionMatrixInverse.copy(ee.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Cl*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return E},this.getFoveation=function(){if(!(d===null&&h===null))return l},this.setFoveation=function($){l=$,d!==null&&(d.fixedFoveation=$),h!==null&&h.fixedFoveation!==void 0&&(h.fixedFoveation=$)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(E)};let J=null;function le($,ee){if(f=ee.getViewerPose(c||o),m=ee,f!==null){const se=f.views;h!==null&&(e.setRenderTargetFramebuffer(x,h.framebuffer),e.setRenderTarget(x));let Z=!1;se.length!==E.cameras.length&&(E.cameras.length=0,Z=!0);for(let Me=0;Me<se.length;Me++){const ye=se[Me];let ke=null;if(h!==null)ke=h.getViewport(ye);else{const nt=u.getViewSubImage(d,ye);ke=nt.viewport,Me===0&&(e.setRenderTargetTextures(x,nt.colorTexture,d.ignoreDepthValues?void 0:nt.depthStencilTexture),e.setRenderTarget(x))}let Se=A[Me];Se===void 0&&(Se=new dn,Se.layers.enable(Me),Se.viewport=new ut,A[Me]=Se),Se.matrix.fromArray(ye.transform.matrix),Se.matrix.decompose(Se.position,Se.quaternion,Se.scale),Se.projectionMatrix.fromArray(ye.projectionMatrix),Se.projectionMatrixInverse.copy(Se.projectionMatrix).invert(),Se.viewport.set(ke.x,ke.y,ke.width,ke.height),Me===0&&(E.matrix.copy(Se.matrix),E.matrix.decompose(E.position,E.quaternion,E.scale)),Z===!0&&E.cameras.push(Se)}const ue=i.enabledFeatures;if(ue&&ue.includes("depth-sensing")){const Me=u.getDepthInformation(se[0]);Me&&Me.isValid&&Me.texture&&v.init(e,Me,i.renderState)}}for(let se=0;se<_.length;se++){const Z=w[se],ue=_[se];Z!==null&&ue!==void 0&&ue.update(Z,ee,c||o)}J&&J($,ee),ee.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ee}),m=null}const pe=new uA;pe.setAnimationLoop(le),this.setAnimationLoop=function($){J=$},this.dispose=function(){}}}const vo=new Qt,wH=new Ce;function SH(t,e){function n(g,p){g.matrixAutoUpdate===!0&&g.updateMatrix(),p.value.copy(g.matrix)}function r(g,p){p.color.getRGB(g.fogColor.value,aA(t)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function i(g,p,x,_,w){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(g,p):p.isMeshToonMaterial?(s(g,p),u(g,p)):p.isMeshPhongMaterial?(s(g,p),f(g,p)):p.isMeshStandardMaterial?(s(g,p),d(g,p),p.isMeshPhysicalMaterial&&h(g,p,w)):p.isMeshMatcapMaterial?(s(g,p),m(g,p)):p.isMeshDepthMaterial?s(g,p):p.isMeshDistanceMaterial?(s(g,p),v(g,p)):p.isMeshNormalMaterial?s(g,p):p.isLineBasicMaterial?(o(g,p),p.isLineDashedMaterial&&a(g,p)):p.isPointsMaterial?l(g,p,x,_):p.isSpriteMaterial?c(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map,n(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform)),p.bumpMap&&(g.bumpMap.value=p.bumpMap,n(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===tr&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,n(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===tr&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,n(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap,n(p.emissiveMap,g.emissiveMapTransform)),p.specularMap&&(g.specularMap.value=p.specularMap,n(p.specularMap,g.specularMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);const x=e.get(p),_=x.envMap,w=x.envMapRotation;_&&(g.envMap.value=_,vo.copy(w),vo.x*=-1,vo.y*=-1,vo.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(vo.y*=-1,vo.z*=-1),g.envMapRotation.value.setFromMatrix4(wH.makeRotationFromEuler(vo)),g.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,n(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,n(p.aoMap,g.aoMapTransform))}function o(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,n(p.map,g.mapTransform))}function a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,x,_){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*x,g.scale.value=_*.5,p.map&&(g.map.value=p.map,n(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,n(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function f(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function u(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function d(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function h(g,p,x){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,n(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,n(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,n(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,n(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,n(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===tr&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,n(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,n(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,n(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,n(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,n(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,n(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,n(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function v(g,p){const x=e.get(p).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function MH(t,e,n,r){let i={},s={},o=[];const a=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,_){const w=_.program;r.uniformBlockBinding(x,w)}function c(x,_){let w=i[x.id];w===void 0&&(m(x),w=f(x),i[x.id]=w,x.addEventListener("dispose",g));const M=_.program;r.updateUBOMapping(x,M);const T=e.render.frame;s[x.id]!==T&&(d(x),s[x.id]=T)}function f(x){const _=u();x.__bindingPointIndex=_;const w=t.createBuffer(),M=x.__size,T=x.usage;return t.bindBuffer(t.UNIFORM_BUFFER,w),t.bufferData(t.UNIFORM_BUFFER,M,T),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,_,w),w}function u(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){const _=i[x.id],w=x.uniforms,M=x.__cache;t.bindBuffer(t.UNIFORM_BUFFER,_);for(let T=0,b=w.length;T<b;T++){const C=Array.isArray(w[T])?w[T]:[w[T]];for(let A=0,E=C.length;A<E;A++){const N=C[A];if(h(N,T,A,M)===!0){const F=N.__offset,I=Array.isArray(N.value)?N.value:[N.value];let U=0;for(let z=0;z<I.length;z++){const O=I[z],j=v(O);typeof O=="number"||typeof O=="boolean"?(N.__data[0]=O,t.bufferSubData(t.UNIFORM_BUFFER,F+U,N.__data)):O.isMatrix3?(N.__data[0]=O.elements[0],N.__data[1]=O.elements[1],N.__data[2]=O.elements[2],N.__data[3]=0,N.__data[4]=O.elements[3],N.__data[5]=O.elements[4],N.__data[6]=O.elements[5],N.__data[7]=0,N.__data[8]=O.elements[6],N.__data[9]=O.elements[7],N.__data[10]=O.elements[8],N.__data[11]=0):(O.toArray(N.__data,U),U+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,F,N.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function h(x,_,w,M){const T=x.value,b=_+"_"+w;if(M[b]===void 0)return typeof T=="number"||typeof T=="boolean"?M[b]=T:M[b]=T.clone(),!0;{const C=M[b];if(typeof T=="number"||typeof T=="boolean"){if(C!==T)return M[b]=T,!0}else if(C.equals(T)===!1)return C.copy(T),!0}return!1}function m(x){const _=x.uniforms;let w=0;const M=16;for(let b=0,C=_.length;b<C;b++){const A=Array.isArray(_[b])?_[b]:[_[b]];for(let E=0,N=A.length;E<N;E++){const F=A[E],I=Array.isArray(F.value)?F.value:[F.value];for(let U=0,z=I.length;U<z;U++){const O=I[U],j=v(O),D=w%M,V=D%j.boundary,Q=D+V;w+=V,Q!==0&&M-Q<j.storage&&(w+=M-Q),F.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=w,w+=j.storage}}}const T=w%M;return T>0&&(w+=M-T),x.__size=w,x.__cache={},this}function v(x){const _={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(_.boundary=4,_.storage=4):x.isVector2?(_.boundary=8,_.storage=8):x.isVector3||x.isColor?(_.boundary=16,_.storage=12):x.isVector4?(_.boundary=16,_.storage=16):x.isMatrix3?(_.boundary=48,_.storage=48):x.isMatrix4?(_.boundary=64,_.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),_}function g(x){const _=x.target;_.removeEventListener("dispose",g);const w=o.indexOf(_.__bindingPointIndex);o.splice(w,1),t.deleteBuffer(i[_.id]),delete i[_.id],delete s[_.id]}function p(){for(const x in i)t.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:p}}class bH{constructor(e={}){const{canvas:n=fF(),context:r=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let h;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=r.getContextAttributes().alpha}else h=o;const m=new Uint32Array(4),v=new Int32Array(4);let g=null,p=null;const x=[],_=[];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._outputColorSpace=ft,this.toneMapping=Ws,this.toneMappingExposure=1;const w=this;let M=!1,T=0,b=0,C=null,A=-1,E=null;const N=new ut,F=new ut;let I=null;const U=new Pe(0);let z=0,O=n.width,j=n.height,D=1,V=null,Q=null;const J=new ut(0,0,O,j),le=new ut(0,0,O,j);let pe=!1;const $=new Qy;let ee=!1,se=!1;const Z=new Ce,ue=new Ce,Me=new k,ye=new ut,ke={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Se=!1;function nt(){return C===null?D:1}let H=r;function Xt(P,G){return n.getContext(P,G)}try{const P={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:f,failIfMajorPerformanceCaveat:u};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${By}`),n.addEventListener("webglcontextlost",te,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",xe,!1),H===null){const G="webgl2";if(H=Xt(G,P),H===null)throw Xt(G)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(P){throw console.error("THREE.WebGLRenderer: "+P.message),P}let Ve,qe,Ue,Ye,Oe,L,R,X,ie,oe,ne,Re,ge,_e,ct,de,Te,Be,Ge,Ee,Ke,Ze,be,B;function ae(){Ve=new Rz(H),Ve.init(),Ze=new pH(H,Ve),qe=new Mz(H,Ve,e,Ze),Ue=new dH(H,Ve),qe.reverseDepthBuffer&&d&&Ue.buffers.depth.setReversed(!0),Ye=new Dz(H),Oe=new q4,L=new hH(H,Ve,Ue,Oe,qe,Ze,Ye),R=new Ez(w),X=new Cz(w),ie=new BF(H),be=new wz(H,ie),oe=new Pz(H,ie,Ye,be),ne=new Iz(H,oe,ie,Ye),Ge=new Lz(H,qe,L),de=new bz(Oe),Re=new K4(w,R,X,Ve,qe,be,de),ge=new SH(w,Oe),_e=new Q4,ct=new iH(Ve),Be=new _z(w,R,X,Ue,ne,h,l),Te=new cH(w,ne,qe),B=new MH(H,Ye,qe,Ue),Ee=new Sz(H,Ve,Ye),Ke=new Nz(H,Ve,Ye),Ye.programs=Re.programs,w.capabilities=qe,w.extensions=Ve,w.properties=Oe,w.renderLists=_e,w.shadowMap=Te,w.state=Ue,w.info=Ye}ae();const q=new _H(w,H);this.xr=q,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const P=Ve.get("WEBGL_lose_context");P&&P.loseContext()},this.forceContextRestore=function(){const P=Ve.get("WEBGL_lose_context");P&&P.restoreContext()},this.getPixelRatio=function(){return D},this.setPixelRatio=function(P){P!==void 0&&(D=P,this.setSize(O,j,!1))},this.getSize=function(P){return P.set(O,j)},this.setSize=function(P,G,Y=!0){if(q.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}O=P,j=G,n.width=Math.floor(P*D),n.height=Math.floor(G*D),Y===!0&&(n.style.width=P+"px",n.style.height=G+"px"),this.setViewport(0,0,P,G)},this.getDrawingBufferSize=function(P){return P.set(O*D,j*D).floor()},this.setDrawingBufferSize=function(P,G,Y){O=P,j=G,D=Y,n.width=Math.floor(P*Y),n.height=Math.floor(G*Y),this.setViewport(0,0,P,G)},this.getCurrentViewport=function(P){return P.copy(N)},this.getViewport=function(P){return P.copy(J)},this.setViewport=function(P,G,Y,K){P.isVector4?J.set(P.x,P.y,P.z,P.w):J.set(P,G,Y,K),Ue.viewport(N.copy(J).multiplyScalar(D).round())},this.getScissor=function(P){return P.copy(le)},this.setScissor=function(P,G,Y,K){P.isVector4?le.set(P.x,P.y,P.z,P.w):le.set(P,G,Y,K),Ue.scissor(F.copy(le).multiplyScalar(D).round())},this.getScissorTest=function(){return pe},this.setScissorTest=function(P){Ue.setScissorTest(pe=P)},this.setOpaqueSort=function(P){V=P},this.setTransparentSort=function(P){Q=P},this.getClearColor=function(P){return P.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor.apply(Be,arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha.apply(Be,arguments)},this.clear=function(P=!0,G=!0,Y=!0){let K=0;if(P){let W=!1;if(C!==null){const fe=C.texture.format;W=fe===Yy||fe===$y||fe===Xy}if(W){const fe=C.texture.type,we=fe===rs||fe===Go||fe===su||fe===Tl||fe===Vy||fe===Gy,De=Be.getClearColor(),Le=Be.getClearAlpha(),Xe=De.r,et=De.g,Ie=De.b;we?(m[0]=Xe,m[1]=et,m[2]=Ie,m[3]=Le,H.clearBufferuiv(H.COLOR,0,m)):(v[0]=Xe,v[1]=et,v[2]=Ie,v[3]=Le,H.clearBufferiv(H.COLOR,0,v))}else K|=H.COLOR_BUFFER_BIT}G&&(K|=H.DEPTH_BUFFER_BIT),Y&&(K|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(K)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",te,!1),n.removeEventListener("webglcontextrestored",ve,!1),n.removeEventListener("webglcontextcreationerror",xe,!1),_e.dispose(),ct.dispose(),Oe.dispose(),R.dispose(),X.dispose(),ne.dispose(),be.dispose(),B.dispose(),Re.dispose(),q.dispose(),q.removeEventListener("sessionstart",xx),q.removeEventListener("sessionend",_x),uo.stop()};function te(P){P.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;const P=Ye.autoReset,G=Te.enabled,Y=Te.autoUpdate,K=Te.needsUpdate,W=Te.type;ae(),Ye.autoReset=P,Te.enabled=G,Te.autoUpdate=Y,Te.needsUpdate=K,Te.type=W}function xe(P){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",P.statusMessage)}function Je(P){const G=P.target;G.removeEventListener("dispose",Je),Ht(G)}function Ht(P){wn(P),Oe.remove(P)}function wn(P){const G=Oe.get(P).programs;G!==void 0&&(G.forEach(function(Y){Re.releaseProgram(Y)}),P.isShaderMaterial&&Re.releaseShaderCache(P))}this.renderBufferDirect=function(P,G,Y,K,W,fe){G===null&&(G=ke);const we=W.isMesh&&W.matrixWorld.determinant()<0,De=qR(P,G,Y,K,W);Ue.setMaterial(K,we);let Le=Y.index,Xe=1;if(K.wireframe===!0){if(Le=oe.getWireframeAttribute(Y),Le===void 0)return;Xe=2}const et=Y.drawRange,Ie=Y.attributes.position;let gt=et.start*Xe,Tt=(et.start+et.count)*Xe;fe!==null&&(gt=Math.max(gt,fe.start*Xe),Tt=Math.min(Tt,(fe.start+fe.count)*Xe)),Le!==null?(gt=Math.max(gt,0),Tt=Math.min(Tt,Le.count)):Ie!=null&&(gt=Math.max(gt,0),Tt=Math.min(Tt,Ie.count));const Rt=Tt-gt;if(Rt<0||Rt===1/0)return;be.setup(W,K,De,Y,Le);let Gn,vt=Ee;if(Le!==null&&(Gn=ie.get(Le),vt=Ke,vt.setIndex(Gn)),W.isMesh)K.wireframe===!0?(Ue.setLineWidth(K.wireframeLinewidth*nt()),vt.setMode(H.LINES)):vt.setMode(H.TRIANGLES);else if(W.isLine){let Fe=K.linewidth;Fe===void 0&&(Fe=1),Ue.setLineWidth(Fe*nt()),W.isLineSegments?vt.setMode(H.LINES):W.isLineLoop?vt.setMode(H.LINE_LOOP):vt.setMode(H.LINE_STRIP)}else W.isPoints?vt.setMode(H.POINTS):W.isSprite&&vt.setMode(H.TRIANGLES);if(W.isBatchedMesh)if(W._multiDrawInstances!==null)vt.renderMultiDrawInstances(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount,W._multiDrawInstances);else if(Ve.get("WEBGL_multi_draw"))vt.renderMultiDraw(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount);else{const Fe=W._multiDrawStarts,Ci=W._multiDrawCounts,yt=W._multiDrawCount,Or=Le?ie.get(Le).bytesPerElement:1,na=Oe.get(K).currentProgram.getUniforms();for(let rr=0;rr<yt;rr++)na.setValue(H,"_gl_DrawID",rr),vt.render(Fe[rr]/Or,Ci[rr])}else if(W.isInstancedMesh)vt.renderInstances(gt,Rt,W.count);else if(Y.isInstancedBufferGeometry){const Fe=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,Ci=Math.min(Y.instanceCount,Fe);vt.renderInstances(gt,Rt,Ci)}else vt.render(gt,Rt)};function _t(P,G,Y){P.transparent===!0&&P.side===pi&&P.forceSinglePass===!1?(P.side=tr,P.needsUpdate=!0,Du(P,G,Y),P.side=ns,P.needsUpdate=!0,Du(P,G,Y),P.side=pi):Du(P,G,Y)}this.compile=function(P,G,Y=null){Y===null&&(Y=P),p=ct.get(Y),p.init(G),_.push(p),Y.traverseVisible(function(W){W.isLight&&W.layers.test(G.layers)&&(p.pushLight(W),W.castShadow&&p.pushShadow(W))}),P!==Y&&P.traverseVisible(function(W){W.isLight&&W.layers.test(G.layers)&&(p.pushLight(W),W.castShadow&&p.pushShadow(W))}),p.setupLights();const K=new Set;return P.traverse(function(W){if(!(W.isMesh||W.isPoints||W.isLine||W.isSprite))return;const fe=W.material;if(fe)if(Array.isArray(fe))for(let we=0;we<fe.length;we++){const De=fe[we];_t(De,Y,W),K.add(De)}else _t(fe,Y,W),K.add(fe)}),_.pop(),p=null,K},this.compileAsync=function(P,G,Y=null){const K=this.compile(P,G,Y);return new Promise(W=>{function fe(){if(K.forEach(function(we){Oe.get(we).currentProgram.isReady()&&K.delete(we)}),K.size===0){W(P);return}setTimeout(fe,10)}Ve.get("KHR_parallel_shader_compile")!==null?fe():setTimeout(fe,10)})};let kr=null;function Ai(P){kr&&kr(P)}function xx(){uo.stop()}function _x(){uo.start()}const uo=new uA;uo.setAnimationLoop(Ai),typeof self<"u"&&uo.setContext(self),this.setAnimationLoop=function(P){kr=P,q.setAnimationLoop(P),P===null?uo.stop():uo.start()},q.addEventListener("sessionstart",xx),q.addEventListener("sessionend",_x),this.render=function(P,G){if(G!==void 0&&G.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;if(P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),G.parent===null&&G.matrixWorldAutoUpdate===!0&&G.updateMatrixWorld(),q.enabled===!0&&q.isPresenting===!0&&(q.cameraAutoUpdate===!0&&q.updateCamera(G),G=q.getCamera()),P.isScene===!0&&P.onBeforeRender(w,P,G,C),p=ct.get(P,_.length),p.init(G),_.push(p),ue.multiplyMatrices(G.projectionMatrix,G.matrixWorldInverse),$.setFromProjectionMatrix(ue),se=this.localClippingEnabled,ee=de.init(this.clippingPlanes,se),g=_e.get(P,x.length),g.init(),x.push(g),q.enabled===!0&&q.isPresenting===!0){const fe=w.xr.getDepthSensingMesh();fe!==null&&sp(fe,G,-1/0,w.sortObjects)}sp(P,G,0,w.sortObjects),g.finish(),w.sortObjects===!0&&g.sort(V,Q),Se=q.enabled===!1||q.isPresenting===!1||q.hasDepthSensing()===!1,Se&&Be.addToRenderList(g,P),this.info.render.frame++,ee===!0&&de.beginShadows();const Y=p.state.shadowsArray;Te.render(Y,P,G),ee===!0&&de.endShadows(),this.info.autoReset===!0&&this.info.reset();const K=g.opaque,W=g.transmissive;if(p.setupLights(),G.isArrayCamera){const fe=G.cameras;if(W.length>0)for(let we=0,De=fe.length;we<De;we++){const Le=fe[we];Sx(K,W,P,Le)}Se&&Be.render(P);for(let we=0,De=fe.length;we<De;we++){const Le=fe[we];wx(g,P,Le,Le.viewport)}}else W.length>0&&Sx(K,W,P,G),Se&&Be.render(P),wx(g,P,G);C!==null&&(L.updateMultisampleRenderTarget(C),L.updateRenderTargetMipmap(C)),P.isScene===!0&&P.onAfterRender(w,P,G),be.resetDefaultState(),A=-1,E=null,_.pop(),_.length>0?(p=_[_.length-1],ee===!0&&de.setGlobalState(w.clippingPlanes,p.state.camera)):p=null,x.pop(),x.length>0?g=x[x.length-1]:g=null};function sp(P,G,Y,K){if(P.visible===!1)return;if(P.layers.test(G.layers)){if(P.isGroup)Y=P.renderOrder;else if(P.isLOD)P.autoUpdate===!0&&P.update(G);else if(P.isLight)p.pushLight(P),P.castShadow&&p.pushShadow(P);else if(P.isSprite){if(!P.frustumCulled||$.intersectsSprite(P)){K&&ye.setFromMatrixPosition(P.matrixWorld).applyMatrix4(ue);const we=ne.update(P),De=P.material;De.visible&&g.push(P,we,De,Y,ye.z,null)}}else if((P.isMesh||P.isLine||P.isPoints)&&(!P.frustumCulled||$.intersectsObject(P))){const we=ne.update(P),De=P.material;if(K&&(P.boundingSphere!==void 0?(P.boundingSphere===null&&P.computeBoundingSphere(),ye.copy(P.boundingSphere.center)):(we.boundingSphere===null&&we.computeBoundingSphere(),ye.copy(we.boundingSphere.center)),ye.applyMatrix4(P.matrixWorld).applyMatrix4(ue)),Array.isArray(De)){const Le=we.groups;for(let Xe=0,et=Le.length;Xe<et;Xe++){const Ie=Le[Xe],gt=De[Ie.materialIndex];gt&>.visible&&g.push(P,we,gt,Y,ye.z,Ie)}}else De.visible&&g.push(P,we,De,Y,ye.z,null)}}const fe=P.children;for(let we=0,De=fe.length;we<De;we++)sp(fe[we],G,Y,K)}function wx(P,G,Y,K){const W=P.opaque,fe=P.transmissive,we=P.transparent;p.setupLightsView(Y),ee===!0&&de.setGlobalState(w.clippingPlanes,Y),K&&Ue.viewport(N.copy(K)),W.length>0&&Nu(W,G,Y),fe.length>0&&Nu(fe,G,Y),we.length>0&&Nu(we,G,Y),Ue.buffers.depth.setTest(!0),Ue.buffers.depth.setMask(!0),Ue.buffers.color.setMask(!0),Ue.setPolygonOffset(!1)}function Sx(P,G,Y,K){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[K.id]===void 0&&(p.state.transmissionRenderTarget[K.id]=new Wo(1,1,{generateMipmaps:!0,type:Ve.has("EXT_color_buffer_half_float")||Ve.has("EXT_color_buffer_float")?Tu:rs,minFilter:Gi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:$e.workingColorSpace}));const fe=p.state.transmissionRenderTarget[K.id],we=K.viewport||N;fe.setSize(we.z,we.w);const De=w.getRenderTarget();w.setRenderTarget(fe),w.getClearColor(U),z=w.getClearAlpha(),z<1&&w.setClearColor(16777215,.5),w.clear(),Se&&Be.render(Y);const Le=w.toneMapping;w.toneMapping=Ws;const Xe=K.viewport;if(K.viewport!==void 0&&(K.viewport=void 0),p.setupLightsView(K),ee===!0&&de.setGlobalState(w.clippingPlanes,K),Nu(P,Y,K),L.updateMultisampleRenderTarget(fe),L.updateRenderTargetMipmap(fe),Ve.has("WEBGL_multisampled_render_to_texture")===!1){let et=!1;for(let Ie=0,gt=G.length;Ie<gt;Ie++){const Tt=G[Ie],Rt=Tt.object,Gn=Tt.geometry,vt=Tt.material,Fe=Tt.group;if(vt.side===pi&&Rt.layers.test(K.layers)){const Ci=vt.side;vt.side=tr,vt.needsUpdate=!0,Mx(Rt,Y,K,Gn,vt,Fe),vt.side=Ci,vt.needsUpdate=!0,et=!0}}et===!0&&(L.updateMultisampleRenderTarget(fe),L.updateRenderTargetMipmap(fe))}w.setRenderTarget(De),w.setClearColor(U,z),Xe!==void 0&&(K.viewport=Xe),w.toneMapping=Le}function Nu(P,G,Y){const K=G.isScene===!0?G.overrideMaterial:null;for(let W=0,fe=P.length;W<fe;W++){const we=P[W],De=we.object,Le=we.geometry,Xe=K===null?we.material:K,et=we.group;De.layers.test(Y.layers)&&Mx(De,G,Y,Le,Xe,et)}}function Mx(P,G,Y,K,W,fe){P.onBeforeRender(w,G,Y,K,W,fe),P.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,P.matrixWorld),P.normalMatrix.getNormalMatrix(P.modelViewMatrix),W.onBeforeRender(w,G,Y,K,P,fe),W.transparent===!0&&W.side===pi&&W.forceSinglePass===!1?(W.side=tr,W.needsUpdate=!0,w.renderBufferDirect(Y,G,K,W,P,fe),W.side=ns,W.needsUpdate=!0,w.renderBufferDirect(Y,G,K,W,P,fe),W.side=pi):w.renderBufferDirect(Y,G,K,W,P,fe),P.onAfterRender(w,G,Y,K,W,fe)}function Du(P,G,Y){G.isScene!==!0&&(G=ke);const K=Oe.get(P),W=p.state.lights,fe=p.state.shadowsArray,we=W.state.version,De=Re.getParameters(P,W.state,fe,G,Y),Le=Re.getProgramCacheKey(De);let Xe=K.programs;K.environment=P.isMeshStandardMaterial?G.environment:null,K.fog=G.fog,K.envMap=(P.isMeshStandardMaterial?X:R).get(P.envMap||K.environment),K.envMapRotation=K.environment!==null&&P.envMap===null?G.environmentRotation:P.envMapRotation,Xe===void 0&&(P.addEventListener("dispose",Je),Xe=new Map,K.programs=Xe);let et=Xe.get(Le);if(et!==void 0){if(K.currentProgram===et&&K.lightsStateVersion===we)return Ex(P,De),et}else De.uniforms=Re.getUniforms(P),P.onBeforeCompile(De,w),et=Re.acquireProgram(De,Le),Xe.set(Le,et),K.uniforms=De.uniforms;const Ie=K.uniforms;return(!P.isShaderMaterial&&!P.isRawShaderMaterial||P.clipping===!0)&&(Ie.clippingPlanes=de.uniform),Ex(P,De),K.needsLights=QR(P),K.lightsStateVersion=we,K.needsLights&&(Ie.ambientLightColor.value=W.state.ambient,Ie.lightProbe.value=W.state.probe,Ie.directionalLights.value=W.state.directional,Ie.directionalLightShadows.value=W.state.directionalShadow,Ie.spotLights.value=W.state.spot,Ie.spotLightShadows.value=W.state.spotShadow,Ie.rectAreaLights.value=W.state.rectArea,Ie.ltc_1.value=W.state.rectAreaLTC1,Ie.ltc_2.value=W.state.rectAreaLTC2,Ie.pointLights.value=W.state.point,Ie.pointLightShadows.value=W.state.pointShadow,Ie.hemisphereLights.value=W.state.hemi,Ie.directionalShadowMap.value=W.state.directionalShadowMap,Ie.directionalShadowMatrix.value=W.state.directionalShadowMatrix,Ie.spotShadowMap.value=W.state.spotShadowMap,Ie.spotLightMatrix.value=W.state.spotLightMatrix,Ie.spotLightMap.value=W.state.spotLightMap,Ie.pointShadowMap.value=W.state.pointShadowMap,Ie.pointShadowMatrix.value=W.state.pointShadowMatrix),K.currentProgram=et,K.uniformsList=null,et}function bx(P){if(P.uniformsList===null){const G=P.currentProgram.getUniforms();P.uniformsList=ff.seqWithValue(G.seq,P.uniforms)}return P.uniformsList}function Ex(P,G){const Y=Oe.get(P);Y.outputColorSpace=G.outputColorSpace,Y.batching=G.batching,Y.batchingColor=G.batchingColor,Y.instancing=G.instancing,Y.instancingColor=G.instancingColor,Y.instancingMorph=G.instancingMorph,Y.skinning=G.skinning,Y.morphTargets=G.morphTargets,Y.morphNormals=G.morphNormals,Y.morphColors=G.morphColors,Y.morphTargetsCount=G.morphTargetsCount,Y.numClippingPlanes=G.numClippingPlanes,Y.numIntersection=G.numClipIntersection,Y.vertexAlphas=G.vertexAlphas,Y.vertexTangents=G.vertexTangents,Y.toneMapping=G.toneMapping}function qR(P,G,Y,K,W){G.isScene!==!0&&(G=ke),L.resetTextureUnits();const fe=G.fog,we=K.isMeshStandardMaterial?G.environment:null,De=C===null?w.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:Ln,Le=(K.isMeshStandardMaterial?X:R).get(K.envMap||we),Xe=K.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,et=!!Y.attributes.tangent&&(!!K.normalMap||K.anisotropy>0),Ie=!!Y.morphAttributes.position,gt=!!Y.morphAttributes.normal,Tt=!!Y.morphAttributes.color;let Rt=Ws;K.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(Rt=w.toneMapping);const Gn=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,vt=Gn!==void 0?Gn.length:0,Fe=Oe.get(K),Ci=p.state.lights;if(ee===!0&&(se===!0||P!==E)){const xr=P===E&&K.id===A;de.setState(K,P,xr)}let yt=!1;K.version===Fe.__version?(Fe.needsLights&&Fe.lightsStateVersion!==Ci.state.version||Fe.outputColorSpace!==De||W.isBatchedMesh&&Fe.batching===!1||!W.isBatchedMesh&&Fe.batching===!0||W.isBatchedMesh&&Fe.batchingColor===!0&&W.colorTexture===null||W.isBatchedMesh&&Fe.batchingColor===!1&&W.colorTexture!==null||W.isInstancedMesh&&Fe.instancing===!1||!W.isInstancedMesh&&Fe.instancing===!0||W.isSkinnedMesh&&Fe.skinning===!1||!W.isSkinnedMesh&&Fe.skinning===!0||W.isInstancedMesh&&Fe.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&Fe.instancingColor===!1&&W.instanceColor!==null||W.isInstancedMesh&&Fe.instancingMorph===!0&&W.morphTexture===null||W.isInstancedMesh&&Fe.instancingMorph===!1&&W.morphTexture!==null||Fe.envMap!==Le||K.fog===!0&&Fe.fog!==fe||Fe.numClippingPlanes!==void 0&&(Fe.numClippingPlanes!==de.numPlanes||Fe.numIntersection!==de.numIntersection)||Fe.vertexAlphas!==Xe||Fe.vertexTangents!==et||Fe.morphTargets!==Ie||Fe.morphNormals!==gt||Fe.morphColors!==Tt||Fe.toneMapping!==Rt||Fe.morphTargetsCount!==vt)&&(yt=!0):(yt=!0,Fe.__version=K.version);let Or=Fe.currentProgram;yt===!0&&(Or=Du(K,G,W));let na=!1,rr=!1,$l=!1;const Pt=Or.getUniforms(),oi=Fe.uniforms;if(Ue.useProgram(Or.program)&&(na=!0,rr=!0,$l=!0),K.id!==A&&(A=K.id,rr=!0),na||E!==P){Ue.buffers.depth.getReversed()?(Z.copy(P.projectionMatrix),pF(Z),mF(Z),Pt.setValue(H,"projectionMatrix",Z)):Pt.setValue(H,"projectionMatrix",P.projectionMatrix),Pt.setValue(H,"viewMatrix",P.matrixWorldInverse);const ss=Pt.map.cameraPosition;ss!==void 0&&ss.setValue(H,Me.setFromMatrixPosition(P.matrixWorld)),qe.logarithmicDepthBuffer&&Pt.setValue(H,"logDepthBufFC",2/(Math.log(P.far+1)/Math.LN2)),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&Pt.setValue(H,"isOrthographic",P.isOrthographicCamera===!0),E!==P&&(E=P,rr=!0,$l=!0)}if(W.isSkinnedMesh){Pt.setOptional(H,W,"bindMatrix"),Pt.setOptional(H,W,"bindMatrixInverse");const xr=W.skeleton;xr&&(xr.boneTexture===null&&xr.computeBoneTexture(),Pt.setValue(H,"boneTexture",xr.boneTexture,L))}W.isBatchedMesh&&(Pt.setOptional(H,W,"batchingTexture"),Pt.setValue(H,"batchingTexture",W._matricesTexture,L),Pt.setOptional(H,W,"batchingIdTexture"),Pt.setValue(H,"batchingIdTexture",W._indirectTexture,L),Pt.setOptional(H,W,"batchingColorTexture"),W._colorsTexture!==null&&Pt.setValue(H,"batchingColorTexture",W._colorsTexture,L));const Yl=Y.morphAttributes;if((Yl.position!==void 0||Yl.normal!==void 0||Yl.color!==void 0)&&Ge.update(W,Y,Or),(rr||Fe.receiveShadow!==W.receiveShadow)&&(Fe.receiveShadow=W.receiveShadow,Pt.setValue(H,"receiveShadow",W.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(oi.envMap.value=Le,oi.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),K.isMeshStandardMaterial&&K.envMap===null&&G.environment!==null&&(oi.envMapIntensity.value=G.environmentIntensity),rr&&(Pt.setValue(H,"toneMappingExposure",w.toneMappingExposure),Fe.needsLights&&ZR(oi,$l),fe&&K.fog===!0&&ge.refreshFogUniforms(oi,fe),ge.refreshMaterialUniforms(oi,K,D,j,p.state.transmissionRenderTarget[P.id]),ff.upload(H,bx(Fe),oi,L)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(ff.upload(H,bx(Fe),oi,L),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&Pt.setValue(H,"center",W.center),Pt.setValue(H,"modelViewMatrix",W.modelViewMatrix),Pt.setValue(H,"normalMatrix",W.normalMatrix),Pt.setValue(H,"modelMatrix",W.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){const xr=K.uniformsGroups;for(let ss=0,os=xr.length;ss<os;ss++){const Tx=xr[ss];B.update(Tx,Or),B.bind(Tx,Or)}}return Or}function ZR(P,G){P.ambientLightColor.needsUpdate=G,P.lightProbe.needsUpdate=G,P.directionalLights.needsUpdate=G,P.directionalLightShadows.needsUpdate=G,P.pointLights.needsUpdate=G,P.pointLightShadows.needsUpdate=G,P.spotLights.needsUpdate=G,P.spotLightShadows.needsUpdate=G,P.rectAreaLights.needsUpdate=G,P.hemisphereLights.needsUpdate=G}function QR(P){return P.isMeshLambertMaterial||P.isMeshToonMaterial||P.isMeshPhongMaterial||P.isMeshStandardMaterial||P.isShadowMaterial||P.isShaderMaterial&&P.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(P,G,Y){Oe.get(P.texture).__webglTexture=G,Oe.get(P.depthTexture).__webglTexture=Y;const K=Oe.get(P);K.__hasExternalTextures=!0,K.__autoAllocateDepthBuffer=Y===void 0,K.__autoAllocateDepthBuffer||Ve.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),K.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(P,G){const Y=Oe.get(P);Y.__webglFramebuffer=G,Y.__useDefaultFramebuffer=G===void 0},this.setRenderTarget=function(P,G=0,Y=0){C=P,T=G,b=Y;let K=!0,W=null,fe=!1,we=!1;if(P){const Le=Oe.get(P);if(Le.__useDefaultFramebuffer!==void 0)Ue.bindFramebuffer(H.FRAMEBUFFER,null),K=!1;else if(Le.__webglFramebuffer===void 0)L.setupRenderTarget(P);else if(Le.__hasExternalTextures)L.rebindTextures(P,Oe.get(P.texture).__webglTexture,Oe.get(P.depthTexture).__webglTexture);else if(P.depthBuffer){const Ie=P.depthTexture;if(Le.__boundDepthTexture!==Ie){if(Ie!==null&&Oe.has(Ie)&&(P.width!==Ie.image.width||P.height!==Ie.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");L.setupDepthRenderbuffer(P)}}const Xe=P.texture;(Xe.isData3DTexture||Xe.isDataArrayTexture||Xe.isCompressedArrayTexture)&&(we=!0);const et=Oe.get(P).__webglFramebuffer;P.isWebGLCubeRenderTarget?(Array.isArray(et[G])?W=et[G][Y]:W=et[G],fe=!0):P.samples>0&&L.useMultisampledRTT(P)===!1?W=Oe.get(P).__webglMultisampledFramebuffer:Array.isArray(et)?W=et[Y]:W=et,N.copy(P.viewport),F.copy(P.scissor),I=P.scissorTest}else N.copy(J).multiplyScalar(D).floor(),F.copy(le).multiplyScalar(D).floor(),I=pe;if(Ue.bindFramebuffer(H.FRAMEBUFFER,W)&&K&&Ue.drawBuffers(P,W),Ue.viewport(N),Ue.scissor(F),Ue.setScissorTest(I),fe){const Le=Oe.get(P.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+G,Le.__webglTexture,Y)}else if(we){const Le=Oe.get(P.texture),Xe=G||0;H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,Le.__webglTexture,Y||0,Xe)}A=-1},this.readRenderTargetPixels=function(P,G,Y,K,W,fe,we){if(!(P&&P.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let De=Oe.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&we!==void 0&&(De=De[we]),De){Ue.bindFramebuffer(H.FRAMEBUFFER,De);try{const Le=P.texture,Xe=Le.format,et=Le.type;if(!qe.textureFormatReadable(Xe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!qe.textureTypeReadable(et)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}G>=0&&G<=P.width-K&&Y>=0&&Y<=P.height-W&&H.readPixels(G,Y,K,W,Ze.convert(Xe),Ze.convert(et),fe)}finally{const Le=C!==null?Oe.get(C).__webglFramebuffer:null;Ue.bindFramebuffer(H.FRAMEBUFFER,Le)}}},this.readRenderTargetPixelsAsync=async function(P,G,Y,K,W,fe,we){if(!(P&&P.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let De=Oe.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&we!==void 0&&(De=De[we]),De){const Le=P.texture,Xe=Le.format,et=Le.type;if(!qe.textureFormatReadable(Xe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qe.textureTypeReadable(et))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(G>=0&&G<=P.width-K&&Y>=0&&Y<=P.height-W){Ue.bindFramebuffer(H.FRAMEBUFFER,De);const Ie=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,Ie),H.bufferData(H.PIXEL_PACK_BUFFER,fe.byteLength,H.STREAM_READ),H.readPixels(G,Y,K,W,Ze.convert(Xe),Ze.convert(et),0);const gt=C!==null?Oe.get(C).__webglFramebuffer:null;Ue.bindFramebuffer(H.FRAMEBUFFER,gt);const Tt=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await hF(H,Tt,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,Ie),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,fe),H.deleteBuffer(Ie),H.deleteSync(Tt),fe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(P,G=null,Y=0){P.isTexture!==!0&&(wc("WebGLRenderer: copyFramebufferToTexture function signature has changed."),G=arguments[0]||null,P=arguments[1]);const K=Math.pow(2,-Y),W=Math.floor(P.image.width*K),fe=Math.floor(P.image.height*K),we=G!==null?G.x:0,De=G!==null?G.y:0;L.setTexture2D(P,0),H.copyTexSubImage2D(H.TEXTURE_2D,Y,0,0,we,De,W,fe),Ue.unbindTexture()},this.copyTextureToTexture=function(P,G,Y=null,K=null,W=0){P.isTexture!==!0&&(wc("WebGLRenderer: copyTextureToTexture function signature has changed."),K=arguments[0]||null,P=arguments[1],G=arguments[2],W=arguments[3]||0,Y=null);let fe,we,De,Le,Xe,et,Ie,gt,Tt;const Rt=P.isCompressedTexture?P.mipmaps[W]:P.image;Y!==null?(fe=Y.max.x-Y.min.x,we=Y.max.y-Y.min.y,De=Y.isBox3?Y.max.z-Y.min.z:1,Le=Y.min.x,Xe=Y.min.y,et=Y.isBox3?Y.min.z:0):(fe=Rt.width,we=Rt.height,De=Rt.depth||1,Le=0,Xe=0,et=0),K!==null?(Ie=K.x,gt=K.y,Tt=K.z):(Ie=0,gt=0,Tt=0);const Gn=Ze.convert(G.format),vt=Ze.convert(G.type);let Fe;G.isData3DTexture?(L.setTexture3D(G,0),Fe=H.TEXTURE_3D):G.isDataArrayTexture||G.isCompressedArrayTexture?(L.setTexture2DArray(G,0),Fe=H.TEXTURE_2D_ARRAY):(L.setTexture2D(G,0),Fe=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,G.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,G.unpackAlignment);const Ci=H.getParameter(H.UNPACK_ROW_LENGTH),yt=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Or=H.getParameter(H.UNPACK_SKIP_PIXELS),na=H.getParameter(H.UNPACK_SKIP_ROWS),rr=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,Rt.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,Rt.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Le),H.pixelStorei(H.UNPACK_SKIP_ROWS,Xe),H.pixelStorei(H.UNPACK_SKIP_IMAGES,et);const $l=P.isDataArrayTexture||P.isData3DTexture,Pt=G.isDataArrayTexture||G.isData3DTexture;if(P.isRenderTargetTexture||P.isDepthTexture){const oi=Oe.get(P),Yl=Oe.get(G),xr=Oe.get(oi.__renderTarget),ss=Oe.get(Yl.__renderTarget);Ue.bindFramebuffer(H.READ_FRAMEBUFFER,xr.__webglFramebuffer),Ue.bindFramebuffer(H.DRAW_FRAMEBUFFER,ss.__webglFramebuffer);for(let os=0;os<De;os++)$l&&H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Oe.get(P).__webglTexture,W,et+os),P.isDepthTexture?(Pt&&H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Oe.get(G).__webglTexture,W,Tt+os),H.blitFramebuffer(Le,Xe,fe,we,Ie,gt,fe,we,H.DEPTH_BUFFER_BIT,H.NEAREST)):Pt?H.copyTexSubImage3D(Fe,W,Ie,gt,Tt+os,Le,Xe,fe,we):H.copyTexSubImage2D(Fe,W,Ie,gt,Tt+os,Le,Xe,fe,we);Ue.bindFramebuffer(H.READ_FRAMEBUFFER,null),Ue.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Pt?P.isDataTexture||P.isData3DTexture?H.texSubImage3D(Fe,W,Ie,gt,Tt,fe,we,De,Gn,vt,Rt.data):G.isCompressedArrayTexture?H.compressedTexSubImage3D(Fe,W,Ie,gt,Tt,fe,we,De,Gn,Rt.data):H.texSubImage3D(Fe,W,Ie,gt,Tt,fe,we,De,Gn,vt,Rt):P.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,W,Ie,gt,fe,we,Gn,vt,Rt.data):P.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,W,Ie,gt,Rt.width,Rt.height,Gn,Rt.data):H.texSubImage2D(H.TEXTURE_2D,W,Ie,gt,fe,we,Gn,vt,Rt);H.pixelStorei(H.UNPACK_ROW_LENGTH,Ci),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,yt),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Or),H.pixelStorei(H.UNPACK_SKIP_ROWS,na),H.pixelStorei(H.UNPACK_SKIP_IMAGES,rr),W===0&&G.generateMipmaps&&H.generateMipmap(Fe),Ue.unbindTexture()},this.copyTextureToTexture3D=function(P,G,Y=null,K=null,W=0){return P.isTexture!==!0&&(wc("WebGLRenderer: copyTextureToTexture3D function signature has changed."),Y=arguments[0]||null,K=arguments[1]||null,P=arguments[2],G=arguments[3],W=arguments[4]||0),wc('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(P,G,Y,K,W)},this.initRenderTarget=function(P){Oe.get(P).__webglFramebuffer===void 0&&L.setupRenderTarget(P)},this.initTexture=function(P){P.isCubeTexture?L.setTextureCube(P,0):P.isData3DTexture?L.setTexture3D(P,0):P.isDataArrayTexture||P.isCompressedArrayTexture?L.setTexture2DArray(P,0):L.setTexture2D(P,0),Ue.unbindTexture()},this.resetState=function(){T=0,b=0,C=null,Ue.reset(),be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Wi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorspace=$e._getDrawingBufferColorSpace(e),n.unpackColorSpace=$e._getUnpackColorSpace()}}class EH extends Et{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 Qt,this.environmentIntensity=1,this.environmentRotation=new Qt,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}}class TH{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=Fv,this.updateRanges=[],this.version=0,this.uuid=ei()}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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ei()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const n=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ei()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const In=new k;class ex{constructor(e,n,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,r=this.data.count;n<r;n++)In.fromBufferAttribute(this,n),In.applyMatrix4(e),this.setXYZ(n,In.x,In.y,In.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)In.fromBufferAttribute(this,n),In.applyNormalMatrix(e),this.setXYZ(n,In.x,In.y,In.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)In.fromBufferAttribute(this,n),In.transformDirection(e),this.setXYZ(n,In.x,In.y,In.z);return this}getComponent(e,n){let r=this.array[e*this.data.stride+this.offset+n];return this.normalized&&(r=Kr(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=wt(r,this.array)),this.data.array[e*this.data.stride+this.offset+n]=r,this}setX(e,n){return this.normalized&&(n=wt(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=wt(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=wt(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=wt(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=Kr(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Kr(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Kr(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Kr(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=wt(n,this.array),r=wt(r,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this}setXYZ(e,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(n=wt(n,this.array),r=wt(r,this.array),i=wt(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(n=wt(n,this.array),r=wt(r,this.array),i=wt(i,this.array),s=wt(s,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return new hn(new this.array.constructor(n),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ex(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const ES=new k,TS=new ut,AS=new ut,AH=new k,CS=new Ce,Md=new k,mm=new bi,RS=new Ce,gm=new zl;class gA extends je{constructor(e,n){super(e,n),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Aw,this.bindMatrix=new Ce,this.bindMatrixInverse=new Ce,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Gt),this.boundingBox.makeEmpty();const n=e.getAttribute("position");for(let r=0;r<n.count;r++)this.getVertexPosition(r,Md),this.boundingBox.expandByPoint(Md)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new bi),this.boundingSphere.makeEmpty();const n=e.getAttribute("position");for(let r=0;r<n.count;r++)this.getVertexPosition(r,Md),this.boundingSphere.expandByPoint(Md)}copy(e,n){return super.copy(e,n),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,n){const r=this.material,i=this.matrixWorld;r!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),mm.copy(this.boundingSphere),mm.applyMatrix4(i),e.ray.intersectsSphere(mm)!==!1&&(RS.copy(i).invert(),gm.copy(e.ray).applyMatrix4(RS),!(this.boundingBox!==null&&gm.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,n,gm)))}getVertexPosition(e,n){return super.getVertexPosition(e,n),this.applyBoneTransform(e,n),n}bind(e,n){this.skeleton=e,n===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),n=this.matrixWorld),this.bindMatrix.copy(n),this.bindMatrixInverse.copy(n).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new ut,n=this.geometry.attributes.skinWeight;for(let r=0,i=n.count;r<i;r++){e.fromBufferAttribute(n,r);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),n.setXYZW(r,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Aw?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===FO?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,n){const r=this.skeleton,i=this.geometry;TS.fromBufferAttribute(i.attributes.skinIndex,e),AS.fromBufferAttribute(i.attributes.skinWeight,e),ES.copy(n).applyMatrix4(this.bindMatrix),n.set(0,0,0);for(let s=0;s<4;s++){const o=AS.getComponent(s);if(o!==0){const a=TS.getComponent(s);CS.multiplyMatrices(r.bones[a].matrixWorld,r.boneInverses[a]),n.addScaledVector(AH.copy(ES).applyMatrix4(CS),o)}}return n.applyMatrix4(this.bindMatrixInverse)}}class Jf extends Et{constructor(){super(),this.isBone=!0,this.type="Bone"}}class vA extends on{constructor(e=null,n=1,r=1,i,s,o,a,l,c=Hn,f=Hn,u,d){super(null,o,a,l,c,f,i,s,u,d),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const PS=new Ce,CH=new Ce;class Kh{constructor(e=[],n=[]){this.uuid=ei(),this.bones=e.slice(0),this.boneInverses=n,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,n=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),n.length===0)this.calculateInverses();else if(e.length!==n.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,i=this.bones.length;r<i;r++)this.boneInverses.push(new Ce)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,n=this.bones.length;e<n;e++){const r=new Ce;this.bones[e]&&r.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let e=0,n=this.bones.length;e<n;e++){const r=this.bones[e];r&&r.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,n=this.bones.length;e<n;e++){const r=this.bones[e];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){const e=this.bones,n=this.boneInverses,r=this.boneMatrices,i=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const a=e[s]?e[s].matrixWorld:CH;PS.multiplyMatrices(a,n[s]),PS.toArray(r,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Kh(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const n=new Float32Array(e*e*4);n.set(this.boneMatrices);const r=new vA(n,e,e,Cr,qr);return r.needsUpdate=!0,this.boneMatrices=n,this.boneTexture=r,this}getBoneByName(e){for(let n=0,r=this.bones.length;n<r;n++){const i=this.bones[n];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,n){this.uuid=e.uuid;for(let r=0,i=e.bones.length;r<i;r++){const s=e.bones[r];let o=n[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Jf),this.bones.push(o),this.boneInverses.push(new Ce().fromArray(e.boneInverses[r]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const n=this.bones,r=this.boneInverses;for(let i=0,s=n.length;i<s;i++){const o=n[i];e.bones.push(o.uuid);const a=r[i];e.boneInverses.push(a.toArray())}return e}}class Bv extends hn{constructor(e,n,r,i=1){super(e,n,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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 ya=new Ce,NS=new Ce,bd=[],DS=new Gt,RH=new Ce,cc=new je,uc=new bi;class PH extends je{constructor(e,n,r){super(e,n),this.isInstancedMesh=!0,this.instanceMatrix=new Bv(new Float32Array(r*16),16),this.instanceColor=null,this.morphTexture=null,this.count=r,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<r;i++)this.setMatrixAt(i,RH)}computeBoundingBox(){const e=this.geometry,n=this.count;this.boundingBox===null&&(this.boundingBox=new Gt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let r=0;r<n;r++)this.getMatrixAt(r,ya),DS.copy(e.boundingBox).applyMatrix4(ya),this.boundingBox.union(DS)}computeBoundingSphere(){const e=this.geometry,n=this.count;this.boundingSphere===null&&(this.boundingSphere=new bi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let r=0;r<n;r++)this.getMatrixAt(r,ya),uc.copy(e.boundingSphere).applyMatrix4(ya),this.boundingSphere.union(uc)}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){n.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,n){n.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,n){const r=n.morphTargetInfluences,i=this.morphTexture.source.data.data,s=r.length+1,o=e*s+1;for(let a=0;a<r.length;a++)r[a]=i[o+a]}raycast(e,n){const r=this.matrixWorld,i=this.count;if(cc.geometry=this.geometry,cc.material=this.material,cc.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),uc.copy(this.boundingSphere),uc.applyMatrix4(r),e.ray.intersectsSphere(uc)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,ya),NS.multiplyMatrices(r,ya),cc.matrixWorld=NS,cc.raycast(e,bd);for(let o=0,a=bd.length;o<a;o++){const l=bd[o];l.instanceId=s,l.object=this,n.push(l)}bd.length=0}}setColorAt(e,n){this.instanceColor===null&&(this.instanceColor=new Bv(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),n.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,n){n.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,n){const r=n.morphTargetInfluences,i=r.length+1;this.morphTexture===null&&(this.morphTexture=new vA(new Float32Array(i*this.count),i,this.count,Wy,qr));const s=this.morphTexture.source.data.data;let o=0;for(let c=0;c<r.length;c++)o+=r[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=i*e;s[l]=a,s.set(r,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class ii extends Nr{static get type(){return"LineBasicMaterial"}constructor(e){super(),this.isLineBasicMaterial=!0,this.color=new Pe(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 eh=new k,th=new k,LS=new Ce,dc=new zl,Ed=new bi,vm=new k,IS=new k;class wi extends Et{constructor(e=new Wt,n=new ii){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,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,r=[0];for(let i=1,s=n.count;i<s;i++)eh.fromBufferAttribute(n,i-1),th.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=eh.distanceTo(th);e.setAttribute("lineDistance",new At(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ed.copy(r.boundingSphere),Ed.applyMatrix4(i),Ed.radius+=s,e.ray.intersectsSphere(Ed)===!1)return;LS.copy(i).invert(),dc.copy(e.ray).applyMatrix4(LS);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,f=r.index,d=r.attributes.position;if(f!==null){const h=Math.max(0,o.start),m=Math.min(f.count,o.start+o.count);for(let v=h,g=m-1;v<g;v+=c){const p=f.getX(v),x=f.getX(v+1),_=Td(this,e,dc,l,p,x);_&&n.push(_)}if(this.isLineLoop){const v=f.getX(m-1),g=f.getX(h),p=Td(this,e,dc,l,v,g);p&&n.push(p)}}else{const h=Math.max(0,o.start),m=Math.min(d.count,o.start+o.count);for(let v=h,g=m-1;v<g;v+=c){const p=Td(this,e,dc,l,v,v+1);p&&n.push(p)}if(this.isLineLoop){const v=Td(this,e,dc,l,m-1,h);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function Td(t,e,n,r,i,s){const o=t.geometry.attributes.position;if(eh.fromBufferAttribute(o,i),th.fromBufferAttribute(o,s),n.distanceSqToSegment(eh,th,vm,IS)>r)return;vm.applyMatrix4(t.matrixWorld);const l=e.ray.origin.distanceTo(vm);if(!(l<e.near||l>e.far))return{distance:l,point:IS.clone().applyMatrix4(t.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:t}}const kS=new k,OS=new k;class to extends wi{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,r=[];for(let i=0,s=n.count;i<s;i+=2)kS.fromBufferAttribute(n,i),OS.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+kS.distanceTo(OS);e.setAttribute("lineDistance",new At(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class NH extends wi{constructor(e,n){super(e,n),this.isLineLoop=!0,this.type="LineLoop"}}class yA extends Nr{static get type(){return"PointsMaterial"}constructor(e){super(),this.isPointsMaterial=!0,this.color=new Pe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const FS=new Ce,zv=new zl,Ad=new bi,Cd=new k;class DH extends Et{constructor(e=new Wt,n=new yA){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=n,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}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ad.copy(r.boundingSphere),Ad.applyMatrix4(i),Ad.radius+=s,e.ray.intersectsSphere(Ad)===!1)return;FS.copy(i).invert(),zv.copy(e.ray).applyMatrix4(FS);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=r.index,u=r.attributes.position;if(c!==null){const d=Math.max(0,o.start),h=Math.min(c.count,o.start+o.count);for(let m=d,v=h;m<v;m++){const g=c.getX(m);Cd.fromBufferAttribute(u,g),US(Cd,g,l,i,e,n,this)}}else{const d=Math.max(0,o.start),h=Math.min(u.count,o.start+o.count);for(let m=d,v=h;m<v;m++)Cd.fromBufferAttribute(u,m),US(Cd,m,l,i,e,n,this)}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function US(t,e,n,r,i,s,o){const a=zv.distanceSqToPoint(t);if(a<n){const l=new k;zv.closestPointToPoint(t,l),l.applyMatrix4(r);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class LH{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,n){const r=this.getUtoTmapping(e);return this.getPoint(r,n)}getPoints(e=5){const n=[];for(let r=0;r<=e;r++)n.push(this.getPoint(r/e));return n}getSpacedPoints(e=5){const n=[];for(let r=0;r<=e;r++)n.push(this.getPointAt(r/e));return n}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const n=[];let r,i=this.getPoint(0),s=0;n.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),n.push(s),i=r;return this.cacheArcLengths=n,n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,n){const r=this.getLengths();let i=0;const s=r.length;let o;n?o=n:o=e*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const f=r[i],d=r[i+1]-f,h=(o-f)/d;return(i+h)/(s-1)}getTangent(e,n){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=n||(o.isVector2?new ze:new k);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,n){const r=this.getUtoTmapping(e);return this.getTangent(r,n)}computeFrenetFrames(e,n){const r=new k,i=[],s=[],o=[],a=new k,l=new Ce;for(let h=0;h<=e;h++){const m=h/e;i[h]=this.getTangentAt(m,new k)}s[0]=new k,o[0]=new k;let c=Number.MAX_VALUE;const f=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);f<=c&&(c=f,r.set(1,0,0)),u<=c&&(c=u,r.set(0,1,0)),d<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let h=1;h<=e;h++){if(s[h]=s[h-1].clone(),o[h]=o[h-1].clone(),a.crossVectors(i[h-1],i[h]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(rn(i[h-1].dot(i[h]),-1,1));s[h].applyMatrix4(l.makeRotationAxis(a,m))}o[h].crossVectors(i[h],s[h])}if(n===!0){let h=Math.acos(rn(s[0].dot(s[e]),-1,1));h/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(h=-h);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],h*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}const Rd=new k,Pd=new k,ym=new k,Nd=new Er;class cu extends Wt{constructor(e=null,n=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:n},e!==null){const i=Math.pow(10,4),s=Math.cos(Qa*n),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],f=["a","b","c"],u=new Array(3),d={},h=[];for(let m=0;m<l;m+=3){o?(c[0]=o.getX(m),c[1]=o.getX(m+1),c[2]=o.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:v,b:g,c:p}=Nd;if(v.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),p.fromBufferAttribute(a,c[2]),Nd.getNormal(ym),u[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,u[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,u[2]=`${Math.round(p.x*i)},${Math.round(p.y*i)},${Math.round(p.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let x=0;x<3;x++){const _=(x+1)%3,w=u[x],M=u[_],T=Nd[f[x]],b=Nd[f[_]],C=`${w}_${M}`,A=`${M}_${w}`;A in d&&d[A]?(ym.dot(d[A].normal)<=s&&(h.push(T.x,T.y,T.z),h.push(b.x,b.y,b.z)),d[A]=null):C in d||(d[C]={index0:c[x],index1:c[_],normal:ym.clone()})}}for(const m in d)if(d[m]){const{index0:v,index1:g}=d[m];Rd.fromBufferAttribute(a,v),Pd.fromBufferAttribute(a,g),h.push(Rd.x,Rd.y,Rd.z),h.push(Pd.x,Pd.y,Pd.z)}this.setAttribute("position",new At(h,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}const IH={triangulate:function(t,e,n=2){const r=e&&e.length,i=r?e[0]*n:t.length;let s=xA(t,0,i,n,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c,f,u,d,h;if(r&&(s=BH(t,e,s,n)),t.length>80*n){a=c=t[0],l=f=t[1];for(let m=n;m<i;m+=n)u=t[m],d=t[m+1],u<a&&(a=u),d<l&&(l=d),u>c&&(c=u),d>f&&(f=d);h=Math.max(c-a,f-l),h=h!==0?32767/h:0}return uu(s,o,n,a,l,h,0),o}};function xA(t,e,n,r,i){let s,o;if(i===qH(t,e,n,r)>0)for(s=e;s<n;s+=r)o=BS(s,t[s],t[s+1],o);else for(s=n-r;s>=e;s-=r)o=BS(s,t[s],t[s+1],o);return o&&qh(o,o.next)&&(fu(o),o=o.next),o}function Xo(t,e){if(!t)return t;e||(e=t);let n=t,r;do if(r=!1,!n.steiner&&(qh(n,n.next)||Ut(n.prev,n,n.next)===0)){if(fu(n),n=e=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==e);return e}function uu(t,e,n,r,i,s,o){if(!t)return;!o&&s&&GH(t,r,i,s);let a=t,l,c;for(;t.prev!==t.next;){if(l=t.prev,c=t.next,s?OH(t,r,i,s):kH(t)){e.push(l.i/n|0),e.push(t.i/n|0),e.push(c.i/n|0),fu(t),t=c.next,a=c.next;continue}if(t=c,t===a){o?o===1?(t=FH(Xo(t),e,n),uu(t,e,n,r,i,s,2)):o===2&&UH(t,e,n,r,i,s):uu(Xo(t),e,n,r,i,s,1);break}}}function kH(t){const e=t.prev,n=t,r=t.next;if(Ut(e,n,r)>=0)return!1;const i=e.x,s=n.x,o=r.x,a=e.y,l=n.y,c=r.y,f=i<s?i<o?i:o:s<o?s:o,u=a<l?a<c?a:c:l<c?l:c,d=i>s?i>o?i:o:s>o?s:o,h=a>l?a>c?a:c:l>c?l:c;let m=r.next;for(;m!==e;){if(m.x>=f&&m.x<=d&&m.y>=u&&m.y<=h&&Ua(i,a,s,l,o,c,m.x,m.y)&&Ut(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function OH(t,e,n,r){const i=t.prev,s=t,o=t.next;if(Ut(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,f=i.y,u=s.y,d=o.y,h=a<l?a<c?a:c:l<c?l:c,m=f<u?f<d?f:d:u<d?u:d,v=a>l?a>c?a:c:l>c?l:c,g=f>u?f>d?f:d:u>d?u:d,p=Hv(h,m,e,n,r),x=Hv(v,g,e,n,r);let _=t.prevZ,w=t.nextZ;for(;_&&_.z>=p&&w&&w.z<=x;){if(_.x>=h&&_.x<=v&&_.y>=m&&_.y<=g&&_!==i&&_!==o&&Ua(a,f,l,u,c,d,_.x,_.y)&&Ut(_.prev,_,_.next)>=0||(_=_.prevZ,w.x>=h&&w.x<=v&&w.y>=m&&w.y<=g&&w!==i&&w!==o&&Ua(a,f,l,u,c,d,w.x,w.y)&&Ut(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;_&&_.z>=p;){if(_.x>=h&&_.x<=v&&_.y>=m&&_.y<=g&&_!==i&&_!==o&&Ua(a,f,l,u,c,d,_.x,_.y)&&Ut(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;w&&w.z<=x;){if(w.x>=h&&w.x<=v&&w.y>=m&&w.y<=g&&w!==i&&w!==o&&Ua(a,f,l,u,c,d,w.x,w.y)&&Ut(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function FH(t,e,n){let r=t;do{const i=r.prev,s=r.next.next;!qh(i,s)&&_A(i,r,r.next,s)&&du(i,s)&&du(s,i)&&(e.push(i.i/n|0),e.push(r.i/n|0),e.push(s.i/n|0),fu(r),fu(r.next),r=t=s),r=r.next}while(r!==t);return Xo(r)}function UH(t,e,n,r,i,s){let o=t;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&$H(o,a)){let l=wA(o,a);o=Xo(o,o.next),l=Xo(l,l.next),uu(o,e,n,r,i,s,0),uu(l,e,n,r,i,s,0);return}a=a.next}o=o.next}while(o!==t)}function BH(t,e,n,r){const i=[];let s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*r,l=s<o-1?e[s+1]*r:t.length,c=xA(t,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(XH(c));for(i.sort(zH),s=0;s<i.length;s++)n=HH(i[s],n);return n}function zH(t,e){return t.x-e.x}function HH(t,e){const n=jH(t,e);if(!n)return e;const r=wA(n,t);return Xo(r,r.next),Xo(n,n.next)}function jH(t,e){let n=e,r=-1/0,i;const s=t.x,o=t.y;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){const d=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(d<=s&&d>r&&(r=d,i=n.x<n.next.x?n:n.next,d===s))return i}n=n.next}while(n!==e);if(!i)return null;const a=i,l=i.x,c=i.y;let f=1/0,u;n=i;do s>=n.x&&n.x>=l&&s!==n.x&&Ua(o<c?s:r,o,l,c,o<c?r:s,o,n.x,n.y)&&(u=Math.abs(o-n.y)/(s-n.x),du(n,t)&&(u<f||u===f&&(n.x>i.x||n.x===i.x&&VH(i,n)))&&(i=n,f=u)),n=n.next;while(n!==a);return i}function VH(t,e){return Ut(t.prev,t,e.prev)<0&&Ut(e.next,t,t.next)<0}function GH(t,e,n,r){let i=t;do i.z===0&&(i.z=Hv(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,WH(i)}function WH(t){let e,n,r,i,s,o,a,l,c=1;do{for(n=t,t=null,s=null,o=0;n;){for(o++,r=n,a=0,e=0;e<c&&(a++,r=r.nextZ,!!r);e++);for(l=c;a>0||l>0&&r;)a!==0&&(l===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:t=i,i.prevZ=s,s=i;n=r}s.nextZ=null,c*=2}while(o>1);return t}function Hv(t,e,n,r,i){return t=(t-n)*i|0,e=(e-r)*i|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function XH(t){let e=t,n=t;do(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next;while(e!==t);return n}function Ua(t,e,n,r,i,s,o,a){return(i-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(r-a)>=(n-o)*(e-a)&&(n-o)*(s-a)>=(i-o)*(r-a)}function $H(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!YH(t,e)&&(du(t,e)&&du(e,t)&&KH(t,e)&&(Ut(t.prev,t,e.prev)||Ut(t,e.prev,e))||qh(t,e)&&Ut(t.prev,t,t.next)>0&&Ut(e.prev,e,e.next)>0)}function Ut(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function qh(t,e){return t.x===e.x&&t.y===e.y}function _A(t,e,n,r){const i=Ld(Ut(t,e,n)),s=Ld(Ut(t,e,r)),o=Ld(Ut(n,r,t)),a=Ld(Ut(n,r,e));return!!(i!==s&&o!==a||i===0&&Dd(t,n,e)||s===0&&Dd(t,r,e)||o===0&&Dd(n,t,r)||a===0&&Dd(n,e,r))}function Dd(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Ld(t){return t>0?1:t<0?-1:0}function YH(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&_A(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function du(t,e){return Ut(t.prev,t,t.next)<0?Ut(t,e,t.next)>=0&&Ut(t,t.prev,e)>=0:Ut(t,e,t.prev)<0||Ut(t,t.next,e)<0}function KH(t,e){let n=t,r=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do n.y>s!=n.next.y>s&&n.next.y!==n.y&&i<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==t);return r}function wA(t,e){const n=new jv(t.i,t.x,t.y),r=new jv(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function BS(t,e,n,r){const i=new jv(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function fu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function jv(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qH(t,e,n,r){let i=0;for(let s=e,o=n-r;s<n;s+=r)i+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return i}class tx{static area(e){const n=e.length;let r=0;for(let i=n-1,s=0;s<n;i=s++)r+=e[i].x*e[s].y-e[s].x*e[i].y;return r*.5}static isClockWise(e){return tx.area(e)<0}static triangulateShape(e,n){const r=[],i=[],s=[];zS(e),HS(r,e);let o=e.length;n.forEach(zS);for(let l=0;l<n.length;l++)i.push(o),o+=n[l].length,HS(r,n[l]);const a=IH.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function zS(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function HS(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class $o extends Wt{constructor(e=1,n=32,r=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:n,heightSegments:r,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},n=Math.max(3,Math.floor(n)),r=Math.max(2,Math.floor(r));const l=Math.min(o+a,Math.PI);let c=0;const f=[],u=new k,d=new k,h=[],m=[],v=[],g=[];for(let p=0;p<=r;p++){const x=[],_=p/r;let w=0;p===0&&o===0?w=.5/n:p===r&&l===Math.PI&&(w=-.5/n);for(let M=0;M<=n;M++){const T=M/n;u.x=-e*Math.cos(i+T*s)*Math.sin(o+_*a),u.y=e*Math.cos(o+_*a),u.z=e*Math.sin(i+T*s)*Math.sin(o+_*a),m.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),g.push(T+w,1-_),x.push(c++)}f.push(x)}for(let p=0;p<r;p++)for(let x=0;x<n;x++){const _=f[p][x+1],w=f[p][x],M=f[p+1][x],T=f[p+1][x+1];(p!==0||o>0)&&h.push(_,w,T),(p!==r-1||l<Math.PI)&&h.push(w,M,T)}this.setIndex(h),this.setAttribute("position",new At(m,3)),this.setAttribute("normal",new At(v,3)),this.setAttribute("uv",new At(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $o(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Pn extends Nr{static get type(){return"MeshStandardMaterial"}constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.color=new Pe(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 Pe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wh,this.normalScale=new ze(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 Qt,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 si extends Pn{static get type(){return"MeshPhysicalMaterial"}constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ze(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return rn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(n){this.ior=(1+.4*n)/(1-.4*n)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Pe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Pe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Pe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class el extends Nr{static get type(){return"MeshPhongMaterial"}constructor(e){super(),this.isMeshPhongMaterial=!0,this.color=new Pe(16777215),this.specular=new Pe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Pe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wh,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qt,this.combine=Vh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class nx extends Nr{static get type(){return"MeshLambertMaterial"}constructor(e){super(),this.isMeshLambertMaterial=!0,this.color=new Pe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Pe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wh,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qt,this.combine=Vh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class rx extends ii{static get type(){return"LineDashedMaterial"}constructor(e){super(),this.isLineDashedMaterial=!0,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Id(t,e,n){return!t||!n&&t.constructor===e?t:typeof e.BYTES_PER_ELEMENT=="number"?new e(t):Array.prototype.slice.call(t)}function ZH(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function QH(t){function e(i,s){return t[i]-t[s]}const n=t.length,r=new Array(n);for(let i=0;i!==n;++i)r[i]=i;return r.sort(e),r}function jS(t,e,n){const r=t.length,i=new t.constructor(r);for(let s=0,o=0;o!==r;++s){const a=n[s]*e;for(let l=0;l!==e;++l)i[o++]=t[a+l]}return i}function SA(t,e,n,r){let i=1,s=t[0];for(;s!==void 0&&s[r]===void 0;)s=t[i++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(e.push(s.time),n.push.apply(n,o)),s=t[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(e.push(s.time),o.toArray(n,n.length)),s=t[i++];while(s!==void 0);else do o=s[r],o!==void 0&&(e.push(s.time),n.push(o)),s=t[i++];while(s!==void 0)}class Au{constructor(e,n,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new n.constructor(r),this.sampleValues=n,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){const n=this.parameterPositions;let r=this._cachedIndex,i=n[r],s=n[r-1];e:{t:{let o;n:{r:if(!(e<i)){for(let a=r+2;;){if(i===void 0){if(e<s)break r;return r=n.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=i,i=n[++r],e<i)break t}o=n.length;break n}if(!(e>=s)){const a=n[1];e<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(i=s,s=n[--r-1],e>=s)break t}o=r,r=0;break n}break e}for(;r<o;){const a=r+o>>>1;e<n[a]?o=a:r=a+1}if(i=n[r],s=n[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return r=n.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,i)}return this.interpolate_(r,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const n=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)n[o]=r[s+o];return n}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class JH extends Au{constructor(e,n,r,i){super(e,n,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Cw,endingEnd:Cw}}intervalChanged_(e,n,r){const i=this.parameterPositions;let s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Rw:s=e,a=2*n-r;break;case Pw:s=i.length-2,a=n+i[s]-i[s+1];break;default:s=e,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case Rw:o=e,l=2*r-n;break;case Pw:o=1,l=r+i[1]-i[0];break;default:o=e-1,l=n}const c=(r-n)*.5,f=this.valueSize;this._weightPrev=c/(n-a),this._weightNext=c/(l-r),this._offsetPrev=s*f,this._offsetNext=o*f}interpolate_(e,n,r,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,f=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,m=(r-n)/(i-n),v=m*m,g=v*m,p=-d*g+2*d*v-d*m,x=(1+d)*g+(-1.5-2*d)*v+(-.5+d)*m+1,_=(-1-h)*g+(1.5+h)*v+.5*m,w=h*g-h*v;for(let M=0;M!==a;++M)s[M]=p*o[f+M]+x*o[c+M]+_*o[l+M]+w*o[u+M];return s}}class ej extends Au{constructor(e,n,r,i){super(e,n,r,i)}interpolate_(e,n,r,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,f=(r-n)/(i-n),u=1-f;for(let d=0;d!==a;++d)s[d]=o[c+d]*u+o[l+d]*f;return s}}class tj extends Au{constructor(e,n,r,i){super(e,n,r,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Ei{constructor(e,n,r,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(n===void 0||n.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Id(n,this.TimeBufferType),this.values=Id(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const n=e.constructor;let r;if(n.toJSON!==this.toJSON)r=n.toJSON(e);else{r={name:e.name,times:Id(e.times,Array),values:Id(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(r.interpolation=i)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new tj(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new ej(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new JH(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let n;switch(e){case ou:n=this.InterpolantFactoryMethodDiscrete;break;case au:n=this.InterpolantFactoryMethodLinear;break;case Hp:n=this.InterpolantFactoryMethodSmooth;break}if(n===void 0){const r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=n,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ou;case this.InterpolantFactoryMethodLinear:return au;case this.InterpolantFactoryMethodSmooth:return Hp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const n=this.times;for(let r=0,i=n.length;r!==i;++r)n[r]+=e}return this}scale(e){if(e!==1){const n=this.times;for(let r=0,i=n.length;r!==i;++r)n[r]*=e}return this}trim(e,n){const r=this.times,i=r.length;let s=0,o=i-1;for(;s!==i&&r[s]<e;)++s;for(;o!==-1&&r[o]>n;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=r.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const n=this.getValueSize();n-Math.floor(n)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&ZH(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),n=this.values.slice(),r=this.getValueSize(),i=this.getInterpolation()===Hp,s=e.length-1;let o=1;for(let a=1;a<s;++a){let l=!1;const c=e[a],f=e[a+1];if(c!==f&&(a!==1||c!==e[0]))if(i)l=!0;else{const u=a*r,d=u-r,h=u+r;for(let m=0;m!==r;++m){const v=n[u+m];if(v!==n[d+m]||v!==n[h+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const u=a*r,d=o*r;for(let h=0;h!==r;++h)n[d+h]=n[u+h]}++o}}if(s>0){e[o]=e[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)n[l+c]=n[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=n.slice(0,o*r)):(this.times=e,this.values=n),this}clone(){const e=this.times.slice(),n=this.values.slice(),r=this.constructor,i=new r(this.name,e,n);return i.createInterpolant=this.createInterpolant,i}}Ei.prototype.TimeBufferType=Float32Array;Ei.prototype.ValueBufferType=Float32Array;Ei.prototype.DefaultInterpolation=au;class Vl extends Ei{constructor(e,n,r){super(e,n,r)}}Vl.prototype.ValueTypeName="bool";Vl.prototype.ValueBufferType=Array;Vl.prototype.DefaultInterpolation=ou;Vl.prototype.InterpolantFactoryMethodLinear=void 0;Vl.prototype.InterpolantFactoryMethodSmooth=void 0;class MA extends Ei{}MA.prototype.ValueTypeName="color";class Yo extends Ei{}Yo.prototype.ValueTypeName="number";class nj extends Au{constructor(e,n,r,i){super(e,n,r,i)}interpolate_(e,n,r,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-n)/(i-n);let c=e*a;for(let f=c+a;c!==f;c+=4)nn.slerpFlat(s,0,o,c-a,o,c,l);return s}}class no extends Ei{InterpolantFactoryMethodLinear(e){return new nj(this.times,this.values,this.getValueSize(),e)}}no.prototype.ValueTypeName="quaternion";no.prototype.InterpolantFactoryMethodSmooth=void 0;class Gl extends Ei{constructor(e,n,r){super(e,n,r)}}Gl.prototype.ValueTypeName="string";Gl.prototype.ValueBufferType=Array;Gl.prototype.DefaultInterpolation=ou;Gl.prototype.InterpolantFactoryMethodLinear=void 0;Gl.prototype.InterpolantFactoryMethodSmooth=void 0;class Ko extends Ei{}Ko.prototype.ValueTypeName="vector";class bA{constructor(e="",n=-1,r=[],i=UO){this.name=e,this.tracks=r,this.duration=n,this.blendMode=i,this.uuid=ei(),this.duration<0&&this.resetDuration()}static parse(e){const n=[],r=e.tracks,i=1/(e.fps||1);for(let o=0,a=r.length;o!==a;++o)n.push(ij(r[o]).scale(i));const s=new this(e.name,e.duration,n,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const n=[],r=e.tracks,i={name:e.name,duration:e.duration,tracks:n,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=r.length;s!==o;++s)n.push(Ei.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(e,n,r,i){const s=n.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);const f=QH(l);l=jS(l,1,f),c=jS(c,1,f),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Yo(".morphTargetInfluences["+n[a].name+"]",l,c).scale(1/r))}return new this(e,-1,o)}static findByName(e,n){let r=e;if(!Array.isArray(e)){const i=e;r=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<r.length;i++)if(r[i].name===n)return r[i];return null}static CreateClipsFromMorphTargetSequences(e,n,r){const i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],f=c.name.match(s);if(f&&f.length>1){const u=f[1];let d=i[u];d||(i[u]=d=[]),d.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],n,r));return o}static parseAnimation(e,n){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const r=function(u,d,h,m,v){if(h.length!==0){const g=[],p=[];SA(h,g,p,m),g.length!==0&&v.push(new u(d,g,p))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const d=c[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const h={};let m;for(m=0;m<d.length;m++)if(d[m].morphTargets)for(let v=0;v<d[m].morphTargets.length;v++)h[d[m].morphTargets[v]]=-1;for(const v in h){const g=[],p=[];for(let x=0;x!==d[m].morphTargets.length;++x){const _=d[m];g.push(_.time),p.push(_.morphTarget===v?1:0)}i.push(new Yo(".morphTargetInfluence["+v+"]",g,p))}l=h.length*o}else{const h=".bones["+n[u].name+"]";r(Ko,h+".position",d,"pos",i),r(no,h+".quaternion",d,"rot",i),r(Ko,h+".scale",d,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){const e=this.tracks;let n=0;for(let r=0,i=e.length;r!==i;++r){const s=this.tracks[r];n=Math.max(n,s.times[s.times.length-1])}return this.duration=n,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let n=0;n<this.tracks.length;n++)e=e&&this.tracks[n].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function rj(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Yo;case"vector":case"vector2":case"vector3":case"vector4":return Ko;case"color":return MA;case"quaternion":return no;case"bool":case"boolean":return Vl;case"string":return Gl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}function ij(t){if(t.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=rj(t.type);if(t.times===void 0){const n=[],r=[];SA(t.keys,n,r,"value"),t.times=n,t.values=r}return e.parse!==void 0?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const ks={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class sj{constructor(e,n,r){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=n,this.onError=r,this.itemStart=function(f){a++,s===!1&&i.onStart!==void 0&&i.onStart(f,o,a),s=!0},this.itemEnd=function(f){o++,i.onProgress!==void 0&&i.onProgress(f,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(f){i.onError!==void 0&&i.onError(f)},this.resolveURL=function(f){return l?l(f):f},this.setURLModifier=function(f){return l=f,this},this.addHandler=function(f,u){return c.push(f,u),this},this.removeHandler=function(f){const u=c.indexOf(f);return u!==-1&&c.splice(u,2),this},this.getHandler=function(f){for(let u=0,d=c.length;u<d;u+=2){const h=c[u],m=c[u+1];if(h.global&&(h.lastIndex=0),h.test(f))return m}return null}}}const oj=new sj;class Si{constructor(e){this.manager=e!==void 0?e:oj,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,n){const r=this;return new Promise(function(i,s){r.load(e,i,n,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Si.DEFAULT_MATERIAL_NAME="__DEFAULT";const ki={};class aj extends Error{constructor(e,n){super(e),this.response=n}}class hu extends Si{constructor(e){super(e)}load(e,n,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=ks.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{n&&n(s),this.manager.itemEnd(e)},0),s;if(ki[e]!==void 0){ki[e].push({onLoad:n,onProgress:r,onError:i});return}ki[e]=[],ki[e].push({onLoad:n,onProgress:r,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const f=ki[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=d?parseInt(d):0,m=h!==0;let v=0;const g=new ReadableStream({start(p){x();function x(){u.read().then(({done:_,value:w})=>{if(_)p.close();else{v+=w.byteLength;const M=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:h});for(let T=0,b=f.length;T<b;T++){const C=f[T];C.onProgress&&C.onProgress(M)}p.enqueue(w),x()}},_=>{p.error(_)})}}});return new Response(g)}else throw new aj(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(f=>new DOMParser().parseFromString(f,a));case"json":return c.json();default:if(a===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(d);return c.arrayBuffer().then(m=>h.decode(m))}}}).then(c=>{ks.add(e,c);const f=ki[e];delete ki[e];for(let u=0,d=f.length;u<d;u++){const h=f[u];h.onLoad&&h.onLoad(c)}}).catch(c=>{const f=ki[e];if(f===void 0)throw this.manager.itemError(e),c;delete ki[e];for(let u=0,d=f.length;u<d;u++){const h=f[u];h.onError&&h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class lj extends Si{constructor(e){super(e)}load(e,n,r,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ks.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){n&&n(o),s.manager.itemEnd(e)},0),o;const a=lu("img");function l(){f(),ks.add(e,this),n&&n(this),s.manager.itemEnd(e)}function c(u){f(),i&&i(u),s.manager.itemError(e),s.manager.itemEnd(e)}function f(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class EA extends Si{constructor(e){super(e)}load(e,n,r,i){const s=new on,o=new lj(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,n!==void 0&&n(s)},r,i),s}}class ao extends Et{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Pe(e),this.intensity=n}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,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}}const xm=new Ce,VS=new k,GS=new k;class ix{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ze(512,512),this.map=null,this.mapPass=null,this.matrix=new Ce,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Qy,this._frameExtents=new ze(1,1),this._viewportCount=1,this._viewports=[new ut(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;VS.setFromMatrixPosition(e.matrixWorld),n.position.copy(VS),GS.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(GS),n.updateMatrixWorld(),xm.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xm),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(xm)}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.mapSize.copy(e.mapSize),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}}class cj extends ix{constructor(){super(new dn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const n=this.camera,r=Cl*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||n.far;(r!==n.fov||i!==n.aspect||s!==n.far)&&(n.fov=r,n.aspect=i,n.far=s,n.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class TA extends ao{constructor(e,n,r=0,i=Math.PI/3,s=0,o=2){super(e,n),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new cj}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const WS=new Ce,fc=new k,_m=new k;class uj extends ix{constructor(){super(new dn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ze(4,2),this._viewportCount=6,this._viewports=[new ut(2,1,1,1),new ut(0,1,1,1),new ut(3,1,1,1),new ut(1,1,1,1),new ut(3,0,1,1),new ut(1,0,1,1)],this._cubeDirections=[new k(1,0,0),new k(-1,0,0),new k(0,0,1),new k(0,0,-1),new k(0,1,0),new k(0,-1,0)],this._cubeUps=[new k(0,1,0),new k(0,1,0),new k(0,1,0),new k(0,1,0),new k(0,0,1),new k(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),fc.setFromMatrixPosition(e.matrixWorld),r.position.copy(fc),_m.copy(r.position),_m.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(_m),r.updateMatrixWorld(),i.makeTranslation(-fc.x,-fc.y,-fc.z),WS.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(WS)}}class Vv extends ao{constructor(e,n,r=0,i=2){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new uj}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class dj extends ix{constructor(){super(new Hi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class sx extends ao{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new dj}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class AA extends ao{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class tl{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let n="";for(let r=0,i=e.length;r<i;r++)n+=String.fromCharCode(e[r]);try{return decodeURIComponent(escape(n))}catch{return n}}static extractUrlBase(e){const n=e.lastIndexOf("/");return n===-1?"./":e.slice(0,n+1)}static resolveURL(e,n){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(n)&&/^\//.test(e)&&(n=n.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:n+e)}}class fj extends Si{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,n,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ks.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(c=>{n&&n(c),s.manager.itemEnd(e)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){n&&n(o),s.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return ks.add(e,c),n&&n(c),s.manager.itemEnd(e),c}).catch(function(c){i&&i(c),ks.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});ks.add(e,l),s.manager.itemStart(e)}}const ox="\\[\\]\\.:\\/",hj=new RegExp("["+ox+"]","g"),ax="[^"+ox+"]",pj="[^"+ox.replace("\\.","")+"]",mj=/((?:WC+[\/:])*)/.source.replace("WC",ax),gj=/(WCOD+)?/.source.replace("WCOD",pj),vj=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ax),yj=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ax),xj=new RegExp("^"+mj+gj+vj+yj+"$"),_j=["material","materials","bones","map"];class wj{constructor(e,n,r){const i=r||pt.parseTrackName(n);this._targetGroup=e,this._bindings=e.subscribe_(n,i)}getValue(e,n){this.bind();const r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(e,n)}setValue(e,n){const r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(e,n)}bind(){const e=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=e.length;n!==r;++n)e[n].bind()}unbind(){const e=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=e.length;n!==r;++n)e[n].unbind()}}class pt{constructor(e,n,r){this.path=n,this.parsedPath=r||pt.parseTrackName(n),this.node=pt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,n,r){return e&&e.isAnimationObjectGroup?new pt.Composite(e,n,r):new pt(e,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(hj,"")}static parseTrackName(e){const n=xj.exec(e);if(n===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=r.nodeName.substring(i+1);_j.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,n){if(n===void 0||n===""||n==="."||n===-1||n===e.name||n===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(n);if(r!==void 0)return r}if(e.children){const r=function(s){for(let o=0;o<s.length;o++){const a=s[o];if(a.name===n||a.uuid===n)return a;const l=r(a.children);if(l)return l}return null},i=r(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,n){e[n]=this.targetObject[this.propertyName]}_getValue_array(e,n){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)e[n++]=r[i]}_getValue_arrayElement(e,n){e[n]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,n){this.resolvedProperty.toArray(e,n)}_setValue_direct(e,n){this.targetObject[this.propertyName]=e[n]}_setValue_direct_setNeedsUpdate(e,n){this.targetObject[this.propertyName]=e[n],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,n){this.targetObject[this.propertyName]=e[n],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,n){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[n++]}_setValue_array_setNeedsUpdate(e,n){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[n++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,n){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[n++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,n){this.resolvedProperty[this.propertyIndex]=e[n]}_setValue_arrayElement_setNeedsUpdate(e,n){this.resolvedProperty[this.propertyIndex]=e[n],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,n){this.resolvedProperty[this.propertyIndex]=e[n],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,n){this.resolvedProperty.fromArray(e,n)}_setValue_fromArray_setNeedsUpdate(e,n){this.resolvedProperty.fromArray(e,n),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,n){this.resolvedProperty.fromArray(e,n),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,n){this.bind(),this.getValue(e,n)}_setValue_unbound(e,n){this.bind(),this.setValue(e,n)}bind(){let e=this.node;const n=this.parsedPath,r=n.objectName,i=n.propertyName;let s=n.propertyIndex;if(e||(e=pt.findNode(this.rootNode,n.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(r){let c=n.objectIndex;switch(r){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let f=0;f<e.length;f++)if(e[f].name===c){c=f;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[r]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[i];if(o===void 0){const c=n.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}pt.Composite=wj;pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pt.prototype.GetterByBindingType=[pt.prototype._getValue_direct,pt.prototype._getValue_array,pt.prototype._getValue_arrayElement,pt.prototype._getValue_toArray];pt.prototype.SetterByBindingTypeAndVersioning=[[pt.prototype._setValue_direct,pt.prototype._setValue_direct_setNeedsUpdate,pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_array,pt.prototype._setValue_array_setNeedsUpdate,pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_arrayElement,pt.prototype._setValue_arrayElement_setNeedsUpdate,pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_fromArray,pt.prototype._setValue_fromArray_setNeedsUpdate,pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const XS=new Ce;class Sj{constructor(e,n,r=0,i=1/0){this.ray=new zl(e,n),this.near=r,this.far=i,this.camera=null,this.layers=new qy,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,n){this.ray.set(e,n)}setFromCamera(e,n){n.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(n.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(n).sub(this.ray.origin).normalize(),this.camera=n):n.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(n.near+n.far)/(n.near-n.far)).unproject(n),this.ray.direction.set(0,0,-1).transformDirection(n.matrixWorld),this.camera=n):console.error("THREE.Raycaster: Unsupported camera type: "+n.type)}setFromXRController(e){return XS.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(XS),this}intersectObject(e,n=!0,r=[]){return Gv(e,this,r,n),r.sort($S),r}intersectObjects(e,n=!0,r=[]){for(let i=0,s=e.length;i<s;i++)Gv(e[i],this,r,n);return r.sort($S),r}}function $S(t,e){return t.distance-e.distance}function Gv(t,e,n,r){let i=!0;if(t.layers.test(e.layers)&&t.raycast(e,n)===!1&&(i=!1),i===!0&&r===!0){const s=t.children;for(let o=0,a=s.length;o<a;o++)Gv(s[o],e,n,!0)}}class YS{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(rn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class KS extends to{constructor(e=10,n=10,r=4473924,i=8947848){r=new Pe(r),i=new Pe(i);const s=n/2,o=e/n,a=e/2,l=[],c=[];for(let d=0,h=0,m=-a;d<=n;d++,m+=o){l.push(-a,0,m,a,0,m),l.push(m,0,-a,m,0,a);const v=d===s?r:i;v.toArray(c,h),h+=3,v.toArray(c,h),h+=3,v.toArray(c,h),h+=3,v.toArray(c,h),h+=3}const f=new Wt;f.setAttribute("position",new At(l,3)),f.setAttribute("color",new At(c,3));const u=new ii({vertexColors:!0,toneMapped:!1});super(f,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Mj extends to{constructor(e=1){const n=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Wt;i.setAttribute("position",new At(n,3)),i.setAttribute("color",new At(r,3));const s=new ii({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new Pe,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(n),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class bj extends ta{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(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:By}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=By);const Ej=()=>{const t=S.useRef(null),e=S.useRef(null),n=S.useRef(null),r=S.useRef(null),i=S.useCallback(()=>{if(!t.current||!n.current)return;const s=new Gt,o=[];t.current.traverse(d=>{d instanceof je&&!d.userData.isHelper&&d.type!=="GridHelper"&&d.type!=="AxesHelper"&&!d.userData.isPrimitive&&!d.userData.isPoint&&!d.userData.isMeasurementGroup&&o.push(d)}),o.length>0&&o.forEach(d=>{s.expandByObject(d)});const a=s.getSize(new k),l=Math.max(a.x,a.z),c=o.length>0?Math.max(l*2,10):10,f=Math.ceil(c);console.log("🔄 Updating adaptive grid:",{boundingBox:{x:a.x,y:a.y,z:a.z},maxDimension:l,gridSize:c,divisions:f,meshCount:o.length}),t.current.remove(n.current);const u=new KS(c,f,11397364,11590369);n.current=u,u.position.set(0,0,0),t.current.add(u)},[]);return S.useEffect(()=>{const s=new EH;t.current=s;const o=new Mj(2);e.current=o,o.position.set(0,0,0),s.add(o);const a=new KS(10,10,11397364,11590369);return n.current=a,a.position.set(0,0,0),a.visible=!0,s.add(a),()=>{}},[]),{sceneRef:t,ucsHelperRef:e,gridHelperRef:n,workplaneRef:r,updateAdaptiveGrid:i}},Tj=t=>{const e=S.useRef(null),n=S.useRef(null),r=S.useRef(null),[i,s]=S.useState(!1),o=S.useCallback((a,l)=>{if(!t.current||!(l!=null&&l.current))return;const c=l.current,f=c.object.position.clone(),u=c.target.clone();if(a&&n.current){const d=n.current;d.position.copy(f),d.lookAt(u),c.object=d,r.current=d,s(!0)}else if(!a&&e.current){const d=e.current;d.position.copy(f),d.lookAt(u),c.object=d,r.current=d,s(!1)}c.target.copy(u),c.update()},[t]);return S.useEffect(()=>{if(!t.current)return;const a=t.current.clientWidth,l=t.current.clientHeight,c=a/l,f=new dn(60,c,.01,2e3);e.current=f,f.position.set(7,7,7),f.lookAt(0,0,0);const u=10,d=new Hi(-u*c/2,u*c/2,u/2,-u/2,.01,2e3);n.current=d,d.position.set(7,7,7),d.lookAt(0,0,0),r.current=f},[t]),{perspectiveCameraRef:e,orthographicCameraRef:n,activeCameraRef:r,isOrthographic:i,switchCamera:o}};class Aj extends Et{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new ze(.5,.5),this.addEventListener("removed",function(){this.traverse(function(n){n.element instanceof n.element.ownerDocument.defaultView.Element&&n.element.parentNode!==null&&n.element.remove()})})}copy(e,n){return super.copy(e,n),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const xa=new k,qS=new Ce,ZS=new Ce,QS=new k,JS=new k;class Cj{constructor(e={}){const n=this;let r,i,s,o;const a={objects:new WeakMap},l=e.element!==void 0?e.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:r,height:i}},this.render=function(m,v){m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),v.parent===null&&v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),qS.copy(v.matrixWorldInverse),ZS.multiplyMatrices(v.projectionMatrix,qS),f(m,m,v),h(m)},this.setSize=function(m,v){r=m,i=v,s=r/2,o=i/2,l.style.width=m+"px",l.style.height=v+"px"};function c(m){m.isCSS2DObject&&(m.element.style.display="none");for(let v=0,g=m.children.length;v<g;v++)c(m.children[v])}function f(m,v,g){if(m.visible===!1){c(m);return}if(m.isCSS2DObject){xa.setFromMatrixPosition(m.matrixWorld),xa.applyMatrix4(ZS);const p=xa.z>=-1&&xa.z<=1&&m.layers.test(g.layers)===!0,x=m.element;x.style.display=p===!0?"":"none",p===!0&&(m.onBeforeRender(n,v,g),x.style.transform="translate("+-100*m.center.x+"%,"+-100*m.center.y+"%)translate("+(xa.x*s+s)+"px,"+(-xa.y*o+o)+"px)",x.parentNode!==l&&l.appendChild(x),m.onAfterRender(n,v,g));const _={distanceToCameraSquared:u(g,m)};a.objects.set(m,_)}for(let p=0,x=m.children.length;p<x;p++)f(m.children[p],v,g)}function u(m,v){return QS.setFromMatrixPosition(m.matrixWorld),JS.setFromMatrixPosition(v.matrixWorld),QS.distanceToSquared(JS)}function d(m){const v=[];return m.traverseVisible(function(g){g.isCSS2DObject&&v.push(g)}),v}function h(m){const v=d(m).sort(function(p,x){if(p.renderOrder!==x.renderOrder)return x.renderOrder-p.renderOrder;const _=a.objects.get(p).distanceToCameraSquared,w=a.objects.get(x).distanceToCameraSquared;return _-w}),g=v.length;for(let p=0,x=v.length;p<x;p++)v[p].element.style.zIndex=g-p}}}const Rj=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||navigator.maxTouchPoints&&navigator.maxTouchPoints>1,Pj=t=>{const e=S.useRef(null),n=S.useRef(null);return S.useEffect(()=>{if(!t.current)return;const r=t.current.clientWidth,i=t.current.clientHeight,s=Rj(),o=new bH({antialias:!s,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:s?"default":"high-performance",stencil:!1,depth:!0,preserveDrawingBuffer:!1});e.current=o,o.setSize(r,i);const a=Math.min(window.devicePixelRatio,2);if(o.setPixelRatio(a),o.shadowMap.enabled=!0,o.shadowMap.type=s?uO:zy,o.shadowMap.autoUpdate=!0,o.toneMapping=Hy,o.toneMappingExposure=1.2,o.outputColorSpace=ft,o.sortObjects=!0,o.info.autoReset=!1,o.setScissorTest(!1),s){const c=o.capabilities.maxTextures,f=o.capabilities.precision;console.log("Mobile capabilities:",{maxTextures:c,precision:f})}t.current.appendChild(o.domElement);const l=new Cj;return n.current=l,l.setSize(r,i),l.domElement.style.position="absolute",l.domElement.style.top="0",l.domElement.style.pointerEvents="none",l.domElement.style.zIndex="1",s&&(l.domElement.style.webkitTransform="translate3d(0,0,0)",l.domElement.style.transform="translate3d(0,0,0)"),t.current.appendChild(l.domElement),()=>{t.current&&(o.domElement.parentNode&&t.current.removeChild(o.domElement),l.domElement.parentNode&&t.current.removeChild(l.domElement)),o.dispose(),o.forceContextLoss()}},[t]),{rendererRef:e,labelRendererRef:n}},eM={type:"change"},lx={type:"start"},CA={type:"end"},kd=new zl,tM=new Ms,Nj=Math.cos(70*gn.DEG2RAD),en=new k,Wn=2*Math.PI,bt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},wm=1e-6;class Dj extends bj{constructor(e,n=null){super(e,n),this.state=bt.NONE,this.enabled=!0,this.target=new k,this.cursor=new k,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.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:Yi.ROTATE,MIDDLE:Yi.DOLLY,RIGHT:Yi.PAN},this.touches={ONE:gi.ROTATE,TWO:gi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new k,this._lastQuaternion=new nn,this._lastTargetPosition=new k,this._quat=new nn().setFromUnitVectors(e.up,new k(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new YS,this._sphericalDelta=new YS,this._scale=1,this._panOffset=new k,this._rotateStart=new ze,this._rotateEnd=new ze,this._rotateDelta=new ze,this._panStart=new ze,this._panEnd=new ze,this._panDelta=new ze,this._dollyStart=new ze,this._dollyEnd=new ze,this._dollyDelta=new ze,this._dollyDirection=new k,this._mouse=new ze,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Ij.bind(this),this._onPointerDown=Lj.bind(this),this._onPointerUp=kj.bind(this),this._onContextMenu=jj.bind(this),this._onMouseWheel=Uj.bind(this),this._onKeyDown=Bj.bind(this),this._onTouchStart=zj.bind(this),this._onTouchMove=Hj.bind(this),this._onMouseDown=Oj.bind(this),this._onMouseMove=Fj.bind(this),this._interceptControlDown=Vj.bind(this),this._interceptControlUp=Gj.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(eM),this.update(),this.state=bt.NONE}update(e=null){const n=this.object.position;en.copy(n).sub(this.target),en.applyQuaternion(this._quat),this._spherical.setFromVector3(en),this.autoRotate&&this.state===bt.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 r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=Wn:r>Math.PI&&(r-=Wn),i<-Math.PI?i+=Wn:i>Math.PI&&(i-=Wn),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,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 s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(en.setFromSpherical(this._spherical),en.applyQuaternion(this._quatInverse),n.copy(this.target).add(en),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=en.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new k(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new k(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=en.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(kd.origin.copy(this.object.position),kd.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(kd.direction))<Nj?this.object.lookAt(this.target):(tM.setFromNormalAndCoplanarPoint(this.object.up,this.target),kd.intersectPlane(tM,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>wm||8*(1-this._lastQuaternion.dot(this.object.quaternion))>wm||this._lastTargetPosition.distanceToSquared(this.target)>wm?(this.dispatchEvent(eM),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Wn/60*this.autoRotateSpeed*e:Wn/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){en.setFromMatrixColumn(n,0),en.multiplyScalar(-e),this._panOffset.add(en)}_panUp(e,n){this.screenSpacePanning===!0?en.setFromMatrixColumn(n,1):(en.setFromMatrixColumn(n,0),en.crossVectors(this.object.up,en)),en.multiplyScalar(e),this._panOffset.add(en)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;en.copy(i).sub(this.target);let s=en.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*n*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.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 r=this.domElement.getBoundingClientRect(),i=e-r.left,s=n-r.top,o=r.width,a=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Wn*this._rotateDelta.x/n.clientHeight),this._rotateUp(Wn*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._rotateUp(Wn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-Wn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(Wn*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-Wn*this.rotateSpeed/this.domElement.clientHeight):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),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_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 r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Wn*this._rotateDelta.x/n.clientHeight),this._rotateUp(Wn*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),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}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),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+n.x)*.5,a=(e.pageY+n.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let 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 ze,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,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function Lj(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function Ij(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function kj(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(CA),this.state=bt.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function Oj(t){let e;switch(t.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 Yi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=bt.DOLLY;break;case Yi.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=bt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=bt.ROTATE}break;case Yi.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=bt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=bt.PAN}break;default:this.state=bt.NONE}this.state!==bt.NONE&&this.dispatchEvent(lx)}function Fj(t){switch(this.state){case bt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case bt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case bt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function Uj(t){this.enabled===!1||this.enableZoom===!1||this.state!==bt.NONE||(t.preventDefault(),this.dispatchEvent(lx),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(CA))}function Bj(t){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(t)}function zj(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case gi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=bt.TOUCH_ROTATE;break;case gi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=bt.TOUCH_PAN;break;default:this.state=bt.NONE}break;case 2:switch(this.touches.TWO){case gi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=bt.TOUCH_DOLLY_PAN;break;case gi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=bt.TOUCH_DOLLY_ROTATE;break;default:this.state=bt.NONE}break;default:this.state=bt.NONE}this.state!==bt.NONE&&this.dispatchEvent(lx)}function Hj(t){switch(this._trackPointer(t),this.state){case bt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case bt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case bt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case bt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=bt.NONE}}function jj(t){this.enabled!==!1&&t.preventDefault()}function Vj(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Gj(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Wj=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||navigator.maxTouchPoints&&navigator.maxTouchPoints>1,Xj=(t,e)=>{const n=S.useRef(null);return S.useEffect(()=>{if(!t||!e)return;const r=new Dj(t,e.domElement);n.current=r;const i=Wj();if(r.enableDamping=!0,r.dampingFactor=i?.1:.05,r.screenSpacePanning=!1,r.minDistance=.1,r.maxDistance=1e3,r.maxPolarAngle=Math.PI,i){r.touches={ONE:gi.ROTATE,TWO:gi.DOLLY_PAN},r.rotateSpeed=.8,r.zoomSpeed=1.2,r.panSpeed=1,r.minZoom=.1,r.maxZoom=10;const s=e.domElement;s.style.touchAction="none";const o=s.style;o.webkitTouchCallout="none",o.webkitUserSelect="none";const a=c=>{(c.touches.length>1||c.target===s)&&c.preventDefault()};document.addEventListener("touchmove",a,{passive:!1});const l=c=>c.preventDefault();return s.addEventListener("contextmenu",l),()=>{r.dispose(),document.removeEventListener("touchmove",a),s.removeEventListener("contextmenu",l)}}else r.mouseButtons={LEFT:Yi.ROTATE,MIDDLE:Yi.DOLLY,RIGHT:Yi.PAN},r.touches={ONE:gi.ROTATE,TWO:gi.DOLLY_PAN},r.rotateSpeed=.5,r.zoomSpeed=.8,r.panSpeed=.8;return()=>{r.dispose()}},[t,e]),{controlsRef:n}},$j=(t,e,n,r,i)=>{const s=S.useCallback(()=>{if(!t.current||!r||!i)return;const o=t.current.clientWidth,a=t.current.clientHeight,l=o/a;e&&(e.aspect=l,e.updateProjectionMatrix()),n&&(n.left=-10*l/2,n.right=10*l/2,n.top=5,n.bottom=-5,n.updateProjectionMatrix()),r.setSize(o,a),i.setSize(o,a)},[t,e,n,r,i]);return S.useEffect(()=>(window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}),[s]),{handleResize:s}},Yj=(t,e,n,r,i)=>{const s=S.useRef(null);return S.useEffect(()=>{if(!t||!e||!n||!r||!i)return;let o=0;const l=1e3/60,c=f=>{s.current=requestAnimationFrame(c),f-o>=l&&(i.update(),n.render(t,e),r.render(t,e),n.info.reset(),o=f)};return c(0),()=>{s.current&&cancelAnimationFrame(s.current)}},[t,e,n,r,i]),{animationIdRef:s}},Kj=t=>{S.useRef(Kf.getInstance());const{sceneRef:e,ucsHelperRef:n,gridHelperRef:r,workplaneRef:i,updateAdaptiveGrid:s}=Ej(),{perspectiveCameraRef:o,orthographicCameraRef:a,activeCameraRef:l,isOrthographic:c,switchCamera:f}=Tj(t),{rendererRef:u,labelRendererRef:d}=Pj(t),{controlsRef:h}=Xj(o.current,u.current),m=S.useCallback(g=>{f(g,h)},[f,h]);$j(t,o.current,a.current,u.current,d.current),Yj(e.current,l.current,u.current,d.current,h.current);const{metrics:v}=aO(u.current);return{sceneRef:e,cameraRef:l,perspectiveCameraRef:o,rendererRef:u,labelRendererRef:d,controlsRef:h,gridHelperRef:r,workplaneRef:i,performanceMetrics:v,isOrthographic:c,switchCamera:m,updateAdaptiveGrid:s}},qj=(t,e,n,r)=>{const i=S.useRef(null),s=S.useRef(null);return S.useEffect(()=>{if(!t)return;const o=new AA(n.color,n.intensity);s.current=o,t.add(o);const a=new sx(e.color,e.intensity);i.current=a;const l=e.azimuth*Math.PI/180,c=e.elevation*Math.PI/180,f=Math.cos(c)*Math.sin(l),u=Math.sin(c),d=Math.cos(c)*Math.cos(l);a.position.set(f*10,u*10,d*10),a.castShadow=e.castShadow;const h={low:512,medium:1024,high:2048};return a.shadow.mapSize.width=h[r],a.shadow.mapSize.height=h[r],a.shadow.camera.near=.5,a.shadow.camera.far=50,a.shadow.camera.left=-10,a.shadow.camera.right=10,a.shadow.camera.top=10,a.shadow.camera.bottom=-10,t.add(a),()=>{o&&t.remove(o),a&&t.remove(a)}},[t]),S.useEffect(()=>{if(!i.current)return;const o=i.current;o.intensity=e.intensity,o.color.set(e.color),o.castShadow=e.castShadow;const a=e.azimuth*Math.PI/180,l=e.elevation*Math.PI/180,c=Math.cos(l)*Math.sin(a),f=Math.sin(l),u=Math.cos(l)*Math.cos(a);o.position.set(c*10,f*10,u*10)},[e]),S.useEffect(()=>{s.current&&(s.current.intensity=n.intensity,s.current.color.set(n.color))},[n]),S.useEffect(()=>{if(!i.current)return;const o={low:512,medium:1024,high:2048},a=i.current;a.shadow.mapSize.width=o[r],a.shadow.mapSize.height=o[r]},[r]),{directionalLightRef:i,ambientLightRef:s}},Zj=(t,e,n)=>{const r=S.useRef(null),i=S.useRef(!1);return S.useEffect(()=>{!t||i.current||(t.background=new Pe("#F8F8F8"),i.current=!0)},[t,e.skyColor]),S.useEffect(()=>{n&&(n.visible=e.showGrid,n.userData.isHelper=!0)},[e.showGrid,n]),S.useEffect(()=>{t&&(t.background=new Pe("#F8F8F8"))},[t]),{planeRef:r}},Qj="modulepreload",Jj=function(t){return"/"+t},nM={},eV=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(l=>{if(l=Jj(l),l in nM)return;nM[l]=!0;const c=l.endsWith(".css"),f=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${f}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":Qj,c||(u.as="script"),u.crossOrigin="",u.href=l,a&&u.setAttribute("nonce",a),document.head.appendChild(u),c)return new Promise((d,h)=>{u.addEventListener("load",d),u.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})};/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.8.2
*/var Tr=Uint8Array,Ba=Uint16Array,tV=Int32Array,RA=new Tr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),PA=new Tr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nV=new Tr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),NA=function(t,e){for(var n=new Ba(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];for(var i=new tV(n[30]),r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return{b:n,r:i}},DA=NA(RA,2),LA=DA.b,rV=DA.r;LA[28]=258,rV[258]=28;var iV=NA(PA,0),sV=iV.b,Wv=new Ba(32768);for(var Lt=0;Lt<32768;++Lt){var gs=(Lt&43690)>>1|(Lt&21845)<<1;gs=(gs&52428)>>2|(gs&13107)<<2,gs=(gs&61680)>>4|(gs&3855)<<4,Wv[Lt]=((gs&65280)>>8|(gs&255)<<8)>>1}var kc=function(t,e,n){for(var r=t.length,i=0,s=new Ba(e);i<r;++i)t[i]&&++s[t[i]-1];var o=new Ba(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(n){a=new Ba(1<<e);var l=15-e;for(i=0;i<r;++i)if(t[i])for(var c=i<<4|t[i],f=e-t[i],u=o[t[i]-1]++<<f,d=u|(1<<f)-1;u<=d;++u)a[Wv[u]>>l]=c}else for(a=new Ba(r),i=0;i<r;++i)t[i]&&(a[i]=Wv[o[t[i]-1]++]>>15-t[i]);return a},Cu=new Tr(288);for(var Lt=0;Lt<144;++Lt)Cu[Lt]=8;for(var Lt=144;Lt<256;++Lt)Cu[Lt]=9;for(var Lt=256;Lt<280;++Lt)Cu[Lt]=7;for(var Lt=280;Lt<288;++Lt)Cu[Lt]=8;var IA=new Tr(32);for(var Lt=0;Lt<32;++Lt)IA[Lt]=5;var oV=kc(Cu,9,1),aV=kc(IA,5,1),Sm=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},Hr=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(e&7)&n},Mm=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(e&7)},lV=function(t){return(t+7)/8|0},cV=function(t,e,n){return(n==null||n>t.length)&&(n=t.length),new Tr(t.subarray(e,n))},uV=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Wr=function(t,e,n){var r=new Error(e||uV[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,Wr),!n)throw r;return r},dV=function(t,e,n,r){var i=t.length,s=0;if(!i||e.f&&!e.l)return n||new Tr(0);var o=!n,a=o||e.i!=2,l=e.i;o&&(n=new Tr(i*3));var c=function(ke){var Se=n.length;if(ke>Se){var nt=new Tr(Math.max(Se*2,ke));nt.set(n),n=nt}},f=e.f||0,u=e.p||0,d=e.b||0,h=e.l,m=e.d,v=e.m,g=e.n,p=i*8;do{if(!h){f=Hr(t,u,1);var x=Hr(t,u+1,3);if(u+=3,x)if(x==1)h=oV,m=aV,v=9,g=5;else if(x==2){var T=Hr(t,u,31)+257,b=Hr(t,u+10,15)+4,C=T+Hr(t,u+5,31)+1;u+=14;for(var A=new Tr(C),E=new Tr(19),N=0;N<b;++N)E[nV[N]]=Hr(t,u+N*3,7);u+=b*3;for(var F=Sm(E),I=(1<<F)-1,U=kc(E,F,1),N=0;N<C;){var z=U[Hr(t,u,I)];u+=z&15;var _=z>>4;if(_<16)A[N++]=_;else{var O=0,j=0;for(_==16?(j=3+Hr(t,u,3),u+=2,O=A[N-1]):_==17?(j=3+Hr(t,u,7),u+=3):_==18&&(j=11+Hr(t,u,127),u+=7);j--;)A[N++]=O}}var D=A.subarray(0,T),V=A.subarray(T);v=Sm(D),g=Sm(V),h=kc(D,v,1),m=kc(V,g,1)}else Wr(1);else{var _=lV(u)+4,w=t[_-4]|t[_-3]<<8,M=_+w;if(M>i){l&&Wr(0);break}a&&c(d+w),n.set(t.subarray(_,M),d),e.b=d+=w,e.p=u=M*8,e.f=f;continue}if(u>p){l&&Wr(0);break}}a&&c(d+131072);for(var Q=(1<<v)-1,J=(1<<g)-1,le=u;;le=u){var O=h[Mm(t,u)&Q],pe=O>>4;if(u+=O&15,u>p){l&&Wr(0);break}if(O||Wr(2),pe<256)n[d++]=pe;else if(pe==256){le=u,h=null;break}else{var $=pe-254;if(pe>264){var N=pe-257,ee=RA[N];$=Hr(t,u,(1<<ee)-1)+LA[N],u+=ee}var se=m[Mm(t,u)&J],Z=se>>4;se||Wr(3),u+=se&15;var V=sV[Z];if(Z>3){var ee=PA[Z];V+=Mm(t,u)&(1<<ee)-1,u+=ee}if(u>p){l&&Wr(0);break}a&&c(d+131072);var ue=d+$;if(d<V){var Me=s-V,ye=Math.min(V,ue);for(Me+d<0&&Wr(3);d<ye;++d)n[d]=r[Me+d]}for(;d<ue;++d)n[d]=n[d-V]}}e.l=h,e.p=le,e.b=d,e.f=f,h&&(f=1,e.m=v,e.d=m,e.n=g)}while(!f);return d!=n.length&&o?cV(n,0,d):n.subarray(0,d)},fV=new Tr(0),hV=function(t,e){return((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&Wr(6,"invalid zlib data"),(t[1]>>5&1)==+!e&&Wr(6,"invalid zlib data: "+(t[1]&32?"need":"unexpected")+" dictionary"),(t[1]>>3&4)+2};function pV(t,e){return dV(t.subarray(hV(t,e),-4),{i:2},e,e)}var mV=typeof TextDecoder<"u"&&new TextDecoder,gV=0;try{mV.decode(fV,{stream:!0}),gV=1}catch{}function kA(t,e,n){const r=n.length-t-1;if(e>=n[r])return r-1;if(e<=n[t])return t;let i=t,s=r,o=Math.floor((i+s)/2);for(;e<n[o]||e>=n[o+1];)e<n[o]?s=o:i=o,o=Math.floor((i+s)/2);return o}function vV(t,e,n,r){const i=[],s=[],o=[];i[0]=1;for(let a=1;a<=n;++a){s[a]=e-r[t+1-a],o[a]=r[t+a]-e;let l=0;for(let c=0;c<a;++c){const f=o[c+1],u=s[a-c],d=i[c]/(f+u);i[c]=l+f*d,l=u*d}i[a]=l}return i}function yV(t,e,n,r){const i=kA(t,r,e),s=vV(i,r,t,e),o=new ut(0,0,0,0);for(let a=0;a<=t;++a){const l=n[i-t+a],c=s[a],f=l.w*c;o.x+=l.x*f,o.y+=l.y*f,o.z+=l.z*f,o.w+=l.w*c}return o}function xV(t,e,n,r,i){const s=[];for(let u=0;u<=n;++u)s[u]=0;const o=[];for(let u=0;u<=r;++u)o[u]=s.slice(0);const a=[];for(let u=0;u<=n;++u)a[u]=s.slice(0);a[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let u=1;u<=n;++u){l[u]=e-i[t+1-u],c[u]=i[t+u]-e;let d=0;for(let h=0;h<u;++h){const m=c[h+1],v=l[u-h];a[u][h]=m+v;const g=a[h][u-1]/a[u][h];a[h][u]=d+m*g,d=v*g}a[u][u]=d}for(let u=0;u<=n;++u)o[0][u]=a[u][n];for(let u=0;u<=n;++u){let d=0,h=1;const m=[];for(let v=0;v<=n;++v)m[v]=s.slice(0);m[0][0]=1;for(let v=1;v<=r;++v){let g=0;const p=u-v,x=n-v;u>=v&&(m[h][0]=m[d][0]/a[x+1][p],g=m[h][0]*a[p][x]);const _=p>=-1?1:-p,w=u-1<=x?v-1:n-u;for(let T=_;T<=w;++T)m[h][T]=(m[d][T]-m[d][T-1])/a[x+1][p+T],g+=m[h][T]*a[p+T][x];u<=x&&(m[h][v]=-m[d][v-1]/a[x+1][u],g+=m[h][v]*a[u][x]),o[v][u]=g;const M=d;d=h,h=M}}let f=n;for(let u=1;u<=r;++u){for(let d=0;d<=n;++d)o[u][d]*=f;f*=n-u}return o}function _V(t,e,n,r,i){const s=i<t?i:t,o=[],a=kA(t,r,e),l=xV(a,r,t,s,e),c=[];for(let f=0;f<n.length;++f){const u=n[f].clone(),d=u.w;u.x*=d,u.y*=d,u.z*=d,c[f]=u}for(let f=0;f<=s;++f){const u=c[a-t].clone().multiplyScalar(l[f][0]);for(let d=1;d<=t;++d)u.add(c[a-t+d].clone().multiplyScalar(l[f][d]));o[f]=u}for(let f=s+1;f<=i+1;++f)o[f]=new ut(0,0,0);return o}function wV(t,e){let n=1;for(let i=2;i<=t;++i)n*=i;let r=1;for(let i=2;i<=e;++i)r*=i;for(let i=2;i<=t-e;++i)r*=i;return n/r}function SV(t){const e=t.length,n=[],r=[];for(let s=0;s<e;++s){const o=t[s];n[s]=new k(o.x,o.y,o.z),r[s]=o.w}const i=[];for(let s=0;s<e;++s){const o=n[s].clone();for(let a=1;a<=s;++a)o.sub(i[s-a].clone().multiplyScalar(wV(s,a)*r[a]));i[s]=o.divideScalar(r[0])}return i}function MV(t,e,n,r,i){const s=_V(t,e,n,r,i);return SV(s)}class bV extends LH{constructor(e,n,r,i,s){super();const o=n?n.length-1:0,a=r?r.length:0;this.degree=e,this.knots=n,this.controlPoints=[],this.startKnot=i||0,this.endKnot=s||o;for(let l=0;l<a;++l){const c=r[l];this.controlPoints[l]=new ut(c.x,c.y,c.z,c.w)}}getPoint(e,n=new k){const r=n,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=yV(this.degree,this.knots,this.controlPoints,i);return s.w!==1&&s.divideScalar(s.w),r.set(s.x,s.y,s.z)}getTangent(e,n=new k){const r=n,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=MV(this.degree,this.knots,this.controlPoints,i,1);return r.copy(s[1]).normalize(),r}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(n=>n.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(n=>new ut(n[0],n[1],n[2],n[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}let st,$t,On;class EV extends Si{constructor(e){super(e)}load(e,n,r,i){const s=this,o=s.path===""?tl.extractUrlBase(e):s.path,a=new hu(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(l){try{n(s.parse(l,o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},r,i)}parse(e,n){if(NV(e))st=new PV().parse(e);else{const i=UA(e);if(!DV(i))throw new Error("THREE.FBXLoader: Unknown format.");if(iM(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+iM(i));st=new RV().parse(i)}const r=new EA(this.manager).setPath(this.resourcePath||n).setCrossOrigin(this.crossOrigin);return new TV(r,this.manager).parse(st)}}class TV{constructor(e,n){this.textureLoader=e,this.manager=n}parse(){$t=this.parseConnections();const e=this.parseImages(),n=this.parseTextures(e),r=this.parseMaterials(n),i=this.parseDeformers(),s=new AV().parse(i);return this.parseScene(i,s,r),On}parseConnections(){const e=new Map;return"Connections"in st&&st.Connections.connections.forEach(function(r){const i=r[0],s=r[1],o=r[2];e.has(i)||e.set(i,{parents:[],children:[]});const a={ID:s,relationship:o};e.get(i).parents.push(a),e.has(s)||e.set(s,{parents:[],children:[]});const l={ID:i,relationship:o};e.get(s).children.push(l)}),e}parseImages(){const e={},n={};if("Video"in st.Objects){const r=st.Objects.Video;for(const i in r){const s=r[i],o=parseInt(i);if(e[o]=s.RelativeFilename||s.Filename,"Content"in s){const a=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,l=typeof s.Content=="string"&&s.Content!=="";if(a||l){const c=this.parseImage(r[i]);n[s.RelativeFilename||s.Filename]=c}}}}for(const r in e){const i=e[r];n[i]!==void 0?e[r]=n[i]:e[r]=e[r].split("\\").pop()}return e}parseImage(e){const n=e.Content,r=e.RelativeFilename||e.Filename,i=r.slice(r.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",r),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof n=="string")return"data:"+s+";base64,"+n;{const o=new Uint8Array(n);return window.URL.createObjectURL(new Blob([o],{type:s}))}}parseTextures(e){const n=new Map;if("Texture"in st.Objects){const r=st.Objects.Texture;for(const i in r){const s=this.parseTexture(r[i],e);n.set(parseInt(i),s)}}return n}parseTexture(e,n){const r=this.loadTexture(e,n);r.ID=e.id,r.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,o=i!==void 0?i.value:0,a=s!==void 0?s.value:0;if(r.wrapS=o===0?Js:vi,r.wrapT=a===0?Js:vi,"Scaling"in e){const l=e.Scaling.value;r.repeat.x=l[0],r.repeat.y=l[1]}if("Translation"in e){const l=e.Translation.value;r.offset.x=l[0],r.offset.y=l[1]}return r}loadTexture(e,n){const r=new Set(["tga","tif","tiff","exr","dds","hdr","ktx2"]),i=e.FileName.split(".").pop().toLowerCase(),s=r.has(i)?this.manager.getHandler(`.${i}`):this.textureLoader;if(!s)return console.warn(`FBXLoader: ${i.toUpperCase()} loader not found, creating placeholder texture for`,e.RelativeFilename),new on;const o=s.path;o||s.setPath(this.textureLoader.path);const a=$t.get(e.id).children;let l;a!==void 0&&a.length>0&&n[a[0].ID]!==void 0&&(l=n[a[0].ID],(l.indexOf("blob:")===0||l.indexOf("data:")===0)&&s.setPath(void 0));const c=s.load(l);return s.setPath(o),c}parseMaterials(e){const n=new Map;if("Material"in st.Objects){const r=st.Objects.Material;for(const i in r){const s=this.parseMaterial(r[i],e);s!==null&&n.set(parseInt(i),s)}}return n}parseMaterial(e,n){const r=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!$t.has(r))return null;const o=this.parseParameters(e,n,r);let a;switch(s.toLowerCase()){case"phong":a=new el;break;case"lambert":a=new nx;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new el;break}return a.setValues(o),a.name=i,a}parseParameters(e,n,r){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=$e.toWorkingColorSpace(new Pe().fromArray(e.Diffuse.value),ft):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=$e.toWorkingColorSpace(new Pe().fromArray(e.DiffuseColor.value),ft)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=$e.toWorkingColorSpace(new Pe().fromArray(e.Emissive.value),ft):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=$e.toWorkingColorSpace(new Pe().fromArray(e.EmissiveColor.value),ft)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),i.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(i.opacity===1||i.opacity===0)&&(i.opacity=e.Opacity?parseFloat(e.Opacity.value):null,i.opacity===null&&(i.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=$e.toWorkingColorSpace(new Pe().fromArray(e.Specular.value),ft):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=$e.toWorkingColorSpace(new Pe().fromArray(e.SpecularColor.value),ft));const s=this;return $t.get(r).children.forEach(function(o){const a=o.relationship;switch(a){case"Bump":i.bumpMap=s.getTexture(n,o.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(n,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(n,o.ID),i.map!==void 0&&(i.map.colorSpace=ft);break;case"DisplacementColor":i.displacementMap=s.getTexture(n,o.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(n,o.ID),i.emissiveMap!==void 0&&(i.emissiveMap.colorSpace=ft);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(n,o.ID);break;case"ReflectionColor":i.envMap=s.getTexture(n,o.ID),i.envMap!==void 0&&(i.envMap.mapping=qf,i.envMap.colorSpace=ft);break;case"SpecularColor":i.specularMap=s.getTexture(n,o.ID),i.specularMap!==void 0&&(i.specularMap.colorSpace=ft);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(n,o.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",a);break}}),i}getTexture(e,n){return"LayeredTexture"in st.Objects&&n in st.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),n=$t.get(n).children[0].ID),e.get(n)}parseDeformers(){const e={},n={};if("Deformer"in st.Objects){const r=st.Objects.Deformer;for(const i in r){const s=r[i],o=$t.get(parseInt(i));if(s.attrType==="Skin"){const a=this.parseSkeleton(o,r);a.ID=i,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=o.parents[0].ID,e[i]=a}else if(s.attrType==="BlendShape"){const a={id:i};a.rawTargets=this.parseMorphTargets(o,r),a.id=i,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),n[i]=a}}}return{skeletons:e,morphTargets:n}}parseSkeleton(e,n){const r=[];return e.children.forEach(function(i){const s=n[i.ID];if(s.attrType!=="Cluster")return;const o={ID:i.ID,indices:[],weights:[],transformLink:new Ce().fromArray(s.TransformLink.a)};"Indexes"in s&&(o.indices=s.Indexes.a,o.weights=s.Weights.a),r.push(o)}),{rawBones:r,bones:[]}}parseMorphTargets(e,n){const r=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],o=n[s.ID],a={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if(o.attrType!=="BlendShapeChannel")return;a.geoID=$t.get(parseInt(s.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,r.push(a)}return r}parseScene(e,n,r){On=new qt;const i=this.parseModels(e.skeletons,n,r),s=st.Objects.Model,o=this;i.forEach(function(l){const c=s[l.ID];o.setLookAtProperties(l,c),$t.get(l.ID).parents.forEach(function(u){const d=i.get(u.ID);d!==void 0&&d.add(l)}),l.parent===null&&On.add(l)}),this.bindSkeleton(e.skeletons,n,i),this.addGlobalSceneSettings(),On.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const c=FA(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});const a=new CV().parse();On.children.length===1&&On.children[0].isGroup&&(On.children[0].animations=a,On=On.children[0]),On.animations=a}parseModels(e,n,r){const i=new Map,s=st.Objects.Model;for(const o in s){const a=parseInt(o),l=s[o],c=$t.get(a);let f=this.buildSkeleton(c,e,a,l.attrName);if(!f){switch(l.attrType){case"Camera":f=this.createCamera(c);break;case"Light":f=this.createLight(c);break;case"Mesh":f=this.createMesh(c,n,r);break;case"NurbsCurve":f=this.createCurve(c,n);break;case"LimbNode":case"Root":f=new Jf;break;case"Null":default:f=new qt;break}f.name=l.attrName?pt.sanitizeNodeName(l.attrName):"",f.userData.originalName=l.attrName,f.ID=a}this.getTransformData(f,l),i.set(a,f)}return i}buildSkeleton(e,n,r,i){let s=null;return e.parents.forEach(function(o){for(const a in n){const l=n[a];l.rawBones.forEach(function(c,f){if(c.ID===o.ID){const u=s;s=new Jf,s.matrixWorld.copy(c.transformLink),s.name=i?pt.sanitizeNodeName(i):"",s.userData.originalName=i,s.ID=r,l.bones[f]=s,u!==null&&s.add(u)}})}}),s}createCamera(e){let n,r;if(e.children.forEach(function(i){const s=st.Objects.NodeAttribute[i.ID];s!==void 0&&(r=s)}),r===void 0)n=new Et;else{let i=0;r.CameraProjectionType!==void 0&&r.CameraProjectionType.value===1&&(i=1);let s=1;r.NearPlane!==void 0&&(s=r.NearPlane.value/1e3);let o=1e3;r.FarPlane!==void 0&&(o=r.FarPlane.value/1e3);let a=window.innerWidth,l=window.innerHeight;r.AspectWidth!==void 0&&r.AspectHeight!==void 0&&(a=r.AspectWidth.value,l=r.AspectHeight.value);const c=a/l;let f=45;r.FieldOfView!==void 0&&(f=r.FieldOfView.value);const u=r.FocalLength?r.FocalLength.value:null;switch(i){case 0:n=new dn(f,c,s,o),u!==null&&n.setFocalLength(u);break;case 1:console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."),n=new Et;break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),n=new Et;break}}return n}createLight(e){let n,r;if(e.children.forEach(function(i){const s=st.Objects.NodeAttribute[i.ID];s!==void 0&&(r=s)}),r===void 0)n=new Et;else{let i;r.LightType===void 0?i=0:i=r.LightType.value;let s=16777215;r.Color!==void 0&&(s=$e.toWorkingColorSpace(new Pe().fromArray(r.Color.value),ft));let o=r.Intensity===void 0?1:r.Intensity.value/100;r.CastLightOnObject!==void 0&&r.CastLightOnObject.value===0&&(o=0);let a=0;r.FarAttenuationEnd!==void 0&&(r.EnableFarAttenuation!==void 0&&r.EnableFarAttenuation.value===0?a=0:a=r.FarAttenuationEnd.value);const l=1;switch(i){case 0:n=new Vv(s,o,a,l);break;case 1:n=new sx(s,o);break;case 2:let c=Math.PI/3;r.InnerAngle!==void 0&&(c=gn.degToRad(r.InnerAngle.value));let f=0;r.OuterAngle!==void 0&&(f=gn.degToRad(r.OuterAngle.value),f=Math.max(f,1)),n=new TA(s,o,a,c,f,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),n=new Vv(s,o);break}r.CastShadows!==void 0&&r.CastShadows.value===1&&(n.castShadow=!0)}return n}createMesh(e,n,r){let i,s=null,o=null;const a=[];return e.children.forEach(function(l){n.has(l.ID)&&(s=n.get(l.ID)),r.has(l.ID)&&a.push(r.get(l.ID))}),a.length>1?o=a:a.length>0?o=a[0]:(o=new el({name:Si.DEFAULT_MATERIAL_NAME,color:13421772}),a.push(o)),"color"in s.attributes&&a.forEach(function(l){l.vertexColors=!0}),s.FBX_Deformer?(i=new gA(s,o),i.normalizeSkinWeights()):i=new je(s,o),i}createCurve(e,n){const r=e.children.reduce(function(s,o){return n.has(o.ID)&&(s=n.get(o.ID)),s},null),i=new ii({name:Si.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new wi(r,i)}getTransformData(e,n){const r={};"InheritType"in n&&(r.inheritType=parseInt(n.InheritType.value)),"RotationOrder"in n?r.eulerOrder=pu(n.RotationOrder.value):r.eulerOrder=pu(0),"Lcl_Translation"in n&&(r.translation=n.Lcl_Translation.value),"PreRotation"in n&&(r.preRotation=n.PreRotation.value),"Lcl_Rotation"in n&&(r.rotation=n.Lcl_Rotation.value),"PostRotation"in n&&(r.postRotation=n.PostRotation.value),"Lcl_Scaling"in n&&(r.scale=n.Lcl_Scaling.value),"ScalingOffset"in n&&(r.scalingOffset=n.ScalingOffset.value),"ScalingPivot"in n&&(r.scalingPivot=n.ScalingPivot.value),"RotationOffset"in n&&(r.rotationOffset=n.RotationOffset.value),"RotationPivot"in n&&(r.rotationPivot=n.RotationPivot.value),e.userData.transformData=r}setLookAtProperties(e,n){"LookAtProperty"in n&&$t.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=st.Objects.Model[i.ID];if("Lcl_Translation"in s){const o=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),On.add(e.target)):e.lookAt(new k().fromArray(o))}}})}bindSkeleton(e,n,r){const i=this.parsePoseNodes();for(const s in e){const o=e[s];$t.get(parseInt(o.ID)).parents.forEach(function(l){if(n.has(l.ID)){const c=l.ID;$t.get(c).parents.forEach(function(u){r.has(u.ID)&&r.get(u.ID).bind(new Kh(o.bones),i[u.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in st.Objects){const n=st.Objects.Pose;for(const r in n)if(n[r].attrType==="BindPose"&&n[r].NbPoseNodes>0){const i=n[r].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Ce().fromArray(s.Matrix.a)}):e[i.Node]=new Ce().fromArray(i.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in st){if("AmbientColor"in st.GlobalSettings){const e=st.GlobalSettings.AmbientColor.value,n=e[0],r=e[1],i=e[2];if(n!==0||r!==0||i!==0){const s=new Pe().setRGB(n,r,i,ft);On.add(new AA(s,1))}}"UnitScaleFactor"in st.GlobalSettings&&(On.userData.unitScaleFactor=st.GlobalSettings.UnitScaleFactor.value)}}}class AV{constructor(){this.negativeMaterialIndices=!1}parse(e){const n=new Map;if("Geometry"in st.Objects){const r=st.Objects.Geometry;for(const i in r){const s=$t.get(parseInt(i)),o=this.parseGeometry(s,r[i],e);n.set(parseInt(i),o)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),n}parseGeometry(e,n,r){switch(n.attrType){case"Mesh":return this.parseMeshGeometry(e,n,r);case"NurbsCurve":return this.parseNurbsGeometry(n)}}parseMeshGeometry(e,n,r){const i=r.skeletons,s=[],o=e.parents.map(function(u){return st.Objects.Model[u.ID]});if(o.length===0)return;const a=e.children.reduce(function(u,d){return i[d.ID]!==void 0&&(u=i[d.ID]),u},null);e.children.forEach(function(u){r.morphTargets[u.ID]!==void 0&&s.push(r.morphTargets[u.ID])});const l=o[0],c={};"RotationOrder"in l&&(c.eulerOrder=pu(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const f=FA(c);return this.genGeometry(n,a,s,f)}genGeometry(e,n,r,i){const s=new Wt;e.attrName&&(s.name=e.attrName);const o=this.parseGeoNode(e,n),a=this.genBuffers(o),l=new At(a.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),a.colors.length>0&&s.setAttribute("color",new At(a.colors,3)),n&&(s.setAttribute("skinIndex",new Zy(a.weightsIndices,4)),s.setAttribute("skinWeight",new At(a.vertexWeights,4)),s.FBX_Deformer=n),a.normal.length>0){const c=new Qe().getNormalMatrix(i),f=new At(a.normal,3);f.applyNormalMatrix(c),s.setAttribute("normal",f)}if(a.uvs.forEach(function(c,f){const u=f===0?"uv":`uv${f}`;s.setAttribute(u,new At(a.uvs[f],2))}),o.material&&o.material.mappingType!=="AllSame"){let c=a.materialIndex[0],f=0;if(a.materialIndex.forEach(function(u,d){u!==c&&(s.addGroup(f,d-f,c),c=u,f=d)}),s.groups.length>0){const u=s.groups[s.groups.length-1],d=u.start+u.count;d!==a.materialIndex.length&&s.addGroup(d,a.materialIndex.length-d,c)}s.groups.length===0&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,r,i),s}parseGeoNode(e,n){const r={};if(r.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],r.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(r.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(r.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(r.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){r.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return r.weightTable={},n!==null&&(r.skeleton=n,n.rawBones.forEach(function(i,s){i.indices.forEach(function(o,a){r.weightTable[o]===void 0&&(r.weightTable[o]=[]),r.weightTable[o].push({id:s,weight:i.weights[a]})})})),r}genBuffers(e){const n={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let r=0,i=0,s=!1,o=[],a=[],l=[],c=[],f=[],u=[];const d=this;return e.vertexIndices.forEach(function(h,m){let v,g=!1;h<0&&(h=h^-1,g=!0);let p=[],x=[];if(o.push(h*3,h*3+1,h*3+2),e.color){const _=Od(m,r,h,e.color);l.push(_[0],_[1],_[2])}if(e.skeleton){if(e.weightTable[h]!==void 0&&e.weightTable[h].forEach(function(_){x.push(_.weight),p.push(_.id)}),x.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const _=[0,0,0,0],w=[0,0,0,0];x.forEach(function(M,T){let b=M,C=p[T];w.forEach(function(A,E,N){if(b>A){N[E]=b,b=A;const F=_[E];_[E]=C,C=F}})}),p=_,x=w}for(;x.length<4;)x.push(0),p.push(0);for(let _=0;_<4;++_)f.push(x[_]),u.push(p[_])}if(e.normal){const _=Od(m,r,h,e.normal);a.push(_[0],_[1],_[2])}e.material&&e.material.mappingType!=="AllSame"&&(v=Od(m,r,h,e.material)[0],v<0&&(d.negativeMaterialIndices=!0,v=0)),e.uv&&e.uv.forEach(function(_,w){const M=Od(m,r,h,_);c[w]===void 0&&(c[w]=[]),c[w].push(M[0]),c[w].push(M[1])}),i++,g&&(d.genFace(n,e,o,v,a,l,c,f,u,i),r++,i=0,o=[],a=[],l=[],c=[],f=[],u=[])}),n}getNormalNewell(e){const n=new k(0,0,0);for(let r=0;r<e.length;r++){const i=e[r],s=e[(r+1)%e.length];n.x+=(i.y-s.y)*(i.z+s.z),n.y+=(i.z-s.z)*(i.x+s.x),n.z+=(i.x-s.x)*(i.y+s.y)}return n.normalize(),n}getNormalTangentAndBitangent(e){const n=this.getNormalNewell(e),i=(Math.abs(n.z)>.5?new k(0,1,0):new k(0,0,1)).cross(n).normalize(),s=n.clone().cross(i).normalize();return{normal:n,tangent:i,bitangent:s}}flattenVertex(e,n,r){return new ze(e.dot(n),e.dot(r))}genFace(e,n,r,i,s,o,a,l,c,f){let u;if(f>3){const d=[],h=n.baseVertexPositions||n.vertexPositions;for(let p=0;p<r.length;p+=3)d.push(new k(h[r[p]],h[r[p+1]],h[r[p+2]]));const{tangent:m,bitangent:v}=this.getNormalTangentAndBitangent(d),g=[];for(const p of d)g.push(this.flattenVertex(p,m,v));u=tx.triangulateShape(g,[])}else u=[[0,1,2]];for(const[d,h,m]of u)e.vertex.push(n.vertexPositions[r[d*3]]),e.vertex.push(n.vertexPositions[r[d*3+1]]),e.vertex.push(n.vertexPositions[r[d*3+2]]),e.vertex.push(n.vertexPositions[r[h*3]]),e.vertex.push(n.vertexPositions[r[h*3+1]]),e.vertex.push(n.vertexPositions[r[h*3+2]]),e.vertex.push(n.vertexPositions[r[m*3]]),e.vertex.push(n.vertexPositions[r[m*3+1]]),e.vertex.push(n.vertexPositions[r[m*3+2]]),n.skeleton&&(e.vertexWeights.push(l[d*4]),e.vertexWeights.push(l[d*4+1]),e.vertexWeights.push(l[d*4+2]),e.vertexWeights.push(l[d*4+3]),e.vertexWeights.push(l[h*4]),e.vertexWeights.push(l[h*4+1]),e.vertexWeights.push(l[h*4+2]),e.vertexWeights.push(l[h*4+3]),e.vertexWeights.push(l[m*4]),e.vertexWeights.push(l[m*4+1]),e.vertexWeights.push(l[m*4+2]),e.vertexWeights.push(l[m*4+3]),e.weightsIndices.push(c[d*4]),e.weightsIndices.push(c[d*4+1]),e.weightsIndices.push(c[d*4+2]),e.weightsIndices.push(c[d*4+3]),e.weightsIndices.push(c[h*4]),e.weightsIndices.push(c[h*4+1]),e.weightsIndices.push(c[h*4+2]),e.weightsIndices.push(c[h*4+3]),e.weightsIndices.push(c[m*4]),e.weightsIndices.push(c[m*4+1]),e.weightsIndices.push(c[m*4+2]),e.weightsIndices.push(c[m*4+3])),n.color&&(e.colors.push(o[d*3]),e.colors.push(o[d*3+1]),e.colors.push(o[d*3+2]),e.colors.push(o[h*3]),e.colors.push(o[h*3+1]),e.colors.push(o[h*3+2]),e.colors.push(o[m*3]),e.colors.push(o[m*3+1]),e.colors.push(o[m*3+2])),n.material&&n.material.mappingType!=="AllSame"&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),n.normal&&(e.normal.push(s[d*3]),e.normal.push(s[d*3+1]),e.normal.push(s[d*3+2]),e.normal.push(s[h*3]),e.normal.push(s[h*3+1]),e.normal.push(s[h*3+2]),e.normal.push(s[m*3]),e.normal.push(s[m*3+1]),e.normal.push(s[m*3+2])),n.uv&&n.uv.forEach(function(v,g){e.uvs[g]===void 0&&(e.uvs[g]=[]),e.uvs[g].push(a[g][d*2]),e.uvs[g].push(a[g][d*2+1]),e.uvs[g].push(a[g][h*2]),e.uvs[g].push(a[g][h*2+1]),e.uvs[g].push(a[g][m*2]),e.uvs[g].push(a[g][m*2+1])})}addMorphTargets(e,n,r,i){if(r.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;r.forEach(function(o){o.rawTargets.forEach(function(a){const l=st.Objects.Geometry[a.geoID];l!==void 0&&s.genMorphGeometry(e,n,l,i,a.name)})})}genMorphGeometry(e,n,r,i,s){const o=n.Vertices!==void 0?n.Vertices.a:[],a=n.PolygonVertexIndex!==void 0?n.PolygonVertexIndex.a:[],l=r.Vertices!==void 0?r.Vertices.a:[],c=r.Indexes!==void 0?r.Indexes.a:[],f=e.attributes.position.count*3,u=new Float32Array(f);for(let v=0;v<c.length;v++){const g=c[v]*3;u[g]=l[v*3],u[g+1]=l[v*3+1],u[g+2]=l[v*3+2]}const d={vertexIndices:a,vertexPositions:u,baseVertexPositions:o},h=this.genBuffers(d),m=new At(h.vertex,3);m.name=s||r.attrName,m.applyMatrix4(i),e.morphAttributes.position.push(m)}parseNormals(e){const n=e.MappingInformationType,r=e.ReferenceInformationType,i=e.Normals.a;let s=[];return r==="IndexToDirect"&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:s,mappingType:n,referenceType:r}}parseUVs(e){const n=e.MappingInformationType,r=e.ReferenceInformationType,i=e.UV.a;let s=[];return r==="IndexToDirect"&&(s=e.UVIndex.a),{dataSize:2,buffer:i,indices:s,mappingType:n,referenceType:r}}parseVertexColors(e){const n=e.MappingInformationType,r=e.ReferenceInformationType,i=e.Colors.a;let s=[];r==="IndexToDirect"&&(s=e.ColorIndex.a);for(let o=0,a=new Pe;o<i.length;o+=4)a.fromArray(i,o),$e.toWorkingColorSpace(a,ft),a.toArray(i,o);return{dataSize:4,buffer:i,indices:s,mappingType:n,referenceType:r}}parseMaterialIndices(e){const n=e.MappingInformationType,r=e.ReferenceInformationType;if(n==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:r};const i=e.Materials.a,s=[];for(let o=0;o<i.length;++o)s.push(o);return{dataSize:1,buffer:i,indices:s,mappingType:n,referenceType:r}}parseNurbsGeometry(e){const n=parseInt(e.Order);if(isNaN(n))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Wt;const r=n-1,i=e.KnotVector.a,s=[],o=e.Points.a;for(let u=0,d=o.length;u<d;u+=4)s.push(new ut().fromArray(o,u));let a,l;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){a=r,l=i.length-1-a;for(let u=0;u<r;++u)s.push(s[u])}const f=new bV(r,i,s,a,l).getPoints(s.length*12);return new Wt().setFromPoints(f)}}class CV{parse(){const e=[],n=this.parseClips();if(n!==void 0)for(const r in n){const i=n[r],s=this.addClip(i);e.push(s)}return e}parseClips(){if(st.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const n=this.parseAnimationLayers(e);return this.parseAnimStacks(n)}parseAnimationCurveNodes(){const e=st.Objects.AnimationCurveNode,n=new Map;for(const r in e){const i=e[r];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){const s={id:i.id,attr:i.attrName,curves:{}};n.set(s.id,s)}}return n}parseAnimationCurves(e){const n=st.Objects.AnimationCurve;for(const r in n){const i={id:n[r].id,times:n[r].KeyTime.a.map(LV),values:n[r].KeyValueFloat.a},s=$t.get(i.id);if(s!==void 0){const o=s.parents[0].ID,a=s.parents[0].relationship;a.match(/X/)?e.get(o).curves.x=i:a.match(/Y/)?e.get(o).curves.y=i:a.match(/Z/)?e.get(o).curves.z=i:a.match(/DeformPercent/)&&e.has(o)&&(e.get(o).curves.morph=i)}}}parseAnimationLayers(e){const n=st.Objects.AnimationLayer,r=new Map;for(const i in n){const s=[],o=$t.get(parseInt(i));o!==void 0&&(o.children.forEach(function(l,c){if(e.has(l.ID)){const f=e.get(l.ID);if(f.curves.x!==void 0||f.curves.y!==void 0||f.curves.z!==void 0){if(s[c]===void 0){const u=$t.get(l.ID).parents.filter(function(d){return d.relationship!==void 0})[0].ID;if(u!==void 0){const d=st.Objects.Model[u.toString()];if(d===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const h={modelName:d.attrName?pt.sanitizeNodeName(d.attrName):"",ID:d.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};On.traverse(function(m){m.ID===d.id&&(h.transform=m.matrix,m.userData.transformData&&(h.eulerOrder=m.userData.transformData.eulerOrder))}),h.transform||(h.transform=new Ce),"PreRotation"in d&&(h.preRotation=d.PreRotation.value),"PostRotation"in d&&(h.postRotation=d.PostRotation.value),s[c]=h}}s[c]&&(s[c][f.attr]=f)}else if(f.curves.morph!==void 0){if(s[c]===void 0){const u=$t.get(l.ID).parents.filter(function(p){return p.relationship!==void 0})[0].ID,d=$t.get(u).parents[0].ID,h=$t.get(d).parents[0].ID,m=$t.get(h).parents[0].ID,v=st.Objects.Model[m],g={modelName:v.attrName?pt.sanitizeNodeName(v.attrName):"",morphName:st.Objects.Deformer[u].attrName};s[c]=g}s[c][f.attr]=f}}}),r.set(parseInt(i),s))}return r}parseAnimStacks(e){const n=st.Objects.AnimationStack,r={};for(const i in n){const s=$t.get(parseInt(i)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const o=e.get(s[0].ID);r[i]={name:n[i].attrName,layer:o}}return r}addClip(e){let n=[];const r=this;return e.layer.forEach(function(i){n=n.concat(r.generateTracks(i))}),new bA(e.name,-1,n)}generateTracks(e){const n=[];let r=new k,i=new k;if(e.transform&&e.transform.decompose(r,new nn,i),r=r.toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.T.curves,r,"position");s!==void 0&&n.push(s)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const s=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);s!==void 0&&n.push(s)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");s!==void 0&&n.push(s)}if(e.DeformPercent!==void 0){const s=this.generateMorphTrack(e);s!==void 0&&n.push(s)}return n}generateVectorTrack(e,n,r,i){const s=this.getTimesForAllAxes(n),o=this.getKeyframeTrackValues(s,n,r);return new Ko(e+"."+i,s,o)}generateRotationTrack(e,n,r,i,s){let o,a;if(n.x!==void 0&&n.y!==void 0&&n.z!==void 0){const d=this.interpolateRotations(n.x,n.y,n.z,s);o=d[0],a=d[1]}const l=pu(0);r!==void 0&&(r=r.map(gn.degToRad),r.push(l),r=new Qt().fromArray(r),r=new nn().setFromEuler(r)),i!==void 0&&(i=i.map(gn.degToRad),i.push(l),i=new Qt().fromArray(i),i=new nn().setFromEuler(i).invert());const c=new nn,f=new Qt,u=[];if(!a||!o)return new no(e+".quaternion",[0],[0]);for(let d=0;d<a.length;d+=3)f.set(a[d],a[d+1],a[d+2],s),c.setFromEuler(f),r!==void 0&&c.premultiply(r),i!==void 0&&c.multiply(i),d>2&&new nn().fromArray(u,(d-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(u,d/3*4);return new no(e+".quaternion",o,u)}generateMorphTrack(e){const n=e.DeformPercent.curves.morph,r=n.values.map(function(s){return s/100}),i=On.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Yo(e.modelName+".morphTargetInfluences["+i+"]",n.times,r)}getTimesForAllAxes(e){let n=[];if(e.x!==void 0&&(n=n.concat(e.x.times)),e.y!==void 0&&(n=n.concat(e.y.times)),e.z!==void 0&&(n=n.concat(e.z.times)),n=n.sort(function(r,i){return r-i}),n.length>1){let r=1,i=n[0];for(let s=1;s<n.length;s++){const o=n[s];o!==i&&(n[r]=o,i=o,r++)}n=n.slice(0,r)}return n}getKeyframeTrackValues(e,n,r){const i=r,s=[];let o=-1,a=-1,l=-1;return e.forEach(function(c){if(n.x&&(o=n.x.times.indexOf(c)),n.y&&(a=n.y.times.indexOf(c)),n.z&&(l=n.z.times.indexOf(c)),o!==-1){const f=n.x.values[o];s.push(f),i[0]=f}else s.push(i[0]);if(a!==-1){const f=n.y.values[a];s.push(f),i[1]=f}else s.push(i[1]);if(l!==-1){const f=n.z.values[l];s.push(f),i[2]=f}else s.push(i[2])}),s}interpolateRotations(e,n,r,i){const s=[],o=[];s.push(e.times[0]),o.push(gn.degToRad(e.values[0])),o.push(gn.degToRad(n.values[0])),o.push(gn.degToRad(r.values[0]));for(let a=1;a<e.values.length;a++){const l=[e.values[a-1],n.values[a-1],r.values[a-1]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;const c=l.map(gn.degToRad),f=[e.values[a],n.values[a],r.values[a]];if(isNaN(f[0])||isNaN(f[1])||isNaN(f[2]))continue;const u=f.map(gn.degToRad),d=[f[0]-l[0],f[1]-l[1],f[2]-l[2]],h=[Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2])];if(h[0]>=180||h[1]>=180||h[2]>=180){const v=Math.max(...h)/180,g=new Qt(...c,i),p=new Qt(...u,i),x=new nn().setFromEuler(g),_=new nn().setFromEuler(p);x.dot(_)&&_.set(-_.x,-_.y,-_.z,-_.w);const w=e.times[a-1],M=e.times[a]-w,T=new nn,b=new Qt;for(let C=0;C<1;C+=1/v)T.copy(x.clone().slerp(_.clone(),C)),s.push(w+C*M),b.setFromQuaternion(T,i),o.push(b.x),o.push(b.y),o.push(b.z)}else s.push(e.times[a]),o.push(gn.degToRad(e.values[a])),o.push(gn.degToRad(n.values[a])),o.push(gn.degToRad(r.values[a]))}return[s,o]}}class RV{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,n){this.currentProp=e,this.currentPropName=n}parse(e){this.currentIndent=0,this.allNodes=new OA,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const n=this,r=e.split(/[\r\n]+/);return r.forEach(function(i,s){const o=i.match(/^[\s\t]*;/),a=i.match(/^[\s\t]*$/);if(o||a)return;const l=i.match("^\\t{"+n.currentIndent+"}(\\w+):(.*){",""),c=i.match("^\\t{"+n.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),f=i.match("^\\t{"+(n.currentIndent-1)+"}}");l?n.parseNodeBegin(i,l):c?n.parseNodeProperty(i,c,r[++s]):f?n.popStack():i.match(/^[^\s\t}]/)&&n.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(e,n){const r=n[1].trim().replace(/^"/,"").replace(/"$/,""),i=n[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:r},o=this.parseNodeAttr(i),a=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(r,s):r in a?(r==="PoseNode"?a.PoseNode.push(s):a[r].id!==void 0&&(a[r]={},a[r][a[r].id]=a[r]),o.id!==""&&(a[r][o.id]=s)):typeof o.id=="number"?(a[r]={},a[r][o.id]=s):r!=="Properties70"&&(r==="PoseNode"?a[r]=[s]:a[r]=s),typeof o.id=="number"&&(s.id=o.id),o.name!==""&&(s.attrName=o.name),o.type!==""&&(s.attrType=o.type),this.pushStack(s)}parseNodeAttr(e){let n=e[0];e[0]!==""&&(n=parseInt(e[0]),isNaN(n)&&(n=e[0]));let r="",i="";return e.length>1&&(r=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:n,name:r,type:i}}parseNodeProperty(e,n,r){let i=n[1].replace(/^"/,"").replace(/"$/,"").trim(),s=n[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=r.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const l=s.split(",").slice(1),c=parseInt(l[0]),f=parseInt(l[1]);let u=s.split(",").slice(3);u=u.map(function(d){return d.trim().replace(/^"/,"")}),i="connections",s=[c,f],kV(s,u),o[i]===void 0&&(o[i]=[])}i==="Node"&&(o.id=s),i in o&&Array.isArray(o[i])?o[i].push(s):i!=="a"?o[i]=s:o.a=s,this.setCurrentProp(o,i),i==="a"&&s.slice(-1)!==","&&(o.a=Em(s))}parseNodePropertyContinued(e){const n=this.getCurrentNode();n.a+=e,e.slice(-1)!==","&&(n.a=Em(n.a))}parseNodeSpecialProperty(e,n,r){const i=r.split('",').map(function(f){return f.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],o=i[1],a=i[2],l=i[3];let c=i[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=Em(c);break}this.getPrevNode()[s]={type:o,type2:a,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),s)}}class PV{parse(e){const n=new rM(e);n.skip(23);const r=n.getUint32();if(r<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+r);const i=new OA;for(;!this.endOfContent(n);){const s=this.parseNode(n,r);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,n){const r={},i=n>=7500?e.getUint64():e.getUint32(),s=n>=7500?e.getUint64():e.getUint32();n>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),a=e.getString(o);if(i===0)return null;const l=[];for(let d=0;d<s;d++)l.push(this.parseProperty(e));const c=l.length>0?l[0]:"",f=l.length>1?l[1]:"",u=l.length>2?l[2]:"";for(r.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const d=this.parseNode(e,n);d!==null&&this.parseSubNode(a,r,d)}return r.propertyList=l,typeof c=="number"&&(r.id=c),f!==""&&(r.attrName=f),u!==""&&(r.attrType=u),a!==""&&(r.name=a),r}parseSubNode(e,n,r){if(r.singleProperty===!0){const i=r.propertyList[0];Array.isArray(i)?(n[r.name]=r,r.a=i):n[r.name]=i}else if(e==="Connections"&&r.name==="C"){const i=[];r.propertyList.forEach(function(s,o){o!==0&&i.push(s)}),n.connections===void 0&&(n.connections=[]),n.connections.push(i)}else if(r.name==="Properties70")Object.keys(r).forEach(function(s){n[s]=r[s]});else if(e==="Properties70"&&r.name==="P"){let i=r.propertyList[0],s=r.propertyList[1];const o=r.propertyList[2],a=r.propertyList[3];let l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?l=[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:l=r.propertyList[4],n[i]={type:s,type2:o,flag:a,value:l}}else n[r.name]===void 0?typeof r.id=="number"?(n[r.name]={},n[r.name][r.id]=r):n[r.name]=r:r.name==="PoseNode"?(Array.isArray(n[r.name])||(n[r.name]=[n[r.name]]),n[r.name].push(r)):n[r.name][r.id]===void 0&&(n[r.name][r.id]=r)}parseProperty(e){const n=e.getString(1);let r;switch(n){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return r=e.getUint32(),e.getArrayBuffer(r);case"S":return r=e.getUint32(),e.getString(r);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),o=e.getUint32();if(s===0)switch(n){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}const a=pV(new Uint8Array(e.getArrayBuffer(o))),l=new rM(a.buffer);switch(n){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+n)}}}class rM{constructor(e,n){this.dv=new DataView(e),this.offset=0,this.littleEndian=n!==void 0?n:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const n=[];for(let r=0;r<e;r++)n.push(this.getBoolean());return n}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const n=[];for(let r=0;r<e;r++)n.push(this.getInt32());return n}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,n;return this.littleEndian?(e=this.getUint32(),n=this.getUint32()):(n=this.getUint32(),e=this.getUint32()),n&2147483648?(n=~n&4294967295,e=~e&4294967295,e===4294967295&&(n=n+1&4294967295),e=e+1&4294967295,-(n*4294967296+e)):n*4294967296+e}getInt64Array(e){const n=[];for(let r=0;r<e;r++)n.push(this.getInt64());return n}getUint64(){let e,n;return this.littleEndian?(e=this.getUint32(),n=this.getUint32()):(n=this.getUint32(),e=this.getUint32()),n*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const n=[];for(let r=0;r<e;r++)n.push(this.getFloat32());return n}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const n=[];for(let r=0;r<e;r++)n.push(this.getFloat64());return n}getArrayBuffer(e){const n=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,n}getString(e){const n=this.offset;let r=new Uint8Array(this.dv.buffer,n,e);this.skip(e);const i=r.indexOf(0);return i>=0&&(r=new Uint8Array(this.dv.buffer,n,i)),this._textDecoder.decode(r)}}class OA{add(e,n){this[e]=n}}function NV(t){const e="Kaydara FBX Binary \0";return t.byteLength>=e.length&&e===UA(t,0,e.length)}function DV(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(i){const s=t[i-1];return t=t.slice(n+i),n++,s}for(let i=0;i<e.length;++i)if(r(1)===e[i])return!1;return!0}function iM(t){const e=/FBXVersion: (\d+)/,n=t.match(e);if(n)return parseInt(n[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function LV(t){return t/46186158e3}const IV=[];function Od(t,e,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=t;break;case"ByPolygon":i=e;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}r.referenceType==="IndexToDirect"&&(i=r.indices[i]);const s=i*r.dataSize,o=s+r.dataSize;return OV(IV,r.buffer,s,o)}const bm=new Qt,_a=new k;function FA(t){const e=new Ce,n=new Ce,r=new Ce,i=new Ce,s=new Ce,o=new Ce,a=new Ce,l=new Ce,c=new Ce,f=new Ce,u=new Ce,d=new Ce,h=t.inheritType?t.inheritType:0;t.translation&&e.setPosition(_a.fromArray(t.translation));const m=pu(0);if(t.preRotation){const N=t.preRotation.map(gn.degToRad);N.push(m),n.makeRotationFromEuler(bm.fromArray(N))}if(t.rotation){const N=t.rotation.map(gn.degToRad);N.push(t.eulerOrder||m),r.makeRotationFromEuler(bm.fromArray(N))}if(t.postRotation){const N=t.postRotation.map(gn.degToRad);N.push(m),i.makeRotationFromEuler(bm.fromArray(N)),i.invert()}t.scale&&s.scale(_a.fromArray(t.scale)),t.scalingOffset&&a.setPosition(_a.fromArray(t.scalingOffset)),t.scalingPivot&&o.setPosition(_a.fromArray(t.scalingPivot)),t.rotationOffset&&l.setPosition(_a.fromArray(t.rotationOffset)),t.rotationPivot&&c.setPosition(_a.fromArray(t.rotationPivot)),t.parentMatrixWorld&&(u.copy(t.parentMatrix),f.copy(t.parentMatrixWorld));const v=n.clone().multiply(r).multiply(i),g=new Ce;g.extractRotation(f);const p=new Ce;p.copyPosition(f);const x=p.clone().invert().multiply(f),_=g.clone().invert().multiply(x),w=s,M=new Ce;if(h===0)M.copy(g).multiply(v).multiply(_).multiply(w);else if(h===1)M.copy(g).multiply(_).multiply(v).multiply(w);else{const F=new Ce().scale(new k().setFromMatrixScale(u)).clone().invert(),I=_.clone().multiply(F);M.copy(g).multiply(v).multiply(I).multiply(w)}const T=c.clone().invert(),b=o.clone().invert();let C=e.clone().multiply(l).multiply(c).multiply(n).multiply(r).multiply(i).multiply(T).multiply(a).multiply(o).multiply(s).multiply(b);const A=new Ce().copyPosition(C),E=f.clone().multiply(A);return d.copyPosition(E),C=d.clone().multiply(M),C.premultiply(f.invert()),C}function pu(t){t=t||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return t===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[t]}function Em(t){return t.split(",").map(function(n){return parseFloat(n)})}function UA(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=t.byteLength),new TextDecoder().decode(new Uint8Array(t,e,n))}function kV(t,e){for(let n=0,r=t.length,i=e.length;n<i;n++,r++)t[r]=e[n]}function OV(t,e,n,r){for(let i=n,s=0;i<r;i++,s++)t[s]=e[i];return t}const FV=t=>{const e=S.useRef(null),[n,r]=S.useState([]),[i,s]=S.useState(null),[o,a]=S.useState(!1),[l,c]=S.useState(null),f=S.useRef(null),u=S.useCallback(g=>{try{g.traverse(p=>{p instanceof je&&(p.geometry&&p.geometry.dispose(),p.material&&(Array.isArray(p.material)?p.material.forEach(x=>{x.map&&x.map.dispose(),x.normalMap&&x.normalMap.dispose(),x.bumpMap&&x.bumpMap.dispose(),x.dispose()}):(p.material.map&&p.material.map.dispose(),p.material.normalMap&&p.material.normalMap.dispose(),p.material.bumpMap&&p.material.bumpMap.dispose(),p.material.dispose())))})}catch(p){console.error("Error disposing object:",p)}},[]),d=S.useCallback(async g=>{try{const p=[],x=[];if(g.traverse(T=>{if(T instanceof je&&T.geometry){const b=T.geometry.clone();b.applyMatrix4(T.matrixWorld),p.push(b),Array.isArray(T.material)?x.push(...T.material):x.push(T.material)}}),p.length===0)return console.warn("No geometries found to merge"),g;let _;try{const{mergeGeometries:T}=await eV(async()=>{const{mergeGeometries:C}=await Promise.resolve().then(()=>BV);return{mergeGeometries:C}},void 0),b=T(p);if(b)_=b;else throw new Error("BufferGeometryUtils merge failed")}catch(T){console.warn("BufferGeometryUtils not available or failed, using basic merge:",T),_=new Wt;const b=[],C=[],A=[];p.forEach(E=>{const N=E.getAttribute("position"),F=E.getAttribute("normal"),I=E.getAttribute("uv");N&&b.push(...Array.from(N.array)),F&&C.push(...Array.from(F.array)),I&&A.push(...Array.from(I.array))}),b.length>0&&_.setAttribute("position",new At(b,3)),C.length>0&&_.setAttribute("normal",new At(C,3)),A.length>0&&_.setAttribute("uv",new At(A,2))}_.getAttribute("normal")||_.computeVertexNormals();let w=x.find(T=>!(T instanceof Xi))||x[0];w?w instanceof Xi&&(w=new el({color:w.color,map:w.map})):w=new el({color:8947848});const M=new je(_,w);return M.name=g.name||"Merged Object",M.castShadow=!0,M.receiveShadow=!0,p.forEach(T=>{try{T.dispose()}catch(b){console.warn("Error disposing geometry:",b)}}),M}catch(p){return console.error("Error in mergeGeometries:",p),g}},[]),h=S.useCallback(async g=>{if(console.log("Starting FBX load process:",g.name),!t){console.error("Scene not available for FBX loading"),c("3D scene not ready. Please try again.");return}f.current&&f.current.abort();const p=new AbortController;f.current=p,a(!0),c(null);try{if(!g.name.toLowerCase().endsWith(".fbx"))throw new Error("Invalid file format. Please select an FBX file.");if(g.size>50*1024*1024)throw new Error("File too large. Please select a file smaller than 50MB.");e.current||(e.current=new EV,console.log("FBX loader initialized")),console.log("Reading file as array buffer...");const x=await g.arrayBuffer();if(p.signal.aborted){console.log("FBX loading aborted");return}console.log("Parsing FBX data...");const _=e.current.parse(x,"");if(p.signal.aborted){console.log("FBX loading aborted after parsing"),u(_);return}console.log("FBX parsed successfully:",_),_.rotateX(-Math.PI/2),_.updateMatrixWorld(!0),console.log("Merging geometries...");const w=await d(_);if(p.signal.aborted){console.log("FBX loading aborted after merging"),u(w);return}const M=new Gt().setFromObject(w),T=M.getCenter(new k),b=M.getSize(new k);w.position.sub(T);const C=Math.max(b.x,b.y,b.z),A=C>4?4/C:1;w.scale.setScalar(A),w.traverse(F=>{F instanceof je&&(F.castShadow=!0,F.receiveShadow=!0)});const E=new qt;E.add(w),E.name=g.name.replace(".fbx","");const N={id:Date.now().toString(),name:g.name.replace(".fbx",""),object:E,boundingBox:new Gt().setFromObject(E),size:g.size};i&&(console.log("Removing previous model from scene"),t.remove(i.object),u(i.object)),console.log("Adding merged model to scene"),t.add(E),r(F=>[...F,N]),s(N),_!==w&&u(_)}catch(x){if(!p.signal.aborted){console.error("Failed to load FBX model:",x);const _=x instanceof Error?x.message:"Failed to load model. Please check the file format.";c(_)}}finally{p.signal.aborted||a(!1),f.current=null}},[t,i,d,u]),m=S.useCallback(g=>{if(!t)return;const p=n.find(x=>x.id===g);p&&(i&&t.remove(i.object),t.add(p.object),s(p))},[t,n,i]),v=S.useCallback(g=>{if(!t)return;const p=n.find(x=>x.id===g);p&&((i==null?void 0:i.id)===g&&(t.remove(p.object),s(null)),u(p.object),r(x=>x.filter(_=>_.id!==g)))},[t,n,i,u]);return S.useEffect(()=>()=>{f.current&&f.current.abort(),n.forEach(g=>{try{u(g.object)}catch(p){console.warn("Error disposing model on cleanup:",p)}})},[n,u]),{loadedModels:n,currentModel:i,isLoading:o,error:l,loadFBXModel:h,switchToModel:m,removeModel:v}};function UV(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),s={},o={},a=t[0].morphTargetsRelative,l=new Wt;let c=0;for(let f=0;f<t.length;++f){const u=t[f];let d=0;if(n!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+f+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const h in u.attributes){if(!r.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+f+'. All geometries must have compatible attributes; make sure "'+h+'" attribute exists among all geometries, or in none of them.'),null;s[h]===void 0&&(s[h]=[]),s[h].push(u.attributes[h]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+f+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+f+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const h in u.morphAttributes){if(!i.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+f+". .morphAttributes must be consistent throughout all geometries."),null;o[h]===void 0&&(o[h]=[]),o[h].push(u.morphAttributes[h])}if(e){let h;if(n)h=u.index.count;else if(u.attributes.position!==void 0)h=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+f+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,h,f),c+=h}}if(n){let f=0;const u=[];for(let d=0;d<t.length;++d){const h=t[d].index;for(let m=0;m<h.count;++m)u.push(h.getX(m)+f);f+=t[d].attributes.position.count}l.setIndex(u)}for(const f in s){const u=Xv(s[f]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+f+" attribute."),null;l.setAttribute(f,u)}for(const f in o){const u=o[f][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[f]=[];for(let d=0;d<u;++d){const h=[];for(let v=0;v<o[f].length;++v)h.push(o[f][v][d]);const m=Xv(h);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+f+" morphAttribute."),null;l.morphAttributes[f].push(m)}}return l}function Xv(t){let e,n,r,i=-1,s=0;for(let c=0;c<t.length;++c){const f=t[c];if(e===void 0&&(e=f.array.constructor),e!==f.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=f.itemSize),n!==f.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=f.normalized),r!==f.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=f.gpuType),i!==f.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=f.count*n}const o=new e(s),a=new hn(o,n,r);let l=0;for(let c=0;c<t.length;++c){const f=t[c];if(f.isInterleavedBufferAttribute){const u=l/n;for(let d=0,h=f.count;d<h;d++)for(let m=0;m<n;m++){const v=f.getComponent(d,m);a.setComponent(d+u,m,v)}}else o.set(f.array,l);l+=f.count*n}return i!==void 0&&(a.gpuType=i),a}function $v(t,e){if(e===BO)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(e===Ov||e===eA){let n=t.getIndex();if(n===null){const o=[],a=t.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);t.setIndex(o),n=t.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t}const r=n.count-2,i=[];if(e===Ov)for(let o=1;o<=r;o++)i.push(n.getX(0)),i.push(n.getX(o)),i.push(n.getX(o+1));else for(let o=0;o<r;o++)o%2===0?(i.push(n.getX(o)),i.push(n.getX(o+1)),i.push(n.getX(o+2))):(i.push(n.getX(o+2)),i.push(n.getX(o+1)),i.push(n.getX(o)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}const BV=Object.freeze(Object.defineProperty({__proto__:null,mergeAttributes:Xv,mergeGeometries:UV,toTrianglesDrawMode:$v},Symbol.toStringTag,{value:"Module"}));class zV extends Si{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new WV(n)}),this.register(function(n){return new XV(n)}),this.register(function(n){return new t5(n)}),this.register(function(n){return new n5(n)}),this.register(function(n){return new r5(n)}),this.register(function(n){return new YV(n)}),this.register(function(n){return new KV(n)}),this.register(function(n){return new qV(n)}),this.register(function(n){return new ZV(n)}),this.register(function(n){return new GV(n)}),this.register(function(n){return new QV(n)}),this.register(function(n){return new $V(n)}),this.register(function(n){return new e5(n)}),this.register(function(n){return new JV(n)}),this.register(function(n){return new jV(n)}),this.register(function(n){return new i5(n)}),this.register(function(n){return new s5(n)})}load(e,n,r,i){const s=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=tl.extractUrlBase(e);o=tl.resolveURL(c,this.path)}else o=tl.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new hu(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,o,function(f){n(f),s.manager.itemEnd(e)},a)}catch(f){a(f)}},r,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,r,i){let s;const o={},a={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===BA){try{o[at.KHR_BINARY_GLTF]=new o5(e)}catch(u){i&&i(u);return}s=JSON.parse(o[at.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new x5(s,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const u=this.pluginCallbacks[f](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(s.extensionsUsed)for(let f=0;f<s.extensionsUsed.length;++f){const u=s.extensionsUsed[f],d=s.extensionsRequired||[];switch(u){case at.KHR_MATERIALS_UNLIT:o[u]=new VV;break;case at.KHR_DRACO_MESH_COMPRESSION:o[u]=new a5(s,this.dracoLoader);break;case at.KHR_TEXTURE_TRANSFORM:o[u]=new l5;break;case at.KHR_MESH_QUANTIZATION:o[u]=new c5;break;default:d.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(r,i)}parseAsync(e,n){const r=this;return new Promise(function(i,s){r.parse(e,n,i,s)})}}function HV(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const at={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class jV{constructor(e){this.parser=e,this.name=at.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let r=0,i=n.length;r<i;r++){const s=n[r];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const n=this.parser,r="light:"+e;let i=n.cache.get(r);if(i)return i;const s=n.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const f=new Pe(16777215);l.color!==void 0&&f.setRGB(l.color[0],l.color[1],l.color[2],Ln);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new sx(f),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Vv(f),c.distance=u;break;case"spot":c=new TA(f),c.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),c.decay=2,Bi(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=n.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),n.cache.add(r,i),i}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,r=this.parser,s=r.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return r._getNodeRef(n.cache,a,l)})}}class VV{constructor(){this.name=at.KHR_MATERIALS_UNLIT}getMaterialType(){return Xi}extendParams(e,n,r){const i=[];e.color=new Pe(1,1,1),e.opacity=1;const s=n.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],Ln),e.opacity=o[3]}s.baseColorTexture!==void 0&&i.push(r.assignTexture(e,"map",s.baseColorTexture,ft))}return Promise.all(i)}}class GV{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(n.emissiveIntensity=s),Promise.resolve()}}class WV{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(n.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(r.assignTexture(n,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(r.assignTexture(n,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(r.assignTexture(n,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new ze(a,a)}return Promise.all(s)}}class XV{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_DISPERSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return n.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class $V{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(n.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(r.assignTexture(n,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(n.iridescenceIOR=o.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(r.assignTexture(n,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}}class YV{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];n.sheenColor=new Pe(0,0,0),n.sheenRoughness=0,n.sheen=1;const o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;n.sheenColor.setRGB(a[0],a[1],a[2],Ln)}return o.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(r.assignTexture(n,"sheenColorMap",o.sheenColorTexture,ft)),o.sheenRoughnessTexture!==void 0&&s.push(r.assignTexture(n,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class KV{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(n.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(r.assignTexture(n,"transmissionMap",o.transmissionTexture)),Promise.all(s)}}class qV{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];n.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(r.assignTexture(n,"thicknessMap",o.thicknessTexture)),n.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return n.attenuationColor=new Pe().setRGB(a[0],a[1],a[2],Ln),Promise.all(s)}}class ZV{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return n.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class QV{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];n.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(r.assignTexture(n,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return n.specularColor=new Pe().setRGB(a[0],a[1],a[2],Ln),o.specularColorTexture!==void 0&&s.push(r.assignTexture(n,"specularColorMap",o.specularColorTexture,ft)),Promise.all(s)}}class JV{constructor(e){this.parser=e,this.name=at.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return n.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(r.assignTexture(n,"bumpMap",o.bumpTexture)),Promise.all(s)}}class e5{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:si}extendMaterialParams(e,n){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(n.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(n.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(r.assignTexture(n,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}}class t5{constructor(e){this.parser=e,this.name=at.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],o=n.options.ktx2Loader;if(!o){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,s.source,o)}}class n5{constructor(e){this.parser=e,this.name=at.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,r=this.parser,i=r.json,s=i.textures[e];if(!s.extensions||!s.extensions[n])return null;const o=s.extensions[n],a=i.images[o.source];let l=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class r5{constructor(e){this.parser=e,this.name=at.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,r=this.parser,i=r.json,s=i.textures[e];if(!s.extensions||!s.extensions[n])return null;const o=s.extensions[n],a=i.images[o.source];let l=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class i5{constructor(e){this.name=at.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,r=n.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const i=r.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,f=i.count,u=i.byteStride,d=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(f,u,d,i.mode,i.filter).then(function(h){return h.buffer}):o.ready.then(function(){const h=new ArrayBuffer(f*u);return o.decodeGltfBuffer(new Uint8Array(h),f,u,d,i.mode,i.filter),h})})}else return null}}class s5{constructor(e){this.name=at.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,r=n.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const i=n.meshes[r.mesh];for(const c of i.primitives)if(c.mode!==wr.TRIANGLES&&c.mode!==wr.TRIANGLE_STRIP&&c.mode!==wr.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=r.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(f=>(l[c]=f,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const f=c.pop(),u=f.isGroup?f.children:[f],d=c[0].count,h=[];for(const m of u){const v=new Ce,g=new k,p=new nn,x=new k(1,1,1),_=new PH(m.geometry,m.material,d);for(let w=0;w<d;w++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,w),l.ROTATION&&p.fromBufferAttribute(l.ROTATION,w),l.SCALE&&x.fromBufferAttribute(l.SCALE,w),_.setMatrixAt(w,v.compose(g,p,x));for(const w in l)if(w==="_COLOR_0"){const M=l[w];_.instanceColor=new Bv(M.array,M.itemSize,M.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&m.geometry.setAttribute(w,l[w]);Et.prototype.copy.call(_,m),this.parser.assignFinalMaterial(_),h.push(_)}return f.isGroup?(f.clear(),f.add(...h),f):h[0]}))}}const BA="glTF",hc=12,sM={JSON:1313821514,BIN:5130562};class o5{constructor(e){this.name=at.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,hc),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==BA)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-hc,s=new DataView(e,hc);let o=0;for(;o<i;){const a=s.getUint32(o,!0);o+=4;const l=s.getUint32(o,!0);if(o+=4,l===sM.JSON){const c=new Uint8Array(e,hc+o,a);this.content=r.decode(c)}else if(l===sM.BIN){const c=hc+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class a5{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=at.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const r=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const f in o){const u=Yv[f]||f.toLowerCase();a[u]=o[f]}for(const f in e.attributes){const u=Yv[f]||f.toLowerCase();if(o[f]!==void 0){const d=r.accessors[e.attributes[f]],h=nl[d.componentType];c[u]=h.name,l[u]=d.normalized===!0}}return n.getDependency("bufferView",s).then(function(f){return new Promise(function(u,d){i.decodeDracoFile(f,function(h){for(const m in h.attributes){const v=h.attributes[m],g=l[m];g!==void 0&&(v.normalized=g)}u(h)},a,c,Ln,d)})})}}class l5{constructor(){this.name=at.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class c5{constructor(){this.name=at.KHR_MESH_QUANTIZATION}}class zA extends Au{constructor(e,n,r,i){super(e,n,r,i)}copySampleValue_(e){const n=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let o=0;o!==i;o++)n[o]=r[s+o];return n}interpolate_(e,n,r,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,f=i-n,u=(r-n)/f,d=u*u,h=d*u,m=e*c,v=m-c,g=-2*h+3*d,p=h-d,x=1-g,_=p-d+u;for(let w=0;w!==a;w++){const M=o[v+w+a],T=o[v+w+l]*f,b=o[m+w+a],C=o[m+w]*f;s[w]=x*M+_*T+g*b+p*C}return s}}const u5=new nn;class d5 extends zA{interpolate_(e,n,r,i){const s=super.interpolate_(e,n,r,i);return u5.fromArray(s).normalize().toArray(s),s}}const wr={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},nl={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},oM={9728:Hn,9729:hr,9984:GT,9985:of,9986:_c,9987:Gi},aM={33071:vi,33648:Zf,10497:Js},Tm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Yv={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},vs={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},f5={CUBICSPLINE:void 0,LINEAR:au,STEP:ou},Am={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function h5(t){return t.DefaultMaterial===void 0&&(t.DefaultMaterial=new Pn({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ns})),t.DefaultMaterial}function yo(t,e,n){for(const r in n.extensions)t[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=n.extensions[r])}function Bi(t,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function p5(t,e,n){let r=!1,i=!1,s=!1;for(let c=0,f=e.length;c<f;c++){const u=e[c];if(u.POSITION!==void 0&&(r=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(t);const o=[],a=[],l=[];for(let c=0,f=e.length;c<f;c++){const u=e[c];if(r){const d=u.POSITION!==void 0?n.getDependency("accessor",u.POSITION):t.attributes.position;o.push(d)}if(i){const d=u.NORMAL!==void 0?n.getDependency("accessor",u.NORMAL):t.attributes.normal;a.push(d)}if(s){const d=u.COLOR_0!==void 0?n.getDependency("accessor",u.COLOR_0):t.attributes.color;l.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const f=c[0],u=c[1],d=c[2];return r&&(t.morphAttributes.position=f),i&&(t.morphAttributes.normal=u),s&&(t.morphAttributes.color=d),t.morphTargetsRelative=!0,t})}function m5(t,e){if(t.updateMorphTargets(),e.weights!==void 0)for(let n=0,r=e.weights.length;n<r;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let r=0,i=n.length;r<i;r++)t.morphTargetDictionary[n[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function g5(t){let e;const n=t.extensions&&t.extensions[at.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+Cm(n.attributes):e=t.indices+":"+Cm(t.attributes)+":"+t.mode,t.targets!==void 0)for(let r=0,i=t.targets.length;r<i;r++)e+=":"+Cm(t.targets[r]);return e}function Cm(t){let e="";const n=Object.keys(t).sort();for(let r=0,i=n.length;r<i;r++)e+=n[r]+":"+t[n[r]]+";";return e}function Kv(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function v5(t){return t.search(/\.jpe?g($|\?)/i)>0||t.search(/^data\:image\/jpeg/)===0?"image/jpeg":t.search(/\.webp($|\?)/i)>0||t.search(/^data\:image\/webp/)===0?"image/webp":t.search(/\.ktx2($|\?)/i)>0||t.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const y5=new Ce;class x5{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new HV,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,i=-1,s=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=r&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&i<17||s&&o<98?this.textureLoader=new EA(this.options.manager):this.textureLoader=new fj(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new hu(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const r=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:r,userData:{}};return yo(s,a,i),Bi(a,i),Promise.all(r._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],r=this.json.meshes||[];for(let i=0,s=n.length;i<s;i++){const o=n[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(r[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,r){if(e.refs[n]<=1)return r;const i=r.clone(),s=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,f]of o.children.entries())s(f,a.children[c])};return s(r,i),i.name+="_instance_"+e.uses[n]++,i}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let r=0;r<n.length;r++){const i=e(n[r]);if(i)return i}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const r=[];for(let i=0;i<n.length;i++){const s=e(n[i]);s&&r.push(s)}return r}getDependency(e,n){const r=e+":"+n;let i=this.cache.get(r);if(!i){switch(e){case"scene":i=this.loadScene(n);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(n)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(n)});break;case"accessor":i=this.loadAccessor(n);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(n)});break;case"buffer":i=this.loadBuffer(n);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(n)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(n)});break;case"skin":i=this.loadSkin(n);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(n)});break;case"camera":i=this.loadCamera(n);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,n)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(r,i)}return i}getDependencies(e){let n=this.cache.get(e);if(!n){const r=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(i.map(function(s,o){return r.getDependency(e,o)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],r=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[at.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,o){r.load(tl.resolveURL(n.uri,i.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(r){const i=n.byteLength||0,s=n.byteOffset||0;return r.slice(s,s+i)})}loadAccessor(e){const n=this,r=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=Tm[i.type],a=nl[i.componentType],l=i.normalized===!0,c=new a(i.count*o);return Promise.resolve(new hn(c,o,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(o){const a=o[0],l=Tm[i.type],c=nl[i.componentType],f=c.BYTES_PER_ELEMENT,u=f*l,d=i.byteOffset||0,h=i.bufferView!==void 0?r.bufferViews[i.bufferView].byteStride:void 0,m=i.normalized===!0;let v,g;if(h&&h!==u){const p=Math.floor(d/h),x="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let _=n.cache.get(x);_||(v=new c(a,p*h,i.count*h/f),_=new TH(v,h/f),n.cache.add(x,_)),g=new ex(_,l,d%h/f,m)}else a===null?v=new c(i.count*l):v=new c(a,d,i.count*l),g=new hn(v,l,m);if(i.sparse!==void 0){const p=Tm.SCALAR,x=nl[i.sparse.indices.componentType],_=i.sparse.indices.byteOffset||0,w=i.sparse.values.byteOffset||0,M=new x(o[1],_,i.sparse.count*p),T=new c(o[2],w,i.sparse.count*l);a!==null&&(g=new hn(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let b=0,C=M.length;b<C;b++){const A=M[b];if(g.setX(A,T[b*l]),l>=2&&g.setY(A,T[b*l+1]),l>=3&&g.setZ(A,T[b*l+2]),l>=4&&g.setW(A,T[b*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const n=this.json,r=this.options,s=n.textures[e].source,o=n.images[s];let a=this.textureLoader;if(o.uri){const l=r.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,n,r){const i=this,s=this.json,o=s.textures[e],a=s.images[n],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(n,r).then(function(f){f.flipY=!1,f.name=o.name||a.name||"",f.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(f.name=a.uri);const d=(s.samplers||{})[o.sampler]||{};return f.magFilter=oM[d.magFilter]||hr,f.minFilter=oM[d.minFilter]||Gi,f.wrapS=aM[d.wrapS]||Js,f.wrapT=aM[d.wrapT]||Js,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==Hn&&f.minFilter!==hr,i.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,n){const r=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=r.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(d),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(l).then(function(u){return new Promise(function(d,h){let m=d;n.isImageBitmapLoader===!0&&(m=function(v){const g=new on(v);g.needsUpdate=!0,d(g)}),n.load(tl.resolveURL(u,s.path),m,void 0,h)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),Bi(u,o),u.userData.mimeType=o.mimeType||v5(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=f,f}assignTexture(e,n,r,i){const s=this;return this.getDependency("texture",r.index).then(function(o){if(!o)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(o=o.clone(),o.channel=r.texCoord),s.extensions[at.KHR_TEXTURE_TRANSFORM]){const a=r.extensions!==void 0?r.extensions[at.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[at.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[n]=o,o})}assignFinalMaterial(e){const n=e.geometry;let r=e.material;const i=n.attributes.tangent===void 0,s=n.attributes.color!==void 0,o=n.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+r.uuid;let l=this.cache.get(a);l||(l=new yA,Nr.prototype.copy.call(l,r),l.color.copy(r.color),l.map=r.map,l.sizeAttenuation=!1,this.cache.add(a,l)),r=l}else if(e.isLine){const a="LineBasicMaterial:"+r.uuid;let l=this.cache.get(a);l||(l=new ii,Nr.prototype.copy.call(l,r),l.color.copy(r.color),l.map=r.map,this.cache.add(a,l)),r=l}if(i||s||o){let a="ClonedMaterial:"+r.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=r.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(r))),r=l}e.material=r}getMaterialType(){return Pn}loadMaterial(e){const n=this,r=this.json,i=this.extensions,s=r.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[at.KHR_MATERIALS_UNLIT]){const u=i[at.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,s,n))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new Pe(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],Ln),a.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(n.assignTexture(a,"map",u.baseColorTexture,ft)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(n.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(n.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=pi);const f=s.alphaMode||Am.OPAQUE;if(f===Am.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,f===Am.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Xi&&(c.push(n.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new ze(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&o!==Xi&&(c.push(n.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Xi){const u=s.emissiveFactor;a.emissive=new Pe().setRGB(u[0],u[1],u[2],Ln)}return s.emissiveTexture!==void 0&&o!==Xi&&c.push(n.assignTexture(a,"emissiveMap",s.emissiveTexture,ft)),Promise.all(c).then(function(){const u=new o(a);return s.name&&(u.name=s.name),Bi(u,s),n.associations.set(u,{materials:e}),s.extensions&&yo(i,u,s),u})}createUniqueName(e){const n=pt.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,r=this.extensions,i=this.primitiveCache;function s(a){return r[at.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,n).then(function(l){return lM(l,a,n)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],f=g5(c),u=i[f];if(u)o.push(u.promise);else{let d;c.extensions&&c.extensions[at.KHR_DRACO_MESH_COMPRESSION]?d=s(c):d=lM(new Wt,c,n),i[f]={primitive:c,promise:d},o.push(d)}}return Promise.all(o)}loadMesh(e){const n=this,r=this.json,i=this.extensions,s=r.meshes[e],o=s.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const f=o[l].material===void 0?h5(this.cache):this.getDependency("material",o[l].material);a.push(f)}return a.push(n.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),f=l[l.length-1],u=[];for(let h=0,m=f.length;h<m;h++){const v=f[h],g=o[h];let p;const x=c[h];if(g.mode===wr.TRIANGLES||g.mode===wr.TRIANGLE_STRIP||g.mode===wr.TRIANGLE_FAN||g.mode===void 0)p=s.isSkinnedMesh===!0?new gA(v,x):new je(v,x),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===wr.TRIANGLE_STRIP?p.geometry=$v(p.geometry,eA):g.mode===wr.TRIANGLE_FAN&&(p.geometry=$v(p.geometry,Ov));else if(g.mode===wr.LINES)p=new to(v,x);else if(g.mode===wr.LINE_STRIP)p=new wi(v,x);else if(g.mode===wr.LINE_LOOP)p=new NH(v,x);else if(g.mode===wr.POINTS)p=new DH(v,x);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&m5(p,s),p.name=n.createUniqueName(s.name||"mesh_"+e),Bi(p,s),g.extensions&&yo(i,p,g),n.assignFinalMaterial(p),u.push(p)}for(let h=0,m=u.length;h<m;h++)n.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1)return s.extensions&&yo(i,u[0],s),u[0];const d=new qt;s.extensions&&yo(i,d,s),n.associations.set(d,{meshes:e});for(let h=0,m=u.length;h<m;h++)d.add(u[h]);return d})}loadCamera(e){let n;const r=this.json.cameras[e],i=r[r.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?n=new dn(gn.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):r.type==="orthographic"&&(n=new Hi(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),r.name&&(n.name=this.createUniqueName(r.name)),Bi(n,r),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],r=[];for(let i=0,s=n.joints.length;i<s;i++)r.push(this._loadNodeShallow(n.joints[i]));return n.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",n.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(i){const s=i.pop(),o=i,a=[],l=[];for(let c=0,f=o.length;c<f;c++){const u=o[c];if(u){a.push(u);const d=new Ce;s!==null&&d.fromArray(s.array,c*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[c])}return new Kh(a,l)})}loadAnimation(e){const n=this.json,r=this,i=n.animations[e],s=i.name?i.name:"animation_"+e,o=[],a=[],l=[],c=[],f=[];for(let u=0,d=i.channels.length;u<d;u++){const h=i.channels[u],m=i.samplers[h.sampler],v=h.target,g=v.node,p=i.parameters!==void 0?i.parameters[m.input]:m.input,x=i.parameters!==void 0?i.parameters[m.output]:m.output;v.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",p)),l.push(this.getDependency("accessor",x)),c.push(m),f.push(v))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(f)]).then(function(u){const d=u[0],h=u[1],m=u[2],v=u[3],g=u[4],p=[];for(let x=0,_=d.length;x<_;x++){const w=d[x],M=h[x],T=m[x],b=v[x],C=g[x];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const A=r._createAnimationTracks(w,M,T,b,C);if(A)for(let E=0;E<A.length;E++)p.push(A[E])}return new bA(s,void 0,p)})}createNodeMesh(e){const n=this.json,r=this,i=n.nodes[e];return i.mesh===void 0?null:r.getDependency("mesh",i.mesh).then(function(s){const o=r._getNodeRef(r.meshCache,i.mesh,s);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const n=this.json,r=this,i=n.nodes[e],s=r._loadNodeShallow(e),o=[],a=i.children||[];for(let c=0,f=a.length;c<f;c++)o.push(r.getDependency("node",a[c]));const l=i.skin===void 0?Promise.resolve(null):r.getDependency("skin",i.skin);return Promise.all([s,Promise.all(o),l]).then(function(c){const f=c[0],u=c[1],d=c[2];d!==null&&f.traverse(function(h){h.isSkinnedMesh&&h.bind(d,y5)});for(let h=0,m=u.length;h<m;h++)f.add(u[h]);return f})}_loadNodeShallow(e){const n=this.json,r=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=n.nodes[e],o=s.name?i.createUniqueName(s.name):"",a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(c){return i._getNodeRef(i.cameraCache,s.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let f;if(s.isBone===!0?f=new Jf:c.length>1?f=new qt:c.length===1?f=c[0]:f=new Et,f!==c[0])for(let u=0,d=c.length;u<d;u++)f.add(c[u]);if(s.name&&(f.userData.name=s.name,f.name=o),Bi(f,s),s.extensions&&yo(r,f,s),s.matrix!==void 0){const u=new Ce;u.fromArray(s.matrix),f.applyMatrix4(u)}else s.translation!==void 0&&f.position.fromArray(s.translation),s.rotation!==void 0&&f.quaternion.fromArray(s.rotation),s.scale!==void 0&&f.scale.fromArray(s.scale);return i.associations.has(f)||i.associations.set(f,{}),i.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const n=this.extensions,r=this.json.scenes[e],i=this,s=new qt;r.name&&(s.name=i.createUniqueName(r.name)),Bi(s,r),r.extensions&&yo(n,s,r);const o=r.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(i.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let f=0,u=l.length;f<u;f++)s.add(l[f]);const c=f=>{const u=new Map;for(const[d,h]of i.associations)(d instanceof Nr||d instanceof on)&&u.set(d,h);return f.traverse(d=>{const h=i.associations.get(d);h!=null&&u.set(d,h)}),u};return i.associations=c(s),s})}_createAnimationTracks(e,n,r,i,s){const o=[],a=e.name?e.name:e.uuid,l=[];vs[s.path]===vs.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(a);let c;switch(vs[s.path]){case vs.weights:c=Yo;break;case vs.rotation:c=no;break;case vs.position:case vs.scale:c=Ko;break;default:switch(r.itemSize){case 1:c=Yo;break;case 2:case 3:default:c=Ko;break}break}const f=i.interpolation!==void 0?f5[i.interpolation]:au,u=this._getArrayFromAccessor(r);for(let d=0,h=l.length;d<h;d++){const m=new c(l[d]+"."+vs[s.path],n.array,u,f);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const r=Kv(n.constructor),i=new Float32Array(n.length);for(let s=0,o=n.length;s<o;s++)i[s]=n[s]*r;n=i}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const i=this instanceof no?d5:zA;return new i(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function _5(t,e,n){const r=e.attributes,i=new Gt;if(r.POSITION!==void 0){const a=n.json.accessors[r.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new k(l[0],l[1],l[2]),new k(c[0],c[1],c[2])),a.normalized){const f=Kv(nl[a.componentType]);i.min.multiplyScalar(f),i.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new k,l=new k;for(let c=0,f=s.length;c<f;c++){const u=s[c];if(u.POSITION!==void 0){const d=n.json.accessors[u.POSITION],h=d.min,m=d.max;if(h!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(h[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(h[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(h[2]),Math.abs(m[2]))),d.normalized){const v=Kv(nl[d.componentType]);l.multiplyScalar(v)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}t.boundingBox=i;const o=new bi;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=o}function lM(t,e,n){const r=e.attributes,i=[];function s(o,a){return n.getDependency("accessor",o).then(function(l){t.setAttribute(a,l)})}for(const o in r){const a=Yv[o]||o.toLowerCase();a in t.attributes||i.push(s(r[o],a))}if(e.indices!==void 0&&!t.index){const o=n.getDependency("accessor",e.indices).then(function(a){t.setIndex(a)});i.push(o)}return $e.workingColorSpace!==Ln&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$e.workingColorSpace}" not supported.`),Bi(t,e),_5(t,e,n),Promise.all(i).then(function(){return e.targets!==void 0?p5(t,e.targets,n):t})}const Rm=new WeakMap;class w5 extends Si{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,n,r,i){const s=new hu(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{this.parse(o,n,i)},r,i)}parse(e,n,r=()=>{}){this.decodeDracoFile(e,n,null,null,ft,r).catch(r)}decodeDracoFile(e,n,r,i,s=Ln,o=()=>{}){const a={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:s};return this.decodeGeometry(e,a).then(n).catch(o)}decodeGeometry(e,n){const r=JSON.stringify(n);if(Rm.has(e)){const l=Rm.get(e);if(l.key===r)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((c,f)=>{i._callbacks[s]={resolve:c,reject:f},i.postMessage({type:"decode",id:s,taskConfig:n,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Rm.set(e,{key:r,promise:a}),a}_createGeometry(e){const n=new Wt;e.index&&n.setIndex(new hn(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const i=e.attributes[r],s=i.name,o=i.array,a=i.itemSize,l=new hn(o,a);s==="color"&&(this._assignVertexColorSpace(l,i.vertexColorSpace),l.normalized=!(o instanceof Float32Array)),n.setAttribute(s,l)}return n}_assignVertexColorSpace(e,n){if(n!==ft)return;const r=new Pe;for(let i=0,s=e.count;i<s;i++)r.fromBufferAttribute(e,i),$e.toWorkingColorSpace(r,ft),e.setXYZ(i,r.r,r.g,r.b)}_loadLibrary(e,n){const r=new hu(this.manager);return r.setPath(this.decoderPath),r.setResponseType(n),r.setWithCredentials(this.withCredentials),new Promise((i,s)=>{r.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",n=[];return e?n.push(this._loadLibrary("draco_decoder.js","text")):(n.push(this._loadLibrary("draco_wasm_wrapper.js","text")),n.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(n).then(r=>{const i=r[0];e||(this.decoderConfig.wasmBinary=r[1]);const s=S5.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,n){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=n,r._taskLoad+=n,r})}_releaseTask(e,n){e._taskLoad-=e._taskCosts[n],delete e._callbacks[n],delete e._taskCosts[n]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function S5(){let t,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":t=a.decoderConfig,e=new Promise(function(f){t.onModuleLoaded=function(u){f({draco:u})},DracoDecoderModule(t)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(f=>{const u=f.draco,d=new u.Decoder;try{const h=n(u,d,new Int8Array(l),c),m=h.attributes.map(v=>v.array.buffer);h.index&&m.push(h.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:h},m)}catch(h){console.error(h),self.postMessage({type:"error",id:a.id,error:h.message})}finally{u.destroy(d)}});break}};function n(o,a,l,c){const f=c.attributeIDs,u=c.attributeTypes;let d,h;const m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)d=new o.Mesh,h=a.DecodeArrayToMesh(l,l.byteLength,d);else if(m===o.POINT_CLOUD)d=new o.PointCloud,h=a.DecodeArrayToPointCloud(l,l.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!h.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+h.error_msg());const v={index:null,attributes:[]};for(const g in f){const p=self[u[g]];let x,_;if(c.useUniqueIDs)_=f[g],x=a.GetAttributeByUniqueId(d,_);else{if(_=a.GetAttributeId(d,o[f[g]]),_===-1)continue;x=a.GetAttribute(d,_)}const w=i(o,a,d,g,p,x);g==="color"&&(w.vertexColorSpace=c.vertexColorSpace),v.attributes.push(w)}return m===o.TRIANGULAR_MESH&&(v.index=r(o,a,d)),o.destroy(d),v}function r(o,a,l){const f=l.num_faces()*3,u=f*4,d=o._malloc(u);a.GetTrianglesUInt32Array(l,u,d);const h=new Uint32Array(o.HEAPF32.buffer,d,f).slice();return o._free(d),{array:h,itemSize:1}}function i(o,a,l,c,f,u){const d=u.num_components(),m=l.num_points()*d,v=m*f.BYTES_PER_ELEMENT,g=s(o,f),p=o._malloc(v);a.GetAttributeDataArrayForAllPoints(l,u,g,v,p);const x=new f(o.HEAPF32.buffer,p,m).slice();return o._free(p),{name:c,array:x,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}const ys={DEBUG:0,INFO:1,WARN:2,ERROR:3},Eo=class Eo{constructor(){kt(this,"currentLevel",ys.INFO);kt(this,"isDevelopment",!1);this.currentLevel=this.isDevelopment?ys.DEBUG:ys.ERROR}static getInstance(){return Eo.instance||(Eo.instance=new Eo),Eo.instance}setLevel(e){this.currentLevel=e}debug(e,...n){this.currentLevel<=ys.DEBUG&&console.log(`[DEBUG] ${e}`,...n)}info(e,...n){this.currentLevel<=ys.INFO&&console.info(`[INFO] ${e}`,...n)}warn(e,...n){this.currentLevel<=ys.WARN&&console.warn(`[WARN] ${e}`,...n)}error(e,...n){this.currentLevel<=ys.ERROR&&console.error(`[ERROR] ${e}`,...n)}performance(e,n){this.currentLevel<=ys.DEBUG?(console.time(e),n(),console.timeEnd(e)):n()}};kt(Eo,"instance");let qv=Eo;const ar=qv.getInstance(),M5=t=>{const e=S.useRef(null),n=S.useRef(null),[r,i]=S.useState([]),[s,o]=S.useState(null),[a,l]=S.useState(!1),[c,f]=S.useState(null),u=S.useRef(null);S.useEffect(()=>{e.current||(e.current=new zV,n.current=new w5,n.current.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.6/"),e.current.setDRACOLoader(n.current),console.log("GLTF and DRACO loaders initialized"))},[]);const d=S.useCallback(g=>{try{g.traverse(p=>{p instanceof je&&(p.geometry&&p.geometry.dispose(),p.material&&(Array.isArray(p.material)?p.material.forEach(x=>{x.map&&x.map.dispose(),x.normalMap&&x.normalMap.dispose(),x.bumpMap&&x.bumpMap.dispose(),x.dispose()}):(p.material.map&&p.material.map.dispose(),p.material.normalMap&&p.material.normalMap.dispose(),p.material.bumpMap&&p.material.bumpMap.dispose(),p.material.dispose())))})}catch(p){console.error("Error disposing object:",p)}},[]),h=S.useCallback(async g=>{const p=Date.now().toString();if(ar.info("Starting GLTF load process:",g.name),!t){ar.error("Scene not available for GLTF loading"),f("3D scene not ready. Please try again.");return}u.current&&u.current.abort();const x=new AbortController;u.current=x,l(!0),f(null);try{const _=g.name.toLowerCase();if(!_.endsWith(".gltf")&&!_.endsWith(".glb"))throw new Error("Invalid file format. Please select a GLTF or GLB file.");if(g.size>50*1024*1024)throw new Error("File too large. Please select a file smaller than 50MB.");if(!e.current)throw new Error("GLTF loader not initialized");console.log("Reading file as array buffer...");const w=await g.arrayBuffer();if(x.signal.aborted){console.log("GLTF loading aborted");return}console.log("Parsing GLTF data...");const M=await new Promise((I,U)=>{e.current.parse(w,"",z=>I(z),z=>U(z))});if(x.signal.aborted){console.log("GLTF loading aborted after parsing"),M.scene&&d(M.scene);return}console.log("GLTF parsed successfully:",M),console.log("Scene children count:",M.scene.children.length),console.log("Scene structure:",M.scene);const T={},b=[];if(console.log("Starting mesh traversal..."),M.scene.traverse(I=>{var U;if(console.log("Traversing node:",I.type,I.name||"unnamed","isMesh:",I.isMesh),console.log("Node userData:",I.userData),I.isMesh){const z=I;b.push(z);let O=null;if(console.log(`🔍 Checking mesh "${z.name}" userData:`,z.userData),(U=z.userData)!=null&&U.object_params){const j=z.userData.object_params;console.log("✅ Found object_params in userData:",j),O={id:j.id,name:j.name,parent_id:j.parent_id,type:j.type,function:j.function},console.log("✅ Extracted metadata from object_params:",O)}else console.log("❌ No object_params found in userData, creating fallback"),O={id:z.name||`mesh_${b.length-1}_${z.uuid.slice(0,8)}`,name:z.name||`Mesh_${b.length-1}`,parent_id:"none",type:"mesh",function:"none"},console.log("🔄 Fallback metadata:",O);if(O||(console.log("No GLTF metadata found, creating fallback..."),O={id:`mesh_${b.length-1}_${z.uuid.slice(0,8)}`,name:I.name||`Mesh_${b.length-1}`,parent_id:"none",type:"mesh",function:"none"}),O&&O.id)console.log(`Found mesh with metadata: id=${O.id}, type=${O.type}, name=${O.name}`),T[O.id]={mesh:z,metadata:O};else{console.log(`Mesh without valid metadata found: ${z.name||"unnamed"}`);const j=`mesh_${b.length-1}_${z.uuid.slice(0,8)}`;T[j]={mesh:z,metadata:{id:j,name:z.name||`Mesh_${b.length-1}`,parent_id:"none",type:"unknown",function:"none"}}}}}),console.log(`Mesh traversal complete. Found ${b.length} meshes, ${Object.keys(T).length} with valid IDs`),b.length===0)throw console.error("No meshes found in GLB file!"),new Error("No meshes found in the GLB file. Please check that the file contains 3D geometry.");Object.keys(T).length===0&&(console.warn("No meshes with ID metadata found. Adding all meshes without metadata..."),b.forEach((I,U)=>{const z=`mesh_${U}_${I.uuid.slice(0,8)}`;T[z]={mesh:I,metadata:{id:z,name:I.name||`Mesh_${U}`,parent_id:"none",type:"unknown",function:"none"}}}),console.log(`Added ${Object.keys(T).length} meshes with fallback IDs`));const C=[];Object.values(T).forEach(({mesh:I,metadata:U})=>{const z=new k,O=new Qt,j=new k;I.getWorldPosition(z),I.getWorldQuaternion(new nn().setFromEuler(O)),I.getWorldScale(j),I.parent&&I.parent.remove(I),I.position.copy(z),I.rotation.copy(O),I.scale.copy(j),I.castShadow=!0,I.receiveShadow=!0,console.log(`💾 Storing metadata in mesh userData for "${I.name}":`,U),I.userData={...I.userData,id:U.id,name:U.name,parent_id:U.parent_id,type:U.type,function:U.function,isDetachedFromGLB:!0,originalMetadata:U,loadedModelId:p},console.log(`✅ Final userData for "${I.name}":`,I.userData),console.log(`✅ Stored metadata in mesh.userData for "${I.name}":`,{id:I.userData.id,name:I.userData.name,parent_id:I.userData.parent_id,type:I.userData.type,function:I.userData.function}),C.push(I),console.log(`Detached mesh: ${U.name||U.id} at position:`,z)});const A=new qt;A.name=g.name.replace(/\.(gltf|glb)$/i,""),C.forEach(I=>{t.add(I),I.userData.loadedModelId=p,I.userData.isDetachedFromGLB=!0});const E=new qt;C.forEach(I=>E.add(I.clone()));const N=new Gt().setFromObject(E);console.log(`Added ${C.length} individual meshes to scene`),A.userData.isLoadedModel=!0,A.userData.objectsById=T,A.userData.detachedMeshes=C,A.userData.meshCount=C.length;const F={id:p,name:g.name.replace(/\.(gltf|glb)$/i,""),object:A,boundingBox:N.clone(),size:g.size};s&&(console.log("Removing previous model from scene"),t.remove(s.object),d(s.object)),console.log(`Added container with ${C.length} mesh objects to scene`),console.log("Objects accessible by ID:",Object.keys(T)),console.log("Container position:",{x:A.position.x.toFixed(2),y:A.position.y.toFixed(2),z:A.position.z.toFixed(2)}),i(I=>[...I,F]),o(F)}catch(_){if(!x.signal.aborted){console.error("Failed to load GLTF model:",_);const w=_ instanceof Error?_.message:"Failed to load model. Please check the file format.";f(w)}}finally{x.signal.aborted||l(!1),u.current=null}},[t,s,d]),m=S.useCallback(g=>{if(!t)return;const p=r.find(x=>x.id===g);p&&(s&&s.object.userData.detachedMeshes&&s.object.userData.detachedMeshes.forEach(x=>{t.remove(x)}),p.object.userData.detachedMeshes&&p.object.userData.detachedMeshes.forEach(x=>{t.add(x)}),o(p))},[t,r,s]),v=S.useCallback(g=>{if(!t)return;const p=r.find(x=>x.id===g);p&&((s==null?void 0:s.id)===g&&(p.object.userData.detachedMeshes&&p.object.userData.detachedMeshes.forEach(x=>{t.remove(x)}),o(null)),d(p.object),i(x=>x.filter(_=>_.id!==g)))},[t,r,s,d]);return S.useEffect(()=>()=>{u.current&&u.current.abort(),n.current&&n.current.dispose(),r.forEach(g=>{try{g.object.userData.detachedMeshes&&g.object.userData.detachedMeshes.forEach(p=>{t&&t.remove(p)}),d(g.object)}catch(p){console.warn("Error disposing model on cleanup:",p)}})},[r,d,t]),{loadedModels:r,currentModel:s,isLoading:a,error:c,loadGLTFModel:h,switchToModel:m,removeModel:v}},b5=(t,e,n,r,i)=>{const s=S.useRef(null);return S.useEffect(()=>{const o={zoomAll:()=>{if(console.log("Executing zoomAll"),!t.current||!e.current||!n.current){console.log("Missing refs for zoomAll");return}const a=[];if(t.current.traverse(_=>{(_ instanceof je||_ instanceof qt)&&a.push(_)}),a.length===0){console.log("No objects found for zoomAll");return}const l=new Gt;if(a.forEach(_=>{if(_.visible){const w=new Gt().setFromObject(_);l.union(w)}}),l.isEmpty()){console.log("Bounding box is empty");return}const c=l.getCenter(new k),f=l.getSize(new k),u=Math.max(f.x,f.y,f.z);let d;if(e.current instanceof dn)d=u/(2*Math.tan(e.current.fov*Math.PI/360))*1.5;else if(e.current instanceof Hi){const _=e.current,w=Math.max(f.x,f.y,f.z),M=Math.min(Math.abs(_.right-_.left)/w,Math.abs(_.top-_.bottom)/w)*.8;_.zoom=M,_.updateProjectionMatrix(),d=w*1.5}else d=u*1.5;const h=c.clone().add(new k(1,1,1).normalize().multiplyScalar(d)),m=e.current.position.clone(),v=n.current.target.clone(),g=Date.now(),p=1e3,x=()=>{const _=Date.now()-g,w=Math.min(_/p,1),M=1-Math.pow(1-w,3);e.current.position.lerpVectors(m,h,M),n.current.target.lerpVectors(v,c,M),n.current.update(),i!=null&&i.current&&i.current.render(t.current,e.current),w<1&&requestAnimationFrame(x)};x()},zoomToSelected:()=>{if(console.log("Executing zoomToSelected",r),!r||!e.current||!n.current){console.log("No selected object or missing refs");return}const a=r.object,l=new Gt().setFromObject(a),c=l.getCenter(new k),f=l.getSize(new k),u=Math.max(f.x,f.y,f.z);let d;if(e.current instanceof dn)d=u/(2*Math.tan(e.current.fov*Math.PI/360))*2;else if(e.current instanceof Hi){const _=e.current,w=Math.min(Math.abs(_.right-_.left)/u,Math.abs(_.top-_.bottom)/u)*.5;_.zoom=w,_.updateProjectionMatrix(),d=u*2}else d=u*2;const h=c.clone().add(new k(1,1,1).normalize().multiplyScalar(d)),m=e.current.position.clone(),v=n.current.target.clone(),g=Date.now(),p=1e3,x=()=>{const _=Date.now()-g,w=Math.min(_/p,1),M=1-Math.pow(1-w,3);e.current.position.lerpVectors(m,h,M),n.current.target.lerpVectors(v,c,M),n.current.update(),i!=null&&i.current&&i.current.render(t.current,e.current),w<1&&requestAnimationFrame(x)};x()},zoomIn:()=>{if(console.log("Executing zoomIn"),!e.current||!n.current){console.log("Missing refs for zoomIn");return}const a=n.current.target;if(e.current instanceof Hi){const g=e.current,p=g.zoom,x=Math.min(g.zoom*1.25,10),_=Date.now(),w=300,M=()=>{const T=Date.now()-_,b=Math.min(T/w,1),C=1-Math.pow(1-b,3);g.zoom=p+(x-p)*C,g.updateProjectionMatrix(),n.current.update(),i!=null&&i.current&&i.current.render(t.current,e.current),b<1&&requestAnimationFrame(M)};M();return}const l=e.current.position.clone().sub(a).normalize(),c=e.current.position.distanceTo(a),f=Math.max(c*.8,n.current.minDistance),u=a.clone().add(l.multiplyScalar(f)),d=e.current.position.clone(),h=Date.now(),m=300,v=()=>{const g=Date.now()-h,p=Math.min(g/m,1),x=1-Math.pow(1-p,3);e.current.position.lerpVectors(d,u,x),n.current.update(),i!=null&&i.current&&i.current.render(t.current,e.current),p<1&&requestAnimationFrame(v)};v()},zoomOut:()=>{if(console.log("Executing zoomOut"),!e.current||!n.current){console.log("Missing refs for zoomOut");return}const a=n.current.target;if(e.current instanceof Hi){const g=e.current,p=g.zoom,x=Math.max(g.zoom*.8,.1),_=Date.now(),w=300,M=()=>{const T=Date.now()-_,b=Math.min(T/w,1),C=1-Math.pow(1-b,3);g.zoom=p+(x-p)*C,g.updateProjectionMatrix(),n.current.update(),i!=null&&i.current&&i.current.render(t.current,e.current),b<1&&requestAnimationFrame(M)};M();return}const l=e.current.position.clone().sub(a).normalize(),c=e.current.position.distanceTo(a),f=Math.min(c*1.25,n.current.maxDistance),u=a.clone().add(l.multiplyScalar(f)),d=e.current.position.clone(),h=Date.now(),m=300,v=()=>{const g=Date.now()-h,p=Math.min(g/m,1),x=1-Math.pow(1-p,3);e.current.position.lerpVectors(d,u,x),n.current.update(),i!=null&&i.current&&i.current.render(t.current,e.current),p<1&&requestAnimationFrame(v)};v()},resetView:()=>{if(console.log("Executing resetView"),!e.current||!n.current){console.log("Missing refs for resetView");return}const a=new k(5,5,5),l=new k(0,0,0);if(e.current instanceof Hi){const m=e.current;m.zoom=1,m.updateProjectionMatrix()}const c=e.current.position.clone(),f=n.current.target.clone(),u=Date.now(),d=1e3,h=()=>{const m=Date.now()-u,v=Math.min(m/d,1),g=1-Math.pow(1-v,3);e.current.position.lerpVectors(c,a,g),n.current.target.lerpVectors(f,l,g),n.current.update(),i!=null&&i.current&&i.current.render(t.current,e.current),v<1&&requestAnimationFrame(h)};h()}};return s.current=o,window.__zoomControls=o,()=>{delete window.__zoomControls}},[t,e,n,r,i]),s.current||{zoomAll:()=>{console.log("zoomAll not ready")},zoomToSelected:()=>{console.log("zoomToSelected not ready")},zoomIn:()=>{console.log("zoomIn not ready")},zoomOut:()=>{console.log("zoomOut not ready")},resetView:()=>{console.log("resetView not ready")}}},E5=(t,e,n,r)=>{const i=S.useCallback((m,v)=>{if(!e.current||!n.current)return;const g=e.current.position.clone(),p=n.current.target.clone(),x=Date.now(),_=800,w=()=>{const M=Date.now()-x,T=Math.min(M/_,1),b=1-Math.pow(1-T,3);e.current.position.lerpVectors(g,m,b),n.current.target.lerpVectors(p,v,b),n.current.update(),r!=null&&r.current&&r.current.render(t.current,e.current),T<1&&requestAnimationFrame(w)};w()},[t,e,n,r]),s=S.useCallback(()=>{if(!t.current)return new Gt;const m=new Gt;return t.current.traverse(v=>{if(v instanceof je&&v.visible){const g=new Gt().setFromObject(v);m.union(g)}}),m.isEmpty()?new Gt(new k(-5,-5,-5),new k(5,5,5)):m},[t]),o=S.useCallback(()=>{const m=s(),v=m.getCenter(new k),g=m.getSize(new k),x=Math.max(g.x,g.z)*1.5,_=v.clone().add(new k(0,x,0));i(_,v)},[s,i]),a=S.useCallback(()=>{const m=s(),v=m.getCenter(new k),g=m.getSize(new k),x=Math.max(g.x,g.y)*1.5,_=v.clone().add(new k(0,0,x));i(_,v)},[s,i]),l=S.useCallback(()=>{const m=s(),v=m.getCenter(new k),g=m.getSize(new k),x=Math.max(g.x,g.y)*1.5,_=v.clone().add(new k(0,0,-x));i(_,v)},[s,i]),c=S.useCallback(()=>{const m=s(),v=m.getCenter(new k),g=m.getSize(new k),x=Math.max(g.x,g.z)*1.5,_=v.clone().add(new k(0,-x,0));i(_,v)},[s,i]),f=S.useCallback(()=>{const m=s(),v=m.getCenter(new k),g=m.getSize(new k),x=Math.max(g.y,g.z)*1.5,_=v.clone().add(new k(x,0,0));i(_,v)},[s,i]),u=S.useCallback(()=>{const m=s(),v=m.getCenter(new k),g=m.getSize(new k),x=Math.max(g.y,g.z)*1.5,_=v.clone().add(new k(-x,0,0));i(_,v)},[s,i]),d=S.useCallback(()=>{const m=s(),v=m.getCenter(new k),g=m.getSize(new k),x=Math.max(g.x,g.y,g.z)*1.5,_=v.clone().add(new k(1,1,1).normalize().multiplyScalar(x));i(_,v)},[s,i]),h={viewTop:o,viewFront:a,viewBack:l,viewBottom:c,viewRight:f,viewLeft:u,viewIsometric:d};return S.useEffect(()=>(window.__standardViews=h,()=>{delete window.__standardViews}),[h]),h},T5=({sunlight:t,ambientLight:e,shadowQuality:n,environment:r,onModelsChange:i,onSceneReady:s})=>{const o=S.useRef(null),{selectedObject:a}=Bl(),{sceneRef:l,perspectiveCameraRef:c,rendererRef:f,labelRendererRef:u,controlsRef:d,gridHelperRef:h,performanceMetrics:m,isOrthographic:v,switchCamera:g,updateAdaptiveGrid:p}=Kj(o),{loadedModels:x,currentModel:_,isLoading:w,error:M,loadFBXModel:T,switchToModel:b,removeModel:C}=FV(l.current),{loadedModels:A,currentModel:E,isLoading:N,error:F,loadGLTFModel:I,switchToModel:U,removeModel:z}=M5(l.current),O=S.useCallback(async ee=>{const se=await I(ee);return setTimeout(()=>p(),100),se},[I,p]),j=[...x,...A],D=_||E,V=w||N,Q=M||F,J=ee=>{const se=x.find(ue=>ue.id===ee),Z=A.find(ue=>ue.id===ee);se?b(ee):Z&&U(ee)},le=ee=>{const se=x.find(ue=>ue.id===ee),Z=A.find(ue=>ue.id===ee);se?C(ee):Z&&z(ee)},pe=b5(l,c,d,a,f),$=E5(l,c,d,f);return qj(l.current,t,e,n),Zj(l.current,r,h.current),S.useEffect(()=>{l.current&&s&&s(l.current)},[s]),S.useEffect(()=>{if(i){const ee=setTimeout(()=>{i(j,D)},0);return()=>clearTimeout(ee)}},[j.length,D==null?void 0:D.id,i]),{mountRef:o,scene:l.current,camera:c.current,renderer:f.current,controls:d.current,currentModel:D,isLoading:V,error:Q,loadFBXModel:T,loadGLTFModel:O,switchToModel:J,removeModel:le,performanceMetrics:m,isOrthographic:v,switchCamera:g,zoomControls:pe,standardViews:$}},A5=t=>{var e;return(e=t.userData)!=null&&e.id?`gltf_${t.userData.id}`:t.userData.isPrimitive?`primitive_${t.uuid}`:t.userData.isPoint?`point_${t.uuid}`:t.userData.isMeasurementGroup?`measurement_${t.uuid}`:t.userData.isLoadedModel||t instanceof qt?`group_${t.uuid}`:t instanceof je?`mesh_${t.uuid}`:t instanceof ao?`light_${t.uuid}`:t.type==="GridHelper"||t.type==="AxesHelper"?`env_${t.uuid}`:`object_${t.uuid}`},C5=t=>t.userData.isLoadedModel?"model":t.userData.isPrimitive?"primitive":t.userData.isPoint?"point":t.userData.isMeasurementGroup?"measurement":t instanceof qt?"group":t instanceof je?"mesh":t instanceof ao?"light":t.type==="GridHelper"||t.type==="AxesHelper"?"environment":"mesh",R5=()=>{const{selectObject:t,selectedObjects:e,clearSelection:n,toggleSelection:r}=Bl(),i=S.useMemo(()=>(s,o=!1)=>{var a,l,c;if(s){const f=A5(s),u=C5(s);let d="";(a=s.userData)!=null&&a.name?d=s.userData.name:(l=s.userData)!=null&&l.id?d=s.userData.id:s.name?d=s.name:d=`${((c=s.userData)==null?void 0:c.type)||s.type}_${s.uuid.slice(0,8)}`;const h={id:f,name:d,type:u,object:s,children:[],visible:s.visible,selected:!0};console.log("Selecting object:",h.name,"Type:",h.type,"Multi:",o),o?r(h):t(h)}else o||(console.log("Clearing selection"),n())},[t,n,r]);return{selectedObjects:e,clearSelection:n,handleObjectSelect:i}};class P5{constructor(){kt(this,"overlayMaterial",null)}getOverlayMaterial(){return this.overlayMaterial||(this.overlayMaterial=new Pn({color:16711680,transparent:!0,opacity:.3,depthTest:!1,depthWrite:!1})),this.overlayMaterial}dispose(){this.overlayMaterial&&(this.overlayMaterial.dispose(),this.overlayMaterial=null)}}const N5=t=>{if(t instanceof je){const e=new cu(t.geometry),n=new ii({color:35071,linewidth:60,transparent:!0,opacity:.8}),r=new to(e,n);return r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.userData.isHelper=!0,r}return null},D5=t=>{if(t instanceof je){const e=new $o(.12,16,16),n=new Pn({color:35071,transparent:!0,opacity:.5,depthTest:!1}),r=new je(e,n);return r.position.copy(t.position),r.userData.isHelper=!0,r}return null},L5=t=>{const e=new qt;return e.userData.isHelper=!0,t.children.forEach(n=>{if(n instanceof je){const r=new $o(.12,16,16),i=new Pn({color:35071,transparent:!0,opacity:.5,depthTest:!1}),s=new je(r,i);s.position.copy(n.position),e.add(s)}else if(n instanceof wi){const r=n.geometry.clone(),i=new rx({color:35071,linewidth:5,dashSize:.1,gapSize:.05,transparent:!0,opacity:.8}),s=new wi(r,i);s.computeLineDistances(),s.position.copy(n.position),s.rotation.copy(n.rotation),s.scale.copy(n.scale),e.add(s)}}),e},I5=t=>{if(t instanceof je){const e=new cu(t.geometry),n=new ii({color:16755200,linewidth:2,transparent:!0,opacity:.8}),r=new to(e,n);return r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.userData.isHelper=!0,r}return null},k5=t=>{if(t instanceof je){const e=new Gt().setFromObject(t),n=e.getSize(new k),r=e.getCenter(new k),i=new Hl(n.x,n.y,n.z),s=new cu(i),o=new ii({color:65535,linewidth:1,transparent:!0,opacity:.6}),a=new to(s,o);return a.position.copy(r),a.userData.isHelper=!0,a}return null},O5=t=>({outline:N5(t),boundingBox:k5(t)}),F5=()=>{const t=S.useRef(new Map);return{applyPointSelection:(n,r)=>{var s,o;const i=t.current;if(r){if(!i.has(n)){const a=D5(n);a&&(i.set(n,a),(s=n.parent)==null||s.add(a))}}else{const a=i.get(n);a&&((o=a.parent)==null||o.remove(a),a.geometry.dispose(),a.material.dispose(),i.delete(n))}}}},U5=()=>{const t=S.useRef(new Map);return{applyMeasurementSelection:(n,r)=>{var s,o;if(!(n instanceof qt))return;const i=t.current;if(r){if(n.userData.label&&(n.userData.label.visible=!0),!i.has(n)){const a=L5(n);a&&(i.set(n,a),(s=n.parent)==null||s.add(a))}}else{const a=i.get(n);a&&((o=a.parent)==null||o.remove(a),a.children.forEach(l=>{(l instanceof je||l instanceof wi)&&(l.geometry.dispose(),l.material.dispose())}),i.delete(n)),n.userData.label&&(n.userData.label.visible=!1)}}}},B5=()=>{const t=S.useRef(new Map),e=S.useRef(new Map);return{applyMeshSelection:(r,i)=>{var a,l,c,f;console.log(`useMeshSelection: ${i?"SELECTING":"DESELECTING"} object:`,r.name||r.type);const s=t.current,o=e.current;if(i)if(s.has(r)){console.log("Selection effects already exist for object:",r.name||r.type);const u=s.get(r),d=o.get(r);u&&(u.visible=!0),d&&(d.visible=!0)}else{console.log("Creating new selection effects for object:",r.name||r.type);const{outline:u,boundingBox:d}=O5(r);if(u){s.set(r,u);const h=((a=r.parent)==null?void 0:a.parent)||r.parent;h?(h.add(u),console.log("Added outline to scene")):console.warn("No scene found for outline")}if(d){o.set(r,d);const h=((l=r.parent)==null?void 0:l.parent)||r.parent;h?(h.add(d),console.log("Added bounding box to scene")):console.warn("No scene found for bounding box")}}else{console.log("Removing selection effects for object:",r.name||r.type);const u=s.get(r);u&&((c=u.parent)==null||c.remove(u),u.geometry.dispose(),u.material.dispose(),s.delete(r),console.log("Removed outline"));const d=o.get(r);d&&((f=d.parent)==null||f.remove(d),d.geometry.dispose(),d.material.dispose(),o.delete(r),console.log("Removed bounding box"))}}}},z5=t=>{const{applyPointSelection:e}=F5(),{applyMeasurementSelection:n}=U5(),{applyMeshSelection:r}=B5(),i=S.useRef(null),s=S.useRef([]);i.current||(i.current=new P5);const o=(a,l,c)=>{if(console.log(`Applying selection effects: ${l?"SELECT":"DESELECT"} for object type: ${c}, object:`,a.name||a.type),c==="point"){e(a,l);return}if(c==="measurement"){n(a,l);return}r(a,l)};S.useEffect(()=>{console.log("Selection effects: selectedObjects changed",t.length,"objects");const a=s.current;a.forEach(l=>{!t.some(f=>f.id===l.id)&&(l!=null&&l.object)&&(console.log("Removing selection effects from deselected object:",l.name),o(l.object,!1,l.type))}),t.forEach(l=>{l!=null&&l.object&&(a.some(f=>f.id===l.id)||(console.log("Applying selection effects to newly selected object:",l.name),o(l.object,!0,l.type)))}),s.current=[...t]},[t]),S.useEffect(()=>()=>{console.log("Selection effects: cleanup on unmount"),i.current&&(i.current.dispose(),i.current=null)},[])};class Pm{constructor(e,n,r=5){kt(this,"objects",[]);kt(this,"createFn");kt(this,"resetFn");this.createFn=e,this.resetFn=n;for(let i=0;i<r;i++)this.objects.push(this.createFn())}get(){return this.objects.length>0?this.objects.pop():this.createFn()}release(e){this.resetFn&&this.resetFn(e),this.objects.push(e)}clear(){this.objects.length=0}}const To=class To{constructor(){kt(this,"raycasterPool");kt(this,"vector3Pool");kt(this,"vector2Pool");this.raycasterPool=new Pm(()=>new Sj,e=>{e.ray.origin.set(0,0,0),e.ray.direction.set(0,0,-1),e.near=0,e.far=1/0}),this.vector3Pool=new Pm(()=>new k,e=>e.set(0,0,0)),this.vector2Pool=new Pm(()=>new ze,e=>e.set(0,0))}static getInstance(){return To.instance||(To.instance=new To),To.instance}getRaycaster(){return this.raycasterPool.get()}releaseRaycaster(e){this.raycasterPool.release(e)}getVector3(){return this.vector3Pool.get()}releaseVector3(e){this.vector3Pool.release(e)}getVector2(){return this.vector2Pool.get()}releaseVector2(e){this.vector2Pool.release(e)}clear(){this.raycasterPool.clear(),this.vector3Pool.clear(),this.vector2Pool.clear()}};kt(To,"instance");let Zv=To;const Fd=Zv.getInstance(),nh=()=>{const t=Fd.getRaycaster(),e=Fd.getVector2();return{raycaster:t,mouse:e,dispose:()=>{Fd.releaseRaycaster(t),Fd.releaseVector2(e)}}},Qv=(t,e,n,r,i)=>{const{raycaster:s,mouse:o,dispose:a}=nh(),l=n.domElement.getBoundingClientRect();o.x=(t-l.left)/l.width*2-1,o.y=-((e-l.top)/l.height)*2+1,s.setFromCamera(o,r);const c=[];i.traverse(d=>{d instanceof je&&d.visible&&c.push(d)});const f=s.intersectObjects(c,!0),u=f.length>0?f[0].point.clone():null;return a(),u};let ba=[],Jv=0;const e0=(t,e=!1)=>{const n=t.children.length;return(e||n!==Jv||ba.length===0)&&(ba=[],t.traverse(r=>{r instanceof je&&r.visible&&!r.userData.isHelper&&ba.push(r),(r.userData.isPoint||r.userData.isMeasurementGroup)&&r.visible&&ba.push(r)}),Jv=n),ba},H5=()=>{ba=[],Jv=0},j5=(t,e,n,r)=>{const i=S.useCallback(a=>{if(a.parent&&a.parent.userData.isMeasurementGroup)return a.parent;if(a.userData.isPartOfLoadedModel&&a.userData.loadedModelRoot)return a.userData.loadedModelRoot;if(a.userData.isLoadedModel||a.parent&&a.parent.userData.isLoadedModel){let l=a;for(;l.parent&&!l.userData.isLoadedModel;)if(l=l.parent,l.userData.isLoadedModel)return l}return a},[]),s=S.useCallback(a=>{if(!t||!e||!n||a.button!==0)return;a.stopPropagation(),a.preventDefault();const l=a.ctrlKey||a.metaKey,{raycaster:c,mouse:f}=nh(),u=t.domElement.getBoundingClientRect();f.x=(a.clientX-u.left)/u.width*2-1,f.y=-((a.clientY-u.top)/u.height)*2+1,c.setFromCamera(f,e);const d=e0(n),h=c.intersectObjects(d,!0);if(h.length>0&&r){const m=h[0].object,v=i(m);console.log("Object selected:",v.name||v.type,"from hit:",m.name||m.type),r(v,l)}else r&&!l&&(console.log("Selection cleared"),r(null,!1))},[t,e,n,r,i]),o=S.useCallback(a=>{if(!t||!e||!n||a.touches.length!==1)return;a.preventDefault(),a.stopPropagation();const l=a.touches[0],{raycaster:c,mouse:f}=nh(),u=t.domElement.getBoundingClientRect();f.x=(l.clientX-u.left)/u.width*2-1,f.y=-((l.clientY-u.top)/u.height)*2+1,c.setFromCamera(f,e);const d=e0(n),h=c.intersectObjects(d,!0);if(h.length>0&&r){const m=h[0].object,v=i(m);console.log("Object selected via touch:",v.name||v.type,"from hit:",m.name||m.type),r(v,!1)}else r&&(console.log("Selection cleared via touch"),r(null,!1))},[t,e,n,r,i]);return{handleClick:s,handleTouch:o}},V5=(t,e)=>{const n=new $o(.05,12,12),r=new Pn({color:16729156,emissive:2228224,emissiveIntensity:.3,metalness:.1,roughness:.4}),i=new je(n,r);return i.position.copy(t),i.userData.isPoint=!0,i.userData.isHelper=!0,i.name=`Point_${Date.now()}`,e.add(i),i},G5=(t,e,n)=>{const r=new qt;r.userData.isMeasurementGroup=!0,r.userData.isHelper=!0,r.name=`Measurement_${Date.now()}`;const i=new $o(.04,12,12),s=new Pn({color:16711680,emissive:4456448,emissiveIntensity:.4,metalness:.2,roughness:.3}),o=new je(i,s);o.position.copy(t),r.add(o);const a=new $o(.04,12,12),l=new je(a,s.clone());l.position.copy(e),r.add(l);const c=t.distanceTo(e),f=[t,e],u=new Wt().setFromPoints(f),d=new rx({color:16724787,linewidth:3,dashSize:.08,gapSize:.04,transparent:!0,opacity:.9}),h=new wi(u,d);h.computeLineDistances(),r.add(h);const m=document.createElement("div");m.className="measurement-label",m.textContent=`${c.toFixed(3)}m`,m.style.cssText=`
background: rgba(0, 0, 0, 0.8);
color: #ffffff;
font-size: 11px;
font-family: 'Monaco', 'Menlo', monospace;
padding: 2px 6px;
border-radius: 4px;
border: 1px solid #ff3333;
pointer-events: none;
white-space: nowrap;
box-shadow: 0 2px 4px rgba(0,0,0,0.3);
`;const v=new Aj(m),g=t.clone().add(e).multiplyScalar(.5);return g.y+=.1,v.position.copy(g),v.visible=!0,r.add(v),r.userData.label=v,r.userData.measurementData={startPoint:t,endPoint:e,distance:c},n.add(r),r},W5=(t,e,n,r)=>{r&&(n.remove(r),r.geometry.dispose(),r.material.dispose());const i=[t,e],s=new Wt().setFromPoints(i),o=new rx({color:8947848,linewidth:2,dashSize:.04,gapSize:.02,transparent:!0,opacity:.6}),a=new wi(s,o);return a.computeLineDistances(),a.userData.isHelper=!0,a.name="PreviewLine",n.add(a),a},Nm=(t,e)=>t&&(e.remove(t),t.geometry.dispose(),t.material.dispose(),null),X5=(t,e,n,r,i)=>({handleClick:S.useCallback(o=>{if(!t||!e||!n||o.button!==0)return;const a=Qv(o.clientX,o.clientY,t,e,n);if(a){const l=V5(a,n);r&&r({x:a.x,y:a.y,z:a.z}),i&&i(l)}},[t,e,n,r,i])}),$5=(t,e,n,r,i)=>{const s=S.useRef(null),o=S.useRef(null),a=S.useCallback(u=>{if(!t||!e||!n||u.button!==0)return;const d=Qv(u.clientX,u.clientY,t,e,n);if(d)if(!s.current)s.current=d.clone();else{const h=s.current,m=d,v=G5(h,m,n);o.current=Nm(o.current,n),r&&r(h,m),i&&i(v),s.current=null}},[t,e,n,r,i]),l=S.useCallback(u=>{if(!t||!e||!n||!s.current)return;const d=Qv(u.clientX,u.clientY,t,e,n);d&&(o.current=W5(s.current,d,n,o.current))},[t,e,n]),c=S.useCallback(()=>{s.current&&n&&(s.current=null,o.current=Nm(o.current,n))},[n]),f=S.useCallback(()=>{n&&o.current&&(o.current=Nm(o.current,n))},[n]);return{handleClick:a,handleMouseMove:l,handleRightClick:c,cleanup:f}},Y5=()=>{const[t,e]=S.useState({x:0,y:0}),n=S.useRef({x:0,y:0}),r=S.useCallback(s=>{let o=!1;return a=>{o||(s(a),o=!0,requestAnimationFrame(()=>{o=!1}))}},[]),i=S.useCallback((s,o)=>{const a={x:s,y:o};e(a),n.current=a},[]);return{mousePosition:t,mousePositionRef:n,throttledMouseMove:r,updateMousePosition:i}},K5=()=>{const[t,e]=S.useState(null),n=S.useRef(!1);S.useEffect(()=>(n.current=!0,()=>{n.current=!1}),[]);const r=S.useCallback(s=>{var l,c,f,u,d;if(!n.current)return{name:"Loading...",id:"loading",type:"Object3D",position:new k};let o="";return(l=s.userData)!=null&&l.id?o=s.userData.id:(c=s.userData)!=null&&c.isPrimitive?o=`primitive_${s.uuid.slice(0,8)}`:(f=s.userData)!=null&&f.isPoint?o=`point_${s.uuid.slice(0,8)}`:o=`${s.type}_${s.uuid.slice(0,8)}`,{name:((u=s.userData)==null?void 0:u.name)||s.name||`${s.type}_${s.uuid.slice(0,8)}`,id:o,type:((d=s.userData)==null?void 0:d.type)||s.type,position:s.position.clone()}},[]),i=S.useCallback(s=>{n.current&&e(s)},[]);return{objectData:t,setObjectData:i,extractObjectData:r}};class HA{constructor(){kt(this,"originalMaterials",new WeakMap);kt(this,"objectStates",new WeakMap);kt(this,"resourceManager",Kf.getInstance());kt(this,"hoverMaterial");kt(this,"selectionMaterial");kt(this,"trackedObjects",new Set);kt(this,"isDisposed",!1);try{this.hoverMaterial=this.resourceManager.getMaterial("hover",()=>new Pn({color:16755200,emissive:4465152,emissiveIntensity:.4,transparent:!1})),this.selectionMaterial=this.resourceManager.getMaterial("selection",()=>new Pn({color:65280,emissive:17408,emissiveIntensity:.3,transparent:!1}))}catch(e){console.error("Error initializing EnhancedMaterialManager:",e),this.hoverMaterial=new Pn({color:16755200}),this.selectionMaterial=new Pn({color:65280})}}setObjectState(e,n){if(this.isDisposed||!e){console.warn("Material manager is disposed or object is null");return}try{this.originalMaterials.has(e)||this.storeOriginalMaterial(e),this.trackedObjects.add(e);const i={...this.objectStates.get(e)||{type:"default",parameters:this.getDefaultParameters(),isHovered:!1,isSelected:!1},...n};this.objectStates.set(e,i),this.applyMaterialByPriority(e,i)}catch(r){console.error("Error setting object state:",r)}}setHoverEffect(e,n){if(!(this.isDisposed||!e))try{const r=this.objectStates.get(e)||{type:"default",parameters:this.getDefaultParameters(),isHovered:!1,isSelected:!1};this.objectStates.set(e,{...r,isHovered:n})}catch(r){console.error("Error setting hover effect:",r)}}setSelectionEffect(e,n){if(!(this.isDisposed||!e))try{const r=this.objectStates.get(e)||{type:"default",parameters:this.getDefaultParameters(),isHovered:!1,isSelected:!1};this.objectStates.set(e,{...r,isSelected:n})}catch(r){console.error("Error setting selection effect:",r)}}setMaterialType(e,n,r){if(!(this.isDisposed||!e))try{const i={...this.getDefaultParameters(),...r};this.setObjectState(e,{type:n,parameters:i})}catch(i){console.error("Error setting material type:",i)}}updateMaterialParameters(e,n){if(!(this.isDisposed||!e))try{const r=this.objectStates.get(e);if(r){const i={...r.parameters,...n};this.setObjectState(e,{parameters:i})}}catch(r){console.error("Error updating material parameters:",r)}}storeOriginalMaterial(e){try{e instanceof je&&e.material&&this.originalMaterials.set(e,e.material),e.children.forEach(n=>{n instanceof je&&!n.userData.isHelper&&n.material&&this.originalMaterials.set(n,n.material)})}catch(n){console.error("Error storing original material:",n)}}applyMaterialByPriority(e,n){try{let r;n.type!=="default"?(r=this.createCustomMaterial(n.type,n.parameters),this.applyMaterialToObject(e,r)):this.restoreOriginalMaterial(e)}catch(r){console.error("Error applying material by priority:",r)}}createCustomMaterial(e,n){const r=`${e}_${JSON.stringify(n)}`;try{return this.resourceManager.getMaterial(r,()=>{switch(e){case"wood":return new Pn({color:9127187,roughness:Math.max(0,Math.min(1,.8-n.reflection*.5)),metalness:.1,transparent:n.opacity<1,opacity:Math.max(0,Math.min(1,n.opacity)),emissiveIntensity:Math.max(0,n.edge*.2)});case"matPaint":return new nx({color:6710886,transparent:n.opacity<1,opacity:Math.max(0,Math.min(1,n.opacity)),reflectivity:Math.max(0,Math.min(1,n.reflection*.3))});case"metal":return new Pn({color:12632256,roughness:Math.max(0,Math.min(1,.2-n.reflection*.15)),metalness:.9,transparent:n.opacity<1,opacity:Math.max(0,Math.min(1,n.opacity)),emissiveIntensity:Math.max(0,n.edge*.1)});case"plastic":return new el({color:16777215,shininess:Math.max(0,100*n.reflection),transparent:n.opacity<1,opacity:Math.max(0,Math.min(1,n.opacity)),specular:2236962});case"glass":return new si({color:16777215,metalness:0,roughness:.1,transparent:!0,opacity:Math.max(0,Math.min(1,n.opacity*.3)),transmission:.9,ior:Math.max(1,Math.min(2.5,n.refraction)),thickness:Math.max(0,n.thickness)});default:return new Pn({color:8947848})}})}catch(i){return console.error("Error creating custom material:",i),new Pn({color:8947848})}}applyMaterialToObject(e,n){try{e instanceof je&&(e.material=n),e.children.forEach(r=>{r instanceof je&&!r.userData.isHelper&&(r.material=n)})}catch(r){console.error("Error applying material to object:",r)}}restoreOriginalMaterial(e){try{if(e instanceof je){const n=this.originalMaterials.get(e);n&&(e.material=n)}e.children.forEach(n=>{if(n instanceof je&&!n.userData.isHelper){const r=this.originalMaterials.get(n);r&&(n.material=r)}})}catch(n){console.error("Error restoring original material:",n)}}getDefaultParameters(){return{diffusion:.5,opacity:1,reflection:.3,refraction:1.4,edge:.1,thickness:1,edgeLinePipe:0}}clearAllEffects(){if(!this.isDisposed)try{this.trackedObjects.forEach(e=>{try{this.restoreOriginalMaterial(e)}catch(n){console.warn("Error restoring material during clear:",n)}}),this.objectStates=new WeakMap,this.trackedObjects.clear()}catch(e){console.error("Error clearing all effects:",e)}}getObjectState(e){return this.isDisposed||!e?null:this.objectStates.get(e)||null}dispose(){try{this.isDisposed=!0,this.clearAllEffects(),this.originalMaterials=new WeakMap}catch(e){console.error("Error disposing material manager:",e)}}}class q5 extends HA{constructor(){super()}}const Z5=()=>{const[t,e]=S.useState(null),n=S.useRef(null),r=S.useCallback(()=>(n.current||(n.current=new q5),n.current),[]),i=S.useCallback(()=>{n.current&&(n.current.dispose(),n.current=null)},[]),s=S.useCallback(o=>{e(o)},[]);return{hoveredObject:t,setHoveredObject:s,materialManagerRef:n,initializeMaterialManager:r,cleanupMaterialManager:i}},jA=()=>{const t=S.useRef(new Map);return{applyHoverEffect:(n,r)=>{var s,o;const i=t.current;if(r){if(!i.has(n)){const a=I5(n);a&&(i.set(n,a),(s=n.parent)==null||s.add(a))}}else{const a=i.get(n);a&&((o=a.parent)==null||o.remove(a),a.geometry.dispose(),a.material.dispose(),i.delete(n))}}}},Q5=({renderer:t,camera:e,scene:n,hoveredObject:r,setHoveredObject:i,materialManager:s,extractObjectData:o,setObjectData:a})=>{const{applyHoverEffect:l}=jA();return{handleRaycastHover:S.useCallback((f,u)=>{if(!t||!e||!n||!s)return;const{raycaster:d,mouse:h}=nh(),m=t.domElement.getBoundingClientRect();h.x=(f-m.left)/m.width*2-1,h.y=-((u-m.top)/m.height)*2+1,d.setFromCamera(h,e);const v=e0(n),g=d.intersectObjects(v,!0);let p=null;if(g.length>0&&(p=g[0].object,p.parent&&p.parent.userData.isMeasurementGroup&&(p=p.parent)),p!==r){if(r&&(s.setHoverEffect(r,!1),l(r,!1),a(null)),p){s.setHoverEffect(p,!0),l(p,!0);const x=o(p);a(x)}i(p)}},[t,e,n,r,i,s,o,a,l])}},J5=t=>({point:"crosshair",measure:"crosshair",move:"move",select:"default"})[t],cM=(t,e)=>{t.domElement.style.cursor=e},eG=()=>{const t=S.useRef(null),e=S.useCallback(()=>(t.current||(t.current=new HA),t.current),[]),n=S.useCallback((a,l,c)=>{e().setMaterialType(a,l,c)},[e]),r=S.useCallback((a,l)=>{e().updateMaterialParameters(a,l)},[e]),i=S.useCallback(a=>e().getObjectState(a),[e]),s=S.useCallback((a,l)=>{e().setHoverEffect(a,l)},[e]),o=S.useCallback((a,l)=>{e().setSelectionEffect(a,l)},[e]);return{materialManager:e(),updateObjectMaterial:n,updateMaterialParameters:r,getObjectMaterialState:i,setHoverEffect:s,setSelectionEffect:o}},VA=(t,e,n,r,i,s="select",o,a,l)=>{const{materialManager:c,setHoverEffect:f,setSelectionEffect:u}=eG(),{applyHoverEffect:d}=jA(),{hoveredObject:h,setHoveredObject:m}=Z5(),{mousePosition:v,mousePositionRef:g,throttledMouseMove:p,updateMousePosition:x}=Y5(),{objectData:_,setObjectData:w,extractObjectData:M}=K5(),T=j5(t,e,r,i),b=X5(t,e,r,a,i),C=$5(t,e,r,l,i),{handleRaycastHover:A}=Q5({renderer:t,camera:e,scene:r,hoveredObject:h,setHoveredObject:m,materialManager:c,extractObjectData:M,setObjectData:w});return S.useEffect(()=>{if(!t||!e||!r)return;const E=p(O=>{x(O.clientX,O.clientY),cM(t,J5(s)),s==="measure"&&C.handleMouseMove(O),s==="select"&&A(O.clientX,O.clientY)}),N=()=>{s==="select"&&A(g.current.x,g.current.y)},F=O=>{switch(O.preventDefault(),O.stopPropagation(),o&&(o.enabled=!1,setTimeout(()=>{o&&(o.enabled=!0)},50)),h&&(f(h,!1),d(h,!1),m(null)),s){case"select":T.handleClick(O);break;case"point":b.handleClick(O);break;case"measure":C.handleClick(O);break}},I=O=>{O.preventDefault(),O.stopPropagation(),o&&(o.enabled=!1,setTimeout(()=>{o&&(o.enabled=!0)},100)),h&&(f(h,!1),d(h,!1),m(null)),s==="select"&&T.handleTouch(O)},U=()=>{h&&(f(h,!1),d(h,!1),m(null),w(null)),C.cleanup(),cM(t,"default")},z=O=>{O.preventDefault(),C.handleRightClick()};return t.domElement.addEventListener("mousemove",E,{passive:!0}),t.domElement.addEventListener("click",F,{capture:!0}),t.domElement.addEventListener("touchend",I,{capture:!0}),t.domElement.addEventListener("mouseleave",U),t.domElement.addEventListener("contextmenu",z),o==null||o.addEventListener("change",N),()=>{t.domElement.removeEventListener("mousemove",E),t.domElement.removeEventListener("click",F,{capture:!0}),t.domElement.removeEventListener("touchend",I,{capture:!0}),t.domElement.removeEventListener("mouseleave",U),t.domElement.removeEventListener("contextmenu",z),o==null||o.removeEventListener("change",N),h&&(f(h,!1),d(h,!1)),C.cleanup()}},[t,e,r,h,s,o,T,b,C,p,x,A,f,d,m,w,c]),S.useEffect(()=>{r&&H5()},[r,n]),{objectData:_,mousePosition:v,isHovering:!!h}},tG=t=>{S.useEffect(()=>(window.__switchCameraMode=t,()=>{delete window.__switchCameraMode}),[t])},nG=(t,e,n,r,i,s,o)=>{const a=S.useRef([]),l=S.useRef(null);S.useEffect(()=>{var c;if(o){const f=t.length!==a.current.length||t.some((d,h)=>{var m;return d.id!==((m=a.current[h])==null?void 0:m.id)}),u=(e==null?void 0:e.id)!==((c=l.current)==null?void 0:c.id);(f||u)&&(console.log("Models changed, notifying parent:",{modelsCount:t.length,currentModelId:e==null?void 0:e.id}),o(t,e),a.current=[...t],l.current=e)}},[t,e,o]),S.useEffect(()=>(window.__fbxUploadHandler=n,window.__gltfUploadHandler=r,window.__fbxSwitchHandler=i,window.__gltfSwitchHandler=i,window.__fbxRemoveHandler=s,window.__gltfRemoveHandler=s,()=>{delete window.__fbxUploadHandler,delete window.__gltfUploadHandler,delete window.__fbxSwitchHandler,delete window.__gltfSwitchHandler,delete window.__fbxRemoveHandler,delete window.__gltfRemoveHandler}),[n,r,i,s])},rG=(t,e)=>{const n=S.useMemo(()=>i=>{t&&t(i)},[t]),r=S.useMemo(()=>(i,s)=>{e&&e(i,s)},[e]);return{handlePointCreate:n,handleMeasureCreate:r}},iG=({renderer:t,camera:e,scene:n,controls:r,currentModel:i,activeTool:s="select",onPointCreate:o,onMeasureCreate:a,loadedModels:l,loadFBXModel:c,loadGLTFModel:f,switchToModel:u,removeModel:d,onModelsChange:h,switchCamera:m})=>{const{selectedObjects:v,clearSelection:g,handleObjectSelect:p}=R5();z5(v),tG(m),nG(l,i,c,f,u,d,h);const{handlePointCreate:x,handleMeasureCreate:_}=rG(o,a),w=i?i.object:null,{objectData:M,mousePosition:T,isHovering:b}=VA(t,e,w,n,p,s,r,x,_);return{objectData:M,mousePosition:T,isHovering:b,selectedObjects:v}},sG=t=>{const e=S.useRef(0);return S.useRef(performance.now()),S.useEffect(()=>{if(!t)return;t.setPixelRatio(Math.min(window.devicePixelRatio,2)),t.shadowMap.enabled=!0,t.shadowMap.type=zy,t.toneMapping=Hy,t.toneMappingExposure=1,t.sortObjects=!0,t.info.autoReset=!1;const n=t.render.bind(t);let r=0;const i=16;return t.render=(s,o)=>{const a=performance.now();a-r>=i&&(n(s,o),r=a,e.current++)},()=>{t.render=n}},[t]),S.useEffect(()=>{const n=setInterval(()=>{},1e3);return()=>clearInterval(n)},[]),{frameCount:e.current}},oG=(t,e,n={})=>{const r=S.useRef(new Map),i=S.useRef({isPinching:!1,initialPinchDistance:0,initialPinchCenter:{x:0,y:0},lastTapTime:0,longPressTimer:null,swipeStartPos:{x:0,y:0},swipeStartTime:0}),s=S.useCallback((u,d)=>{try{return Math.sqrt(Math.pow(d.clientX-u.clientX,2)+Math.pow(d.clientY-u.clientY,2))}catch(h){return console.error("Error calculating touch distance:",h),0}},[]),o=S.useCallback((u,d)=>{try{return{x:(u.clientX+d.clientX)/2,y:(u.clientY+d.clientY)/2}}catch(h){return console.error("Error calculating touch center:",h),{x:0,y:0}}},[]),a=S.useCallback(u=>{if(t)try{u.preventDefault();const d=Array.from(u.touches);r.current.clear(),d.forEach(v=>{r.current.set(v.identifier,v)});const h=Date.now(),m=i.current;if(d.length===1){const v=d[0];m.swipeStartPos={x:v.clientX,y:v.clientY},m.swipeStartTime=h,m.longPressTimer&&clearTimeout(m.longPressTimer),m.longPressTimer=setTimeout(()=>{n.onLongPress&&n.onLongPress({x:v.clientX,y:v.clientY})},500),h-m.lastTapTime<300?(n.onDoubleTap&&n.onDoubleTap({x:v.clientX,y:v.clientY}),m.lastTapTime=0):m.lastTapTime=h}else d.length===2?(m.isPinching=!0,m.initialPinchDistance=s(d[0],d[1]),m.initialPinchCenter=o(d[0],d[1]),e&&(e.enabled=!1)):d.length===3&&n.onThreeFingerTap&&n.onThreeFingerTap()}catch(d){console.error("Error in handleTouchStart:",d)}},[t,e,n,s,o]),l=S.useCallback(u=>{if(t)try{u.preventDefault();const d=Array.from(u.touches),h=i.current;if(h.longPressTimer&&(clearTimeout(h.longPressTimer),h.longPressTimer=null),d.length===2&&h.isPinching){const m=s(d[0],d[1]),v=o(d[0],d[1]);if(h.initialPinchDistance>0&&n.onPinchZoom){const g=m/h.initialPinchDistance;n.onPinchZoom(g,v)}}}catch(d){console.error("Error in handleTouchMove:",d)}},[t,n,s,o]),c=S.useCallback(u=>{if(t)try{u.preventDefault();const d=i.current;d.longPressTimer&&(clearTimeout(d.longPressTimer),d.longPressTimer=null);const h=Array.from(u.touches);if(h.length===0){const v=Date.now()-d.swipeStartTime;if(v<300&&v>50){const g=u.changedTouches[0];if(g&&n.onSwipe){const p=g.clientX-d.swipeStartPos.x,x=g.clientY-d.swipeStartPos.y,_=Math.sqrt(p*p+x*x);if(_>50){const w=_/v;Math.abs(p)>Math.abs(x)?n.onSwipe(p>0?"right":"left",w):n.onSwipe(x>0?"down":"up",w)}}}d.isPinching=!1,e&&(e.enabled=!0)}else h.length<2&&(d.isPinching=!1,e&&(e.enabled=!0));r.current.clear(),h.forEach(m=>{r.current.set(m.identifier,m)})}catch(d){console.error("Error in handleTouchEnd:",d)}},[t,e,n]);S.useEffect(()=>{if(!t){console.log("useTouchGestures: element not available, skipping event listeners");return}try{return t.addEventListener("touchstart",a,{passive:!1}),t.addEventListener("touchmove",l,{passive:!1}),t.addEventListener("touchend",c,{passive:!1}),t.addEventListener("touchcancel",c,{passive:!1}),console.log("useTouchGestures: Event listeners added successfully"),()=>{try{t.removeEventListener("touchstart",a),t.removeEventListener("touchmove",l),t.removeEventListener("touchend",c),t.removeEventListener("touchcancel",c);const u=i.current;u.longPressTimer&&(clearTimeout(u.longPressTimer),u.longPressTimer=null),console.log("useTouchGestures: Event listeners removed successfully")}catch(u){console.error("Error removing touch event listeners:",u)}}}catch(u){return console.error("Error setting up touch event listeners:",u),()=>{}}},[t,a,l,c]);const f=i.current;return{isGesturing:f?f.isPinching:!1}},aG=()=>{try{return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||navigator.maxTouchPoints&&navigator.maxTouchPoints>1}catch(t){return console.error("Error detecting mobile device:",t),!1}},lG=(t,e,n,r,i,s="select",o,a,l)=>{const c=aG();console.log("useMobileMouseInteraction: Mobile detected:",c),console.log("useMobileMouseInteraction: Dependencies available:",{renderer:!!t,camera:!!e,scene:!!r,controls:!!o});const f=VA(t,e,n,r,i,s,o,a,l),u=S.useCallback((m,v)=>{if(!(!c||!e||!o))try{const g=(m-1)*.5,p=e.position.distanceTo(o.target),x=Math.max(.1,Math.min(1e3,p-g*10)),_=new k().subVectors(e.position,o.target).normalize();e.position.copy(o.target).add(_.multiplyScalar(x)),o.update()}catch(g){console.error("Error in handlePinchZoom:",g)}},[c,e,o]),d=S.useCallback(m=>{if(!(!c||!e||!o||!r))try{const v=new Gt;if(r.traverse(g=>{g.visible&&g.geometry&&v.expandByObject(g)}),!v.isEmpty()){const g=v.getCenter(new k),p=v.getSize(new k),_=Math.max(p.x,p.y,p.z)*2;o.target.copy(g),e.position.copy(g).add(new k(_,_,_)),o.update()}}catch(v){console.error("Error in handleDoubleTap:",v)}},[c,e,o,r]),h=S.useCallback(()=>{if(!(!c||!e||!o))try{e.position.set(5,5,5),o.target.set(0,0,0),o.update()}catch(m){console.error("Error in handleThreeFingerTap:",m)}},[c,e,o]);return oG(c&&t?t.domElement:null,c&&o?o:null,{onPinchZoom:u,onDoubleTap:d,onThreeFingerTap:h,onSwipe:(m,v)=>{c&&console.log(`Swipe ${m} with velocity ${v}`)}}),S.useEffect(()=>{if(!(!c||!t))try{const m=t.domElement,v=g=>{try{m.style.filter="brightness(1.1)",setTimeout(()=>{m.style.filter="brightness(1)"},100)}catch(p){console.error("Error adding touch feedback:",p)}};return m.addEventListener("touchstart",v,{passive:!0}),console.log("useMobileMouseInteraction: Touch feedback setup complete"),()=>{try{m.removeEventListener("touchstart",v)}catch(g){console.error("Error removing touch feedback listener:",g)}}}catch(m){return console.error("Error setting up touch feedback:",m),()=>{}}},[c,t]),{...f,isMobile:c}},cG=({objectData:t,mousePosition:e,visible:n})=>{const{formatValue:r,convertValue:i}=Vk();return!n||!t?null:y.jsx("div",{className:"fixed bg-slate-900/90 backdrop-blur-sm border border-slate-600 rounded-lg p-3 text-sm text-white z-50 pointer-events-none",style:{left:e.x+15,top:e.y-10,maxWidth:"200px"},children:y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"font-semibold text-cyan-400",children:t.name}),y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsxs("div",{children:[y.jsx("span",{className:"text-slate-400",children:"ID:"}),y.jsx("span",{className:"text-white ml-1",children:t.id})]}),y.jsxs("div",{children:[y.jsx("span",{className:"text-slate-400",children:"Type:"}),y.jsx("span",{className:"text-white ml-1",children:t.type})]}),y.jsxs("div",{children:[y.jsx("span",{className:"text-slate-400",children:"Position:"}),y.jsxs("div",{className:"text-white font-mono ml-1",children:["X: ",r(i(t.position.x)),y.jsx("br",{}),"Y: ",r(i(t.position.y)),y.jsx("br",{}),"Z: ",r(i(t.position.z))]})]})]})]})})},uG=({selectedObject:t})=>t?y.jsxs("div",{className:"absolute top-4 left-4 bg-black/80 text-white px-4 py-2 rounded-lg shadow-lg border border-blue-500/50",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"w-3 h-3 bg-blue-500 rounded-full animate-pulse"}),y.jsx("span",{className:"font-medium",children:"Selected:"}),y.jsx("span",{className:"text-blue-300",children:t.name})]}),y.jsx("div",{className:"text-xs text-gray-700 dark:text-gray-300 mt-1",children:"Press ESC to deselect • F to focus"})]}):null,GA=S.memo(({objectData:t,mousePosition:e,isHovering:n,selectedObjects:r})=>y.jsxs(y.Fragment,{children:[y.jsx(cG,{objectData:t,mousePosition:e,visible:n}),y.jsx(uG,{selectedObject:r.length>0?r[0]:null})]}));GA.displayName="ModelViewerOverlays";const WA=S.memo(t=>{const{mountRef:e,scene:n,camera:r,renderer:i,controls:s,currentModel:o,isLoading:a,error:l,loadFBXModel:c,loadGLTFModel:f,switchToModel:u,removeModel:d,performanceMetrics:h,isOrthographic:m,switchCamera:v}=T5({sunlight:t.sunlight,ambientLight:t.ambientLight,shadowQuality:t.shadowQuality,environment:t.environment,onModelsChange:t.onModelsChange,onSceneReady:t.onSceneReady});sG(i);const{objectData:g,mousePosition:p,isHovering:x,isMobile:_}=lG(i,r,o?o.object:null,n,void 0,t.activeTool,s,t.onPointCreate,t.onMeasureCreate),{selectedObjects:w}=iG({renderer:i,camera:r,scene:n,controls:s,currentModel:o,activeTool:t.activeTool,onPointCreate:t.onPointCreate,onMeasureCreate:t.onMeasureCreate,loadedModels:t.loadedModels,loadFBXModel:c,loadGLTFModel:f,switchToModel:u,removeModel:d,onModelsChange:t.onModelsChange,switchCamera:v});return he.useEffect(()=>{},[h,_]),l?y.jsx("div",{className:"w-full h-full flex items-center justify-center text-red-500",children:y.jsxs("div",{className:"text-center",children:[y.jsx("h2",{className:"text-xl font-bold mb-2",children:"Model Viewer Error"}),y.jsx("p",{children:l}),y.jsx("button",{onClick:()=>window.location.reload(),className:"mt-4 px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 min-h-[44px] min-w-[44px]",children:"Reload Application"})]})}):y.jsxs("div",{className:"relative w-full h-full",children:[y.jsx("div",{ref:e,className:"w-full h-full",style:{touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}}),y.jsx(GA,{objectData:g,mousePosition:p,isHovering:x,selectedObjects:w}),a&&y.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center",children:y.jsxs("div",{className:"text-white flex items-center gap-2",children:[y.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-white"}),"Loading 3D model..."]})}),_&&y.jsx("div",{className:"absolute top-2 left-2 bg-black bg-opacity-50 text-white text-xs px-2 py-1 rounded pointer-events-none",children:"Touch: Rotate • Pinch: Zoom • Double-tap: Fit • 3-finger: Reset"})]})});WA.displayName="ThreeViewer";const XA=S.createContext({}),dG=()=>S.useContext(XA),fG=({children:t,value:e})=>y.jsx(XA.Provider,{value:e,children:t}),$A=S.memo(({sunlight:t,ambientLight:e,shadowQuality:n,environment:r,loadedModels:i,currentModel:s,onFileUpload:o,onModelsChange:a,onSceneReady:l,activeTool:c,onPointCreate:f,onMeasureCreate:u})=>{const d={onFileUpload:o,onModelsChange:a};return y.jsx(fG,{value:d,children:y.jsx("div",{className:"w-full h-full",children:y.jsx(WA,{sunlight:t,ambientLight:e,shadowQuality:n,environment:r,onFileUpload:o,onModelsChange:a,loadedModels:i,currentModel:s,onSceneReady:l,activeTool:c,onPointCreate:f,onMeasureCreate:u})})})});$A.displayName="ModelViewerContainer";const YA=()=>{uy();const{addMessage:t}=ky(),{loadedModels:e,setLoadedModels:n,setCurrentModel:r,setUploading:i,setUploadError:s}=Uy(),{onFileUpload:o,onModelSelect:a,onModelRemove:l}=dG();return{handleFileUpload:async m=>{if(ar.info("Starting file upload process:",{name:m.name,type:m.type,size:m.size}),o)return o(m);try{i(!0),s(null),t({type:"info",title:"Loading model...",description:`Processing ${m.name}`});const v=m.name.toLowerCase();let g=null;if(v.endsWith(".fbx"))g=window.__fbxUploadHandler,ar.debug("Using FBX loader for:",m.name);else if(v.endsWith(".gltf")||v.endsWith(".glb"))g=window.__gltfUploadHandler,ar.debug("Using GLTF loader for:",m.name);else if(v.endsWith(".obj"))g=window.__objUploadHandler||window.__fbxUploadHandler,ar.debug("Using OBJ loader (fallback to FBX) for:",m.name);else throw new Error("Unsupported file format. Please select FBX, GLTF, GLB, or OBJ files.");if(g)ar.debug("Upload handler found, processing file..."),await g(m),t({type:"success",title:"Model loaded successfully",description:`${m.name} is now ready`}),ar.info("File upload completed successfully");else throw new Error("No suitable loader found for this file type")}catch(v){ar.error("Upload failed:",v);const g=v instanceof Error?v.message:"Unknown error occurred";s(`Failed to load ${m.name}: ${g}`),t({type:"error",title:"Upload failed",description:`Failed to load ${m.name}. ${g}`})}finally{i(!1)}},handleModelsChange:(m,v)=>{ar.info("Models changed:",{modelCount:m.length,currentModel:v==null?void 0:v.name}),n(m),r(v)},handleModelSelect:m=>{const v=e.find(g=>g.id===m);if(v){if(ar.info("Selecting model:",v.name),a)a(m);else{const g=window.__fbxSwitchHandler,p=window.__gltfSwitchHandler;g?g(m):p&&p(m)}t({type:"success",title:"Model selected",description:`Now viewing ${v.name}`})}},handleModelRemove:m=>{const v=e.find(g=>g.id===m);if(v){if(ar.info("Removing model:",v.name),l)l(m);else{const g=window.__fbxRemoveHandler,p=window.__gltfRemoveHandler;g?g(m):p&&p(m)}t({type:"warning",title:"Model removed",description:`${v.name} has been removed`})}},handlePrimitiveSelect:m=>{m==="box"&&(ar.info("Selecting box primitive"),r(null),t({type:"info",title:"Primitive selected",description:"Now showing box primitive"}))}}},hG=({onPointCreate:t,onMeasureCreate:e})=>{const{setScene:n}=BT(),r=Uy(),{activeTool:i}=iu(),{handleFileUpload:s,handleModelsChange:o}=YA();return y.jsx($A,{sunlight:r.sunlight,ambientLight:r.ambientLight,shadowQuality:r.shadowQuality,environment:r.environment,loadedModels:r.loadedModels,currentModel:r.currentModel,onFileUpload:s,onModelsChange:o,onSceneReady:n,activeTool:i,onPointCreate:t,onMeasureCreate:e})},pG=Th("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ot=S.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...i},s)=>{const o=r?_l:"button";return y.jsx(o,{className:ht(pG({variant:e,size:n,className:t})),ref:s,...i})});ot.displayName="Button";function vn(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function mG(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}const Ud=43200,uM=1440;let gG={};function vG(){return gG}function dM(t){const e=vn(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function hf(t,e){const n=vn(t),r=vn(e),i=n.getTime()-r.getTime();return i<0?-1:i>0?1:i}function yG(t){return mG(t,Date.now())}function xG(t,e){const n=vn(t),r=vn(e),i=n.getFullYear()-r.getFullYear(),s=n.getMonth()-r.getMonth();return i*12+s}function _G(t){return e=>{const r=(t?Math[t]:Math.trunc)(e);return r===0?0:r}}function wG(t,e){return+vn(t)-+vn(e)}function SG(t){const e=vn(t);return e.setHours(23,59,59,999),e}function MG(t){const e=vn(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function bG(t){const e=vn(t);return+SG(e)==+MG(e)}function EG(t,e){const n=vn(t),r=vn(e),i=hf(n,r),s=Math.abs(xG(n,r));let o;if(s<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*s);let a=hf(n,r)===-i;bG(vn(t))&&s===1&&hf(t,r)===1&&(a=!1),o=i*(s-Number(a))}return o===0?0:o}function TG(t,e,n){const r=wG(t,e)/1e3;return _G(n==null?void 0:n.roundingMethod)(r)}const AG={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},CG=(t,e,n)=>{let r;const i=AG[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Dm(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const RG={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},PG={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},NG={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},DG={date:Dm({formats:RG,defaultWidth:"full"}),time:Dm({formats:PG,defaultWidth:"full"}),dateTime:Dm({formats:NG,defaultWidth:"full"})},LG={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},IG=(t,e,n,r)=>LG[t];function pc(t){return(e,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const o=t.defaultFormattingWidth||t.defaultWidth,a=n!=null&&n.width?String(n.width):o;i=t.formattingValues[a]||t.formattingValues[o]}else{const o=t.defaultWidth,a=n!=null&&n.width?String(n.width):t.defaultWidth;i=t.values[a]||t.values[o]}const s=t.argumentCallback?t.argumentCallback(e):e;return i[s]}}const kG={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},OG={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},FG={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},UG={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},BG={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},zG={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},HG=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},jG={ordinalNumber:HG,era:pc({values:kG,defaultWidth:"wide"}),quarter:pc({values:OG,defaultWidth:"wide",argumentCallback:t=>t-1}),month:pc({values:FG,defaultWidth:"wide"}),day:pc({values:UG,defaultWidth:"wide"}),dayPeriod:pc({values:BG,defaultWidth:"wide",formattingValues:zG,defaultFormattingWidth:"wide"})};function mc(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],s=e.match(i);if(!s)return null;const o=s[0],a=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(a)?GG(a,u=>u.test(o)):VG(a,u=>u.test(o));let c;c=t.valueCallback?t.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const f=e.slice(o.length);return{value:c,rest:f}}}function VG(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function GG(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function WG(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],s=e.match(t.parsePattern);if(!s)return null;let o=t.valueCallback?t.valueCallback(s[0]):s[0];o=n.valueCallback?n.valueCallback(o):o;const a=e.slice(i.length);return{value:o,rest:a}}}const XG=/^(\d+)(th|st|nd|rd)?/i,$G=/\d+/i,YG={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},KG={any:[/^b/i,/^(a|c)/i]},qG={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ZG={any:[/1/i,/2/i,/3/i,/4/i]},QG={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},JG={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},e8={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},t8={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},n8={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},r8={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},i8={ordinalNumber:WG({matchPattern:XG,parsePattern:$G,valueCallback:t=>parseInt(t,10)}),era:mc({matchPatterns:YG,defaultMatchWidth:"wide",parsePatterns:KG,defaultParseWidth:"any"}),quarter:mc({matchPatterns:qG,defaultMatchWidth:"wide",parsePatterns:ZG,defaultParseWidth:"any",valueCallback:t=>t+1}),month:mc({matchPatterns:QG,defaultMatchWidth:"wide",parsePatterns:JG,defaultParseWidth:"any"}),day:mc({matchPatterns:e8,defaultMatchWidth:"wide",parsePatterns:t8,defaultParseWidth:"any"}),dayPeriod:mc({matchPatterns:n8,defaultMatchWidth:"any",parsePatterns:r8,defaultParseWidth:"any"})},s8={code:"en-US",formatDistance:CG,formatLong:DG,formatRelative:IG,localize:jG,match:i8,options:{weekStartsOn:0,firstWeekContainsDate:1}};function o8(t,e,n){const r=vG(),i=(n==null?void 0:n.locale)??r.locale??s8,s=2520,o=hf(t,e);if(isNaN(o))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:o});let l,c;o>0?(l=vn(e),c=vn(t)):(l=vn(t),c=vn(e));const f=TG(c,l),u=(dM(c)-dM(l))/1e3,d=Math.round((f-u)/60);let h;if(d<2)return n!=null&&n.includeSeconds?f<5?i.formatDistance("lessThanXSeconds",5,a):f<10?i.formatDistance("lessThanXSeconds",10,a):f<20?i.formatDistance("lessThanXSeconds",20,a):f<40?i.formatDistance("halfAMinute",0,a):f<60?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",1,a):d===0?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",d,a);if(d<45)return i.formatDistance("xMinutes",d,a);if(d<90)return i.formatDistance("aboutXHours",1,a);if(d<uM){const m=Math.round(d/60);return i.formatDistance("aboutXHours",m,a)}else{if(d<s)return i.formatDistance("xDays",1,a);if(d<Ud){const m=Math.round(d/uM);return i.formatDistance("xDays",m,a)}else if(d<Ud*2)return h=Math.round(d/Ud),i.formatDistance("aboutXMonths",h,a)}if(h=EG(c,l),h<12){const m=Math.round(d/Ud);return i.formatDistance("xMonths",m,a)}else{const m=h%12,v=Math.trunc(h/12);return m<3?i.formatDistance("aboutXYears",v,a):m<9?i.formatDistance("overXYears",v,a):i.formatDistance("almostXYears",v+1,a)}}function a8(t,e){return o8(t,yG(t),e)}const l8=()=>{const[t,e]=S.useState(!1),{messages:n,unreadCount:r,markAsRead:i,markAllAsRead:s,clearAllMessages:o}=ky(),a=l=>{switch(l){case"success":return"✅";case"error":return"❌";case"warning":return"⚠️";default:return"ℹ️"}};return y.jsxs("div",{className:"relative",children:[y.jsxs(ot,{variant:"ghost",size:"sm",onClick:()=>e(!t),className:"relative text-white hover:text-slate-200 hover:bg-slate-700/50 border-slate-500",children:[y.jsx(T1,{className:"h-5 w-5"}),r>0&&y.jsx("span",{className:"absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center",children:r>9?"9+":r})]}),t&&y.jsxs("div",{className:"absolute right-0 top-full mt-2 w-80 bg-slate-800 border border-slate-600 rounded-lg shadow-lg z-50",children:[y.jsxs("div",{className:"p-3 border-b border-slate-600 flex items-center justify-between",children:[y.jsx("h3",{className:"font-semibold text-slate-100",children:"Notifications"}),y.jsxs("div",{className:"flex gap-1",children:[r>0&&y.jsx(ot,{variant:"ghost",size:"sm",onClick:s,className:"h-7 w-7 p-0 text-slate-400 hover:text-slate-200 hover:bg-slate-700",children:y.jsx(TD,{className:"h-4 w-4"})}),y.jsx(ot,{variant:"ghost",size:"sm",onClick:o,className:"h-7 w-7 p-0 text-slate-400 hover:text-slate-200 hover:bg-slate-700",children:y.jsx(P1,{className:"h-4 w-4"})}),y.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>e(!1),className:"h-7 w-7 p-0 text-slate-400 hover:text-slate-200 hover:bg-slate-700",children:y.jsx(bu,{className:"h-4 w-4"})})]})]}),y.jsx("div",{className:"max-h-80 overflow-y-auto",children:n.length===0?y.jsx("div",{className:"p-4 text-center text-slate-400",children:"No notifications yet"}):n.map(l=>y.jsx("div",{className:`p-3 border-b border-slate-700 cursor-pointer hover:bg-slate-700/50 ${l.read?"":"bg-slate-700/30"}`,onClick:()=>i(l.id),children:y.jsxs("div",{className:"flex items-start gap-2",children:[y.jsx("span",{className:"text-sm",children:a(l.type)}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("h4",{className:"font-medium text-slate-100 text-sm truncate",children:l.title}),!l.read&&y.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full flex-shrink-0"})]}),l.description&&y.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300 mt-1 line-clamp-2",children:l.description}),y.jsx("p",{className:"text-xs text-slate-500 mt-1",children:a8(l.timestamp,{addSuffix:!0})})]})]})},l.id))})]})]})},c8=({onToolSelect:t,activeTool:e,onViewFront:n,onViewBack:r,onViewLeft:i,onViewRight:s,onViewIsometric:o,onToggle3DRotate:a,isOrthographic:l=!1,onCameraToggle:c,onZoomAll:f,onZoomToSelected:u,onZoomIn:d,onZoomOut:h,onResetView:m,selectedObject:v,zoomLevel:g=100})=>{const[p,x]=S.useState(!1),_=S.useRef(null),w=()=>{x(!p)};return S.useEffect(()=>{const M=T=>{_.current&&!_.current.contains(T.target)&&x(!1)};if(p)return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[p]),y.jsx(Ul,{children:y.jsx("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 bg-card/95 backdrop-blur-sm border border-border rounded-lg p-2 z-40 shadow-lg",children:y.jsxs("div",{className:"flex gap-1",children:[y.jsx(ot,{variant:e==="select"?"default":"ghost",size:"sm",onClick:()=>t("select"),className:`h-8 w-8 p-0 transition-all ${e==="select"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:"Select Tool",children:y.jsx(rf,{className:"h-4 w-4"})}),y.jsx(ot,{variant:e==="point"?"default":"ghost",size:"sm",onClick:()=>t("point"),className:`h-8 w-8 p-0 transition-all ${e==="point"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:"Point Tool - Click to add points",children:y.jsx(Rh,{className:"h-4 w-4"})}),y.jsx(ot,{variant:e==="measure"?"default":"ghost",size:"sm",onClick:()=>t("measure"),className:`h-8 w-8 p-0 transition-all ${e==="measure"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:"Measure Tool",children:y.jsx(zf,{className:"h-4 w-4"})}),y.jsx("div",{className:"w-px h-6 bg-border mx-1"}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:i,className:"h-8 w-8 p-0 hover:bg-accent",children:y.jsx(b1,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Left View"})})]}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:s,className:"h-8 w-8 p-0 hover:bg-accent",children:y.jsx(E1,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Right View"})})]}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:o,className:"h-8 w-8 p-0 hover:bg-accent",children:y.jsx(Pr,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Isometric View (I)"})})]}),y.jsx("div",{className:"w-px h-6 bg-border mx-1"}),y.jsxs("div",{ref:_,className:"relative",children:[y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsxs(ot,{variant:"ghost",size:"sm",className:"h-8 px-2 text-muted-foreground hover:text-foreground hover:bg-accent flex items-center gap-1",onClick:w,children:[y.jsx(Hf,{className:"h-4 w-4"}),y.jsxs("span",{className:"text-xs",children:[g,"%"]}),y.jsx(my,{className:`h-3 w-3 transition-transform ${p?"rotate-180":""}`})]})}),y.jsx(mn,{children:y.jsx("p",{children:"Zoom Controls"})})]}),p&&y.jsx("div",{className:"absolute top-full left-0 mt-2 bg-card/95 backdrop-blur-sm border border-border rounded-md p-1 z-50 shadow-lg",children:y.jsxs("div",{className:"flex gap-1",children:[y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0 hover:bg-accent",children:y.jsx(UD,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Zoom All (A)"})})]}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:u,disabled:!v,className:"h-8 w-8 p-0 hover:bg-accent disabled:opacity-30",children:y.jsx(LD,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Focus Selected (F)"})})]}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0 hover:bg-accent",children:y.jsx(Hf,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Zoom In"})})]}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:h,className:"h-8 w-8 p-0 hover:bg-accent",children:y.jsx($D,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Zoom Out"})})]}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0 hover:bg-accent",children:y.jsx(R1,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Reset View (R)"})})]})]})})]}),y.jsx("div",{className:"w-px h-6 bg-border mx-1"}),c&&y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:l?"default":"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:y.jsx(bD,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsxs("p",{children:["Toggle ",l?"Perspective":"Orthographic"," Camera"]})})]}),y.jsx(l8,{})]})})})},u8=({activeTab:t,onTabChange:e,isPanelOpen:n})=>{const r=[{id:"scene",label:"Scene Objects",icon:Pr,description:"Manage 3D objects and hierarchy"},{id:"properties",label:"Object Properties",icon:Xa,description:"Edit object properties and materials"},{id:"lighting",label:"Lighting & Environment",icon:xy,description:"Control lighting and environment settings"},{id:"settings",label:"Settings",icon:C1,description:"App settings and units configuration"},{id:"help",label:"User Guide",icon:RD,description:"Touch and desktop controls guide"}],i=s=>{e(s)};return y.jsx(Ul,{children:y.jsx("div",{className:"fixed left-4 top-20 bg-card/95 backdrop-blur-sm border border-border rounded-lg p-2 z-50 shadow-lg",children:y.jsx("div",{className:"flex flex-col gap-1",children:r.map(s=>{const o=s.icon,a=t===s.id&&n;return y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>i(s.id),className:`h-10 w-10 p-0 transition-all duration-150 hover:scale-105 ${a?"bg-primary text-primary-foreground shadow-md":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:y.jsx(o,{className:"h-4 w-4"})})}),y.jsx(mn,{side:"right",className:"max-w-48",children:y.jsxs("div",{className:"text-xs",children:[y.jsx("p",{className:"font-medium",children:s.label}),y.jsx("p",{className:"text-muted-foreground mt-1",children:s.description})]})})]},s.id)})})})})},KA=S.forwardRef(({className:t,type:e,...n},r)=>y.jsx("input",{type:e,className:ht("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:r,...n}));KA.displayName="Input";function cx(t){const e=S.useRef({value:t,previous:t});return S.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var ux="Switch",[d8,b7]=ea(ux),[f8,h8]=d8(ux),qA=S.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:s,required:o,disabled:a,value:l="on",onCheckedChange:c,form:f,...u}=t,[d,h]=S.useState(null),m=dt(e,_=>h(_)),v=S.useRef(!1),g=d?f||!!d.closest("form"):!0,[p=!1,x]=Ys({prop:i,defaultProp:s,onChange:c});return y.jsxs(f8,{scope:n,checked:p,disabled:a,children:[y.jsx(We.button,{type:"button",role:"switch","aria-checked":p,"aria-required":o,"data-state":JA(p),"data-disabled":a?"":void 0,disabled:a,value:l,...u,ref:m,onClick:Ne(t.onClick,_=>{x(w=>!w),g&&(v.current=_.isPropagationStopped(),v.current||_.stopPropagation())})}),g&&y.jsx(p8,{control:d,bubbles:!v.current,name:r,value:l,checked:p,required:o,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});qA.displayName=ux;var ZA="SwitchThumb",QA=S.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,i=h8(ZA,n);return y.jsx(We.span,{"data-state":JA(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e})});QA.displayName=ZA;var p8=t=>{const{control:e,checked:n,bubbles:r=!0,...i}=t,s=S.useRef(null),o=cx(n),a=Cy(e);return S.useEffect(()=>{const l=s.current,c=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(c,"checked").set;if(o!==n&&u){const d=new Event("click",{bubbles:r});u.call(l,n),l.dispatchEvent(d)}},[o,n,r]),y.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...t.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function JA(t){return t?"checked":"unchecked"}var eC=qA,m8=QA;const tC=S.forwardRef(({className:t,...e},n)=>y.jsx(eC,{className:ht("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...e,ref:n,children:y.jsx(m8,{className:ht("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));tC.displayName=eC.displayName;var g8="Label",nC=S.forwardRef((t,e)=>y.jsx(We.label,{...t,ref:e,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=t.onMouseDown)==null||i.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));nC.displayName=g8;var rC=nC;const v8=Th("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Oo=S.forwardRef(({className:t,...e},n)=>y.jsx(rC,{ref:n,className:ht(v8(),t),...e}));Oo.displayName=rC.displayName;const y8=({onFileSelect:t,isLoading:e})=>{const[n,r]=S.useState(!1),[i,s]=S.useState(null),o=S.useRef(null),a=h=>{h.preventDefault(),h.stopPropagation(),h.type==="dragenter"||h.type==="dragover"?r(!0):h.type==="dragleave"&&r(!1)},l=h=>{if(h.preventDefault(),h.stopPropagation(),r(!1),h.dataTransfer.files&&h.dataTransfer.files[0]){const m=h.dataTransfer.files[0];c(m)}},c=h=>{console.log("File selected:",h.name,"Type:",h.type,"Size:",h.size);const m=[".fbx",".obj",".gltf",".glb"],v=["application/octet-stream","model/gltf+json","model/gltf-binary","application/json","text/plain",""],g=h.name.toLowerCase(),p=m.some(M=>g.endsWith(M)),x=v.includes(h.type)||h.type==="",_=/iPad|iPhone|iPod/.test(navigator.userAgent);if(!(p&&(x||_))){console.warn("Invalid file type:",{name:h.name,type:h.type,extension:g.split(".").pop()}),alert("Please select a valid 3D model file (.fbx, .obj, .gltf, .glb)");return}if(h.size>50*1024*1024){alert("File size too large. Please select a file smaller than 50MB.");return}console.log("File validation passed, setting selected file"),s(h)},f=h=>{console.log("File input change triggered"),h.target.files&&h.target.files[0]&&c(h.target.files[0])},u=()=>{i&&(console.log("Uploading file:",i.name),t(i),s(null))},d=()=>{console.log("Browse button clicked"),o.current&&(o.current.value="",o.current.click())};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${n?"border-green-400 bg-green-400/10":"border-slate-600 hover:border-slate-500"}`,onDragEnter:a,onDragLeave:a,onDragOver:a,onDrop:l,children:[y.jsx(WD,{className:"h-8 w-8 mx-auto mb-3 text-slate-400"}),y.jsx("p",{className:"text-slate-300 mb-2 text-sm",children:"Drag and drop your 3D model here, or click to browse"}),y.jsx("p",{className:"text-xs text-slate-500 mb-3",children:"Supported formats: FBX, OBJ, GLTF, GLB (Max 50MB)"}),y.jsx(ot,{variant:"outline",size:"sm",className:"text-slate-300 border-slate-600",onClick:d,children:"Browse Files"}),y.jsx("input",{ref:o,type:"file",className:"hidden",accept:".fbx,.obj,.gltf,.glb,application/octet-stream,model/gltf+json,model/gltf-binary",onChange:f,multiple:!1,capture:!1})]}),i&&y.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-700 rounded-lg",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(DD,{className:"h-4 w-4 text-green-400"}),y.jsx("span",{className:"text-sm text-slate-300",children:i.name}),y.jsxs("span",{className:"text-xs text-slate-500",children:["(",(i.size/1024/1024).toFixed(1)," MB)"]})]}),y.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>s(null),className:"h-6 w-6 p-0",children:y.jsx(bu,{className:"h-4 w-4"})})]}),y.jsx(ot,{className:"w-full bg-green-600 hover:bg-green-700",onClick:u,disabled:!i||e,children:e?"Uploading...":"Upload Model"})]})},x8=({selectedObjects:t,onClearSelection:e})=>y.jsxs("div",{className:"flex items-center justify-between text-sm font-medium text-slate-700 dark:text-slate-300 mb-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Pr,{className:"h-4 w-4"}),"Scene Hierarchy"]}),t.length>0&&y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsxs("span",{className:"text-xs bg-blue-600/20 text-blue-300 px-2 py-1 rounded",children:[t.length," selected"]}),y.jsx("button",{onClick:e,className:"text-xs text-slate-400 hover:text-slate-200",title:"Clear selection",children:"Clear"})]})]}),_8=()=>y.jsxs("div",{className:"text-center py-4 text-slate-400",children:[y.jsx(Pr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),y.jsx("p",{className:"text-sm",children:"No objects in scene"})]}),w8=({type:t,objectType:e})=>{if(e)switch(e.toLowerCase()){case"plot":return y.jsx(GD,{className:"h-4 w-4 text-green-500"});case"building":return y.jsx(MD,{className:"h-4 w-4 text-blue-500"});case"room":return y.jsx(OD,{className:"h-4 w-4 text-purple-500"})}switch(t){case"mesh":return y.jsx(D1,{className:"h-4 w-4 text-green-400"});case"group":return y.jsx(Pr,{className:"h-4 w-4 text-blue-400"});case"primitive":return y.jsx(Pr,{className:"h-4 w-4 text-purple-400"});case"ground":return y.jsx(N1,{className:"h-4 w-4 text-brown-400"});case"light":return y.jsx(_y,{className:"h-4 w-4 text-yellow-400"});case"point":return y.jsx(Rh,{className:"h-4 w-4 text-red-400"});case"measurement":return y.jsx(zf,{className:"h-4 w-4 text-orange-400"});default:return y.jsx(Pr,{className:"h-4 w-4 text-gray-400"})}},iC=({sceneObject:t,level:e,expandedNodes:n,onToggleExpanded:r,onToggleVisibility:i,onObjectSelect:s,onDelete:o})=>{var m,v;const{isSelected:a}=Bl(),l=n.has(t.id),c=t.children.length>0,f=e*16,u=a(t),d=t.type==="point"||t.type==="measurement",h=g=>{const p=g.ctrlKey||g.metaKey;s(t,p)};return y.jsxs("div",{children:[y.jsx("div",{className:`flex items-center py-1 px-2 hover:bg-slate-700/30 rounded text-sm cursor-pointer ${u?"bg-blue-600/30 border border-blue-500/50":""}`,style:{paddingLeft:f},onClick:h,children:y.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[c?y.jsx(ot,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-slate-400",onClick:g=>{g.stopPropagation(),r(t.id)},children:l?y.jsx(Ah,{className:"h-3 w-3"}):y.jsx(A1,{className:"h-3 w-3"})}):y.jsx("div",{className:"w-6"}),y.jsx(w8,{type:t.type,objectType:(v=(m=t.object)==null?void 0:m.userData)==null?void 0:v.type}),y.jsx("span",{className:`truncate flex-1 ${u?"text-blue-300 font-medium":"text-slate-200"}`,children:t.name}),y.jsxs("div",{className:"flex gap-1",children:[y.jsx(ot,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-slate-400 hover:text-slate-200",onClick:g=>{g.stopPropagation(),i(t)},children:t.object.visible?y.jsx(gy,{className:"h-3 w-3"}):y.jsx(Ch,{className:"h-3 w-3"})}),d&&y.jsx(ot,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-slate-400 hover:text-red-400",onClick:g=>o(t,g),title:"Delete",children:y.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})}),c&&l&&y.jsx("div",{children:t.children.map(g=>y.jsx(iC,{sceneObject:g,level:e+1,expandedNodes:n,onToggleExpanded:r,onToggleVisibility:i,onObjectSelect:s,onDelete:o},g.id))})]})},S8=({title:t,objects:e,expandedNodes:n,onToggleExpanded:r,onToggleVisibility:i,onObjectSelect:s,onDelete:o,hideTitle:a=!1})=>e.length===0?null:y.jsxs("div",{children:[!a&&y.jsxs("div",{className:"text-xs font-medium text-slate-400 uppercase tracking-wide mb-1 px-2",children:[t," (",e.length,")"]}),e.map(l=>y.jsx(iC,{sceneObject:l,level:0,expandedNodes:n,onToggleExpanded:r,onToggleVisibility:i,onObjectSelect:s,onDelete:o},l.id))]}),M8=t=>{var e;return(e=t.userData)!=null&&e.id?`gltf_${t.userData.id}`:t.userData.isPrimitive?`primitive_${t.uuid}`:t.userData.isPoint?`point_${t.uuid}`:t.userData.isMeasurementGroup?`measurement_${t.uuid}`:t.userData.isLoadedModel||t instanceof qt?`group_${t.uuid}`:t instanceof je?`mesh_${t.uuid}`:t instanceof ao?`light_${t.uuid}`:t.type==="GridHelper"||t.type==="AxesHelper"?`env_${t.uuid}`:`object_${t.uuid}`},b8=(t,e)=>{var r,i,s;return e?e.name:(r=t.userData)!=null&&r.name?t.userData.name:(i=t.userData)!=null&&i.id?t.userData.id:t.name?t.name:`${((s=t.userData)==null?void 0:s.type)||t.type}_${t.uuid.slice(0,8)}`},E8=(t,e,n,r=[])=>{if(!t)return console.log("No scene provided to buildSceneObjects"),[];console.log("Building scene objects with:",{sceneChildren:t.children.length,loadedModels:e.length,showPrimitives:n});const i=[],s=new Set(r.map(c=>c.id)),o=new Set,a=new Map;e.forEach(c=>{a.set(c.object,c),c.object.userData.isLoadedModel=!0,c.object.traverse(f=>{f!==c.object&&(f.userData.isPartOfLoadedModel=!0,f.userData.loadedModelRoot=c.object)})});const l=(c,f)=>{let u="mesh";const d=M8(c),h=a.get(c);h||c.userData.isLoadedModel?u="model":c.userData.isPrimitive?u="primitive":c.userData.isPoint?u="point":c.userData.isMeasurementGroup?u="measurement":c instanceof qt?u="group":c instanceof je?u="mesh":c instanceof ao?u="light":(c.type==="GridHelper"||c.type==="AxesHelper")&&(u="environment");const m={id:d,name:b8(c,h),type:u,object:c,children:[],visible:c.visible,selected:s.has(d)};return c.children.length>0&&(m.children=c.children.map(v=>l(v)).filter(v=>!(!n&&v.type==="primitive"||v.object.userData.isHelper))),m};return t.children.forEach((c,f)=>{var u,d,h,m;if(console.log(`Processing scene child ${f}:`,{name:c.name,type:c.type,isDetachedFromGLB:(u=c.userData)==null?void 0:u.isDetachedFromGLB,isHelper:(d=c.userData)==null?void 0:d.isHelper,hasChildren:c.children.length>0}),o.has(c)||c.userData.isHelper){console.log("Skipping child (already processed or helper)");return}if((h=c.userData)!=null&&h.isDetachedFromGLB&&c instanceof je){console.log("Processing detached GLB mesh:",((m=c.userData)==null?void 0:m.name)||c.name||c.type);const v=l(c);i.push(v),console.log("Added detached GLB mesh to scene objects:",v.name),o.add(c)}else if(a.has(c)||c.userData.isLoadedModel){console.log("Processing loaded model container:",c.name);const v=l(c);i.push(v),console.log("Added loaded model to scene objects:",v.name),o.add(c)}else{console.log("Processing as standalone object:",c.name||c.type);const v=l(c);i.push(v),console.log("Added standalone object to scene objects:",v.name),o.add(c)}}),console.log("Built scene objects final result:",i.length),i},T8=t=>{const e={models:[],meshes:[],groups:[],primitives:[],points:[],measurements:[],lights:[],environment:[]},n=(r,i=!0)=>{if(i)switch(r.type){case"model":e.models.push(r);break;case"mesh":r.object.userData.isPartOfLoadedModel||e.meshes.push(r);break;case"group":!r.object.userData.isLoadedModel&&!r.object.userData.isPartOfLoadedModel&&e.groups.push(r);break;case"primitive":e.primitives.push(r);break;case"point":e.points.push(r);break;case"measurement":e.measurements.push(r);break;case"light":e.lights.push(r);break;case"environment":e.environment.push(r);break}};return t.forEach(r=>n(r,!0)),e},A8=({sceneObjects:t,expandedNodes:e,onToggleExpanded:n,onToggleVisibility:r,onObjectSelect:i,onDelete:s})=>{const[o,a]=S.useState(new Set),[l,c]=S.useState(new Set),f=T8(t),u=m=>{const v=new Set(o);v.has(m)?v.delete(m):v.add(m),a(v)},d=(m,v)=>{const g=new Set(l),p=g.has(m);p?g.delete(m):g.add(m),c(g),v.forEach(x=>{x.object.visible=p})},h=(m,v)=>{if(v.length===0)return null;const g=o.has(m),p=l.has(m);return y.jsxs("div",{className:"mb-2",children:[y.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 hover:bg-slate-700/30 rounded",children:[y.jsx(ot,{variant:"ghost",size:"sm",className:"h-4 w-4 p-0 text-slate-400",onClick:()=>u(m),children:g?y.jsx(A1,{className:"h-3 w-3"}):y.jsx(Ah,{className:"h-3 w-3"})}),y.jsxs("span",{className:"text-xs font-medium text-slate-400 uppercase tracking-wide flex-1",children:[m," (",v.length,")"]}),y.jsx(ot,{variant:"ghost",size:"sm",className:"h-4 w-4 p-0 text-slate-400 hover:text-slate-200",onClick:()=>d(m,v),title:`${p?"Show":"Hide"} all ${m.toLowerCase()}`,children:p?y.jsx(Ch,{className:"h-3 w-3"}):y.jsx(gy,{className:"h-3 w-3"})})]}),!g&&y.jsx(S8,{title:m,objects:v,expandedNodes:e,onToggleExpanded:n,onToggleVisibility:r,onObjectSelect:i,onDelete:s,hideTitle:!0})]},m)};return y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"text-xs text-slate-400 mb-2 px-2",children:"Hold Ctrl+Click to select multiple objects"}),h("Models",f.models),h("Meshes",f.meshes),h("Groups",f.groups),h("Primitives",f.primitives),h("Points",f.points),h("Measurements",f.measurements),h("Lights",f.lights),h("Environment",f.environment)]})},C8=(t,e,n,r="",i=!1)=>{const[s,o]=S.useState(new Set(["root"])),[a,l]=S.useState([]),[c,f]=S.useState(0),{selectedObjects:u,selectObject:d,toggleSelection:h,clearSelection:m}=Bl(),v=S.useCallback(()=>{console.log("Triggering scene tree update"),f(w=>w+1)},[]);S.useEffect(()=>{console.log("Building scene objects",{sceneExists:!!t,showSelectedOnly:i,selectedObjects:u.length,searchQuery:r,loadedModelsCount:e.length});let w=E8(t,e,n,u);if(console.log("Built scene objects:",w.length,w.map(M=>M.name)),i&&u.length>0){console.log("Applying selected-only filter");const M=new Set(u.map(b=>b.id)),T=b=>b.filter(C=>{if(M.has(C.id))return console.log("Object is selected:",C.name),!0;const A=N=>N.some(F=>M.has(F.id)?!0:A(F.children)),E=A(C.children);return E&&console.log("Object has selected children:",C.name),E}).map(C=>({...C,children:T(C.children)}));w=T(w),console.log("Filtered objects:",w.length)}r.trim()&&(console.log("Applying search filter:",r),w=(T=>T.filter(b=>b.name.toLowerCase().includes(r.toLowerCase())))(w),console.log("Search filtered objects:",w.length)),l(w)},[t,e,n,u,r,i,c]);const g=w=>{const M=new Set(s);M.has(w)?M.delete(w):M.add(w),o(M)},p=S.useCallback(w=>{console.log("Toggling visibility for:",w.name,"current:",w.object.visible);const M=!w.object.visible,T=w.object,b=(C,A)=>{C.visible=A,C.children.forEach(E=>b(E,A))};b(T,M),w.visible=M,v(),console.log("Visibility toggled to:",M,"for object:",w.name)},[v]);return{expandedNodes:s,sceneObjects:a,selectedObjects:u,toggleExpanded:g,toggleVisibility:p,handleObjectSelect:(w,M)=>{console.log("Selecting object:",w.name,"multi:",M),M?h(w):d(w)},handleDelete:(w,M)=>{var T,b;M.stopPropagation(),console.log("Deleting object:",w.name,w.type),(w.type==="point"||w.type==="measurement")&&(t==null||t.remove(w.object),w.type==="measurement"&&w.object instanceof qt&&w.object.children.forEach(C=>{var A,E,N,F;C instanceof je?((A=C.geometry)==null||A.dispose(),Array.isArray(C.material)?C.material.forEach(I=>I.dispose()):(E=C.material)==null||E.dispose()):C instanceof wi&&((N=C.geometry)==null||N.dispose(),(F=C.material)==null||F.dispose())}),w.type==="point"&&w.object instanceof je&&((T=w.object.geometry)==null||T.dispose(),Array.isArray(w.object.material)?w.object.material.forEach(C=>C.dispose()):(b=w.object.material)==null||b.dispose()),v())},clearSelection:m,triggerUpdate:v}},R8=({loadedModels:t,currentModel:e,showPrimitives:n,scene:r,searchQuery:i="",showSelectedOnly:s=!1})=>{const{expandedNodes:o,sceneObjects:a,selectedObjects:l,toggleExpanded:c,toggleVisibility:f,handleObjectSelect:u,handleDelete:d,clearSelection:h}=C8(r,t,n,i,s);return y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsx(x8,{selectedObjects:l,onClearSelection:h}),y.jsx("div",{className:"flex-1 overflow-y-auto bg-slate-800/30 border border-slate-600 rounded",children:y.jsx("div",{className:"p-2",children:a.length===0?y.jsx(_8,{}):y.jsx(A8,{sceneObjects:a,expandedNodes:o,onToggleExpanded:c,onToggleVisibility:f,onObjectSelect:u,onDelete:d})})})]})},P8=({loadedModels:t,currentModel:e,isUploading:n,uploadError:r,onFileUpload:i,scene:s})=>{const[o,a]=S.useState(""),[l,c]=S.useState(!1),[f,u]=S.useState(!1);return y.jsx(Ul,{children:y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-slate-600/50",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(ID,{className:"h-4 w-4 text-indigo-400"}),y.jsx("span",{className:"text-sm font-medium text-slate-200",children:"Scene Objects"})]}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"h-7 w-7 p-0 text-slate-400 hover:text-indigo-400",children:y.jsx(jD,{className:"h-4 w-4"})})}),y.jsx(mn,{children:y.jsx("p",{children:"Import 3D Model"})})]})]}),y.jsxs("div",{className:"p-3 space-y-2 border-b border-slate-600/50",children:[y.jsxs("div",{className:"relative",children:[y.jsx(VD,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-slate-400"}),y.jsx(KA,{placeholder:"Search objects...",value:o,onChange:d=>a(d.target.value),className:"h-7 pl-7 bg-slate-700/50 border-slate-600/50 text-slate-200 text-xs placeholder:text-slate-400"})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center space-x-2",children:[y.jsx(tC,{id:"selected-only",checked:l,onCheckedChange:c,className:"scale-75"}),y.jsx(Oo,{htmlFor:"selected-only",className:"text-xs text-slate-400",children:"Selected only"})]}),y.jsxs("div",{className:"text-xs text-slate-500",children:[t.length," model",t.length!==1?"s":""]})]})]}),r&&y.jsx("div",{className:"mx-3 mt-2 p-2 bg-red-900/30 border border-red-800/50 rounded text-red-200 text-xs",children:y.jsxs("div",{className:"flex items-start gap-2",children:[y.jsx("span",{className:"text-red-400",children:"⚠"}),y.jsx("span",{children:r})]})}),y.jsx("div",{className:"flex-1 overflow-hidden",children:y.jsx(R8,{loadedModels:t,currentModel:e,showPrimitives:!0,scene:s,searchQuery:o,showSelectedOnly:l})}),f&&y.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:y.jsxs("div",{className:"bg-slate-800 p-4 rounded-lg border border-slate-600 max-w-sm w-full mx-4",children:[y.jsxs("div",{className:"flex items-center justify-between mb-3",children:[y.jsx("h3",{className:"text-sm font-medium text-slate-200",children:"Import 3D Model"}),y.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>u(!1),className:"h-6 w-6 p-0 text-slate-400",children:"×"})]}),y.jsxs("div",{className:"space-y-3",children:[y.jsx(y8,{onFileSelect:d=>{i(d),u(!1)},isLoading:n}),y.jsx("p",{className:"text-xs text-slate-400 text-center",children:"Supports FBX, OBJ, and GLTF formats"})]})]})})]})})},Xn=S.forwardRef(({className:t,...e},n)=>y.jsx("div",{ref:n,className:ht("rounded-lg border bg-card text-card-foreground shadow-sm",t),...e}));Xn.displayName="Card";const $n=S.forwardRef(({className:t,...e},n)=>y.jsx("div",{ref:n,className:ht("flex flex-col space-y-1.5 p-6",t),...e}));$n.displayName="CardHeader";const Yn=S.forwardRef(({className:t,...e},n)=>y.jsx("h3",{ref:n,className:ht("text-2xl font-semibold leading-none tracking-tight",t),...e}));Yn.displayName="CardTitle";const N8=S.forwardRef(({className:t,...e},n)=>y.jsx("p",{ref:n,className:ht("text-sm text-muted-foreground",t),...e}));N8.displayName="CardDescription";const Kn=S.forwardRef(({className:t,...e},n)=>y.jsx("div",{ref:n,className:ht("p-6 pt-0",t),...e}));Kn.displayName="CardContent";const D8=S.forwardRef(({className:t,...e},n)=>y.jsx("div",{ref:n,className:ht("flex items-center p-6 pt-0",t),...e}));D8.displayName="CardFooter";var L8="Separator",fM="horizontal",I8=["horizontal","vertical"],sC=S.forwardRef((t,e)=>{const{decorative:n,orientation:r=fM,...i}=t,s=k8(r)?r:fM,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return y.jsx(We.div,{"data-orientation":s,...a,...i,ref:e})});sC.displayName=L8;function k8(t){return I8.includes(t)}var oC=sC;const Fo=S.forwardRef(({className:t,orientation:e="horizontal",decorative:n=!0,...r},i)=>y.jsx(oC,{ref:i,decorative:n,orientation:e,className:ht("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...r}));Fo.displayName=oC.displayName;const O8=({selectedObject:t,onPropertyChange:e})=>{var s;if(!t)return y.jsx("div",{className:"space-y-4 p-4",children:y.jsxs(Xn,{className:"bg-card/95 backdrop-blur-sm",children:[y.jsx($n,{className:"pb-2",children:y.jsx(Yn,{className:"text-base flex items-center justify-between",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"}),"Properties"]})})}),y.jsx(Kn,{className:"pt-0",children:y.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[y.jsx(Xa,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),y.jsx("p",{className:"text-sm",children:"No object selected"}),y.jsx("p",{className:"text-xs opacity-70",children:"Select an object to view its properties"})]})})]})});const n=o=>{switch(o){case"mesh":return y.jsx(D1,{className:"h-5 w-5 text-green-400"});case"group":return y.jsx(Pr,{className:"h-5 w-5 text-blue-400"});case"primitive":return y.jsx(Pr,{className:"h-5 w-5 text-purple-400"});case"ground":return y.jsx(N1,{className:"h-5 w-5 text-brown-400"});case"light":return y.jsx(_y,{className:"h-5 w-5 text-yellow-400"});case"point":return y.jsx(Rh,{className:"h-5 w-5 text-red-400"});default:return y.jsx(Xa,{className:"h-5 w-5 text-gray-400"})}},i=(o=>{const a=o.userData;let l=(a==null?void 0:a.object_params)||a;const c=(l==null?void 0:l.id)!==void 0,f=(l==null?void 0:l.name)!==void 0,u=(l==null?void 0:l.parent_id)!==void 0,d=(l==null?void 0:l.type)!==void 0,h=(l==null?void 0:l.function)!==void 0;return c&&f&&u&&d&&h?{id:String(l.id),name:l.name===""?"(empty)":String(l.name),parent_id:l.parent_id===""?"(empty)":String(l.parent_id),type:String(l.type),function:l.function===""?"(empty)":String(l.function),hasValidMetadata:!0}:{hasValidMetadata:!1,error:"Missing required metadata fields",availableFields:Object.keys(l||{}),rawUserData:a}})(t.object);return y.jsx("div",{className:"space-y-3 p-3",children:y.jsxs(Xn,{className:"bg-card/95 backdrop-blur-sm",children:[y.jsx($n,{className:"pb-2",children:y.jsx(Yn,{className:"text-base flex items-center justify-between",children:y.jsxs("div",{className:"flex items-center gap-2",children:[n(t.type),"Properties"]})})}),y.jsxs(Kn,{className:"pt-0 space-y-3",children:[i.hasValidMetadata?y.jsxs("div",{className:"space-y-2",children:[y.jsx(Oo,{className:"text-sm font-medium",children:"Object Properties"}),y.jsxs("div",{className:"grid grid-cols-1 gap-2 text-xs",children:[y.jsxs("div",{className:"flex justify-between items-center py-1",children:[y.jsx("span",{className:"text-muted-foreground",children:"ID:"}),y.jsx("span",{className:"font-mono text-right max-w-[120px] truncate",children:"id"in i?i.id:""})]}),y.jsxs("div",{className:"flex justify-between items-center py-1",children:[y.jsx("span",{className:"text-muted-foreground",children:"Name:"}),y.jsx("span",{className:"text-right max-w-[120px] truncate",children:"name"in i?i.name:""})]}),y.jsxs("div",{className:"flex justify-between items-center py-1",children:[y.jsx("span",{className:"text-muted-foreground",children:"Type:"}),y.jsx("span",{className:"text-right max-w-[120px] truncate",children:"type"in i?i.type:""})]}),y.jsxs("div",{className:"flex justify-between items-center py-1",children:[y.jsx("span",{className:"text-muted-foreground",children:"Function:"}),y.jsx("span",{className:"text-right max-w-[120px] truncate",children:"function"in i?i.function:""})]})]})]}):y.jsxs("div",{className:"space-y-2",children:[y.jsx(Oo,{className:"text-sm font-medium",children:"Object Properties"}),y.jsx("div",{className:"text-xs text-muted-foreground py-2",children:"No metadata available"})]}),y.jsx(Fo,{}),y.jsx("div",{className:"space-y-2",children:y.jsxs(ot,{size:"sm",variant:t.visible?"default":"outline",onClick:()=>e("visibility",!t.visible),className:"w-full flex items-center gap-2 h-8",children:[t.visible?y.jsx(gy,{className:"h-3 w-3"}):y.jsx(Ch,{className:"h-3 w-3"}),t.visible?"Visible":"Hidden"]})}),t.type==="mesh"&&t.object instanceof je&&y.jsxs(y.Fragment,{children:[y.jsx(Fo,{}),y.jsxs("div",{className:"space-y-2",children:[y.jsx(Oo,{className:"text-sm font-medium",children:"Material"}),y.jsxs("div",{className:"flex justify-between items-center py-1 text-xs",children:[y.jsx("span",{className:"text-muted-foreground",children:"Type:"}),y.jsx("span",{className:"text-right max-w-[120px] truncate",children:Array.isArray(t.object.material)?t.object.material.map(o=>o.type).join(", "):((s=t.object.material)==null?void 0:s.type)||"None"})]})]})]})]})]})})},F8=t=>{const{selectedObjects:e}=Bl(),n=e.length>0?e[0]:null,r=(i,s)=>{n&&(i==="name"?(n.object.name=s,n.name=s):i==="visibility"&&(n.object.visible=s,n.visible=s))};return y.jsx(O8,{selectedObject:n,onPropertyChange:r})};function mu(t,[e,n]){return Math.min(n,Math.max(e,t))}var U8=S.createContext(void 0);function Ru(t){const e=S.useContext(U8);return t||e||"ltr"}var aC=["PageUp","PageDown"],lC=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],cC={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Wl="Slider",[t0,B8,z8]=Sh(Wl),[uC,E7]=ea(Wl,[z8]),[H8,Zh]=uC(Wl),dC=S.forwardRef((t,e)=>{const{name:n,min:r=0,max:i=100,step:s=1,orientation:o="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:f,onValueChange:u=()=>{},onValueCommit:d=()=>{},inverted:h=!1,form:m,...v}=t,g=S.useRef(new Set),p=S.useRef(0),_=o==="horizontal"?j8:V8,[w=[],M]=Ys({prop:f,defaultProp:c,onChange:N=>{var I;(I=[...g.current][p.current])==null||I.focus(),u(N)}}),T=S.useRef(w);function b(N){const F=Y8(w,N);E(N,F)}function C(N){E(N,p.current)}function A(){const N=T.current[p.current];w[p.current]!==N&&d(w)}function E(N,F,{commit:I}={commit:!1}){const U=Q8(s),z=J8(Math.round((N-r)/s)*s+r,U),O=mu(z,[r,i]);M((j=[])=>{const D=X8(j,O,F);if(Z8(D,l*s)){p.current=D.indexOf(O);const V=String(D)!==String(j);return V&&I&&d(D),V?D:j}else return j})}return y.jsx(H8,{scope:t.__scopeSlider,name:n,disabled:a,min:r,max:i,valueIndexToChangeRef:p,thumbs:g.current,values:w,orientation:o,form:m,children:y.jsx(t0.Provider,{scope:t.__scopeSlider,children:y.jsx(t0.Slot,{scope:t.__scopeSlider,children:y.jsx(_,{"aria-disabled":a,"data-disabled":a?"":void 0,...v,ref:e,onPointerDown:Ne(v.onPointerDown,()=>{a||(T.current=w)}),min:r,max:i,inverted:h,onSlideStart:a?void 0:b,onSlideMove:a?void 0:C,onSlideEnd:a?void 0:A,onHomeKeyDown:()=>!a&&E(r,0,{commit:!0}),onEndKeyDown:()=>!a&&E(i,w.length-1,{commit:!0}),onStepKeyDown:({event:N,direction:F})=>{if(!a){const z=aC.includes(N.key)||N.shiftKey&&lC.includes(N.key)?10:1,O=p.current,j=w[O],D=s*z*F;E(j+D,O,{commit:!0})}}})})})})});dC.displayName=Wl;var[fC,hC]=uC(Wl,{startEdge:"left",endEdge:"right",size:"width",direction:1}),j8=S.forwardRef((t,e)=>{const{min:n,max:r,dir:i,inverted:s,onSlideStart:o,onSlideMove:a,onSlideEnd:l,onStepKeyDown:c,...f}=t,[u,d]=S.useState(null),h=dt(e,_=>d(_)),m=S.useRef(),v=Ru(i),g=v==="ltr",p=g&&!s||!g&&s;function x(_){const w=m.current||u.getBoundingClientRect(),M=[0,w.width],b=dx(M,p?[n,r]:[r,n]);return m.current=w,b(_-w.left)}return y.jsx(fC,{scope:t.__scopeSlider,startEdge:p?"left":"right",endEdge:p?"right":"left",direction:p?1:-1,size:"width",children:y.jsx(pC,{dir:v,"data-orientation":"horizontal",...f,ref:h,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const w=x(_.clientX);o==null||o(w)},onSlideMove:_=>{const w=x(_.clientX);a==null||a(w)},onSlideEnd:()=>{m.current=void 0,l==null||l()},onStepKeyDown:_=>{const M=cC[p?"from-left":"from-right"].includes(_.key);c==null||c({event:_,direction:M?-1:1})}})})}),V8=S.forwardRef((t,e)=>{const{min:n,max:r,inverted:i,onSlideStart:s,onSlideMove:o,onSlideEnd:a,onStepKeyDown:l,...c}=t,f=S.useRef(null),u=dt(e,f),d=S.useRef(),h=!i;function m(v){const g=d.current||f.current.getBoundingClientRect(),p=[0,g.height],_=dx(p,h?[r,n]:[n,r]);return d.current=g,_(v-g.top)}return y.jsx(fC,{scope:t.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:y.jsx(pC,{"data-orientation":"vertical",...c,ref:u,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{const g=m(v.clientY);s==null||s(g)},onSlideMove:v=>{const g=m(v.clientY);o==null||o(g)},onSlideEnd:()=>{d.current=void 0,a==null||a()},onStepKeyDown:v=>{const p=cC[h?"from-bottom":"from-top"].includes(v.key);l==null||l({event:v,direction:p?-1:1})}})})}),pC=S.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:s,onHomeKeyDown:o,onEndKeyDown:a,onStepKeyDown:l,...c}=t,f=Zh(Wl,n);return y.jsx(We.span,{...c,ref:e,onKeyDown:Ne(t.onKeyDown,u=>{u.key==="Home"?(o(u),u.preventDefault()):u.key==="End"?(a(u),u.preventDefault()):aC.concat(lC).includes(u.key)&&(l(u),u.preventDefault())}),onPointerDown:Ne(t.onPointerDown,u=>{const d=u.target;d.setPointerCapture(u.pointerId),u.preventDefault(),f.thumbs.has(d)?d.focus():r(u)}),onPointerMove:Ne(t.onPointerMove,u=>{u.target.hasPointerCapture(u.pointerId)&&i(u)}),onPointerUp:Ne(t.onPointerUp,u=>{const d=u.target;d.hasPointerCapture(u.pointerId)&&(d.releasePointerCapture(u.pointerId),s(u))})})}),mC="SliderTrack",gC=S.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=Zh(mC,n);return y.jsx(We.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:e})});gC.displayName=mC;var n0="SliderRange",vC=S.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=Zh(n0,n),s=hC(n0,n),o=S.useRef(null),a=dt(e,o),l=i.values.length,c=i.values.map(d=>xC(d,i.min,i.max)),f=l>1?Math.min(...c):0,u=100-Math.max(...c);return y.jsx(We.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:a,style:{...t.style,[s.startEdge]:f+"%",[s.endEdge]:u+"%"}})});vC.displayName=n0;var r0="SliderThumb",yC=S.forwardRef((t,e)=>{const n=B8(t.__scopeSlider),[r,i]=S.useState(null),s=dt(e,a=>i(a)),o=S.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return y.jsx(G8,{...t,ref:s,index:o})}),G8=S.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:i,...s}=t,o=Zh(r0,n),a=hC(r0,n),[l,c]=S.useState(null),f=dt(e,x=>c(x)),u=l?o.form||!!l.closest("form"):!0,d=Cy(l),h=o.values[r],m=h===void 0?0:xC(h,o.min,o.max),v=$8(r,o.values.length),g=d==null?void 0:d[a.size],p=g?K8(g,m,a.direction):0;return S.useEffect(()=>{if(l)return o.thumbs.add(l),()=>{o.thumbs.delete(l)}},[l,o.thumbs]),y.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${m}% + ${p}px)`},children:[y.jsx(t0.ItemSlot,{scope:t.__scopeSlider,children:y.jsx(We.span,{role:"slider","aria-label":t["aria-label"]||v,"aria-valuemin":o.min,"aria-valuenow":h,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...s,ref:f,style:h===void 0?{display:"none"}:t.style,onFocus:Ne(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),u&&y.jsx(W8,{name:i??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:h},r)]})});yC.displayName=r0;var W8=t=>{const{value:e,...n}=t,r=S.useRef(null),i=cx(e);return S.useEffect(()=>{const s=r.current,o=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(o,"value").set;if(i!==e&&l){const c=new Event("input",{bubbles:!0});l.call(s,e),s.dispatchEvent(c)}},[i,e]),y.jsx("input",{style:{display:"none"},...n,ref:r,defaultValue:e})};function X8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((i,s)=>i-s)}function xC(t,e,n){const s=100/(n-e)*(t-e);return mu(s,[0,100])}function $8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function Y8(t,e){if(t.length===1)return 0;const n=t.map(i=>Math.abs(i-e)),r=Math.min(...n);return n.indexOf(r)}function K8(t,e,n){const r=t/2,s=dx([0,50],[0,r]);return(r-s(e)*n)*n}function q8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function Z8(t,e){if(e>0){const n=q8(t);return Math.min(...n)>=e}return!0}function dx(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function Q8(t){return(String(t).split(".")[1]||"").length}function J8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var _C=dC,e6=gC,t6=vC,n6=yC;const i0=S.forwardRef(({className:t,...e},n)=>y.jsxs(_C,{ref:n,className:ht("relative flex w-full touch-none select-none items-center",t),...e,children:[y.jsx(e6,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:y.jsx(t6,{className:"absolute h-full bg-primary"})}),y.jsx(n6,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));i0.displayName=_C.displayName;var Lm=0;function r6(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??hM()),document.body.insertAdjacentElement("beforeend",t[1]??hM()),Lm++,()=>{Lm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Lm--}},[])}function hM(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Im="focusScope.autoFocusOnMount",km="focusScope.autoFocusOnUnmount",pM={bubbles:!1,cancelable:!0},i6="FocusScope",wC=S.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[a,l]=S.useState(null),c=Kt(i),f=Kt(s),u=S.useRef(null),d=dt(e,v=>l(v)),h=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(r){let v=function(_){if(h.paused||!a)return;const w=_.target;a.contains(w)?u.current=w:_s(u.current,{select:!0})},g=function(_){if(h.paused||!a)return;const w=_.relatedTarget;w!==null&&(a.contains(w)||_s(u.current,{select:!0}))},p=function(_){if(document.activeElement===document.body)for(const M of _)M.removedNodes.length>0&&_s(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const x=new MutationObserver(p);return a&&x.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),x.disconnect()}}},[r,a,h.paused]),S.useEffect(()=>{if(a){gM.add(h);const v=document.activeElement;if(!a.contains(v)){const p=new CustomEvent(Im,pM);a.addEventListener(Im,c),a.dispatchEvent(p),p.defaultPrevented||(s6(u6(SC(a)),{select:!0}),document.activeElement===v&&_s(a))}return()=>{a.removeEventListener(Im,c),setTimeout(()=>{const p=new CustomEvent(km,pM);a.addEventListener(km,f),a.dispatchEvent(p),p.defaultPrevented||_s(v??document.body,{select:!0}),a.removeEventListener(km,f),gM.remove(h)},0)}}},[a,c,f,h]);const m=S.useCallback(v=>{if(!n&&!r||h.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,p=document.activeElement;if(g&&p){const x=v.currentTarget,[_,w]=o6(x);_&&w?!v.shiftKey&&p===w?(v.preventDefault(),n&&_s(_,{select:!0})):v.shiftKey&&p===_&&(v.preventDefault(),n&&_s(w,{select:!0})):p===x&&v.preventDefault()}},[n,r,h.paused]);return y.jsx(We.div,{tabIndex:-1,...o,ref:d,onKeyDown:m})});wC.displayName=i6;function s6(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(_s(r,{select:e}),document.activeElement!==n)return}function o6(t){const e=SC(t),n=mM(e,t),r=mM(e.reverse(),t);return[n,r]}function SC(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function mM(t,e){for(const n of t)if(!a6(n,{upTo:e}))return n}function a6(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function l6(t){return t instanceof HTMLInputElement&&"select"in t}function _s(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&l6(t)&&e&&t.select()}}var gM=c6();function c6(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=vM(t,e),t.unshift(e)},remove(e){var n;t=vM(t,e),(n=t[0])==null||n.resume()}}}function vM(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function u6(t){return t.filter(e=>e.tagName!=="A")}var d6=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},wa=new WeakMap,Bd=new WeakMap,zd={},Om=0,MC=function(t){return t&&(t.host||MC(t.parentNode))},f6=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=MC(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},h6=function(t,e,n,r){var i=f6(e,Array.isArray(t)?t:[t]);zd[n]||(zd[n]=new WeakMap);var s=zd[n],o=[],a=new Set,l=new Set(i),c=function(u){!u||a.has(u)||(a.add(u),c(u.parentNode))};i.forEach(c);var f=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(d){if(a.has(d))f(d);else try{var h=d.getAttribute(r),m=h!==null&&h!=="false",v=(wa.get(d)||0)+1,g=(s.get(d)||0)+1;wa.set(d,v),s.set(d,g),o.push(d),v===1&&m&&Bd.set(d,!0),g===1&&d.setAttribute(n,"true"),m||d.setAttribute(r,"true")}catch(p){console.error("aria-hidden: cannot operate on ",d,p)}})};return f(e),a.clear(),Om++,function(){o.forEach(function(u){var d=wa.get(u)-1,h=s.get(u)-1;wa.set(u,d),s.set(u,h),d||(Bd.has(u)||u.removeAttribute(r),Bd.delete(u)),h||u.removeAttribute(n)}),Om--,Om||(wa=new WeakMap,wa=new WeakMap,Bd=new WeakMap,zd={})}},p6=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=d6(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),h6(r,i,n,"aria-hidden")):function(){return null}},mi=function(){return mi=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},mi.apply(this,arguments)};function bC(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function m6(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var pf="right-scroll-bar-position",mf="width-before-scroll-bar",g6="with-scroll-bars-hidden",v6="--removed-body-scroll-bar-size";function Fm(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function y6(t,e){var n=S.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var x6=typeof window<"u"?S.useLayoutEffect:S.useEffect,yM=new WeakMap;function _6(t,e){var n=y6(null,function(r){return t.forEach(function(i){return Fm(i,r)})});return x6(function(){var r=yM.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(a){s.has(a)||Fm(a,null)}),s.forEach(function(a){i.has(a)||Fm(a,o)})}yM.set(n,t)},[t]),n}function w6(t){return t}function S6(t,e){e===void 0&&(e=w6);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var f=o;o=[],f.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(f){o.push(f),c()},filter:function(f){return o=o.filter(f),n}}}};return i}function M6(t){t===void 0&&(t={});var e=S6(null);return e.options=mi({async:!0,ssr:!1},t),e}var EC=function(t){var e=t.sideCar,n=bC(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return S.createElement(r,mi({},n))};EC.isSideCarExport=!0;function b6(t,e){return t.useMedium(e),EC}var TC=M6(),Um=function(){},Qh=S.forwardRef(function(t,e){var n=S.useRef(null),r=S.useState({onScrollCapture:Um,onWheelCapture:Um,onTouchMoveCapture:Um}),i=r[0],s=r[1],o=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,f=t.enabled,u=t.shards,d=t.sideCar,h=t.noIsolation,m=t.inert,v=t.allowPinchZoom,g=t.as,p=g===void 0?"div":g,x=t.gapMode,_=bC(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=d,M=_6([n,e]),T=mi(mi({},_),i);return S.createElement(S.Fragment,null,f&&S.createElement(w,{sideCar:TC,removeScrollBar:c,shards:u,noIsolation:h,inert:m,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:x}),o?S.cloneElement(S.Children.only(a),mi(mi({},T),{ref:M})):S.createElement(p,mi({},T,{className:l,ref:M}),a))});Qh.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Qh.classNames={fullWidth:mf,zeroRight:pf};var E6=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function T6(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=E6();return e&&t.setAttribute("nonce",e),t}function A6(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function C6(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var R6=function(){var t=0,e=null;return{add:function(n){t==0&&(e=T6())&&(A6(e,n),C6(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},P6=function(){var t=R6();return function(e,n){S.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},AC=function(){var t=P6(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},N6={left:0,top:0,right:0,gap:0},Bm=function(t){return parseInt(t||"",10)||0},D6=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[Bm(n),Bm(r),Bm(i)]},L6=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return N6;var e=D6(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},I6=AC(),rl="data-scroll-locked",k6=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
.`.concat(g6,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(a,"px ").concat(r,`;
}
body[`).concat(rl,`] {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(i,`px;
padding-top: `).concat(s,`px;
padding-right: `).concat(o,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(a,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(pf,` {
right: `).concat(a,"px ").concat(r,`;
}
.`).concat(mf,` {
margin-right: `).concat(a,"px ").concat(r,`;
}
.`).concat(pf," .").concat(pf,` {
right: 0 `).concat(r,`;
}
.`).concat(mf," .").concat(mf,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(rl,`] {
`).concat(v6,": ").concat(a,`px;
}
`)},xM=function(){var t=parseInt(document.body.getAttribute(rl)||"0",10);return isFinite(t)?t:0},O6=function(){S.useEffect(function(){return document.body.setAttribute(rl,(xM()+1).toString()),function(){var t=xM()-1;t<=0?document.body.removeAttribute(rl):document.body.setAttribute(rl,t.toString())}},[])},F6=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;O6();var s=S.useMemo(function(){return L6(i)},[i]);return S.createElement(I6,{styles:k6(s,!e,i,n?"":"!important")})},s0=!1;if(typeof window<"u")try{var Hd=Object.defineProperty({},"passive",{get:function(){return s0=!0,!0}});window.addEventListener("test",Hd,Hd),window.removeEventListener("test",Hd,Hd)}catch{s0=!1}var Sa=s0?{passive:!1}:!1,U6=function(t){return t.tagName==="TEXTAREA"},CC=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!U6(t)&&n[e]==="visible")},B6=function(t){return CC(t,"overflowY")},z6=function(t){return CC(t,"overflowX")},_M=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=RC(t,r);if(i){var s=PC(t,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},H6=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},j6=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},RC=function(t,e){return t==="v"?B6(e):z6(e)},PC=function(t,e){return t==="v"?H6(e):j6(e)},V6=function(t,e){return t==="h"&&e==="rtl"?-1:1},G6=function(t,e,n,r,i){var s=V6(t,window.getComputedStyle(e).direction),o=s*r,a=n.target,l=e.contains(a),c=!1,f=o>0,u=0,d=0;do{var h=PC(t,a),m=h[0],v=h[1],g=h[2],p=v-g-s*m;(m||p)&&RC(t,a)&&(u+=p,d+=m),a instanceof ShadowRoot?a=a.host:a=a.parentNode}while(!l&&a!==document.body||l&&(e.contains(a)||e===a));return(f&&(Math.abs(u)<1||!i)||!f&&(Math.abs(d)<1||!i))&&(c=!0),c},jd=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},wM=function(t){return[t.deltaX,t.deltaY]},SM=function(t){return t&&"current"in t?t.current:t},W6=function(t,e){return t[0]===e[0]&&t[1]===e[1]},X6=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},$6=0,Ma=[];function Y6(t){var e=S.useRef([]),n=S.useRef([0,0]),r=S.useRef(),i=S.useState($6++)[0],s=S.useState(AC)[0],o=S.useRef(t);S.useEffect(function(){o.current=t},[t]),S.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var v=m6([t.lockRef.current],(t.shards||[]).map(SM),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var a=S.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var p=jd(v),x=n.current,_="deltaX"in v?v.deltaX:x[0]-p[0],w="deltaY"in v?v.deltaY:x[1]-p[1],M,T=v.target,b=Math.abs(_)>Math.abs(w)?"h":"v";if("touches"in v&&b==="h"&&T.type==="range")return!1;var C=_M(b,T);if(!C)return!0;if(C?M=b:(M=b==="v"?"h":"v",C=_M(b,T)),!C)return!1;if(!r.current&&"changedTouches"in v&&(_||w)&&(r.current=M),!M)return!0;var A=r.current||M;return G6(A,g,v,A==="h"?_:w,!0)},[]),l=S.useCallback(function(v){var g=v;if(!(!Ma.length||Ma[Ma.length-1]!==s)){var p="deltaY"in g?wM(g):jd(g),x=e.current.filter(function(M){return M.name===g.type&&(M.target===g.target||g.target===M.shadowParent)&&W6(M.delta,p)})[0];if(x&&x.should){g.cancelable&&g.preventDefault();return}if(!x){var _=(o.current.shards||[]).map(SM).filter(Boolean).filter(function(M){return M.contains(g.target)}),w=_.length>0?a(g,_[0]):!o.current.noIsolation;w&&g.cancelable&&g.preventDefault()}}},[]),c=S.useCallback(function(v,g,p,x){var _={name:v,delta:g,target:p,should:x,shadowParent:K6(p)};e.current.push(_),setTimeout(function(){e.current=e.current.filter(function(w){return w!==_})},1)},[]),f=S.useCallback(function(v){n.current=jd(v),r.current=void 0},[]),u=S.useCallback(function(v){c(v.type,wM(v),v.target,a(v,t.lockRef.current))},[]),d=S.useCallback(function(v){c(v.type,jd(v),v.target,a(v,t.lockRef.current))},[]);S.useEffect(function(){return Ma.push(s),t.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:d}),document.addEventListener("wheel",l,Sa),document.addEventListener("touchmove",l,Sa),document.addEventListener("touchstart",f,Sa),function(){Ma=Ma.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,Sa),document.removeEventListener("touchmove",l,Sa),document.removeEventListener("touchstart",f,Sa)}},[]);var h=t.removeScrollBar,m=t.inert;return S.createElement(S.Fragment,null,m?S.createElement(s,{styles:X6(i)}):null,h?S.createElement(F6,{gapMode:t.gapMode}):null)}function K6(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const q6=b6(TC,Y6);var NC=S.forwardRef(function(t,e){return S.createElement(Qh,mi({},t,{ref:e,sideCar:q6}))});NC.classNames=Qh.classNames;var Z6=[" ","Enter","ArrowUp","ArrowDown"],Q6=[" ","Enter"],Pu="Select",[Jh,ep,J6]=Sh(Pu),[Xl,T7]=ea(Pu,[J6,Lh]),tp=Lh(),[eW,lo]=Xl(Pu),[tW,nW]=Xl(Pu),DC=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:i,onOpenChange:s,value:o,defaultValue:a,onValueChange:l,dir:c,name:f,autoComplete:u,disabled:d,required:h,form:m}=t,v=tp(e),[g,p]=S.useState(null),[x,_]=S.useState(null),[w,M]=S.useState(!1),T=Ru(c),[b=!1,C]=Ys({prop:r,defaultProp:i,onChange:s}),[A,E]=Ys({prop:o,defaultProp:a,onChange:l}),N=S.useRef(null),F=g?m||!!g.closest("form"):!0,[I,U]=S.useState(new Set),z=Array.from(I).map(O=>O.props.value).join(";");return y.jsx(aT,{...v,children:y.jsxs(eW,{required:h,scope:e,trigger:g,onTriggerChange:p,valueNode:x,onValueNodeChange:_,valueNodeHasChildren:w,onValueNodeHasChildrenChange:M,contentId:kl(),value:A,onValueChange:E,open:b,onOpenChange:C,dir:T,triggerPointerDownPosRef:N,disabled:d,children:[y.jsx(Jh.Provider,{scope:e,children:y.jsx(tW,{scope:t.__scopeSelect,onNativeOptionAdd:S.useCallback(O=>{U(j=>new Set(j).add(O))},[]),onNativeOptionRemove:S.useCallback(O=>{U(j=>{const D=new Set(j);return D.delete(O),D})},[]),children:n})}),F?y.jsxs(rR,{"aria-hidden":!0,required:h,tabIndex:-1,name:f,autoComplete:u,value:A,onChange:O=>E(O.target.value),disabled:d,form:m,children:[A===void 0?y.jsx("option",{value:""}):null,Array.from(I)]},z):null]})})};DC.displayName=Pu;var LC="SelectTrigger",IC=S.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...i}=t,s=tp(n),o=lo(LC,n),a=o.disabled||r,l=dt(e,o.onTriggerChange),c=ep(n),f=S.useRef("touch"),[u,d,h]=iR(v=>{const g=c().filter(_=>!_.disabled),p=g.find(_=>_.value===o.value),x=sR(g,v,p);x!==void 0&&o.onValueChange(x.value)}),m=v=>{a||(o.onOpenChange(!0),h()),v&&(o.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return y.jsx(lT,{asChild:!0,...s,children:y.jsx(We.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":nR(o.value)?"":void 0,...i,ref:l,onClick:Ne(i.onClick,v=>{v.currentTarget.focus(),f.current!=="mouse"&&m(v)}),onPointerDown:Ne(i.onPointerDown,v=>{f.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(m(v),v.preventDefault())}),onKeyDown:Ne(i.onKeyDown,v=>{const g=u.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&d(v.key),!(g&&v.key===" ")&&Z6.includes(v.key)&&(m(),v.preventDefault())})})})});IC.displayName=LC;var kC="SelectValue",OC=S.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:o="",...a}=t,l=lo(kC,n),{onValueNodeHasChildrenChange:c}=l,f=s!==void 0,u=dt(e,l.onValueNodeChange);return _n(()=>{c(f)},[c,f]),y.jsx(We.span,{...a,ref:u,style:{pointerEvents:"none"},children:nR(l.value)?y.jsx(y.Fragment,{children:o}):s})});OC.displayName=kC;var rW="SelectIcon",FC=S.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...i}=t;return y.jsx(We.span,{"aria-hidden":!0,...i,ref:e,children:r||"▼"})});FC.displayName=rW;var iW="SelectPortal",UC=t=>y.jsx(dy,{asChild:!0,...t});UC.displayName=iW;var qo="SelectContent",BC=S.forwardRef((t,e)=>{const n=lo(qo,t.__scopeSelect),[r,i]=S.useState();if(_n(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?Jo.createPortal(y.jsx(zC,{scope:t.__scopeSelect,children:y.jsx(Jh.Slot,{scope:t.__scopeSelect,children:y.jsx("div",{children:t.children})})}),s):null}return y.jsx(HC,{...t,ref:e})});BC.displayName=qo;var jr=10,[zC,co]=Xl(qo),sW="SelectContentImpl",HC=S.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:o,side:a,sideOffset:l,align:c,alignOffset:f,arrowPadding:u,collisionBoundary:d,collisionPadding:h,sticky:m,hideWhenDetached:v,avoidCollisions:g,...p}=t,x=lo(qo,n),[_,w]=S.useState(null),[M,T]=S.useState(null),b=dt(e,Z=>w(Z)),[C,A]=S.useState(null),[E,N]=S.useState(null),F=ep(n),[I,U]=S.useState(!1),z=S.useRef(!1);S.useEffect(()=>{if(_)return p6(_)},[_]),r6();const O=S.useCallback(Z=>{const[ue,...Me]=F().map(Se=>Se.ref.current),[ye]=Me.slice(-1),ke=document.activeElement;for(const Se of Z)if(Se===ke||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===ue&&M&&(M.scrollTop=0),Se===ye&&M&&(M.scrollTop=M.scrollHeight),Se==null||Se.focus(),document.activeElement!==ke))return},[F,M]),j=S.useCallback(()=>O([C,_]),[O,C,_]);S.useEffect(()=>{I&&j()},[I,j]);const{onOpenChange:D,triggerPointerDownPosRef:V}=x;S.useEffect(()=>{if(_){let Z={x:0,y:0};const ue=ye=>{var ke,Se;Z={x:Math.abs(Math.round(ye.pageX)-(((ke=V.current)==null?void 0:ke.x)??0)),y:Math.abs(Math.round(ye.pageY)-(((Se=V.current)==null?void 0:Se.y)??0))}},Me=ye=>{Z.x<=10&&Z.y<=10?ye.preventDefault():_.contains(ye.target)||D(!1),document.removeEventListener("pointermove",ue),V.current=null};return V.current!==null&&(document.addEventListener("pointermove",ue),document.addEventListener("pointerup",Me,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ue),document.removeEventListener("pointerup",Me,{capture:!0})}}},[_,D,V]),S.useEffect(()=>{const Z=()=>D(!1);return window.addEventListener("blur",Z),window.addEventListener("resize",Z),()=>{window.removeEventListener("blur",Z),window.removeEventListener("resize",Z)}},[D]);const[Q,J]=iR(Z=>{const ue=F().filter(ke=>!ke.disabled),Me=ue.find(ke=>ke.ref.current===document.activeElement),ye=sR(ue,Z,Me);ye&&setTimeout(()=>ye.ref.current.focus())}),le=S.useCallback((Z,ue,Me)=>{const ye=!z.current&&!Me;(x.value!==void 0&&x.value===ue||ye)&&(A(Z),ye&&(z.current=!0))},[x.value]),pe=S.useCallback(()=>_==null?void 0:_.focus(),[_]),$=S.useCallback((Z,ue,Me)=>{const ye=!z.current&&!Me;(x.value!==void 0&&x.value===ue||ye)&&N(Z)},[x.value]),ee=r==="popper"?o0:jC,se=ee===o0?{side:a,sideOffset:l,align:c,alignOffset:f,arrowPadding:u,collisionBoundary:d,collisionPadding:h,sticky:m,hideWhenDetached:v,avoidCollisions:g}:{};return y.jsx(zC,{scope:n,content:_,viewport:M,onViewportChange:T,itemRefCallback:le,selectedItem:C,onItemLeave:pe,itemTextRefCallback:$,focusSelectedItem:j,selectedItemText:E,position:r,isPositioned:I,searchRef:Q,children:y.jsx(NC,{as:_l,allowPinchZoom:!0,children:y.jsx(wC,{asChild:!0,trapped:x.open,onMountAutoFocus:Z=>{Z.preventDefault()},onUnmountAutoFocus:Ne(i,Z=>{var ue;(ue=x.trigger)==null||ue.focus({preventScroll:!0}),Z.preventDefault()}),children:y.jsx(Mh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:Z=>Z.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:y.jsx(ee,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:Z=>Z.preventDefault(),...p,...se,onPlaced:()=>U(!0),ref:b,style:{display:"flex",flexDirection:"column",outline:"none",...p.style},onKeyDown:Ne(p.onKeyDown,Z=>{const ue=Z.ctrlKey||Z.altKey||Z.metaKey;if(Z.key==="Tab"&&Z.preventDefault(),!ue&&Z.key.length===1&&J(Z.key),["ArrowUp","ArrowDown","Home","End"].includes(Z.key)){let ye=F().filter(ke=>!ke.disabled).map(ke=>ke.ref.current);if(["ArrowUp","End"].includes(Z.key)&&(ye=ye.slice().reverse()),["ArrowUp","ArrowDown"].includes(Z.key)){const ke=Z.target,Se=ye.indexOf(ke);ye=ye.slice(Se+1)}setTimeout(()=>O(ye)),Z.preventDefault()}})})})})})})});HC.displayName=sW;var oW="SelectItemAlignedPosition",jC=S.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...i}=t,s=lo(qo,n),o=co(qo,n),[a,l]=S.useState(null),[c,f]=S.useState(null),u=dt(e,b=>f(b)),d=ep(n),h=S.useRef(!1),m=S.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:p,focusSelectedItem:x}=o,_=S.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&v&&g&&p){const b=s.trigger.getBoundingClientRect(),C=c.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),E=p.getBoundingClientRect();if(s.dir!=="rtl"){const ke=E.left-C.left,Se=A.left-ke,nt=b.left-Se,H=b.width+nt,Xt=Math.max(H,C.width),Ve=window.innerWidth-jr,qe=mu(Se,[jr,Math.max(jr,Ve-Xt)]);a.style.minWidth=H+"px",a.style.left=qe+"px"}else{const ke=C.right-E.right,Se=window.innerWidth-A.right-ke,nt=window.innerWidth-b.right-Se,H=b.width+nt,Xt=Math.max(H,C.width),Ve=window.innerWidth-jr,qe=mu(Se,[jr,Math.max(jr,Ve-Xt)]);a.style.minWidth=H+"px",a.style.right=qe+"px"}const N=d(),F=window.innerHeight-jr*2,I=v.scrollHeight,U=window.getComputedStyle(c),z=parseInt(U.borderTopWidth,10),O=parseInt(U.paddingTop,10),j=parseInt(U.borderBottomWidth,10),D=parseInt(U.paddingBottom,10),V=z+O+I+D+j,Q=Math.min(g.offsetHeight*5,V),J=window.getComputedStyle(v),le=parseInt(J.paddingTop,10),pe=parseInt(J.paddingBottom,10),$=b.top+b.height/2-jr,ee=F-$,se=g.offsetHeight/2,Z=g.offsetTop+se,ue=z+O+Z,Me=V-ue;if(ue<=$){const ke=N.length>0&&g===N[N.length-1].ref.current;a.style.bottom="0px";const Se=c.clientHeight-v.offsetTop-v.offsetHeight,nt=Math.max(ee,se+(ke?pe:0)+Se+j),H=ue+nt;a.style.height=H+"px"}else{const ke=N.length>0&&g===N[0].ref.current;a.style.top="0px";const nt=Math.max($,z+v.offsetTop+(ke?le:0)+se)+Me;a.style.height=nt+"px",v.scrollTop=ue-$+v.offsetTop}a.style.margin=`${jr}px 0`,a.style.minHeight=Q+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[d,s.trigger,s.valueNode,a,c,v,g,p,s.dir,r]);_n(()=>_(),[_]);const[w,M]=S.useState();_n(()=>{c&&M(window.getComputedStyle(c).zIndex)},[c]);const T=S.useCallback(b=>{b&&m.current===!0&&(_(),x==null||x(),m.current=!1)},[_,x]);return y.jsx(lW,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:T,children:y.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:y.jsx(We.div,{...i,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});jC.displayName=oW;var aW="SelectPopperPosition",o0=S.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=jr,...s}=t,o=tp(n);return y.jsx(cT,{...o,...s,ref:e,align:r,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});o0.displayName=aW;var[lW,fx]=Xl(qo,{}),a0="SelectViewport",VC=S.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...i}=t,s=co(a0,n),o=fx(a0,n),a=dt(e,s.onViewportChange),l=S.useRef(0);return y.jsxs(y.Fragment,{children:[y.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),y.jsx(Jh.Slot,{scope:n,children:y.jsx(We.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:Ne(i.onScroll,c=>{const f=c.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:d}=o;if(d!=null&&d.current&&u){const h=Math.abs(l.current-f.scrollTop);if(h>0){const m=window.innerHeight-jr*2,v=parseFloat(u.style.minHeight),g=parseFloat(u.style.height),p=Math.max(v,g);if(p<m){const x=p+h,_=Math.min(m,x),w=x-_;u.style.height=_+"px",u.style.bottom==="0px"&&(f.scrollTop=w>0?w:0,u.style.justifyContent="flex-end")}}}l.current=f.scrollTop})})})]})});VC.displayName=a0;var GC="SelectGroup",[cW,uW]=Xl(GC),dW=S.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=kl();return y.jsx(cW,{scope:n,id:i,children:y.jsx(We.div,{role:"group","aria-labelledby":i,...r,ref:e})})});dW.displayName=GC;var WC="SelectLabel",XC=S.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=uW(WC,n);return y.jsx(We.div,{id:i.id,...r,ref:e})});XC.displayName=WC;var rh="SelectItem",[fW,$C]=Xl(rh),YC=S.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...o}=t,a=lo(rh,n),l=co(rh,n),c=a.value===r,[f,u]=S.useState(s??""),[d,h]=S.useState(!1),m=dt(e,x=>{var _;return(_=l.itemRefCallback)==null?void 0:_.call(l,x,r,i)}),v=kl(),g=S.useRef("touch"),p=()=>{i||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return y.jsx(fW,{scope:n,value:r,disabled:i,textId:v,isSelected:c,onItemTextChange:S.useCallback(x=>{u(_=>_||((x==null?void 0:x.textContent)??"").trim())},[]),children:y.jsx(Jh.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:y.jsx(We.div,{role:"option","aria-labelledby":v,"data-highlighted":d?"":void 0,"aria-selected":c&&d,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:Ne(o.onFocus,()=>h(!0)),onBlur:Ne(o.onBlur,()=>h(!1)),onClick:Ne(o.onClick,()=>{g.current!=="mouse"&&p()}),onPointerUp:Ne(o.onPointerUp,()=>{g.current==="mouse"&&p()}),onPointerDown:Ne(o.onPointerDown,x=>{g.current=x.pointerType}),onPointerMove:Ne(o.onPointerMove,x=>{var _;g.current=x.pointerType,i?(_=l.onItemLeave)==null||_.call(l):g.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ne(o.onPointerLeave,x=>{var _;x.currentTarget===document.activeElement&&((_=l.onItemLeave)==null||_.call(l))}),onKeyDown:Ne(o.onKeyDown,x=>{var w;((w=l.searchRef)==null?void 0:w.current)!==""&&x.key===" "||(Q6.includes(x.key)&&p(),x.key===" "&&x.preventDefault())})})})})});YC.displayName=rh;var Mc="SelectItemText",KC=S.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,...s}=t,o=lo(Mc,n),a=co(Mc,n),l=$C(Mc,n),c=nW(Mc,n),[f,u]=S.useState(null),d=dt(e,p=>u(p),l.onItemTextChange,p=>{var x;return(x=a.itemTextRefCallback)==null?void 0:x.call(a,p,l.value,l.disabled)}),h=f==null?void 0:f.textContent,m=S.useMemo(()=>y.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=c;return _n(()=>(v(m),()=>g(m)),[v,g,m]),y.jsxs(y.Fragment,{children:[y.jsx(We.span,{id:l.textId,...s,ref:d}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Jo.createPortal(s.children,o.valueNode):null]})});KC.displayName=Mc;var qC="SelectItemIndicator",ZC=S.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return $C(qC,n).isSelected?y.jsx(We.span,{"aria-hidden":!0,...r,ref:e}):null});ZC.displayName=qC;var l0="SelectScrollUpButton",QC=S.forwardRef((t,e)=>{const n=co(l0,t.__scopeSelect),r=fx(l0,t.__scopeSelect),[i,s]=S.useState(!1),o=dt(e,r.onScrollButtonChange);return _n(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),i?y.jsx(eR,{...t,ref:o,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});QC.displayName=l0;var c0="SelectScrollDownButton",JC=S.forwardRef((t,e)=>{const n=co(c0,t.__scopeSelect),r=fx(c0,t.__scopeSelect),[i,s]=S.useState(!1),o=dt(e,r.onScrollButtonChange);return _n(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,f=Math.ceil(l.scrollTop)<c;s(f)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),i?y.jsx(eR,{...t,ref:o,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});JC.displayName=c0;var eR=S.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=t,s=co("SelectScrollButton",n),o=S.useRef(null),a=ep(n),l=S.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return S.useEffect(()=>()=>l(),[l]),_n(()=>{var f;const c=a().find(u=>u.ref.current===document.activeElement);(f=c==null?void 0:c.ref.current)==null||f.scrollIntoView({block:"nearest"})},[a]),y.jsx(We.div,{"aria-hidden":!0,...i,ref:e,style:{flexShrink:0,...i.style},onPointerDown:Ne(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Ne(i.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Ne(i.onPointerLeave,()=>{l()})})}),hW="SelectSeparator",tR=S.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return y.jsx(We.div,{"aria-hidden":!0,...r,ref:e})});tR.displayName=hW;var u0="SelectArrow",pW=S.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=tp(n),s=lo(u0,n),o=co(u0,n);return s.open&&o.position==="popper"?y.jsx(uT,{...i,...r,ref:e}):null});pW.displayName=u0;function nR(t){return t===""||t===void 0}var rR=S.forwardRef((t,e)=>{const{value:n,...r}=t,i=S.useRef(null),s=dt(e,i),o=cx(n);return S.useEffect(()=>{const a=i.current,l=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(l,"value").set;if(o!==n&&f){const u=new Event("change",{bubbles:!0});f.call(a,n),a.dispatchEvent(u)}},[o,n]),y.jsx(Mu,{asChild:!0,children:y.jsx("select",{...r,ref:s,defaultValue:n})})});rR.displayName="BubbleSelect";function iR(t){const e=Kt(t),n=S.useRef(""),r=S.useRef(0),i=S.useCallback(o=>{const a=n.current+o;e(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[e]),s=S.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return S.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}function sR(t,e,n){const i=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=mW(t,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.textValue.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function mW(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var gW=DC,oR=IC,vW=OC,yW=FC,xW=UC,aR=BC,_W=VC,lR=XC,cR=YC,wW=KC,SW=ZC,uR=QC,dR=JC,fR=tR;const MM=gW,bM=vW,d0=S.forwardRef(({className:t,children:e,...n},r)=>y.jsxs(oR,{ref:r,className:ht("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,y.jsx(yW,{asChild:!0,children:y.jsx(Ah,{className:"h-4 w-4 opacity-50"})})]}));d0.displayName=oR.displayName;const hR=S.forwardRef(({className:t,...e},n)=>y.jsx(uR,{ref:n,className:ht("flex cursor-default items-center justify-center py-1",t),...e,children:y.jsx(my,{className:"h-4 w-4"})}));hR.displayName=uR.displayName;const pR=S.forwardRef(({className:t,...e},n)=>y.jsx(dR,{ref:n,className:ht("flex cursor-default items-center justify-center py-1",t),...e,children:y.jsx(Ah,{className:"h-4 w-4"})}));pR.displayName=dR.displayName;const f0=S.forwardRef(({className:t,children:e,position:n="popper",...r},i)=>y.jsx(xW,{children:y.jsxs(aR,{ref:i,className:ht("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...r,children:[y.jsx(hR,{}),y.jsx(_W,{className:ht("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),y.jsx(pR,{})]})}));f0.displayName=aR.displayName;const MW=S.forwardRef(({className:t,...e},n)=>y.jsx(lR,{ref:n,className:ht("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...e}));MW.displayName=lR.displayName;const or=S.forwardRef(({className:t,children:e,...n},r)=>y.jsxs(cR,{ref:r,className:ht("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[y.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:y.jsx(SW,{children:y.jsx(AD,{className:"h-4 w-4"})})}),y.jsx(wW,{children:e})]}));or.displayName=cR.displayName;const bW=S.forwardRef(({className:t,...e},n)=>y.jsx(fR,{ref:n,className:ht("-mx-1 my-1 h-px bg-muted",t),...e}));bW.displayName=fR.displayName;const EW=Th("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Zr({className:t,variant:e,...n}){return y.jsx("div",{className:ht(EW({variant:e}),t),...n})}const TW=({sunlight:t,setSunlight:e,ambientLight:n,setAmbientLight:r,shadowQuality:i,setShadowQuality:s,environment:o,setEnvironment:a})=>y.jsxs("div",{className:"space-y-4 p-3",children:[y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-3",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(_y,{className:"h-4 w-4 text-amber-500"}),"Sunlight"]})}),y.jsx(Kn,{className:"space-y-3",children:y.jsxs("div",{children:[y.jsx(Oo,{className:"text-sm font-medium",children:"Intensity"}),y.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[y.jsx(i0,{value:[t.intensity],onValueChange:([l])=>e({...t,intensity:l}),max:3,step:.1,className:"flex-1"}),y.jsx(Zr,{variant:"outline",className:"min-w-[3rem] text-xs",children:t.intensity.toFixed(1)})]})]})})]}),y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-3",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(xy,{className:"h-4 w-4 text-blue-500"}),"Ambient Light"]})}),y.jsx(Kn,{className:"space-y-3",children:y.jsxs("div",{children:[y.jsx(Oo,{className:"text-sm font-medium",children:"Intensity"}),y.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[y.jsx(i0,{value:[n.intensity],onValueChange:([l])=>r({...n,intensity:l}),max:2,step:.1,className:"flex-1"}),y.jsx(Zr,{variant:"outline",className:"min-w-[3rem] text-xs",children:n.intensity.toFixed(1)})]})]})})]}),y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-3",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(XD,{className:"h-4 w-4 text-purple-500"}),"Shadows"]})}),y.jsx(Kn,{children:y.jsxs(MM,{value:i,onValueChange:s,children:[y.jsx(d0,{children:y.jsx(bM,{})}),y.jsxs(f0,{children:[y.jsx(or,{value:"low",children:"Low Quality"}),y.jsx(or,{value:"medium",children:"Medium Quality"}),y.jsx(or,{value:"high",children:"High Quality"})]})]})})]}),y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-3",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(kD,{className:"h-4 w-4 text-green-500"}),"Environment"]})}),y.jsx(Kn,{children:y.jsxs(MM,{value:o.preset,onValueChange:l=>a({...o,preset:l}),children:[y.jsx(d0,{children:y.jsx(bM,{})}),y.jsxs(f0,{children:[y.jsx(or,{value:"sunset",children:"🌅 Sunset"}),y.jsx(or,{value:"dawn",children:"🌄 Dawn"}),y.jsx(or,{value:"night",children:"🌃 Night"}),y.jsx(or,{value:"forest",children:"🌲 Forest"}),y.jsx(or,{value:"apartment",children:"🏠 Apartment"}),y.jsx(or,{value:"studio",children:"🎬 Studio"}),y.jsx(or,{value:"city",children:"🏙️ City"}),y.jsx(or,{value:"park",children:"🌳 Park"}),y.jsx(or,{value:"lobby",children:"🏢 Lobby"})]})]})})]})]});function AW(t,e=[]){let n=[];function r(s,o){const a=S.createContext(o),l=n.length;n=[...n,o];function c(u){const{scope:d,children:h,...m}=u,v=(d==null?void 0:d[t][l])||a,g=S.useMemo(()=>m,Object.values(m));return y.jsx(v.Provider,{value:g,children:h})}function f(u,d){const h=(d==null?void 0:d[t][l])||a,m=S.useContext(h);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${u}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,f]}const i=()=>{const s=n.map(o=>S.createContext(o));return function(a){const l=(a==null?void 0:a[t])||s;return S.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[r,CW(i,...e)]}function CW(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const u=l(s)[`__scope${c}`];return{...a,...u}},{});return S.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var zm="rovingFocusGroup.onEntryFocus",RW={bubbles:!1,cancelable:!0},np="RovingFocusGroup",[h0,mR,PW]=Sh(np),[NW,gR]=AW(np,[PW]),[DW,LW]=NW(np),vR=S.forwardRef((t,e)=>y.jsx(h0.Provider,{scope:t.__scopeRovingFocusGroup,children:y.jsx(h0.Slot,{scope:t.__scopeRovingFocusGroup,children:y.jsx(IW,{...t,ref:e})})}));vR.displayName=np;var IW=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:f=!1,...u}=t,d=S.useRef(null),h=dt(e,d),m=Ru(s),[v=null,g]=Ys({prop:o,defaultProp:a,onChange:l}),[p,x]=S.useState(!1),_=Kt(c),w=mR(n),M=S.useRef(!1),[T,b]=S.useState(0);return S.useEffect(()=>{const C=d.current;if(C)return C.addEventListener(zm,_),()=>C.removeEventListener(zm,_)},[_]),y.jsx(DW,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:v,onItemFocus:S.useCallback(C=>g(C),[g]),onItemShiftTab:S.useCallback(()=>x(!0),[]),onFocusableItemAdd:S.useCallback(()=>b(C=>C+1),[]),onFocusableItemRemove:S.useCallback(()=>b(C=>C-1),[]),children:y.jsx(We.div,{tabIndex:p||T===0?-1:0,"data-orientation":r,...u,ref:h,style:{outline:"none",...t.style},onMouseDown:Ne(t.onMouseDown,()=>{M.current=!0}),onFocus:Ne(t.onFocus,C=>{const A=!M.current;if(C.target===C.currentTarget&&A&&!p){const E=new CustomEvent(zm,RW);if(C.currentTarget.dispatchEvent(E),!E.defaultPrevented){const N=w().filter(O=>O.focusable),F=N.find(O=>O.active),I=N.find(O=>O.id===v),z=[F,I,...N].filter(Boolean).map(O=>O.ref.current);_R(z,f)}}M.current=!1}),onBlur:Ne(t.onBlur,()=>x(!1))})})}),yR="RovingFocusGroupItem",xR=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,...o}=t,a=kl(),l=s||a,c=LW(yR,n),f=c.currentTabStopId===l,u=mR(n),{onFocusableItemAdd:d,onFocusableItemRemove:h}=c;return S.useEffect(()=>{if(r)return d(),()=>h()},[r,d,h]),y.jsx(h0.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:y.jsx(We.span,{tabIndex:f?0:-1,"data-orientation":c.orientation,...o,ref:e,onMouseDown:Ne(t.onMouseDown,m=>{r?c.onItemFocus(l):m.preventDefault()}),onFocus:Ne(t.onFocus,()=>c.onItemFocus(l)),onKeyDown:Ne(t.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){c.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const v=FW(m,c.orientation,c.dir);if(v!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let p=u().filter(x=>x.focusable).map(x=>x.ref.current);if(v==="last")p.reverse();else if(v==="prev"||v==="next"){v==="prev"&&p.reverse();const x=p.indexOf(m.currentTarget);p=c.loop?UW(p,x+1):p.slice(x+1)}setTimeout(()=>_R(p))}})})})});xR.displayName=yR;var kW={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function OW(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function FW(t,e,n){const r=OW(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return kW[r]}function _R(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function UW(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var BW=vR,zW=xR,hx="Tabs",[HW,A7]=ea(hx,[gR]),wR=gR(),[jW,px]=HW(hx),SR=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:l="automatic",...c}=t,f=Ru(a),[u,d]=Ys({prop:r,onChange:i,defaultProp:s});return y.jsx(jW,{scope:n,baseId:kl(),value:u,onValueChange:d,orientation:o,dir:f,activationMode:l,children:y.jsx(We.div,{dir:f,"data-orientation":o,...c,ref:e})})});SR.displayName=hx;var MR="TabsList",bR=S.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,s=px(MR,n),o=wR(n);return y.jsx(BW,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:r,children:y.jsx(We.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:e})})});bR.displayName=MR;var ER="TabsTrigger",TR=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=t,o=px(ER,n),a=wR(n),l=RR(o.baseId,r),c=PR(o.baseId,r),f=r===o.value;return y.jsx(zW,{asChild:!0,...a,focusable:!i,active:f,children:y.jsx(We.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":c,"data-state":f?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l,...s,ref:e,onMouseDown:Ne(t.onMouseDown,u=>{!i&&u.button===0&&u.ctrlKey===!1?o.onValueChange(r):u.preventDefault()}),onKeyDown:Ne(t.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&o.onValueChange(r)}),onFocus:Ne(t.onFocus,()=>{const u=o.activationMode!=="manual";!f&&!i&&u&&o.onValueChange(r)})})})});TR.displayName=ER;var AR="TabsContent",CR=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=t,a=px(AR,n),l=RR(a.baseId,r),c=PR(a.baseId,r),f=r===a.value,u=S.useRef(f);return S.useEffect(()=>{const d=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(d)},[]),y.jsx(oo,{present:i||f,children:({present:d})=>y.jsx(We.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!d,id:c,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:u.current?"0s":void 0},children:d&&s})})});CR.displayName=AR;function RR(t,e){return`${t}-trigger-${e}`}function PR(t,e){return`${t}-content-${e}`}var VW=SR,NR=bR,DR=TR,LR=CR;const GW=VW,IR=S.forwardRef(({className:t,...e},n)=>y.jsx(NR,{ref:n,className:ht("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));IR.displayName=NR.displayName;const p0=S.forwardRef(({className:t,...e},n)=>y.jsx(DR,{ref:n,className:ht("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...e}));p0.displayName=DR.displayName;const m0=S.forwardRef(({className:t,...e},n)=>y.jsx(LR,{ref:n,className:ht("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));m0.displayName=LR.displayName;const WW=()=>y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"p-3 border-b border-border",children:[y.jsxs("h3",{className:"text-base font-semibold flex items-center gap-2",children:[y.jsx(zg,{className:"h-4 w-4 text-primary"}),"User Guide"]}),y.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Essential controls and interface guide for the 3D viewer"})]}),y.jsx("div",{className:"flex-1 overflow-y-auto",children:y.jsxs(GW,{defaultValue:"controls",className:"h-full",children:[y.jsxs(IR,{className:"grid w-full grid-cols-2 m-3 mb-0",children:[y.jsxs(p0,{value:"controls",className:"flex items-center gap-1 text-xs",children:[y.jsx(V_,{className:"h-3 w-3"}),"Controls"]}),y.jsxs(p0,{value:"panels",className:"flex items-center gap-1 text-xs",children:[y.jsx(HD,{className:"h-3 w-3"}),"Interface"]})]}),y.jsxs(m0,{value:"controls",className:"p-3 space-y-4",children:[y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-2",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(V_,{className:"h-4 w-4 text-primary"}),"Navigation Controls"]})}),y.jsx(Kn,{className:"space-y-2",children:y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(R1,{className:"h-3 w-3 text-blue-500"}),y.jsx("span",{children:"Rotate"})]}),y.jsx("div",{className:"text-muted-foreground",children:"Left drag / Single finger"})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Hf,{className:"h-3 w-3 text-green-500"}),y.jsx("span",{children:"Zoom"})]}),y.jsx("div",{className:"text-muted-foreground",children:"Wheel / Pinch"})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(zD,{className:"h-3 w-3 text-purple-500"}),y.jsx("span",{children:"Pan"})]}),y.jsx("div",{className:"text-muted-foreground",children:"Right drag / Two finger"})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(rf,{className:"h-3 w-3 text-orange-500"}),y.jsx("span",{children:"Select"})]}),y.jsx("div",{className:"text-muted-foreground",children:"Left click / Tap"})]})]})})]}),y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-2",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(FD,{className:"h-4 w-4 text-primary"}),"Keyboard Shortcuts"]})}),y.jsx(Kn,{children:y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsxs("div",{className:"flex justify-between",children:[y.jsx("span",{children:"Zoom All"}),y.jsx(Zr,{variant:"outline",className:"text-xs h-5",children:"A"})]}),y.jsxs("div",{className:"flex justify-between",children:[y.jsx("span",{children:"Focus Selected"}),y.jsx(Zr,{variant:"outline",className:"text-xs h-5",children:"F"})]}),y.jsxs("div",{className:"flex justify-between",children:[y.jsx("span",{children:"Reset View"}),y.jsx(Zr,{variant:"outline",className:"text-xs h-5",children:"R"})]}),y.jsxs("div",{className:"flex justify-between",children:[y.jsx("span",{children:"Toggle Panel"}),y.jsx(Zr,{variant:"outline",className:"text-xs h-5",children:"Tab"})]})]})})]}),y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-2",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(rf,{className:"h-4 w-4 text-primary"}),"Aid Tools (Top Bar)"]})}),y.jsx(Kn,{children:y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(rf,{className:"h-3 w-3 text-blue-500"}),y.jsx("span",{children:"Select Tool - Click objects to select and inspect"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Rh,{className:"h-3 w-3 text-green-500"}),y.jsx("span",{children:"Point Tool - Add measurement reference points"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(zf,{className:"h-3 w-3 text-purple-500"}),y.jsx("span",{children:"Measure Tool - Create distance measurements"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(b1,{className:"h-3 w-3 text-amber-500"}),y.jsx("span",{children:"Left View - Switch to left side view"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(E1,{className:"h-3 w-3 text-amber-500"}),y.jsx("span",{children:"Right View - Switch to right side view"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(T1,{className:"h-3 w-3 text-orange-500"}),y.jsx("span",{children:"Camera & Notifications - Toggle orthographic view"})]})]})})]}),y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-2",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(ED,{className:"h-4 w-4 text-primary"}),"Status Bar (Bottom)"]})}),y.jsx(Kn,{children:y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(vy,{className:"h-3 w-3 text-blue-500"}),y.jsx("span",{children:"Grid Toggle - Show/hide reference grid"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(BD,{className:"h-3 w-3 text-green-500"}),y.jsx("span",{children:"Ground Plane - Show/hide ground reference"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Hf,{className:"h-3 w-3 text-purple-500"}),y.jsx("span",{children:"Zoom Controls - Zoom in/out and reset view"})]})]})})]})]}),y.jsxs(m0,{value:"panels",className:"p-3 space-y-4",children:[y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-2",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(yy,{className:"h-4 w-4 text-primary"}),"Left Control Panels"]})}),y.jsx(Kn,{children:y.jsxs("div",{className:"text-xs space-y-2",children:[y.jsxs("div",{className:"p-2 bg-accent/50 rounded",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[y.jsx(Pr,{className:"h-3 w-3 text-blue-500"}),y.jsx("span",{className:"font-medium",children:"Scene Objects"})]}),y.jsx("div",{className:"text-muted-foreground",children:"Import models, manage scene hierarchy, add primitives"})]}),y.jsxs("div",{className:"p-2 bg-accent/50 rounded",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[y.jsx(Xa,{className:"h-3 w-3 text-green-500"}),y.jsx("span",{className:"font-medium",children:"Object Properties"})]}),y.jsx("div",{className:"text-muted-foreground",children:"Edit materials, dimensions, transformations"})]}),y.jsxs("div",{className:"p-2 bg-accent/50 rounded",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[y.jsx(xy,{className:"h-3 w-3 text-yellow-500"}),y.jsx("span",{className:"font-medium",children:"Lighting & Environment"})]}),y.jsx("div",{className:"text-muted-foreground",children:"Control sunlight, ambient lighting, environment"})]}),y.jsxs("div",{className:"p-2 bg-accent/50 rounded",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[y.jsx(C1,{className:"h-3 w-3 text-purple-500"}),y.jsx("span",{className:"font-medium",children:"Settings"})]}),y.jsx("div",{className:"text-muted-foreground",children:"Theme, measurement units, app preferences"})]})]})})]}),y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-2",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(zf,{className:"h-4 w-4 text-primary"}),"Measurement Panel"]})}),y.jsx(Kn,{children:y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsx("div",{children:"• View all active measurements with precise distances"}),y.jsx("div",{children:"• Delete individual measurements or clear all"}),y.jsx("div",{children:"• Export measurement data for external use"}),y.jsx("div",{children:"• Automatic unit conversion based on settings"})]})})]}),y.jsxs(Xn,{children:[y.jsx($n,{className:"pb-2",children:y.jsxs(Yn,{className:"text-sm flex items-center gap-2",children:[y.jsx(Pr,{className:"h-4 w-4 text-primary"}),"Model Import"]})}),y.jsx(Kn,{children:y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsx("div",{children:"• Supported formats: GLTF, GLB, FBX, OBJ"}),y.jsx("div",{children:"• Drag & drop files or use file browser"}),y.jsx("div",{children:"• Multiple models can be loaded simultaneously"}),y.jsx("div",{children:"• Models are automatically centered and scaled"})]})})]})]})]})})]}),XW=({activeTab:t,isOpen:e,onClose:n,controlsPanelProps:r})=>{if(!e)return null;const i=o=>{switch(o){case"scene":return"Scene Objects";case"properties":return"Object Properties";case"lighting":return"Lighting & Environment";case"environment":return"View Settings";case"help":return"User Guide";default:return"Control Panel"}},s=()=>{switch(t){case"scene":return y.jsx(P8,{loadedModels:r.loadedModels,currentModel:r.currentModel,isUploading:r.isUploading,uploadError:r.uploadError,onFileUpload:r.onFileUpload,scene:r.scene});case"properties":return y.jsx(F8,{});case"lighting":return y.jsx(TW,{sunlight:r.sunlight,setSunlight:r.setSunlight,ambientLight:r.ambientLight,setAmbientLight:r.setAmbientLight,shadowQuality:r.shadowQuality,setShadowQuality:r.setShadowQuality,environment:r.environment,setEnvironment:r.setEnvironment});case"environment":return y.jsx("div",{className:"p-4 text-center text-muted-foreground",children:"Environment settings have been moved to other panels"});case"help":return y.jsx(WW,{});default:return null}};return y.jsxs("div",{className:"fixed left-20 top-20 bg-card/95 backdrop-blur-sm border border-border rounded-lg shadow-2xl z-40",style:{width:340,height:520,maxHeight:"85vh"},children:[y.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border",children:[y.jsx("h3",{className:"text-sm font-medium text-card-foreground",children:i(t)}),y.jsx(ot,{variant:"ghost",size:"sm",onClick:n,className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground hover:bg-accent",children:y.jsx(bu,{className:"h-3 w-3"})})]}),y.jsx("div",{className:"overflow-y-auto",style:{height:"calc(100% - 60px)"},children:s()})]})};function $W(t,e){return S.useReducer((n,r)=>e[n][r]??n,t)}var mx="ScrollArea",[kR,C7]=ea(mx),[YW,Ir]=kR(mx),OR=S.forwardRef((t,e)=>{const{__scopeScrollArea:n,type:r="hover",dir:i,scrollHideDelay:s=600,...o}=t,[a,l]=S.useState(null),[c,f]=S.useState(null),[u,d]=S.useState(null),[h,m]=S.useState(null),[v,g]=S.useState(null),[p,x]=S.useState(0),[_,w]=S.useState(0),[M,T]=S.useState(!1),[b,C]=S.useState(!1),A=dt(e,N=>l(N)),E=Ru(i);return y.jsx(YW,{scope:n,type:r,dir:E,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:f,content:u,onContentChange:d,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:M,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:b,onScrollbarYEnabledChange:C,onCornerWidthChange:x,onCornerHeightChange:w,children:y.jsx(We.div,{dir:E,...o,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":p+"px","--radix-scroll-area-corner-height":_+"px",...t.style}})})});OR.displayName=mx;var FR="ScrollAreaViewport",UR=S.forwardRef((t,e)=>{const{__scopeScrollArea:n,children:r,asChild:i,nonce:s,...o}=t,a=Ir(FR,n),l=S.useRef(null),c=dt(e,l,a.onViewportChange);return y.jsxs(y.Fragment,{children:[y.jsx("style",{dangerouslySetInnerHTML:{__html:`
[data-radix-scroll-area-viewport] {
scrollbar-width: none;
-ms-overflow-style: none;
-webkit-overflow-scrolling: touch;
}
[data-radix-scroll-area-viewport]::-webkit-scrollbar {
display: none;
}
:where([data-radix-scroll-area-viewport]) {
display: flex;
flex-direction: column;
align-items: stretch;
}
:where([data-radix-scroll-area-content]) {
flex-grow: 1;
}
`},nonce:s}),y.jsx(We.div,{"data-radix-scroll-area-viewport":"",...o,asChild:i,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:i7({asChild:i,children:r},f=>y.jsx("div",{"data-radix-scroll-area-content":"",ref:a.onContentChange,style:{minWidth:a.scrollbarXEnabled?"fit-content":void 0},children:f}))})]})});UR.displayName=FR;var Ti="ScrollAreaScrollbar",gx=S.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=Ir(Ti,t.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:o}=i,a=t.orientation==="horizontal";return S.useEffect(()=>(a?s(!0):o(!0),()=>{a?s(!1):o(!1)}),[a,s,o]),i.type==="hover"?y.jsx(KW,{...r,ref:e,forceMount:n}):i.type==="scroll"?y.jsx(qW,{...r,ref:e,forceMount:n}):i.type==="auto"?y.jsx(BR,{...r,ref:e,forceMount:n}):i.type==="always"?y.jsx(vx,{...r,ref:e}):null});gx.displayName=Ti;var KW=S.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=Ir(Ti,t.__scopeScrollArea),[s,o]=S.useState(!1);return S.useEffect(()=>{const a=i.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),o(!0)},f=()=>{l=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",f),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",f)}}},[i.scrollArea,i.scrollHideDelay]),y.jsx(oo,{present:n||s,children:y.jsx(BR,{"data-state":s?"visible":"hidden",...r,ref:e})})}),qW=S.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=Ir(Ti,t.__scopeScrollArea),s=t.orientation==="horizontal",o=ip(()=>l("SCROLL_END"),100),[a,l]=$W("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return S.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,i.scrollHideDelay,l]),S.useEffect(()=>{const c=i.viewport,f=s?"scrollLeft":"scrollTop";if(c){let u=c[f];const d=()=>{const h=c[f];u!==h&&(l("SCROLL"),o()),u=h};return c.addEventListener("scroll",d),()=>c.removeEventListener("scroll",d)}},[i.viewport,s,l,o]),y.jsx(oo,{present:n||a!=="hidden",children:y.jsx(vx,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:Ne(t.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:Ne(t.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),BR=S.forwardRef((t,e)=>{const n=Ir(Ti,t.__scopeScrollArea),{forceMount:r,...i}=t,[s,o]=S.useState(!1),a=t.orientation==="horizontal",l=ip(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,f=n.viewport.offsetHeight<n.viewport.scrollHeight;o(a?c:f)}},10);return Pl(n.viewport,l),Pl(n.content,l),y.jsx(oo,{present:r||s,children:y.jsx(vx,{"data-state":s?"visible":"hidden",...i,ref:e})})}),vx=S.forwardRef((t,e)=>{const{orientation:n="vertical",...r}=t,i=Ir(Ti,t.__scopeScrollArea),s=S.useRef(null),o=S.useRef(0),[a,l]=S.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=GR(a.viewport,a.content),f={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:d=>s.current=d,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:d=>o.current=d};function u(d,h){return n7(d,o.current,a,h)}return n==="horizontal"?y.jsx(ZW,{...f,ref:e,onThumbPositionChange:()=>{if(i.viewport&&s.current){const d=i.viewport.scrollLeft,h=EM(d,a,i.dir);s.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:d=>{i.viewport&&(i.viewport.scrollLeft=d)},onDragScroll:d=>{i.viewport&&(i.viewport.scrollLeft=u(d,i.dir))}}):n==="vertical"?y.jsx(QW,{...f,ref:e,onThumbPositionChange:()=>{if(i.viewport&&s.current){const d=i.viewport.scrollTop,h=EM(d,a);s.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:d=>{i.viewport&&(i.viewport.scrollTop=d)},onDragScroll:d=>{i.viewport&&(i.viewport.scrollTop=u(d))}}):null}),ZW=S.forwardRef((t,e)=>{const{sizes:n,onSizesChange:r,...i}=t,s=Ir(Ti,t.__scopeScrollArea),[o,a]=S.useState(),l=S.useRef(null),c=dt(e,l,s.onScrollbarXChange);return S.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),y.jsx(HR,{"data-orientation":"horizontal",...i,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":rp(n)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.x),onDragScroll:f=>t.onDragScroll(f.x),onWheelScroll:(f,u)=>{if(s.viewport){const d=s.viewport.scrollLeft+f.deltaX;t.onWheelScroll(d),XR(d,u)&&f.preventDefault()}},onResize:()=>{l.current&&s.viewport&&o&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:sh(o.paddingLeft),paddingEnd:sh(o.paddingRight)}})}})}),QW=S.forwardRef((t,e)=>{const{sizes:n,onSizesChange:r,...i}=t,s=Ir(Ti,t.__scopeScrollArea),[o,a]=S.useState(),l=S.useRef(null),c=dt(e,l,s.onScrollbarYChange);return S.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),y.jsx(HR,{"data-orientation":"vertical",...i,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":rp(n)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.y),onDragScroll:f=>t.onDragScroll(f.y),onWheelScroll:(f,u)=>{if(s.viewport){const d=s.viewport.scrollTop+f.deltaY;t.onWheelScroll(d),XR(d,u)&&f.preventDefault()}},onResize:()=>{l.current&&s.viewport&&o&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:sh(o.paddingTop),paddingEnd:sh(o.paddingBottom)}})}})}),[JW,zR]=kR(Ti),HR=S.forwardRef((t,e)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:s,onThumbPointerUp:o,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:f,onResize:u,...d}=t,h=Ir(Ti,n),[m,v]=S.useState(null),g=dt(e,A=>v(A)),p=S.useRef(null),x=S.useRef(""),_=h.viewport,w=r.content-r.viewport,M=Kt(f),T=Kt(l),b=ip(u,10);function C(A){if(p.current){const E=A.clientX-p.current.left,N=A.clientY-p.current.top;c({x:E,y:N})}}return S.useEffect(()=>{const A=E=>{const N=E.target;(m==null?void 0:m.contains(N))&&M(E,w)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[_,m,w,M]),S.useEffect(T,[r,T]),Pl(m,b),Pl(h.content,b),y.jsx(JW,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Kt(s),onThumbPointerUp:Kt(o),onThumbPositionChange:T,onThumbPointerDown:Kt(a),children:y.jsx(We.div,{...d,ref:g,style:{position:"absolute",...d.style},onPointerDown:Ne(t.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),p.current=m.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),C(A))}),onPointerMove:Ne(t.onPointerMove,C),onPointerUp:Ne(t.onPointerUp,A=>{const E=A.target;E.hasPointerCapture(A.pointerId)&&E.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=x.current,h.viewport&&(h.viewport.style.scrollBehavior=""),p.current=null})})})}),ih="ScrollAreaThumb",jR=S.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=zR(ih,t.__scopeScrollArea);return y.jsx(oo,{present:n||i.hasThumb,children:y.jsx(e7,{ref:e,...r})})}),e7=S.forwardRef((t,e)=>{const{__scopeScrollArea:n,style:r,...i}=t,s=Ir(ih,n),o=zR(ih,n),{onThumbPositionChange:a}=o,l=dt(e,u=>o.onThumbChange(u)),c=S.useRef(),f=ip(()=>{c.current&&(c.current(),c.current=void 0)},100);return S.useEffect(()=>{const u=s.viewport;if(u){const d=()=>{if(f(),!c.current){const h=r7(u,a);c.current=h,a()}};return a(),u.addEventListener("scroll",d),()=>u.removeEventListener("scroll",d)}},[s.viewport,f,a]),y.jsx(We.div,{"data-state":o.hasThumb?"visible":"hidden",...i,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Ne(t.onPointerDownCapture,u=>{const h=u.target.getBoundingClientRect(),m=u.clientX-h.left,v=u.clientY-h.top;o.onThumbPointerDown({x:m,y:v})}),onPointerUp:Ne(t.onPointerUp,o.onThumbPointerUp)})});jR.displayName=ih;var yx="ScrollAreaCorner",VR=S.forwardRef((t,e)=>{const n=Ir(yx,t.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?y.jsx(t7,{...t,ref:e}):null});VR.displayName=yx;var t7=S.forwardRef((t,e)=>{const{__scopeScrollArea:n,...r}=t,i=Ir(yx,n),[s,o]=S.useState(0),[a,l]=S.useState(0),c=!!(s&&a);return Pl(i.scrollbarX,()=>{var u;const f=((u=i.scrollbarX)==null?void 0:u.offsetHeight)||0;i.onCornerHeightChange(f),l(f)}),Pl(i.scrollbarY,()=>{var u;const f=((u=i.scrollbarY)==null?void 0:u.offsetWidth)||0;i.onCornerWidthChange(f),o(f)}),c?y.jsx(We.div,{...r,ref:e,style:{width:s,height:a,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function sh(t){return t?parseInt(t,10):0}function GR(t,e){const n=t/e;return isNaN(n)?0:n}function rp(t){const e=GR(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,r=(t.scrollbar.size-n)*e;return Math.max(r,18)}function n7(t,e,n,r="ltr"){const i=rp(n),s=i/2,o=e||s,a=i-o,l=n.scrollbar.paddingStart+o,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,f=n.content-n.viewport,u=r==="ltr"?[0,f]:[f*-1,0];return WR([l,c],u)(t)}function EM(t,e,n="ltr"){const r=rp(e),i=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=e.scrollbar.size-i,o=e.content-e.viewport,a=s-r,l=n==="ltr"?[0,o]:[o*-1,0],c=mu(t,l);return WR([0,o],[0,a])(c)}function WR(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function XR(t,e){return t>0&&t<e}var r7=(t,e=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},r=0;return function i(){const s={left:t.scrollLeft,top:t.scrollTop},o=n.left!==s.left,a=n.top!==s.top;(o||a)&&e(),n=s,r=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(r)};function ip(t,e){const n=Kt(t),r=S.useRef(0);return S.useEffect(()=>()=>window.clearTimeout(r.current),[]),S.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,e)},[n,e])}function Pl(t,e){const n=Kt(e);_n(()=>{let r=0;if(t){const i=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return i.observe(t),()=>{window.cancelAnimationFrame(r),i.unobserve(t)}}},[t,n])}function i7(t,e){const{asChild:n,children:r}=t;if(!n)return typeof e=="function"?e(r):e;const i=S.Children.only(r);return S.cloneElement(i,{children:typeof e=="function"?e(i.props.children):e})}var $R=OR,s7=UR,o7=VR;const YR=S.forwardRef(({className:t,children:e,...n},r)=>y.jsxs($R,{ref:r,className:ht("relative overflow-hidden",t),...n,children:[y.jsx(s7,{className:"h-full w-full rounded-[inherit]",children:e}),y.jsx(KR,{}),y.jsx(o7,{})]}));YR.displayName=$R.displayName;const KR=S.forwardRef(({className:t,orientation:e="vertical",...n},r)=>y.jsx(gx,{ref:r,orientation:e,className:ht("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...n,children:y.jsx(jR,{className:"relative flex-1 rounded-full bg-border"})}));KR.displayName=gx.displayName;const a7=({measurements:t,onClearAll:e,onRemoveMeasurement:n,visible:r,onClose:i})=>r?y.jsxs("div",{className:"fixed left-4 bottom-20 bg-card/95 backdrop-blur-sm border border-border rounded-lg shadow-2xl z-40 w-80 max-h-96",children:[y.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("h3",{className:"text-sm font-medium text-card-foreground",children:"Measurements"}),y.jsx(Zr,{variant:"secondary",className:"text-xs",children:t.length})]}),y.jsxs("div",{className:"flex items-center gap-1",children:[t.length>0&&y.jsxs(y.Fragment,{children:[y.jsx(ot,{variant:"ghost",size:"sm",onClick:e,className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive",children:"Clear All"}),y.jsx(Fo,{orientation:"vertical",className:"h-4"})]}),y.jsx(ot,{variant:"ghost",size:"sm",onClick:i,className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground hover:bg-accent",children:y.jsx(bu,{className:"h-3 w-3"})})]})]}),y.jsx("div",{className:"p-3",children:t.length===0?y.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[y.jsx("div",{className:"text-sm",children:"No measurements created"}),y.jsx("div",{className:"text-xs mt-1",children:"Use the measure tool to add measurements"})]}):y.jsx(YR,{className:"max-h-64",children:y.jsx("div",{className:"space-y-2",children:t.map((s,o)=>y.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border border-border hover:bg-muted/70 transition-colors",children:[y.jsxs("div",{className:"flex items-center justify-between mb-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsxs(Zr,{variant:"outline",className:"text-xs",children:["#",o+1]}),y.jsx("span",{className:"text-sm font-medium",children:s.label||`Measurement ${o+1}`})]}),y.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>n(s.id),className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",children:y.jsx(P1,{className:"h-3 w-3"})})]}),y.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[y.jsxs("div",{children:["Distance: ",y.jsxs("span",{className:"text-foreground font-mono",children:[s.distance.toFixed(3),"m"]})]}),y.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[y.jsxs("div",{children:[y.jsx("div",{className:"font-medium",children:"Start Point:"}),y.jsxs("div",{className:"font-mono text-xs",children:["X: ",s.startPoint.x.toFixed(2),y.jsx("br",{}),"Y: ",s.startPoint.y.toFixed(2),y.jsx("br",{}),"Z: ",s.startPoint.z.toFixed(2)]})]}),y.jsxs("div",{children:[y.jsx("div",{className:"font-medium",children:"End Point:"}),y.jsxs("div",{className:"font-mono text-xs",children:["X: ",s.endPoint.x.toFixed(2),y.jsx("br",{}),"Y: ",s.endPoint.y.toFixed(2),y.jsx("br",{}),"Z: ",s.endPoint.z.toFixed(2)]})]})]})]})]},s.id))})})}),t.length>0&&y.jsx("div",{className:"border-t border-border p-3",children:y.jsxs(ot,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:()=>{console.log("Export measurements:",t)},children:[y.jsx(ND,{className:"h-3 w-3 mr-2"}),"Export Measurements"]})})]}):null,Hm=[{type:"shaded",label:"Shaded",icon:y.jsx(Pr,{className:"h-3 w-3"})},{type:"wireframe",label:"Wireframe",icon:y.jsx(vy,{className:"h-3 w-3"})},{type:"hidden",label:"Hidden",icon:y.jsx(Ch,{className:"h-3 w-3"})},{type:"shaded-with-edges",label:"Shaded with Edges",icon:y.jsx(yy,{className:"h-3 w-3"})}],l7=({currentShadeType:t,onShadeTypeChange:e})=>{const[n,r]=S.useState(!1),i=S.useRef(null),s=Hm.find(l=>l.type===t)||Hm[0],o=l=>{e(l),r(!1)},a=()=>{r(!n)};return S.useEffect(()=>{const l=c=>{i.current&&!i.current.contains(c.target)&&r(!1)};if(n)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[n]),y.jsx(Ul,{children:y.jsxs("div",{ref:i,className:"relative",children:[y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsxs(ot,{variant:"ghost",size:"sm",className:"h-6 px-2 text-slate-700 dark:text-slate-300 hover:text-white hover:bg-slate-700/50 flex items-center gap-1",onClick:a,children:[s.icon,y.jsx(my,{className:`h-3 w-3 transition-transform ${n?"rotate-180":""}`})]})}),y.jsx(mn,{children:y.jsxs("p",{children:[s.label," (Click for options)"]})})]}),n&&y.jsx("div",{className:"absolute bottom-full left-0 mb-2 bg-slate-800/95 backdrop-blur-sm border border-slate-700/50 rounded-md p-1 z-50 shadow-lg",children:y.jsx("div",{className:"flex flex-col gap-1",children:Hm.map(l=>y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:t===l.type?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>o(l.type),children:l.icon})}),y.jsx(mn,{children:y.jsx("p",{children:l.label})})]},l.type))})})]})})},c7=({objectCount:t=1,gridEnabled:e=!0,gridSpacing:n="1m",units:r="m",cursorPosition:i={x:0,y:0},zoomLevel:s=100,shadeType:o,onShadeTypeChange:a,onGridToggle:l=()=>{},groundPlaneEnabled:c=!1,onGroundPlaneToggle:f=()=>{}})=>{const{selectedObject:u}=Bl();return y.jsx(Ul,{children:y.jsx("div",{className:"fixed bottom-4 left-4 right-4 bg-card/95 backdrop-blur-sm border border-border rounded-lg px-4 py-3 z-30 shadow-lg",children:y.jsxs("div",{className:"flex items-center justify-between text-xs",children:[y.jsxs("div",{className:"flex items-center gap-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-muted-foreground",children:"Objects:"}),y.jsx(Zr,{variant:"secondary",className:"text-xs font-medium",children:t}),u&&y.jsxs(y.Fragment,{children:[y.jsx(Fo,{orientation:"vertical",className:"h-4"}),y.jsx("span",{className:"text-muted-foreground",children:"Selected:"}),y.jsx(Zr,{variant:"outline",className:"text-xs",children:u.name||"Object"})]})]}),y.jsx(Fo,{orientation:"vertical",className:"h-4"}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:l,className:`h-6 w-6 p-0 hover:bg-accent ${e?"bg-accent":""}`,children:y.jsx(vy,{className:`h-3 w-3 ${e?"text-primary":"text-muted-foreground"}`})})}),y.jsx(mn,{children:y.jsx("p",{children:"Toggle Grid (G)"})})]}),y.jsxs(Cn,{children:[y.jsx(Rn,{asChild:!0,children:y.jsx(ot,{variant:"ghost",size:"sm",onClick:f,className:`h-6 w-6 p-0 hover:bg-accent ${c?"bg-accent":""}`,children:y.jsx(yy,{className:`h-3 w-3 ${c?"text-primary":"text-muted-foreground"}`})})}),y.jsx(mn,{children:y.jsx("p",{children:"Toggle Ground Plane"})})]})]}),y.jsx(Fo,{orientation:"vertical",className:"h-4"}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-muted-foreground",children:"Units:"}),y.jsx(Zr,{variant:"outline",className:"text-xs font-medium",children:r})]})]}),y.jsx("div",{className:"flex items-center gap-4",children:y.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{children:"X:"}),y.jsx("span",{className:"text-foreground font-mono text-xs min-w-[3rem] text-right",children:i.x.toFixed(2)})]}),y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{children:"Y:"}),y.jsx("span",{className:"text-foreground font-mono text-xs min-w-[3rem] text-right",children:i.y.toFixed(2)})]})]})}),y.jsx("div",{className:"flex items-center gap-3",children:y.jsx(l7,{currentShadeType:o,onShadeTypeChange:a})})]})})})},u7=({activeTool:t,onToolSelect:e,activeControlTab:n,showControlPanel:r,onTabChange:i,onCloseControlPanel:s,controlsPanelProps:o,showMeasurePanel:a,onCloseMeasurePanel:l,measurements:c,onClearAllMeasurements:f,onRemoveMeasurement:u,onZoomAll:d,onZoomToSelected:h,onZoomIn:m,onZoomOut:v,onResetView:g,onViewFront:p,onViewBack:x,onViewLeft:_,onViewRight:w,onViewIsometric:M,shadeType:T,onShadeTypeChange:b,modelCount:C,onGridToggle:A,gridEnabled:E=!1,groundPlaneEnabled:N=!1,onGroundPlaneToggle:F,isOrthographic:I=!1,onCameraToggle:U})=>y.jsxs(y.Fragment,{children:[y.jsx(c8,{onToolSelect:e,activeTool:t,onViewLeft:_,onViewRight:w,onViewIsometric:M,isOrthographic:I,onCameraToggle:U,onZoomAll:d,onZoomToSelected:h,onZoomIn:m,onZoomOut:v,onResetView:g,selectedObject:null,zoomLevel:100}),y.jsx(u8,{activeTab:n,onTabChange:i,isPanelOpen:r}),y.jsx(XW,{activeTab:n,isOpen:r,onClose:s,controlsPanelProps:o}),y.jsx(a7,{measurements:c,onClearAll:f,onRemoveMeasurement:u,visible:a,onClose:l}),y.jsx(c7,{objectCount:C,gridEnabled:E,gridSpacing:"1m",units:"m",cursorPosition:{x:0,y:0},zoomLevel:100,shadeType:T,onShadeTypeChange:b,onGridToggle:A,groundPlaneEnabled:N,onGroundPlaneToggle:F})]}),d7=t=>{const[e,n]=S.useState("shaded"),r=i=>{t.current&&t.current.traverse(s=>{if(s instanceof je){const o=s;switch(!o.userData.originalMaterial&&o.material&&(o.userData.originalMaterial=Array.isArray(o.material)?o.material.map(a=>a.clone()):o.material.clone()),i){case"shaded":o.userData.originalMaterial&&(o.material=o.userData.originalMaterial),o.userData.edgesHelper&&(o.remove(o.userData.edgesHelper),o.userData.edgesHelper.geometry.dispose(),o.userData.edgesHelper.material.dispose(),delete o.userData.edgesHelper),o.visible=!0,Array.isArray(o.material)?o.material.forEach(l=>{"wireframe"in l&&(l.wireframe=!1)}):"wireframe"in o.material&&(o.material.wireframe=!1);break;case"wireframe":o.userData.originalMaterial&&(o.material=o.userData.originalMaterial),o.userData.edgesHelper&&(o.remove(o.userData.edgesHelper),o.userData.edgesHelper.geometry.dispose(),o.userData.edgesHelper.material.dispose(),delete o.userData.edgesHelper),o.visible=!0,Array.isArray(o.material)?o.material.forEach(l=>{"wireframe"in l&&(l.wireframe=!0)}):"wireframe"in o.material&&(o.material.wireframe=!0);break;case"hidden":o.visible=!0;const a=new nx({color:13421772,transparent:!0,opacity:.8});if(o.material=a,!o.userData.edgesHelper&&o.geometry){const l=new cu(o.geometry),c=new ii({color:3355443}),f=new to(l,c);o.add(f),o.userData.edgesHelper=f}break;case"shaded-with-edges":if(o.userData.originalMaterial&&(o.material=o.userData.originalMaterial),o.visible=!0,Array.isArray(o.material)?o.material.forEach(l=>{"wireframe"in l&&(l.wireframe=!1)}):"wireframe"in o.material&&(o.material.wireframe=!1),!o.userData.edgesHelper&&o.geometry){const l=new cu(o.geometry),c=new ii({color:0}),f=new to(l,c);o.add(f),o.userData.edgesHelper=f}break}}})};return S.useEffect(()=>{r(e)},[e,t]),{shadeType:e,setShadeType:i=>{n(i),r(i)}}},f7=()=>({viewTop:()=>{console.log("viewTop called");const a=window.__standardViews;a&&a.viewTop?a.viewTop():console.log("standardViews not available")},viewFront:()=>{console.log("viewFront called");const a=window.__standardViews;a&&a.viewFront?a.viewFront():console.log("standardViews not available")},viewBack:()=>{console.log("viewBack called");const a=window.__standardViews;a&&a.viewBack?a.viewBack():console.log("standardViews not available")},viewBottom:()=>{console.log("viewBottom called");const a=window.__standardViews;a&&a.viewBottom?a.viewBottom():console.log("standardViews not available")},viewRight:()=>{console.log("viewRight called");const a=window.__standardViews;a&&a.viewRight?a.viewRight():console.log("standardViews not available")},viewLeft:()=>{console.log("viewLeft called");const a=window.__standardViews;a&&a.viewLeft?a.viewLeft():console.log("standardViews not available")},viewIsometric:()=>{console.log("viewIsometric called");const a=window.__standardViews;a&&a.viewIsometric?a.viewIsometric():console.log("standardViews not available")}}),h7=()=>{const{activeControlTab:t,showControlPanel:e,setActiveControlTab:n,setShowControlPanel:r,setIsOrthographic:i}=iu(),s=S.useCallback(a=>{console.log("handleTabChange called with:",a,"current:",t,"panelOpen:",e),t===a&&e?r(!1):(n(a),r(!0))},[t,e,n,r]),o=S.useCallback(a=>{const l=iu(),c=a!==void 0?a:!l.isOrthographic;i(c),console.log("Camera toggle:",{newOrthographic:c,currentState:l.isOrthographic});const f=window.__cameraControls;f&&typeof f.toggleCameraType=="function"?(console.log("Using window.__cameraControls"),f.toggleCameraType(c)):(console.log("Dispatching toggleCameraType event"),window.dispatchEvent(new CustomEvent("toggleCameraType",{detail:{orthographic:c}})))},[i]);return{handleTabChange:s,handleCameraToggle:o}},p7=()=>{const{scene:t}=BT(),e=Uy(),n=iu(),{shadeType:r,setShadeType:i}=d7({current:t}),{measurements:s,addMeasurement:o,removeMeasurement:a,clearAllMeasurements:l}=UT(),{handleToolSelect:c,handlePointCreate:f,handleMeasureCreate:u}=zT(n.setActiveTool,n.setShowMeasurePanel,o),{handleFileUpload:d,handleModelsChange:h,handleModelSelect:m,handleModelRemove:v,handlePrimitiveSelect:g}=YA(),{handleZoomAll:p,handleZoomToSelected:x,handleZoomIn:_,handleZoomOut:w,handleResetView:M}=HT(),{viewFront:T,viewBack:b,viewLeft:C,viewRight:A,viewIsometric:E}=f7(),N=()=>{const O=window.__updateSceneGrid;O&&O(),n.setGridEnabled(!n.gridEnabled)},F=()=>{const O=!n.groundPlaneEnabled;console.log("Ground plane toggle:",{newState:O,currentState:n.groundPlaneEnabled});const j=window.__updateGroundPlane;j?(console.log("Using window.__updateGroundPlane"),j(O)):(console.log("Dispatching toggleGroundPlane event"),window.dispatchEvent(new CustomEvent("toggleGroundPlane",{detail:{enabled:O}}))),n.setGroundPlaneEnabled(O)},{handleTabChange:I,handleCameraToggle:U}=h7(),z={loadedModels:e.loadedModels,currentModel:e.currentModel,isUploading:e.isUploading,uploadError:e.uploadError,onFileUpload:d,onModelSelect:m,onModelRemove:v,onPrimitiveSelect:g,scene:t,activeTab:n.activeControlTab,isOrthographic:n.isOrthographic,onCameraToggle:U,...e};return y.jsx(u7,{activeTool:n.activeTool,onToolSelect:c,activeControlTab:n.activeControlTab,showControlPanel:n.showControlPanel,onTabChange:I,onCloseControlPanel:()=>n.setShowControlPanel(!1),controlsPanelProps:z,showMeasurePanel:n.showMeasurePanel,onCloseMeasurePanel:()=>n.setShowMeasurePanel(!1),measurements:s,onClearAllMeasurements:l,onRemoveMeasurement:a,onZoomAll:p,onZoomToSelected:x,onZoomIn:_,onZoomOut:w,onResetView:M,onViewFront:T,onViewBack:b,onViewLeft:C,onViewRight:A,onViewIsometric:E,onGridToggle:N,gridEnabled:n.gridEnabled,groundPlaneEnabled:n.groundPlaneEnabled,onGroundPlaneToggle:F,isOrthographic:n.isOrthographic,onCameraToggle:U,shadeType:r,onShadeTypeChange:i,modelCount:e.loadedModels.length})};class jm extends S.Component{constructor(){super(...arguments);kt(this,"state",{hasError:!1})}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){console.error("ErrorBoundary caught an error:",n,r)}render(){var n;return this.state.hasError?this.props.fallback||y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background text-foreground",children:y.jsxs("div",{className:"text-center",children:[y.jsx("h2",{className:"text-xl font-bold mb-2",children:"Something went wrong"}),y.jsx("p",{className:"text-muted-foreground mb-4",children:((n=this.state.error)==null?void 0:n.message)||"An unexpected error occurred"}),y.jsx("button",{onClick:()=>this.setState({hasError:!1,error:void 0}),className:"px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90",children:"Try again"})]})}):this.props.children}}const m7=()=>{console.log("IndexContent rendering...");try{const{setShowControlPanel:t}=iu();console.log("useUIState hook loaded successfully");const{measurements:e,addMeasurement:n}=UT();console.log("useMeasurements hook loaded successfully");const{handleZoomAll:r,handleZoomToSelected:i,handleResetView:s}=HT();console.log("useZoomHandlers hook loaded successfully");const{handlePointCreate:o,handleMeasureCreate:a}=zT(()=>{},()=>{},n);return console.log("useToolHandlers hook loaded successfully"),Yk({onToggleControlPanel:()=>t(!0),onZoomAll:r,onZoomToSelected:i,onResetView:s}),console.log("useKeyboardShortcuts hook loaded successfully"),console.log("IndexContent about to render JSX..."),y.jsxs(jm,{children:[y.jsx("div",{className:"absolute inset-0",children:y.jsx(jm,{fallback:y.jsx("div",{className:"w-full h-full bg-red-500 text-white flex items-center justify-center",children:"Model Viewer Error"}),children:y.jsx(hG,{onPointCreate:o,onMeasureCreate:a})})}),y.jsx(jm,{fallback:y.jsx("div",{className:"fixed top-4 left-4 bg-red-500 text-white p-4 rounded",children:"UI Error"}),children:y.jsx(p7,{})})]})}catch(t){return console.error("Error in IndexContent:",t),y.jsx("div",{className:"w-full h-full bg-red-500 text-white flex items-center justify-center",children:y.jsxs("div",{className:"text-center",children:[y.jsx("h2",{className:"text-xl font-bold mb-2",children:"IndexContent Error"}),y.jsxs("p",{className:"mb-4",children:["Error: ",t instanceof Error?t.message:"Unknown error"]})]})})}},g7=()=>y.jsx($k,{children:y.jsx(m7,{})}),v7=()=>{const t=IT();return S.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),y.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:y.jsxs("div",{className:"text-center",children:[y.jsx("h1",{className:"text-4xl font-bold mb-4",children:"404"}),y.jsx("p",{className:"text-xl text-gray-600 mb-4",children:"Oops! Page not found"}),y.jsx("a",{href:"/",className:"text-blue-500 hover:text-blue-700 underline",children:"Return to Home"})]})})},y7=new ek,x7=()=>y.jsx(nk,{client:y7,children:y.jsx(jk,{children:y.jsx(Gk,{children:y.jsx(Wk,{children:y.jsxs(Ul,{children:[y.jsx(PL,{}),y.jsx(sI,{}),y.jsx(zk,{children:y.jsxs(Fk,{children:[y.jsx(Qg,{path:"/",element:y.jsx(g7,{})}),y.jsx(Qg,{path:"*",element:y.jsx(v7,{})})]})})]})})})})});KE(document.getElementById("root")).render(y.jsx(x7,{}));