4724 lines
1.8 MiB
4724 lines
1.8 MiB
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var F=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee={pending:!1,data:null,method:null,action:null},R=[],te=-1;function z(e){return{current:e}}function B(e){0>te||(e.current=R[te],R[te]=null,te--)}function V(e,t){te++,R[te]=e.current,e.current=t}var ne=z(null),re=z(null),ie=z(null),ae=z(null);function oe(e,t){switch(V(ie,t),V(re,e),V(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(ne),V(ne,e)}function se(){B(ne),B(re),B(ie)}function ce(e){e.memoizedState!==null&&V(ae,e);var t=ne.current,n=Kd(t,e.type);t!==n&&(V(re,e),V(ne,n))}function H(e){re.current===e&&(B(ne),B(re)),ae.current===e&&(B(ae),tp._currentValue=ee)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
|
||
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
||
`+le+e+ue}var fe=!1;function pe(e,t){if(!e||fe)return``;fe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
||
`),l=s.split(`
|
||
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
||
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{fe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?de(n):``}function me(e,t){switch(e.tag){case 26:case 27:case 5:return de(e.type);case 16:return de(`Lazy`);case 13:return e.child!==t&&t!==null?de(`Suspense Fallback`):de(`Suspense`);case 19:return de(`SuspenseList`);case 0:case 15:return pe(e.type,!1);case 11:return pe(e.type.render,!1);case 1:return pe(e.type,!0);case 31:return de(`Activity`);default:return``}}function he(e){try{var t=``,n=null;do t+=me(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
||
Error generating stack: `+e.message+`
|
||
`+e.stack}}var ge=Object.prototype.hasOwnProperty,_e=t.unstable_scheduleCallback,ve=t.unstable_cancelCallback,ye=t.unstable_shouldYield,be=t.unstable_requestPaint,xe=t.unstable_now,Se=t.unstable_getCurrentPriorityLevel,U=t.unstable_ImmediatePriority,Ce=t.unstable_UserBlockingPriority,we=t.unstable_NormalPriority,Te=t.unstable_LowPriority,W=t.unstable_IdlePriority,Ee=t.log,De=t.unstable_setDisableYieldValue,Oe=null,ke=null;function Ae(e){if(typeof Ee==`function`&&De(e),ke&&typeof ke.setStrictMode==`function`)try{ke.setStrictMode(Oe,e)}catch{}}var je=Math.clz32?Math.clz32:Pe,Me=Math.log,Ne=Math.LN2;function Pe(e){return e>>>=0,e===0?32:31-(Me(e)/Ne|0)|0}var Fe=256,Ie=262144,Le=4194304;function Re(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ze(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Re(n))):i=Re(o):i=Re(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Re(n))):i=Re(o)):i=Re(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Be(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ve(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function He(){var e=Le;return Le<<=1,!(Le&62914560)&&(Le=4194304),e}function Ue(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function We(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ge(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-je(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Ke(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Ke(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-je(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function qe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-je(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Je(e,t){var n=t&-t;return n=n&42?1:Ye(n),(n&(e.suspendedLanes|t))===0?n:0}function Ye(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Xe(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ze(){var e=L.p;return e===0?(e=window.event,e===void 0?32:_p(e.type)):e}function Qe(e,t){var n=L.p;try{return L.p=e,t()}finally{L.p=n}}var $e=Math.random().toString(36).slice(2),et=`__reactFiber$`+$e,tt=`__reactProps$`+$e,nt=`__reactContainer$`+$e,rt=`__reactEvents$`+$e,it=`__reactListeners$`+$e,at=`__reactHandles$`+$e,ot=`__reactResources$`+$e,st=`__reactMarker$`+$e;function ct(e){delete e[et],delete e[tt],delete e[rt],delete e[it],delete e[at]}function lt(e){var t=e[et];if(t)return t;for(var n=e.parentNode;n;){if(t=n[nt]||n[et]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=hf(e);e!==null;){if(n=e[et])return n;e=hf(e)}return t}e=n,n=e.parentNode}return null}function ut(e){if(e=e[et]||e[nt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function dt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function ft(e){var t=e[ot];return t||=e[ot]={hoistableStyles:new Map,hoistableScripts:new Map},t}function pt(e){e[st]=!0}var mt=new Set,ht={};function gt(e,t){_t(e,t),_t(e+`Capture`,t)}function _t(e,t){for(ht[e]=t,e=0;e<t.length;e++)mt.add(t[e])}var vt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),yt={},bt={};function xt(e){return ge.call(bt,e)?!0:ge.call(yt,e)?!1:vt.test(e)?bt[e]=!0:(yt[e]=!0,!1)}function St(e,t,n){if(xt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Ct(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function wt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Tt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Et(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Dt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ot(e){if(!e._valueTracker){var t=Et(e)?`checked`:`value`;e._valueTracker=Dt(e,t,``+e[t])}}function kt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Et(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function At(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var jt=/[\n"\\]/g;function Mt(e){return e.replace(jt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Nt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Tt(t)):e.value!==``+Tt(t)&&(e.value=``+Tt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Ft(e,o,Tt(n)):Ft(e,o,Tt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Tt(s):e.removeAttribute(`name`)}function Pt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Ot(e);return}n=n==null?``:``+Tt(n),t=t==null?n:``+Tt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Ot(e)}function Ft(e,t,n){t===`number`&&At(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function It(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Tt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Lt(e,t,n){if(t!=null&&(t=``+Tt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Tt(n)}function Rt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(F(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Tt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Ot(e)}function zt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Bt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Vt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Bt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Ht(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Vt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Vt(e,o,t[o])}function Ut(e){if(e.indexOf(`-`)===-1)return!1;switch(e){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 Wt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Gt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Kt(e){return Gt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function qt(){}var Jt=null;function Yt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xt=null,Zt=null;function Qt(e){var t=ut(e);if(t&&(e=t.stateNode)){var n=e[tt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Nt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Mt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[tt]||null;if(!a)throw Error(i(90));Nt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&kt(r)}break a;case`textarea`:Lt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&It(e,!!n.multiple,t,!1)}}}var G=!1;function $t(e,t,n){if(G)return e(t,n);G=!0;try{return e(t)}finally{if(G=!1,(Xt!==null||Zt!==null)&&(xu(),Xt&&(t=Xt,e=Zt,Zt=Xt=null,Qt(t),e)))for(t=0;t<e.length;t++)Qt(e[t])}}function en(e,t){var n=e.stateNode;if(n===null)return null;var r=n[tt]||null;if(r===null)return null;n=r[t];a:switch(t){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)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var tn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),nn=!1;if(tn)try{var rn={};Object.defineProperty(rn,"passive",{get:function(){nn=!0}}),window.addEventListener(`test`,rn,rn),window.removeEventListener(`test`,rn,rn)}catch{nn=!1}var an=null,on=null,sn=null;function cn(){if(sn)return sn;var e,t=on,n=t.length,r,i=`value`in an?an.value:an.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return sn=i.slice(e,1<r?1-r:void 0)}function ln(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function un(){return!0}function dn(){return!1}function fn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?un:dn,this.isPropagationStopped=dn,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=un)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=un)},persist:function(){},isPersistent:un}),t}var pn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},mn=fn(pn),hn=m({},pn,{view:0,detail:0}),gn=fn(hn),_n,vn,yn,bn=m({},hn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==yn&&(yn&&e.type===`mousemove`?(_n=e.screenX-yn.screenX,vn=e.screenY-yn.screenY):vn=_n=0,yn=e),_n)},movementY:function(e){return`movementY`in e?e.movementY:vn}}),xn=fn(bn),Sn=fn(m({},bn,{dataTransfer:0})),Cn=fn(m({},hn,{relatedTarget:0})),wn=fn(m({},pn,{animationName:0,elapsedTime:0,pseudoElement:0})),Tn=fn(m({},pn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),En=fn(m({},pn,{data:0})),Dn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},On={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`},kn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function An(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=kn[e])?!!t[e]:!1}function jn(){return An}var K=fn(m({},hn,{key:function(e){if(e.key){var t=Dn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=ln(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?On[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jn,charCode:function(e){return e.type===`keypress`?ln(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?ln(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Mn=fn(m({},bn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),q=fn(m({},hn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jn})),Nn=fn(m({},pn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Pn=fn(m({},bn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Fn=fn(m({},pn,{newState:0,oldState:0})),In=[9,13,27,32],Ln=tn&&`CompositionEvent`in window,Rn=null;tn&&`documentMode`in document&&(Rn=document.documentMode);var zn=tn&&`TextEvent`in window&&!Rn,Bn=tn&&(!Ln||Rn&&8<Rn&&11>=Rn),Vn=` `,Hn=!1;function Un(e,t){switch(e){case`keyup`:return In.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Wn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Gn=!1;function Kn(e,t){switch(e){case`compositionend`:return Wn(t);case`keypress`:return t.which===32?(Hn=!0,Vn):null;case`textInput`:return e=t.data,e===Vn&&Hn?null:e;default:return null}}function qn(e,t){if(Gn)return e===`compositionend`||!Ln&&Un(e,t)?(e=cn(),sn=on=an=null,Gn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Bn&&t.locale!==`ko`?null:t.data;default:return null}}var Jn={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 Yn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Jn[e.type]:t===`textarea`}function Xn(e,t,n,r){Xt?Zt?Zt.push(r):Zt=[r]:Xt=r,t=kd(t,`onChange`),0<t.length&&(n=new mn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Zn=null,Qn=null;function $n(e){xd(e,0)}function er(e){if(kt(dt(e)))return e}function tr(e,t){if(e===`change`)return t}var nr=!1;if(tn){var rr;if(tn){var J=`oninput`in document;if(!J){var ir=document.createElement(`div`);ir.setAttribute(`oninput`,`return;`),J=typeof ir.oninput==`function`}rr=J}else rr=!1;nr=rr&&(!document.documentMode||9<document.documentMode)}function ar(){Zn&&(Zn.detachEvent(`onpropertychange`,or),Qn=Zn=null)}function or(e){if(e.propertyName===`value`&&er(Qn)){var t=[];Xn(t,Qn,e,Yt(e)),$t($n,t)}}function sr(e,t,n){e===`focusin`?(ar(),Zn=t,Qn=n,Zn.attachEvent(`onpropertychange`,or)):e===`focusout`&&ar()}function cr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return er(Qn)}function lr(e,t){if(e===`click`)return er(t)}function ur(e,t){if(e===`input`||e===`change`)return er(t)}function dr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var fr=typeof Object.is==`function`?Object.is:dr;function pr(e,t){if(fr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!ge.call(t,i)||!fr(e[i],t[i]))return!1}return!0}function mr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function hr(e,t){var n=mr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=mr(n)}}function gr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?gr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function _r(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=At(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=At(e.document)}return t}function vr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var yr=tn&&`documentMode`in document&&11>=document.documentMode,br=null,xr=null,Sr=null,Cr=!1;function wr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Cr||br==null||br!==At(r)||(r=br,`selectionStart`in r&&vr(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}),Sr&&pr(Sr,r)||(Sr=r,r=kd(xr,`onSelect`),0<r.length&&(t=new mn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=br)))}function Tr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Er={animationend:Tr(`Animation`,`AnimationEnd`),animationiteration:Tr(`Animation`,`AnimationIteration`),animationstart:Tr(`Animation`,`AnimationStart`),transitionrun:Tr(`Transition`,`TransitionRun`),transitionstart:Tr(`Transition`,`TransitionStart`),transitioncancel:Tr(`Transition`,`TransitionCancel`),transitionend:Tr(`Transition`,`TransitionEnd`)},Dr={},Or={};tn&&(Or=document.createElement(`div`).style,`AnimationEvent`in window||(delete Er.animationend.animation,delete Er.animationiteration.animation,delete Er.animationstart.animation),`TransitionEvent`in window||delete Er.transitionend.transition);function kr(e){if(Dr[e])return Dr[e];if(!Er[e])return e;var t=Er[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Or)return Dr[e]=t[n];return e}var Ar=kr(`animationend`),jr=kr(`animationiteration`),Mr=kr(`animationstart`),Nr=kr(`transitionrun`),Pr=kr(`transitionstart`),Fr=kr(`transitioncancel`),Ir=kr(`transitionend`),Lr=new Map,Y=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Y.push(`scrollEnd`);function Rr(e,t){Lr.set(e,t),gt(t,[e])}var zr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Br=[],Vr=0,Hr=0;function Ur(){for(var e=Vr,t=Hr=Vr=0;t<e;){var n=Br[t];Br[t++]=null;var r=Br[t];Br[t++]=null;var i=Br[t];Br[t++]=null;var a=Br[t];if(Br[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&qr(n,i,a)}}function Wr(e,t,n,r){Br[Vr++]=e,Br[Vr++]=t,Br[Vr++]=n,Br[Vr++]=r,Hr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Gr(e,t,n,r){return Wr(e,t,n,r),Jr(e)}function Kr(e,t){return Wr(e,null,null,t),Jr(e)}function qr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-je(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Jr(e){if(50<fu)throw fu=0,pu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Yr={};function Xr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,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 Zr(e,t,n,r){return new Xr(e,t,n,r)}function Qr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $r(e,t){var n=e.alternate;return n===null?(n=Zr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function ei(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ti(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Qr(e)&&(s=1);else if(typeof e==`string`)s=qf(e,n,ne.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=Zr(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return ni(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=Zr(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=Zr(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=Zr(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Zr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ni(e,t,n,r){return e=Zr(7,e,r,t),e.lanes=n,e}function ri(e,t,n){return e=Zr(6,e,null,t),e.lanes=n,e}function ii(e){var t=Zr(18,null,null,0);return t.stateNode=e,t}function ai(e,t,n){return t=Zr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var oi=new WeakMap;function si(e,t){if(typeof e==`object`&&e){var n=oi.get(e);return n===void 0?(t={value:e,source:t,stack:he(t)},oi.set(e,t),t):n}return{value:e,source:t,stack:he(t)}}var ci=[],li=0,ui=null,di=0,fi=[],pi=0,mi=null,hi=1,gi=``;function _i(e,t){ci[li++]=di,ci[li++]=ui,ui=e,di=t}function vi(e,t,n){fi[pi++]=hi,fi[pi++]=gi,fi[pi++]=mi,mi=e;var r=hi;e=gi;var i=32-je(r)-1;r&=~(1<<i),n+=1;var a=32-je(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,hi=1<<32-je(t)+i|n<<i|r,gi=a+e}else hi=1<<a|n<<i|r,gi=e}function yi(e){e.return!==null&&(_i(e,1),vi(e,1,0))}function bi(e){for(;e===ui;)ui=ci[--li],ci[li]=null,di=ci[--li],ci[li]=null;for(;e===mi;)mi=fi[--pi],fi[pi]=null,gi=fi[--pi],fi[pi]=null,hi=fi[--pi],fi[pi]=null}function xi(e,t){fi[pi++]=hi,fi[pi++]=gi,fi[pi++]=mi,hi=t.id,gi=t.overflow,mi=e}var Si=null,Ci=null,wi=!1,Ti=null,Ei=!1,Di=Error(i(519));function Oi(e){throw Pi(si(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Di}function ki(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[et]=e,t[tt]=r,n){case`dialog`:Sd(`cancel`,t),Sd(`close`,t);break;case`iframe`:case`object`:case`embed`:Sd(`load`,t);break;case`video`:case`audio`:for(n=0;n<yd.length;n++)Sd(yd[n],t);break;case`source`:Sd(`error`,t);break;case`img`:case`image`:case`link`:Sd(`error`,t),Sd(`load`,t);break;case`details`:Sd(`toggle`,t);break;case`input`:Sd(`invalid`,t),Pt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Sd(`invalid`,t);break;case`textarea`:Sd(`invalid`,t),Rt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Fd(t.textContent,n)?(r.popover!=null&&(Sd(`beforetoggle`,t),Sd(`toggle`,t)),r.onScroll!=null&&Sd(`scroll`,t),r.onScrollEnd!=null&&Sd(`scrollend`,t),r.onClick!=null&&(t.onclick=qt),t=!0):t=!1,t||Oi(e,!0)}function Ai(e){for(Si=e.return;Si;)switch(Si.tag){case 5:case 31:case 13:Ei=!1;return;case 27:case 3:Ei=!0;return;default:Si=Si.return}}function ji(e){if(e!==Si)return!1;if(!wi)return Ai(e),wi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||qd(e.type,e.memoizedProps)),n=!n),n&&Ci&&Oi(e),Ai(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ci=mf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ci=mf(e)}else t===27?(t=Ci,tf(e.type)?(e=pf,pf=null,Ci=e):Ci=t):Ci=Si?ff(e.stateNode.nextSibling):null;return!0}function Mi(){Ci=Si=null,wi=!1}function Ni(){var e=Ti;return e!==null&&(Ql===null?Ql=e:Ql.push.apply(Ql,e),Ti=null),e}function Pi(e){Ti===null?Ti=[e]:Ti.push(e)}var Fi=z(null),Ii=null,Li=null;function Ri(e,t,n){V(Fi,t._currentValue),t._currentValue=n}function zi(e){e._currentValue=Fi.current,B(Fi)}function Bi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Vi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Bi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Bi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Hi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;fr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ae.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[tp]:e.push(tp))}a=a.return}e!==null&&Vi(t,e,n,r),t.flags|=262144}function Ui(e){for(e=e.firstContext;e!==null;){if(!fr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Wi(e){Ii=e,Li=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Gi(e){return qi(Ii,e)}function Ki(e,t){return Ii===null&&Wi(e),qi(e,t)}function qi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Li===null){if(e===null)throw Error(i(308));Li=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Li=Li.next=t;return n}var Ji=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Yi=t.unstable_scheduleCallback,Xi=t.unstable_NormalPriority,Zi={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qi(){return{controller:new Ji,data:new Map,refCount:0}}function $i(e){e.refCount--,e.refCount===0&&Yi(Xi,function(){e.controller.abort()})}var ea=null,ta=0,na=0,ra=null;function ia(e,t){if(ea===null){var n=ea=[];ta=0,na=pd(),ra={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ta++,t.then(aa,aa),t}function aa(){if(--ta===0&&ea!==null){ra!==null&&(ra.status=`fulfilled`);var e=ea;ea=null,na=0,ra=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function oa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var sa=I.S;I.S=function(e,t){tu=xe(),typeof t==`object`&&t&&typeof t.then==`function`&&ia(e,t),sa!==null&&sa(e,t)};var ca=z(null);function la(){var e=ca.current;return e===null?Il.pooledCache:e}function ua(e,t){t===null?V(ca,ca.current):V(ca,t.pool)}function da(){var e=la();return e===null?null:{parent:Zi._currentValue,pool:e}}var fa=Error(i(460)),pa=Error(i(474)),ma=Error(i(542)),ha={then:function(){}};function ga(e){return e=e.status,e===`fulfilled`||e===`rejected`}function _a(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(qt,qt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,xa(e),e;default:if(typeof t.status==`string`)t.then(qt,qt);else{if(e=Il,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,xa(e),e}throw ya=t,fa}}function va(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ya=e,fa):e}}var ya=null;function ba(){if(ya===null)throw Error(i(459));var e=ya;return ya=null,e}function xa(e){if(e===fa||e===ma)throw Error(i(483))}var Sa=null,Ca=0;function wa(e){var t=Ca;return Ca+=1,Sa===null&&(Sa=[]),_a(Sa,e,t)}function Ta(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ea(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Da(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=$r(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ri(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&va(i)===t.type)?(t=a(t,n.props),Ta(t,n),t.return=e,t):(t=ti(n.type,n.key,n.props,null,e.mode,r),Ta(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ai(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ni(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ri(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=ti(t.type,t.key,t.props,null,e.mode,n),Ta(n,t),n.return=e,n;case v:return t=ai(t,e.mode,n),t.return=e,t;case O:return t=va(t),f(e,t,n)}if(F(t)||M(t))return t=ni(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,wa(t),n);if(t.$$typeof===C)return f(e,Ki(e,t),n);Ea(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=va(n),p(e,t,n,r)}if(F(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,wa(n),r);if(n.$$typeof===C)return p(e,t,Ki(e,n),r);Ea(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=va(r),m(e,t,n,r,i)}if(F(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,wa(r),i);if(r.$$typeof===C)return m(e,t,n,Ki(t,r),i);Ea(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),wi&&_i(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return wi&&_i(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),wi&&_i(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),wi&&_i(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return wi&&_i(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),wi&&_i(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&va(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ta(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ni(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ti(o.type,o.key,o.props,null,e.mode,c),Ta(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ai(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=va(o),b(e,r,o,c)}if(F(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,wa(o),c);if(o.$$typeof===C)return b(e,r,Ki(e,o),c);Ea(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ri(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ca=0;var i=b(e,t,n,r);return Sa=null,i}catch(t){if(t===fa||t===ma)throw t;var a=Zr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Oa=Da(!0),ka=Da(!1),Aa=!1;function ja(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ma(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Na(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Pa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Fl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Jr(e),qr(e,null,n),t}return Wr(e,r,t,n),Jr(e)}function Fa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,qe(e,n)}}function Ia(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var La=!1;function Ra(){if(La){var e=ra;if(e!==null)throw e}}function za(e,t,n,r){La=!1;var i=e.updateQueue;Aa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Rl&f)===f:(r&f)===f){f!==0&&f===na&&(La=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Aa=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Kl|=o,e.lanes=o,e.memoizedState=d}}function Ba(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Va(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ba(n[e],t)}var Ha=z(null),Ua=z(0);function Wa(e,t){e=Wl,V(Ua,e),V(Ha,t),Wl=e|t.baseLanes}function Ga(){V(Ua,Wl),V(Ha,Ha.current)}function Ka(){Wl=Ua.current,B(Ha),B(Ua)}var qa=z(null),Ja=null;function Ya(e){var t=e.alternate;V(eo,eo.current&1),V(qa,e),Ja===null&&(t===null||Ha.current!==null||t.memoizedState!==null)&&(Ja=e)}function Xa(e){V(eo,eo.current),V(qa,e),Ja===null&&(Ja=e)}function Za(e){e.tag===22?(V(eo,eo.current),V(qa,e),Ja===null&&(Ja=e)):Qa(e)}function Qa(){V(eo,eo.current),V(qa,qa.current)}function $a(e){B(qa),Ja===e&&(Ja=null),B(eo)}var eo=z(0);function to(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||lf(n)||uf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var no=0,ro=null,io=null,ao=null,oo=!1,so=!1,co=!1,lo=0,uo=0,fo=null,po=0;function mo(){throw Error(i(321))}function ho(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!fr(e[n],t[n]))return!1;return!0}function go(e,t,n,r,i,a){return no=a,ro=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?Ns:Ps,co=!1,a=n(r,i),co=!1,so&&(a=vo(t,n,r,i)),_o(e),a}function _o(e){I.H=Ms;var t=io!==null&&io.next!==null;if(no=0,ao=io=ro=null,oo=!1,uo=0,fo=null,t)throw Error(i(300));e===null||Zs||(e=e.dependencies,e!==null&&Ui(e)&&(Zs=!0))}function vo(e,t,n,r){ro=e;var a=0;do{if(so&&(fo=null),uo=0,so=!1,25<=a)throw Error(i(301));if(a+=1,ao=io=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}I.H=Fs,o=t(n,r)}while(so);return o}function yo(){var e=I.H,t=e.useState()[0];return t=typeof t.then==`function`?Eo(t):t,e=e.useState()[0],(io===null?null:io.memoizedState)!==e&&(ro.flags|=1024),t}function bo(){var e=lo!==0;return lo=0,e}function xo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function So(e){if(oo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}oo=!1}no=0,ao=io=ro=null,so=!1,uo=lo=0,fo=null}function Co(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ao===null?ro.memoizedState=ao=e:ao=ao.next=e,ao}function wo(){if(io===null){var e=ro.alternate;e=e===null?null:e.memoizedState}else e=io.next;var t=ao===null?ro.memoizedState:ao.next;if(t!==null)ao=t,io=e;else{if(e===null)throw ro.alternate===null?Error(i(467)):Error(i(310));io=e,e={memoizedState:io.memoizedState,baseState:io.baseState,baseQueue:io.baseQueue,queue:io.queue,next:null},ao===null?ro.memoizedState=ao=e:ao=ao.next=e}return ao}function To(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Eo(e){var t=uo;return uo+=1,fo===null&&(fo=[]),e=_a(fo,e,t),t=ro,(ao===null?t.memoizedState:ao.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?Ns:Ps),e}function Do(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Eo(e);if(e.$$typeof===C)return Gi(e)}throw Error(i(438,String(e)))}function Oo(e){var t=null,n=ro.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=ro.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=To(),ro.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function ko(e,t){return typeof t==`function`?t(e):t}function Ao(e){return jo(wo(),io,e)}function jo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(no&f)===f:(Rl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===na&&(d=!0);else if((no&p)===p){u=u.next,p===na&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,ro.lanes|=p,Kl|=p;f=u.action,co&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,ro.lanes|=f,Kl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!fr(o,e.memoizedState)&&(Zs=!0,d&&(n=ra,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Mo(e){var t=wo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);fr(o,t.memoizedState)||(Zs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function No(e,t,n){var r=ro,a=wo(),o=wi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!fr((io||a).memoizedState,n);if(s&&(a.memoizedState=n,Zs=!0),a=a.queue,is(Io.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||ao!==null&&ao.memoizedState.tag&1){if(r.flags|=2048,$o(9,{destroy:void 0},Fo.bind(null,r,a,n,t),null),Il===null)throw Error(i(349));o||no&127||Po(r,t,n)}return n}function Po(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=ro.updateQueue,t===null?(t=To(),ro.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Fo(e,t,n,r){t.value=n,t.getSnapshot=r,Lo(t)&&Ro(e)}function Io(e,t,n){return n(function(){Lo(t)&&Ro(e)})}function Lo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!fr(e,n)}catch{return!0}}function Ro(e){var t=Kr(e,2);t!==null&&gu(t,e,2)}function zo(e){var t=Co();if(typeof e==`function`){var n=e;if(e=n(),co){Ae(!0);try{n()}finally{Ae(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ko,lastRenderedState:e},t}function Bo(e,t,n,r){return e.baseState=n,jo(e,io,typeof r==`function`?r:ko)}function Vo(e,t,n,r,a){if(ks(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};I.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ho(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ho(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=I.T,o={};I.T=o;try{var s=n(i,r),c=I.S;c!==null&&c(o,s),Uo(e,t,s)}catch(n){Go(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),I.T=a}}else try{a=n(i,r),Uo(e,t,a)}catch(n){Go(e,t,n)}}function Uo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Wo(e,t,n)},function(n){return Go(e,t,n)}):Wo(e,t,n)}function Wo(e,t,n){t.status=`fulfilled`,t.value=n,Ko(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ho(e,n)))}function Go(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ko(t),t=t.next;while(t!==r)}e.action=null}function Ko(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function qo(e,t){return t}function Jo(e,t){if(wi){var n=Il.formState;if(n!==null){a:{var r=ro;if(wi){if(Ci){b:{for(var i=Ci,a=Ei;i.nodeType!==8;){if(!a){i=null;break b}if(i=ff(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ci=ff(i.nextSibling),r=i.data===`F!`;break a}}Oi(r)}r=!1}r&&(t=n[0])}}return n=Co(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:qo,lastRenderedState:t},n.queue=r,n=Es.bind(null,ro,r),r.dispatch=n,r=zo(!1),a=Os.bind(null,ro,!1,r.queue),r=Co(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Vo.bind(null,ro,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Yo(e){return Xo(wo(),io,e)}function Xo(e,t,n){if(t=jo(e,t,qo)[0],e=Ao(ko)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Eo(t)}catch(e){throw e===fa?ma:e}else r=t;t=wo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(ro.flags|=2048,$o(9,{destroy:void 0},Zo.bind(null,i,n),null)),[r,a,e]}function Zo(e,t){e.action=t}function Qo(e){var t=wo(),n=io;if(n!==null)return Xo(t,n,e);wo(),t=t.memoizedState,n=wo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function $o(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=ro.updateQueue,t===null&&(t=To(),ro.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function es(){return wo().memoizedState}function ts(e,t,n,r){var i=Co();ro.flags|=e,i.memoizedState=$o(1|t,{destroy:void 0},n,r===void 0?null:r)}function ns(e,t,n,r){var i=wo();r=r===void 0?null:r;var a=i.memoizedState.inst;io!==null&&r!==null&&ho(r,io.memoizedState.deps)?i.memoizedState=$o(t,a,n,r):(ro.flags|=e,i.memoizedState=$o(1|t,a,n,r))}function rs(e,t){ts(8390656,8,e,t)}function is(e,t){ns(2048,8,e,t)}function as(e){ro.flags|=4;var t=ro.updateQueue;if(t===null)t=To(),ro.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function os(e){var t=wo().memoizedState;return as({ref:t,nextImpl:e}),function(){if(Fl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function ss(e,t){return ns(4,2,e,t)}function cs(e,t){return ns(4,4,e,t)}function ls(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function us(e,t,n){n=n==null?null:n.concat([e]),ns(4,4,ls.bind(null,t,e),n)}function ds(){}function fs(e,t){var n=wo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&ho(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ps(e,t){var n=wo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&ho(t,r[1]))return r[0];if(r=e(),co){Ae(!0);try{e()}finally{Ae(!1)}}return n.memoizedState=[r,t],r}function ms(e,t,n){return n===void 0||no&1073741824&&!(Rl&261930)?e.memoizedState=t:(e.memoizedState=n,e=hu(),ro.lanes|=e,Kl|=e,n)}function hs(e,t,n,r){return fr(n,t)?n:Ha.current===null?!(no&42)||no&1073741824&&!(Rl&261930)?(Zs=!0,e.memoizedState=n):(e=hu(),ro.lanes|=e,Kl|=e,t):(e=ms(e,n,r),fr(e,t)||(Zs=!0),e)}function gs(e,t,n,r,i){var a=L.p;L.p=a!==0&&8>a?a:8;var o=I.T,s={};I.T=s,Os(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ds(e,t,oa(c,r),mu(e)):Ds(e,t,r,mu(e))}catch(n){Ds(e,t,{then:function(){},status:`rejected`,reason:n},mu())}finally{L.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function _s(){}function vs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=ys(e).queue;gs(e,a,t,ee,n===null?_s:function(){return bs(e),n(r)})}function ys(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ee,baseState:ee,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ko,lastRenderedState:ee},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ko,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function bs(e){var t=ys(e);t.next===null&&(t=e.alternate.memoizedState),Ds(e,t.next.queue,{},mu())}function xs(){return Gi(tp)}function Ss(){return wo().memoizedState}function Cs(){return wo().memoizedState}function ws(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=mu();e=Na(n);var r=Pa(t,e,n);r!==null&&(gu(r,t,n),Fa(r,t,n)),t={cache:Qi()},e.payload=t;return}t=t.return}}function Ts(e,t,n){var r=mu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ks(e)?As(t,n):(n=Gr(e,t,n,r),n!==null&&(gu(n,e,r),js(n,t,r)))}function Es(e,t,n){Ds(e,t,n,mu())}function Ds(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(ks(e))As(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,fr(s,o))return Wr(e,t,i,0),Il===null&&Ur(),!1}catch{}if(n=Gr(e,t,i,r),n!==null)return gu(n,e,r),js(n,t,r),!0}return!1}function Os(e,t,n,r){if(r={lane:2,revertLane:pd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},ks(e)){if(t)throw Error(i(479))}else t=Gr(e,n,r,2),t!==null&&gu(t,e,2)}function ks(e){var t=e.alternate;return e===ro||t!==null&&t===ro}function As(e,t){so=oo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function js(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,qe(e,n)}}var Ms={readContext:Gi,use:Do,useCallback:mo,useContext:mo,useEffect:mo,useImperativeHandle:mo,useLayoutEffect:mo,useInsertionEffect:mo,useMemo:mo,useReducer:mo,useRef:mo,useState:mo,useDebugValue:mo,useDeferredValue:mo,useTransition:mo,useSyncExternalStore:mo,useId:mo,useHostTransitionStatus:mo,useFormState:mo,useActionState:mo,useOptimistic:mo,useMemoCache:mo,useCacheRefresh:mo};Ms.useEffectEvent=mo;var Ns={readContext:Gi,use:Do,useCallback:function(e,t){return Co().memoizedState=[e,t===void 0?null:t],e},useContext:Gi,useEffect:rs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ts(4194308,4,ls.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ts(4194308,4,e,t)},useInsertionEffect:function(e,t){ts(4,2,e,t)},useMemo:function(e,t){var n=Co();t=t===void 0?null:t;var r=e();if(co){Ae(!0);try{e()}finally{Ae(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Co();if(n!==void 0){var i=n(t);if(co){Ae(!0);try{n(t)}finally{Ae(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ts.bind(null,ro,e),[r.memoizedState,e]},useRef:function(e){var t=Co();return e={current:e},t.memoizedState=e},useState:function(e){e=zo(e);var t=e.queue,n=Es.bind(null,ro,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ds,useDeferredValue:function(e,t){return ms(Co(),e,t)},useTransition:function(){var e=zo(!1);return e=gs.bind(null,ro,e.queue,!0,!1),Co().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=ro,a=Co();if(wi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Il===null)throw Error(i(349));Rl&127||Po(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,rs(Io.bind(null,r,o,e),[e]),r.flags|=2048,$o(9,{destroy:void 0},Fo.bind(null,r,o,n,t),null),n},useId:function(){var e=Co(),t=Il.identifierPrefix;if(wi){var n=gi,r=hi;n=(r&~(1<<32-je(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=lo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=po++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:xs,useFormState:Jo,useActionState:Jo,useOptimistic:function(e){var t=Co();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Os.bind(null,ro,!0,n),n.dispatch=t,[e,t]},useMemoCache:Oo,useCacheRefresh:function(){return Co().memoizedState=ws.bind(null,ro)},useEffectEvent:function(e){var t=Co(),n={impl:e};return t.memoizedState=n,function(){if(Fl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ps={readContext:Gi,use:Do,useCallback:fs,useContext:Gi,useEffect:is,useImperativeHandle:us,useInsertionEffect:ss,useLayoutEffect:cs,useMemo:ps,useReducer:Ao,useRef:es,useState:function(){return Ao(ko)},useDebugValue:ds,useDeferredValue:function(e,t){return hs(wo(),io.memoizedState,e,t)},useTransition:function(){var e=Ao(ko)[0],t=wo().memoizedState;return[typeof e==`boolean`?e:Eo(e),t]},useSyncExternalStore:No,useId:Ss,useHostTransitionStatus:xs,useFormState:Yo,useActionState:Yo,useOptimistic:function(e,t){return Bo(wo(),io,e,t)},useMemoCache:Oo,useCacheRefresh:Cs};Ps.useEffectEvent=os;var Fs={readContext:Gi,use:Do,useCallback:fs,useContext:Gi,useEffect:is,useImperativeHandle:us,useInsertionEffect:ss,useLayoutEffect:cs,useMemo:ps,useReducer:Mo,useRef:es,useState:function(){return Mo(ko)},useDebugValue:ds,useDeferredValue:function(e,t){var n=wo();return io===null?ms(n,e,t):hs(n,io.memoizedState,e,t)},useTransition:function(){var e=Mo(ko)[0],t=wo().memoizedState;return[typeof e==`boolean`?e:Eo(e),t]},useSyncExternalStore:No,useId:Ss,useHostTransitionStatus:xs,useFormState:Qo,useActionState:Qo,useOptimistic:function(e,t){var n=wo();return io===null?(n.baseState=e,[e,n.queue.dispatch]):Bo(n,io,e,t)},useMemoCache:Oo,useCacheRefresh:Cs};Fs.useEffectEvent=os;function Is(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ls={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=mu(),i=Na(r);i.payload=t,n!=null&&(i.callback=n),t=Pa(e,i,r),t!==null&&(gu(t,e,r),Fa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=mu(),i=Na(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Pa(e,i,r),t!==null&&(gu(t,e,r),Fa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=mu(),r=Na(n);r.tag=2,t!=null&&(r.callback=t),t=Pa(e,r,n),t!==null&&(gu(t,e,n),Fa(t,e,n))}};function Rs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!pr(n,r)||!pr(i,a):!0}function zs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ls.enqueueReplaceState(t,t.state,null)}function Bs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Vs(e){zr(e)}function Hs(e){console.error(e)}function Us(e){zr(e)}function Ws(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Gs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ks(e,t,n){return n=Na(n),n.tag=3,n.payload={element:null},n.callback=function(){Ws(e,t)},n}function qs(e){return e=Na(e),e.tag=3,e}function Js(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Gs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Gs(t,n,r),typeof i!=`function`&&(iu===null?iu=new Set([this]):iu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Ys(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Hi(t,n,a,!0),n=qa.current,n!==null){switch(n.tag){case 31:case 13:return Ja===null?Ou():n.alternate===null&&Gl===0&&(Gl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ha?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),qu(e,r,a)),!1;case 22:return n.flags|=65536,r===ha?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),qu(e,r,a)),!1}throw Error(i(435,n.tag))}return qu(e,r,a),Ou(),!1}if(wi)return t=qa.current,t===null?(r!==Di&&(t=Error(i(423),{cause:r}),Pi(si(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=si(r,n),a=Ks(e.stateNode,r,a),Ia(e,a),Gl!==4&&(Gl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Di&&(e=Error(i(422),{cause:r}),Pi(si(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=si(o,n),Zl===null?Zl=[o]:Zl.push(o),Gl!==4&&(Gl=2),t===null)return!0;r=si(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ks(n.stateNode,r,e),Ia(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(iu===null||!iu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=qs(a),Js(a,e,n,r),Ia(n,a),!1}n=n.return}while(n!==null);return!1}var Xs=Error(i(461)),Zs=!1;function Qs(e,t,n,r){t.child=e===null?ka(t,null,n,r):Oa(t,e.child,n,r)}function $s(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Wi(t),r=go(e,t,n,o,a,i),s=bo(),e!==null&&!Zs?(xo(e,t,i),Cc(e,t,i)):(wi&&s&&yi(t),t.flags|=1,Qs(e,t,r,i),t.child)}function ec(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Qr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,tc(e,t,a,r,i)):(e=ti(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!wc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?pr:n,n(o,r)&&e.ref===t.ref)return Cc(e,t,i)}return t.flags|=1,e=$r(a,r),e.ref=t.ref,e.return=t,t.child=e}function tc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(pr(a,r)&&e.ref===t.ref)if(Zs=!1,t.pendingProps=r=a,wc(e,i))e.flags&131072&&(Zs=!0);else return t.lanes=e.lanes,Cc(e,t,i)}return lc(e,t,n,r,i)}function nc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return ic(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ua(t,a===null?null:a.cachePool),a===null?Ga():Wa(t,a),Za(t);else return r=t.lanes=536870912,ic(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ua(t,null),Ga(),Qa(t)):(ua(t,a.cachePool),Wa(t,a),Qa(t),t.memoizedState=null);return Qs(e,t,i,n),t.child}function rc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function ic(e,t,n,r,i){var a=la();return a=a===null?null:{parent:Zi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ua(t,null),Ga(),Za(t),e!==null&&Hi(e,t,r,!0),t.childLanes=i,null}function ac(e,t){return t=vc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function oc(e,t,n){return Oa(t,e.child,null,n),e=ac(t,t.pendingProps),e.flags|=2,$a(t),t.memoizedState=null,e}function sc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(wi){if(r.mode===`hidden`)return e=ac(t,r),t.lanes=536870912,rc(null,e);if(Xa(t),(e=Ci)?(e=cf(e,Ei),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:mi===null?null:{id:hi,overflow:gi},retryLane:536870912,hydrationErrors:null},n=ii(e),n.return=t,t.child=n,Si=t,Ci=null)):e=null,e===null)throw Oi(t);return t.lanes=536870912,null}return ac(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Xa(t),a)if(t.flags&256)t.flags&=-257,t=oc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Zs||Hi(e,t,n,!1),a=(n&e.childLanes)!==0,Zs||a){if(r=Il,r!==null&&(s=Je(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Kr(e,s),gu(r,e,s),Xs;Ou(),t=oc(e,t,n)}else e=o.treeContext,Ci=ff(s.nextSibling),Si=t,wi=!0,Ti=null,Ei=!1,e!==null&&xi(t,e),t=ac(t,r),t.flags|=4096;return t}return e=$r(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function cc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function lc(e,t,n,r,i){return Wi(t),n=go(e,t,n,r,void 0,i),r=bo(),e!==null&&!Zs?(xo(e,t,i),Cc(e,t,i)):(wi&&r&&yi(t),t.flags|=1,Qs(e,t,n,i),t.child)}function uc(e,t,n,r,i,a){return Wi(t),t.updateQueue=null,n=vo(t,r,n,i),_o(e),r=bo(),e!==null&&!Zs?(xo(e,t,a),Cc(e,t,a)):(wi&&r&&yi(t),t.flags|=1,Qs(e,t,n,a),t.child)}function dc(e,t,n,r,i){if(Wi(t),t.stateNode===null){var a=Yr,o=n.contextType;typeof o==`object`&&o&&(a=Gi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ls,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ja(t),o=n.contextType,a.context=typeof o==`object`&&o?Gi(o):Yr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Is(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Ls.enqueueReplaceState(a,a.state,null),za(t,r,a,i),Ra(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Bs(n,s);a.props=c;var l=a.context,u=n.contextType;o=Yr,typeof u==`object`&&u&&(o=Gi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&zs(t,a,r,o),Aa=!1;var f=t.memoizedState;a.state=f,za(t,r,a,i),Ra(),l=t.memoizedState,s||f!==l||Aa?(typeof d==`function`&&(Is(t,n,d,r),l=t.memoizedState),(c=Aa||Rs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ma(e,t),o=t.memoizedProps,u=Bs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Yr,typeof l==`object`&&l&&(c=Gi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&zs(t,a,r,c),Aa=!1,f=t.memoizedState,a.state=f,za(t,r,a,i),Ra();var p=t.memoizedState;o!==d||f!==p||Aa||e!==null&&e.dependencies!==null&&Ui(e.dependencies)?(typeof s==`function`&&(Is(t,n,s,r),p=t.memoizedState),(u=Aa||Rs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ui(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,cc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Oa(t,e.child,null,i),t.child=Oa(t,null,n,i)):Qs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Cc(e,t,i),e}function fc(e,t,n,r){return Mi(),t.flags|=256,Qs(e,t,n,r),t.child}var pc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mc(e){return{baseLanes:e,cachePool:da()}}function hc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Yl),e}function gc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(eo.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(wi){if(a?Ya(t):Qa(t),(e=Ci)?(e=cf(e,Ei),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:mi===null?null:{id:hi,overflow:gi},retryLane:536870912,hydrationErrors:null},n=ii(e),n.return=t,t.child=n,Si=t,Ci=null)):e=null,e===null)throw Oi(t);return uf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Qa(t),a=t.mode,c=vc({mode:`hidden`,children:c},a),r=ni(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=mc(n),r.childLanes=hc(e,s,n),t.memoizedState=pc,rc(null,r)):(Ya(t),_c(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ya(t),t.flags&=-257,t=yc(e,t,n)):t.memoizedState===null?(Qa(t),c=r.fallback,a=t.mode,r=vc({mode:`visible`,children:r.children},a),c=ni(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Oa(t,e.child,null,n),r=t.child,r.memoizedState=mc(n),r.childLanes=hc(e,s,n),t.memoizedState=pc,t=rc(null,r)):(Qa(t),t.child=e.child,t.flags|=128,t=null);else if(Ya(t),uf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Pi({value:r,source:null,stack:null}),t=yc(e,t,n)}else if(Zs||Hi(e,t,n,!1),s=(n&e.childLanes)!==0,Zs||s){if(s=Il,s!==null&&(r=Je(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Kr(e,r),gu(s,e,r),Xs;lf(c)||Ou(),t=yc(e,t,n)}else lf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ci=ff(c.nextSibling),Si=t,wi=!0,Ti=null,Ei=!1,e!==null&&xi(t,e),t=_c(t,r.children),t.flags|=4096);return t}return a?(Qa(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=$r(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ni(c,a,n,null),c.flags|=2):c=$r(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,rc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=mc(n):(a=c.cachePool,a===null?a=da():(l=Zi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=hc(e,s,n),t.memoizedState=pc,rc(e.child,r)):(Ya(t),n=e.child,e=n.sibling,n=$r(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function _c(e,t){return t=vc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function vc(e,t){return e=Zr(22,e,null,t),e.lanes=0,e}function yc(e,t,n){return Oa(t,e.child,null,n),e=_c(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function bc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Bi(e.return,t,n)}function xc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Sc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=eo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,V(eo,o),Qs(e,t,r,n),r=wi?di:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&bc(e,n,t);else if(e.tag===19)bc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&to(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),xc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&to(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}xc(t,!0,n,null,a,r);break;case`together`:xc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Cc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Kl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Hi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=$r(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=$r(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function wc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Ui(e))):!0}function Tc(e,t,n){switch(t.tag){case 3:oe(t,t.stateNode.containerInfo),Ri(t,Zi,e.memoizedState.cache),Mi();break;case 27:case 5:ce(t);break;case 4:oe(t,t.stateNode.containerInfo);break;case 10:Ri(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Xa(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ya(t),e=Cc(e,t,n),e===null?null:e.sibling):gc(e,t,n):(Ya(t),t.flags|=128,null);Ya(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Hi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Sc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(eo,eo.current),r)break;return null;case 22:return t.lanes=0,nc(e,t,n,t.pendingProps);case 24:Ri(t,Zi,e.memoizedState.cache)}return Cc(e,t,n)}function Ec(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Zs=!0;else{if(!wc(e,n)&&!(t.flags&128))return Zs=!1,Tc(e,t,n);Zs=!!(e.flags&131072)}else Zs=!1,wi&&t.flags&1048576&&vi(t,di,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=va(t.elementType),t.type=e,typeof e==`function`)Qr(e)?(r=Bs(e,r),t.tag=1,t=dc(null,t,e,r,n)):(t.tag=0,t=lc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=$s(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=ec(null,t,e,r,n);break a}}throw t=P(e)||e,Error(i(306,t,``))}}return t;case 0:return lc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Bs(r,t.pendingProps),dc(e,t,r,a,n);case 3:a:{if(oe(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ma(e,t),za(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ri(t,Zi,r),r!==o.cache&&Vi(t,[Zi],n,!0),Ra(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=fc(e,t,r,n);break a}else if(r!==a){a=si(Error(i(424)),t),Pi(a),t=fc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ci=ff(e.firstChild),Si=t,wi=!0,Ti=null,Ei=!0,n=ka(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Mi(),r===a){t=Cc(e,t,n);break a}Qs(e,t,r,n)}t=t.child}return t;case 26:return cc(e,t),e===null?(n=Nf(t.type,null,t.pendingProps,null))?t.memoizedState=n:wi||(n=t.type,e=t.pendingProps,r=Wd(ie.current).createElement(n),r[et]=t,r[tt]=e,Rd(r,n,e),pt(r),t.stateNode=r):t.memoizedState=Nf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ce(t),e===null&&wi&&(r=t.stateNode=gf(t.type,t.pendingProps,ie.current),Si=t,Ei=!0,a=Ci,tf(t.type)?(pf=a,Ci=ff(r.firstChild)):Ci=a),Qs(e,t,t.pendingProps.children,n),cc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&wi&&((a=r=Ci)&&(r=of(r,t.type,t.pendingProps,Ei),r===null?a=!1:(t.stateNode=r,Si=t,Ci=ff(r.firstChild),Ei=!1,a=!0)),a||Oi(t)),ce(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,qd(a,o)?r=null:s!==null&&qd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=go(e,t,yo,null,null,n),tp._currentValue=a),cc(e,t),Qs(e,t,r,n),t.child;case 6:return e===null&&wi&&((e=n=Ci)&&(n=sf(n,t.pendingProps,Ei),n===null?e=!1:(t.stateNode=n,Si=t,Ci=null,e=!0)),e||Oi(t)),null;case 13:return gc(e,t,n);case 4:return oe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Oa(t,null,r,n):Qs(e,t,r,n),t.child;case 11:return $s(e,t,t.type,t.pendingProps,n);case 7:return Qs(e,t,t.pendingProps,n),t.child;case 8:return Qs(e,t,t.pendingProps.children,n),t.child;case 12:return Qs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ri(t,t.type,r.value),Qs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Wi(t),a=Gi(a),r=r(a),t.flags|=1,Qs(e,t,r,n),t.child;case 14:return ec(e,t,t.type,t.pendingProps,n);case 15:return tc(e,t,t.type,t.pendingProps,n);case 19:return Sc(e,t,n);case 31:return sc(e,t,n);case 22:return nc(e,t,n,t.pendingProps);case 24:return Wi(t),r=Gi(Zi),e===null?(a=la(),a===null&&(a=Il,o=Qi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},ja(t),Ri(t,Zi,a)):((e.lanes&n)!==0&&(Ma(e,t),za(t,null,null,n),Ra()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ri(t,Zi,r),r!==a.cache&&Vi(t,[Zi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ri(t,Zi,r))),Qs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Dc(e){e.flags|=4}function Oc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Tu())e.flags|=8192;else throw ya=ha,pa}else e.flags&=-16777217}function kc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Jf(t))if(Tu())e.flags|=8192;else throw ya=ha,pa}function Ac(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:He(),e.lanes|=t,Xl|=t)}function jc(e,t){if(!wi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Mc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Nc(e,t,n){var r=t.pendingProps;switch(bi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mc(t),null;case 1:return Mc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),zi(Zi),se(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ji(t)?Dc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ni())),Mc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Dc(t),o===null?(Mc(t),Oc(t,a,null,r,n)):(Mc(t),kc(t,o))):o?o===e.memoizedState?(Mc(t),t.flags&=-16777217):(Dc(t),Mc(t),kc(t,o)):(e=e.memoizedProps,e!==r&&Dc(t),Mc(t),Oc(t,a,e,r,n)),null;case 27:if(H(t),n=ie.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Dc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Mc(t),null}e=ne.current,ji(t)?ki(t,e):(e=gf(a,r,n),t.stateNode=e,Dc(t))}return Mc(t),null;case 5:if(H(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Dc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Mc(t),null}if(o=ne.current,ji(t))ki(t,o);else{var s=Wd(ie.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[et]=t,o[tt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Rd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Dc(t)}}return Mc(t),Oc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Dc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ie.current,ji(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Si,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[et]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Fd(e.nodeValue,n)),e||Oi(t,!0)}else e=Wd(e).createTextNode(r),e[et]=t,t.stateNode=e}return Mc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ji(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[et]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Mc(t),e=!1}else n=Ni(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?($a(t),t):($a(t),null);if(t.flags&128)throw Error(i(558))}return Mc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ji(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[et]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Mc(t),a=!1}else a=Ni(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?($a(t),t):($a(t),null)}return $a(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Ac(t,t.updateQueue),Mc(t),null);case 4:return se(),e===null&&Td(t.stateNode.containerInfo),Mc(t),null;case 10:return zi(t.type),Mc(t),null;case 19:if(B(eo),r=t.memoizedState,r===null)return Mc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)jc(r,!1);else{if(Gl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=to(e),o!==null){for(t.flags|=128,jc(r,!1),e=o.updateQueue,t.updateQueue=e,Ac(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ei(n,e),n=n.sibling;return V(eo,eo.current&1|2),wi&&_i(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&xe()>nu&&(t.flags|=128,a=!0,jc(r,!1),t.lanes=4194304)}else{if(!a)if(e=to(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Ac(t,e),jc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!wi)return Mc(t),null}else 2*xe()-r.renderingStartTime>nu&&n!==536870912&&(t.flags|=128,a=!0,jc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Mc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=xe(),e.sibling=null,n=eo.current,V(eo,a?n&1|2:n&1),wi&&_i(t,r.treeForkCount),e);case 22:case 23:return $a(t),Ka(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Mc(t),t.subtreeFlags&6&&(t.flags|=8192)):Mc(t),n=t.updateQueue,n!==null&&Ac(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&B(ca),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),zi(Zi),Mc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Pc(e,t){switch(bi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zi(Zi),se(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return H(t),null;case 31:if(t.memoizedState!==null){if($a(t),t.alternate===null)throw Error(i(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if($a(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(eo),null;case 4:return se(),null;case 10:return zi(t.type),null;case 22:case 23:return $a(t),Ka(),e!==null&&B(ca),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zi(Zi),null;case 25:return null;default:return null}}function Fc(e,t){switch(bi(t),t.tag){case 3:zi(Zi),se();break;case 26:case 27:case 5:H(t);break;case 4:se();break;case 31:t.memoizedState!==null&&$a(t);break;case 13:$a(t);break;case 19:B(eo);break;case 10:zi(t.type);break;case 22:case 23:$a(t),Ka(),e!==null&&B(ca);break;case 24:zi(Zi)}}function Ic(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Ku(t,t.return,e)}}function Lc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Ku(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Ku(t,t.return,e)}}function Rc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Va(t,n)}catch(t){Ku(e,e.return,t)}}}function zc(e,t,n){n.props=Bs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Ku(e,t,n)}}function Bc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Ku(e,t,n)}}function Vc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Ku(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Ku(e,t,n)}else n.current=null}function Hc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Ku(e,e.return,t)}}function Uc(e,t,n){try{var r=e.stateNode;zd(r,e.type,n,t),r[tt]=t}catch(t){Ku(e,e.return,t)}}function Wc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&tf(e.type)||e.tag===4}function Gc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Wc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&tf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Kc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=qt));else if(r!==4&&(r===27&&tf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Kc(e,t,n),e=e.sibling;e!==null;)Kc(e,t,n),e=e.sibling}function qc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&tf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(qc(e,t,n),e=e.sibling;e!==null;)qc(e,t,n),e=e.sibling}function Jc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Rd(t,r,n),t[et]=e,t[tt]=n}catch(t){Ku(e,e.return,t)}}var Yc=!1,Xc=!1,Zc=!1,Qc=typeof WeakSet==`function`?WeakSet:Set,$c=null;function el(e,t){if(e=e.containerInfo,Hd=up,e=_r(e),vr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ud={focusedElem:e,selectionRange:n},up=!1,$c=t;$c!==null;)if(t=$c,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,$c=e;else for(;$c!==null;){switch(t=$c,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Bs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Ku(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)af(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:af(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,$c=e;break}$c=t.return}}function tl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:gl(e,n),r&4&&Ic(5,n);break;case 1:if(gl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Ku(n,n.return,e)}else{var i=Bs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Ku(n,n.return,e)}}r&64&&Rc(n),r&512&&Bc(n,n.return);break;case 3:if(gl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Va(e,t)}catch(e){Ku(n,n.return,e)}}break;case 27:t===null&&r&4&&Jc(n);case 26:case 5:gl(e,n),t===null&&r&4&&Hc(n),r&512&&Bc(n,n.return);break;case 12:gl(e,n);break;case 31:gl(e,n),r&4&&sl(e,n);break;case 13:gl(e,n),r&4&&cl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Xu.bind(null,n),df(e,n))));break;case 22:if(r=n.memoizedState!==null||Yc,!r){t=t!==null&&t.memoizedState!==null||Xc,i=Yc;var a=Xc;Yc=r,(Xc=t)&&!a?vl(e,n,(n.subtreeFlags&8772)!=0):gl(e,n),Yc=i,Xc=a}break;case 30:break;default:gl(e,n)}}function nl(e){var t=e.alternate;t!==null&&(e.alternate=null,nl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ct(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var rl=null,il=!1;function al(e,t,n){for(n=n.child;n!==null;)ol(e,t,n),n=n.sibling}function ol(e,t,n){if(ke&&typeof ke.onCommitFiberUnmount==`function`)try{ke.onCommitFiberUnmount(Oe,n)}catch{}switch(n.tag){case 26:Xc||Vc(n,t),al(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Xc||Vc(n,t);var r=rl,i=il;tf(n.type)&&(rl=n.stateNode,il=!1),al(e,t,n),_f(n.stateNode),rl=r,il=i;break;case 5:Xc||Vc(n,t);case 6:if(r=rl,i=il,rl=null,al(e,t,n),rl=r,il=i,rl!==null)if(il)try{(rl.nodeType===9?rl.body:rl.nodeName===`HTML`?rl.ownerDocument.body:rl).removeChild(n.stateNode)}catch(e){Ku(n,t,e)}else try{rl.removeChild(n.stateNode)}catch(e){Ku(n,t,e)}break;case 18:rl!==null&&(il?(e=rl,nf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Ip(e)):nf(rl,n.stateNode));break;case 4:r=rl,i=il,rl=n.stateNode.containerInfo,il=!0,al(e,t,n),rl=r,il=i;break;case 0:case 11:case 14:case 15:Lc(2,n,t),Xc||Lc(4,n,t),al(e,t,n);break;case 1:Xc||(Vc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&zc(n,t,r)),al(e,t,n);break;case 21:al(e,t,n);break;case 22:Xc=(r=Xc)||n.memoizedState!==null,al(e,t,n),Xc=r;break;default:al(e,t,n)}}function sl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ip(e)}catch(e){Ku(t,t.return,e)}}}function cl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ip(e)}catch(e){Ku(t,t.return,e)}}function ll(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Qc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Qc),t;default:throw Error(i(435,e.tag))}}function ul(e,t){var n=ll(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Zu.bind(null,e,t);t.then(r,r)}})}function dl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(tf(c.type)){rl=c.stateNode,il=!1;break a}break;case 5:rl=c.stateNode,il=!1;break a;case 3:case 4:rl=c.stateNode.containerInfo,il=!0;break a}c=c.return}if(rl===null)throw Error(i(160));ol(o,s,a),rl=null,il=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)pl(t,e),t=t.sibling}var fl=null;function pl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:dl(t,e),ml(e),r&4&&(Lc(3,e,e.return),Ic(3,e),Lc(5,e,e.return));break;case 1:dl(t,e),ml(e),r&512&&(Xc||n===null||Vc(n,n.return)),r&64&&Yc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=fl;if(dl(t,e),ml(e),r&512&&(Xc||n===null||Vc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[st]||o[et]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Rd(o,r,n),o[et]=e,pt(o),r=o;break a;case`link`:var s=Gf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Rd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Gf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Rd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[et]=e,pt(o),r=o}e.stateNode=r}else Kf(a,e.type,e.stateNode);else e.stateNode=Bf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Uc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Kf(a,e.type,e.stateNode):Bf(a,r,e.memoizedProps))}break;case 27:dl(t,e),ml(e),r&512&&(Xc||n===null||Vc(n,n.return)),n!==null&&r&4&&Uc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(dl(t,e),ml(e),r&512&&(Xc||n===null||Vc(n,n.return)),e.flags&32){a=e.stateNode;try{zt(a,``)}catch(t){Ku(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Uc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Zc=!0);break;case 6:if(dl(t,e),ml(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Ku(e,e.return,t)}}break;case 3:if(Wf=null,a=fl,fl=bf(t.containerInfo),dl(t,e),fl=a,ml(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Ip(t.containerInfo)}catch(t){Ku(e,e.return,t)}Zc&&(Zc=!1,hl(e));break;case 4:r=fl,fl=bf(e.stateNode.containerInfo),dl(t,e),ml(e),fl=r;break;case 12:dl(t,e),ml(e);break;case 31:dl(t,e),ml(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ul(e,r)));break;case 13:dl(t,e),ml(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(eu=xe()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ul(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Yc,d=Xc;if(Yc=u||a,Xc=d||l,dl(t,e),Xc=d,Yc=u,ml(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||Yc||Xc||_l(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Ku(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Ku(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?rf(m,!0):rf(l.stateNode,!1)}catch(e){Ku(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,ul(e,n))));break;case 19:dl(t,e),ml(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ul(e,r)));break;case 30:break;case 21:break;default:dl(t,e),ml(e)}}function ml(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Wc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;qc(e,Gc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(zt(o,``),n.flags&=-33),qc(e,Gc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Kc(e,Gc(e),s);break;default:throw Error(i(161))}}catch(t){Ku(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function hl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;hl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function gl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)tl(e,t.alternate,t),t=t.sibling}function _l(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Lc(4,t,t.return),_l(t);break;case 1:Vc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&zc(t,t.return,n),_l(t);break;case 27:_f(t.stateNode);case 26:case 5:Vc(t,t.return),_l(t);break;case 22:t.memoizedState===null&&_l(t);break;case 30:_l(t);break;default:_l(t)}e=e.sibling}}function vl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:vl(i,a,n),Ic(4,a);break;case 1:if(vl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Ku(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ba(c[i],s)}catch(e){Ku(r,r.return,e)}}n&&o&64&&Rc(a),Bc(a,a.return);break;case 27:Jc(a);case 26:case 5:vl(i,a,n),n&&r===null&&o&4&&Hc(a),Bc(a,a.return);break;case 12:vl(i,a,n);break;case 31:vl(i,a,n),n&&o&4&&sl(i,a);break;case 13:vl(i,a,n),n&&o&4&&cl(i,a);break;case 22:a.memoizedState===null&&vl(i,a,n),Bc(a,a.return);break;case 30:break;default:vl(i,a,n)}t=t.sibling}}function yl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&$i(n))}function bl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&$i(e))}function xl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Sl(e,t,n,r),t=t.sibling}function Sl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:xl(e,t,n,r),i&2048&&Ic(9,t);break;case 1:xl(e,t,n,r);break;case 3:xl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&$i(e)));break;case 12:if(i&2048){xl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Ku(t,t.return,e)}}else xl(e,t,n,r);break;case 31:xl(e,t,n,r);break;case 13:xl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?xl(e,t,n,r):(a._visibility|=2,Cl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?xl(e,t,n,r):wl(e,t),i&2048&&yl(o,t);break;case 24:xl(e,t,n,r),i&2048&&bl(t.alternate,t);break;default:xl(e,t,n,r)}}function Cl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Cl(a,o,s,c,i),Ic(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Cl(a,o,s,c,i)):u._visibility&2?Cl(a,o,s,c,i):wl(a,o),i&&l&2048&&yl(o.alternate,o);break;case 24:Cl(a,o,s,c,i),i&&l&2048&&bl(o.alternate,o);break;default:Cl(a,o,s,c,i)}t=t.sibling}}function wl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:wl(n,r),i&2048&&yl(r.alternate,r);break;case 24:wl(n,r),i&2048&&bl(r.alternate,r);break;default:wl(n,r)}t=t.sibling}}var Tl=8192;function El(e,t,n){if(e.subtreeFlags&Tl)for(e=e.child;e!==null;)Dl(e,t,n),e=e.sibling}function Dl(e,t,n){switch(e.tag){case 26:El(e,t,n),e.flags&Tl&&e.memoizedState!==null&&Yf(n,fl,e.memoizedState,e.memoizedProps);break;case 5:El(e,t,n);break;case 3:case 4:var r=fl;fl=bf(e.stateNode.containerInfo),El(e,t,n),fl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Tl,Tl=16777216,El(e,t,n),Tl=r):El(e,t,n));break;default:El(e,t,n)}}function Ol(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];$c=r,Ml(r,e)}Ol(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Al(e),e=e.sibling}function Al(e){switch(e.tag){case 0:case 11:case 15:kl(e),e.flags&2048&&Lc(9,e,e.return);break;case 3:kl(e);break;case 12:kl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,jl(e)):kl(e);break;default:kl(e)}}function jl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];$c=r,Ml(r,e)}Ol(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Lc(8,t,t.return),jl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,jl(t));break;default:jl(t)}e=e.sibling}}function Ml(e,t){for(;$c!==null;){var n=$c;switch(n.tag){case 0:case 11:case 15:Lc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:$i(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,$c=r;else a:for(n=e;$c!==null;){r=$c;var i=r.sibling,a=r.return;if(nl(r),r===n){$c=null;break a}if(i!==null){i.return=a,$c=i;break a}$c=a}}}var Nl={getCacheForType:function(e){var t=Gi(Zi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Gi(Zi).controller.signal}},Pl=typeof WeakMap==`function`?WeakMap:Map,Fl=0,Il=null,Ll=null,Rl=0,zl=0,Bl=null,Vl=!1,Hl=!1,Ul=!1,Wl=0,Gl=0,Kl=0,ql=0,Jl=0,Yl=0,Xl=0,Zl=null,Ql=null,$l=!1,eu=0,tu=0,nu=1/0,ru=null,iu=null,au=0,ou=null,su=null,cu=0,lu=0,uu=null,du=null,fu=0,pu=null;function mu(){return Fl&2&&Rl!==0?Rl&-Rl:I.T===null?Ze():pd()}function hu(){if(Yl===0)if(!(Rl&536870912)||wi){var e=Ie;Ie<<=1,!(Ie&3932160)&&(Ie=262144),Yl=e}else Yl=536870912;return e=qa.current,e!==null&&(e.flags|=32),Yl}function gu(e,t,n){(e===Il&&(zl===2||zl===9)||e.cancelPendingCommit!==null)&&(Cu(e,0),bu(e,Rl,Yl,!1)),We(e,n),(!(Fl&2)||e!==Il)&&(e===Il&&(!(Fl&2)&&(ql|=n),Gl===4&&bu(e,Rl,Yl,!1)),ad(e))}function _u(e,t,n){if(Fl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Be(e,t),a=r?ju(e,t):ku(e,t,!0),o=r;do{if(a===0){Hl&&!r&&bu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!yu(n)){a=ku(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Zl;var l=c.current.memoizedState.isDehydrated;if(l&&(Cu(c,s).flags|=256),s=ku(c,s,!1),s!==2){if(Ul&&!l){c.errorRecoveryDisabledLanes|=o,ql|=o,a=4;break a}o=Ql,Ql=a,o!==null&&(Ql===null?Ql=o:Ql.push.apply(Ql,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Cu(e,0),bu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:bu(r,t,Yl,!Vl);break a;case 2:Ql=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=eu+300-xe(),10<a)){if(bu(r,t,Yl,!Vl),ze(r,0,!0)!==0)break a;cu=t,r.timeoutHandle=Xd(vu.bind(null,r,n,Ql,ru,$l,t,Yl,ql,Xl,Vl,o,`Throttled`,-0,0),a);break a}vu(r,n,Ql,ru,$l,t,Yl,ql,Xl,Vl,o,null,-0,0)}}break}while(1);ad(e)}function vu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:qt},Dl(t,a,d);var m=(a&62914560)===a?eu-xe():(a&4194048)===a?tu-xe():0;if(m=Zf(d,m),m!==null){cu=a,e.cancelPendingCommit=m(Ru.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),bu(e,a,o,!l);return}}Ru(e,t,a,n,r,i,o,s,c)}function yu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!fr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function bu(e,t,n,r){t&=~Jl,t&=~ql,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-je(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Ke(e,n,t)}function xu(){return Fl&6?!0:(od(0,!1),!1)}function Su(){if(Ll!==null){if(zl===0)var e=Ll.return;else e=Ll,Li=Ii=null,So(e),Sa=null,Ca=0,e=Ll;for(;e!==null;)Fc(e.alternate,e),e=e.return;Ll=null}}function Cu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Zd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),cu=0,Su(),Il=e,Ll=n=$r(e.current,null),Rl=t,zl=0,Bl=null,Vl=!1,Hl=Be(e,t),Ul=!1,Xl=Yl=Jl=ql=Kl=Gl=0,Ql=Zl=null,$l=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-je(r),a=1<<i;t|=e[i],r&=~a}return Wl=t,Ur(),n}function wu(e,t){ro=null,I.H=Ms,t===fa||t===ma?(t=ba(),zl=3):t===pa?(t=ba(),zl=4):zl=t===Xs?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Bl=t,Ll===null&&(Gl=1,Ws(e,si(t,e.current)))}function Tu(){var e=qa.current;return e===null?!0:(Rl&4194048)===Rl?Ja===null:(Rl&62914560)===Rl||Rl&536870912?e===Ja:!1}function Eu(){var e=I.H;return I.H=Ms,e===null?Ms:e}function Du(){var e=I.A;return I.A=Nl,e}function Ou(){Gl=4,Vl||(Rl&4194048)!==Rl&&qa.current!==null||(Hl=!0),!(Kl&134217727)&&!(ql&134217727)||Il===null||bu(Il,Rl,Yl,!1)}function ku(e,t,n){var r=Fl;Fl|=2;var i=Eu(),a=Du();(Il!==e||Rl!==t)&&(ru=null,Cu(e,t)),t=!1;var o=Gl;a:do try{if(zl!==0&&Ll!==null){var s=Ll,c=Bl;switch(zl){case 8:Su(),o=6;break a;case 3:case 2:case 9:case 6:qa.current===null&&(t=!0);var l=zl;if(zl=0,Bl=null,Fu(e,s,c,l),n&&Hl){o=0;break a}break;default:l=zl,zl=0,Bl=null,Fu(e,s,c,l)}}Au(),o=Gl;break}catch(t){wu(e,t)}while(1);return t&&e.shellSuspendCounter++,Li=Ii=null,Fl=r,I.H=i,I.A=a,Ll===null&&(Il=null,Rl=0,Ur()),o}function Au(){for(;Ll!==null;)Nu(Ll)}function ju(e,t){var n=Fl;Fl|=2;var r=Eu(),a=Du();Il!==e||Rl!==t?(ru=null,nu=xe()+500,Cu(e,t)):Hl=Be(e,t);a:do try{if(zl!==0&&Ll!==null){t=Ll;var o=Bl;b:switch(zl){case 1:zl=0,Bl=null,Fu(e,t,o,1);break;case 2:case 9:if(ga(o)){zl=0,Bl=null,Pu(t);break}t=function(){zl!==2&&zl!==9||Il!==e||(zl=7),ad(e)},o.then(t,t);break a;case 3:zl=7;break a;case 4:zl=5;break a;case 7:ga(o)?(zl=0,Bl=null,Pu(t)):(zl=0,Bl=null,Fu(e,t,o,7));break;case 5:var s=null;switch(Ll.tag){case 26:s=Ll.memoizedState;case 5:case 27:var c=Ll;if(s?Jf(s):c.stateNode.complete){zl=0,Bl=null;var l=c.sibling;if(l!==null)Ll=l;else{var u=c.return;u===null?Ll=null:(Ll=u,Iu(u))}break b}}zl=0,Bl=null,Fu(e,t,o,5);break;case 6:zl=0,Bl=null,Fu(e,t,o,6);break;case 8:Su(),Gl=6;break a;default:throw Error(i(462))}}Mu();break}catch(t){wu(e,t)}while(1);return Li=Ii=null,I.H=r,I.A=a,Fl=n,Ll===null?(Il=null,Rl=0,Ur(),Gl):0}function Mu(){for(;Ll!==null&&!ye();)Nu(Ll)}function Nu(e){var t=Ec(e.alternate,e,Wl);e.memoizedProps=e.pendingProps,t===null?Iu(e):Ll=t}function Pu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=uc(n,t,t.pendingProps,t.type,void 0,Rl);break;case 11:t=uc(n,t,t.pendingProps,t.type.render,t.ref,Rl);break;case 5:So(t);default:Fc(n,t),t=Ll=ei(t,Wl),t=Ec(n,t,Wl)}e.memoizedProps=e.pendingProps,t===null?Iu(e):Ll=t}function Fu(e,t,n,r){Li=Ii=null,So(t),Sa=null,Ca=0;var i=t.return;try{if(Ys(e,i,t,n,Rl)){Gl=1,Ws(e,si(n,e.current)),Ll=null;return}}catch(t){if(i!==null)throw Ll=i,t;Gl=1,Ws(e,si(n,e.current)),Ll=null;return}t.flags&32768?(wi||r===1?e=!0:Hl||Rl&536870912?e=!1:(Vl=e=!0,(r===2||r===9||r===3||r===6)&&(r=qa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Lu(t,e)):Iu(t)}function Iu(e){var t=e;do{if(t.flags&32768){Lu(t,Vl);return}e=t.return;var n=Nc(t.alternate,t,Wl);if(n!==null){Ll=n;return}if(t=t.sibling,t!==null){Ll=t;return}Ll=t=e}while(t!==null);Gl===0&&(Gl=5)}function Lu(e,t){do{var n=Pc(e.alternate,e);if(n!==null){n.flags&=32767,Ll=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ll=e;return}Ll=e=n}while(e!==null);Gl=6,Ll=null}function Ru(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Uu();while(au!==0);if(Fl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Hr,Ge(e,n,o,s,c,l),e===Il&&(Ll=Il=null,Rl=0),su=t,ou=e,cu=n,lu=o,uu=a,du=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Qu(we,function(){return Wu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=I.T,I.T=null,a=L.p,L.p=2,s=Fl,Fl|=4;try{el(e,t,n)}finally{Fl=s,L.p=a,I.T=r}}au=1,zu(),Bu(),Vu()}}function zu(){if(au===1){au=0;var e=ou,t=su,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Fl;Fl|=4;try{pl(t,e);var a=Ud,o=_r(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&gr(s.ownerDocument.documentElement,s)){if(c!==null&&vr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=hr(s,h),v=hr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}up=!!Hd,Ud=Hd=null}finally{Fl=i,L.p=r,I.T=n}}e.current=t,au=2}}function Bu(){if(au===2){au=0;var e=ou,t=su,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Fl;Fl|=4;try{tl(e,t.alternate,t)}finally{Fl=i,L.p=r,I.T=n}}au=3}}function Vu(){if(au===4||au===3){au=0,be();var e=ou,t=su,n=cu,r=du;t.subtreeFlags&10256||t.flags&10256?au=5:(au=0,su=ou=null,Hu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(iu=null),Xe(n),t=t.stateNode,ke&&typeof ke.onCommitFiberRoot==`function`)try{ke.onCommitFiberRoot(Oe,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=I.T,i=L.p,L.p=2,I.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{I.T=t,L.p=i}}cu&3&&Uu(),ad(e),i=e.pendingLanes,n&261930&&i&42?e===pu?fu++:(fu=0,pu=e):fu=0,od(0,!1)}}function Hu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,$i(t)))}function Uu(){return zu(),Bu(),Vu(),Wu()}function Wu(){if(au!==5)return!1;var e=ou,t=lu;lu=0;var n=Xe(cu),r=I.T,a=L.p;try{L.p=32>n?32:n,I.T=null,n=uu,uu=null;var o=ou,s=cu;if(au=0,su=ou=null,cu=0,Fl&6)throw Error(i(331));var c=Fl;if(Fl|=4,Al(o.current),Sl(o,o.current,s,n),Fl=c,od(0,!1),ke&&typeof ke.onPostCommitFiberRoot==`function`)try{ke.onPostCommitFiberRoot(Oe,o)}catch{}return!0}finally{L.p=a,I.T=r,Hu(e,t)}}function Gu(e,t,n){t=si(n,t),t=Ks(e.stateNode,t,2),e=Pa(e,t,2),e!==null&&(We(e,2),ad(e))}function Ku(e,t,n){if(e.tag===3)Gu(e,e,n);else for(;t!==null;){if(t.tag===3){Gu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(iu===null||!iu.has(r))){e=si(n,e),n=qs(2),r=Pa(t,n,2),r!==null&&(Js(n,r,t,e),We(r,2),ad(r));break}}t=t.return}}function qu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Pl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ul=!0,i.add(n),e=Ju.bind(null,e,t,n),t.then(e,e))}function Ju(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Il===e&&(Rl&n)===n&&(Gl===4||Gl===3&&(Rl&62914560)===Rl&&300>xe()-eu?!(Fl&2)&&Cu(e,0):Jl|=n,Xl===Rl&&(Xl=0)),ad(e)}function Yu(e,t){t===0&&(t=He()),e=Kr(e,t),e!==null&&(We(e,t),ad(e))}function Xu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Yu(e,n)}function Zu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Yu(e,n)}function Qu(e,t){return _e(e,t)}var $u=null,ed=null,td=!1,nd=!1,rd=!1,id=0;function ad(e){e!==ed&&e.next===null&&(ed===null?$u=ed=e:ed=ed.next=e),nd=!0,td||(td=!0,fd())}function od(e,t){if(!rd&&nd){rd=!0;do for(var n=!1,r=$u;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-je(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,dd(r,a))}else a=Rl,a=ze(r,r===Il?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Be(r,a)||(n=!0,dd(r,a));r=r.next}while(n);rd=!1}}function sd(){cd()}function cd(){nd=td=!1;var e=0;id!==0&&Yd()&&(e=id);for(var t=xe(),n=null,r=$u;r!==null;){var i=r.next,a=ld(r,t);a===0?(r.next=null,n===null?$u=i:n.next=i,i===null&&(ed=n)):(n=r,(e!==0||a&3)&&(nd=!0)),r=i}au!==0&&au!==5||od(e,!1),id!==0&&(id=0)}function ld(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-je(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ve(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Il,n=Rl,n=ze(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(zl===2||zl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ve(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Be(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ve(r),Xe(n)){case 2:case 8:n=Ce;break;case 32:n=we;break;case 268435456:n=W;break;default:n=we}return r=ud.bind(null,e),n=_e(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ve(r),e.callbackPriority=2,e.callbackNode=null,2}function ud(e,t){if(au!==0&&au!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Uu()&&e.callbackNode!==n)return null;var r=Rl;return r=ze(e,e===Il?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(_u(e,r,t),ld(e,xe()),e.callbackNode!=null&&e.callbackNode===n?ud.bind(null,e):null)}function dd(e,t){if(Uu())return null;_u(e,t,!0)}function fd(){$d(function(){Fl&6?_e(U,sd):cd()})}function pd(){if(id===0){var e=na;e===0&&(e=Fe,Fe<<=1,!(Fe&261888)&&(Fe=256)),id=e}return id}function md(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Kt(``+e)}function hd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function gd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=md((i[tt]||null).action),o=r.submitter;o&&(t=(t=o[tt]||null)?md(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new mn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(id!==0){var e=o?hd(i,o):new FormData(i);vs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?hd(i,o):new FormData(i),vs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var _d=0;_d<Y.length;_d++){var vd=Y[_d];Rr(vd.toLowerCase(),`on`+(vd[0].toUpperCase()+vd.slice(1)))}Rr(Ar,`onAnimationEnd`),Rr(jr,`onAnimationIteration`),Rr(Mr,`onAnimationStart`),Rr(`dblclick`,`onDoubleClick`),Rr(`focusin`,`onFocus`),Rr(`focusout`,`onBlur`),Rr(Nr,`onTransitionRun`),Rr(Pr,`onTransitionStart`),Rr(Fr,`onTransitionCancel`),Rr(Ir,`onTransitionEnd`),_t(`onMouseEnter`,[`mouseout`,`mouseover`]),_t(`onMouseLeave`,[`mouseout`,`mouseover`]),_t(`onPointerEnter`,[`pointerout`,`pointerover`]),_t(`onPointerLeave`,[`pointerout`,`pointerover`]),gt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),gt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),gt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),gt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),gt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),gt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var yd=`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(` `),bd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(yd));function xd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){zr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){zr(e)}i.currentTarget=null,a=c}}}}function Sd(e,t){var n=t[rt];n===void 0&&(n=t[rt]=new Set);var r=e+`__bubble`;n.has(r)||(Ed(t,e,2,!1),n.add(r))}function Cd(e,t,n){var r=0;t&&(r|=4),Ed(n,e,r,t)}var wd=`_reactListening`+Math.random().toString(36).slice(2);function Td(e){if(!e[wd]){e[wd]=!0,mt.forEach(function(t){t!==`selectionchange`&&(bd.has(t)||Cd(t,!1,e),Cd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[wd]||(t[wd]=!0,Cd(`selectionchange`,!1,t))}}function Ed(e,t,n,r){switch(_p(t)){case 2:var i=dp;break;case 8:i=fp;break;default:i=pp}n=i.bind(null,t,n,e),i=void 0,!nn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Dd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=lt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}$t(function(){var r=a,i=Yt(n),s=[];a:{var c=Lr.get(e);if(c!==void 0){var l=mn,u=e;switch(e){case`keypress`:if(ln(n)===0)break a;case`keydown`:case`keyup`:l=K;break;case`focusin`:u=`focus`,l=Cn;break;case`focusout`:u=`blur`,l=Cn;break;case`beforeblur`:case`afterblur`:l=Cn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=xn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Sn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=q;break;case Ar:case jr:case Mr:l=wn;break;case Ir:l=Nn;break;case`scroll`:case`scrollend`:l=gn;break;case`wheel`:l=Pn;break;case`copy`:case`cut`:case`paste`:l=Tn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Mn;break;case`toggle`:case`beforetoggle`:l=Fn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=en(m,p),g!=null&&d.push(Od(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Jt&&(u=n.relatedTarget||n.fromElement)&&(lt(u)||u[nt]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?lt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=xn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Mn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:dt(l),h=u==null?c:dt(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,lt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ad,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&jd(s,c,l,d,!1),u!==null&&f!==null&&jd(s,f,u,d,!0)}}a:{if(c=r?dt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=tr;else if(Yn(c))if(nr)v=ur;else{v=cr;var y=sr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Ut(r.elementType)&&(v=tr):v=lr;if(v&&=v(e,r)){Xn(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Ft(c,`number`,c.value)}switch(y=r?dt(r):window,e){case`focusin`:(Yn(y)||y.contentEditable===`true`)&&(br=y,xr=r,Sr=null);break;case`focusout`:Sr=xr=br=null;break;case`mousedown`:Cr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Cr=!1,wr(s,n,i);break;case`selectionchange`:if(yr)break;case`keydown`:case`keyup`:wr(s,n,i)}var b;if(Ln)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Gn?Un(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Bn&&n.locale!==`ko`&&(Gn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Gn&&(b=cn()):(an=i,on=`value`in an?an.value:an.textContent,Gn=!0)),y=kd(r,x),0<y.length&&(x=new En(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Wn(n),b!==null&&(x.data=b)))),(b=zn?Kn(e,n):qn(e,n))&&(x=kd(r,`onBeforeInput`),0<x.length&&(y=new En(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),gd(s,e,r,n,i)}xd(s,t)})}function Od(e,t,n){return{instance:e,listener:t,currentTarget:n}}function kd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=en(e,n),i!=null&&r.unshift(Od(e,i,a)),i=en(e,t),i!=null&&r.push(Od(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ad(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function jd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=en(n,a),l!=null&&o.unshift(Od(n,l,c))):i||(l=en(n,a),l!=null&&o.push(Od(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Md=/\r\n?/g,Nd=/\u0000|\uFFFD/g;function Pd(e){return(typeof e==`string`?e:``+e).replace(Md,`
|
||
`).replace(Nd,``)}function Fd(e,t){return t=Pd(t),Pd(e)===t}function Id(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||zt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&zt(e,``+r);break;case`className`:Ct(e,`class`,r);break;case`tabIndex`:Ct(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ct(e,n,r);break;case`style`:Ht(e,r,o);break;case`data`:if(t!==`object`){Ct(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Kt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Id(e,t,`name`,a.name,a,null),Id(e,t,`formEncType`,a.formEncType,a,null),Id(e,t,`formMethod`,a.formMethod,a,null),Id(e,t,`formTarget`,a.formTarget,a,null)):(Id(e,t,`encType`,a.encType,a,null),Id(e,t,`method`,a.method,a,null),Id(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Kt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=qt);break;case`onScroll`:r!=null&&Sd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Sd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Kt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Sd(`beforetoggle`,e),Sd(`toggle`,e),St(e,`popover`,r);break;case`xlinkActuate`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:St(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Wt.get(n)||n,St(e,n,r))}}function Ld(e,t,n,r,a,o){switch(n){case`style`:Ht(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?zt(e,r):(typeof r==`number`||typeof r==`bigint`)&&zt(e,``+r);break;case`onScroll`:r!=null&&Sd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Sd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=qt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!ht.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[tt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):St(e,n,r)}}}function Rd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Sd(`error`,e),Sd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Id(e,t,o,s,n,null)}}a&&Id(e,t,`srcSet`,n.srcSet,n,null),r&&Id(e,t,`src`,n.src,n,null);return;case`input`:Sd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Id(e,t,r,d,n,null)}}Pt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Sd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Id(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&It(e,!!r,n,!0):It(e,!!r,t,!1);return;case`textarea`:for(s in Sd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Id(e,t,s,c,n,null)}Rt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Id(e,t,l,r,n,null)}return;case`dialog`:Sd(`beforetoggle`,e),Sd(`toggle`,e),Sd(`cancel`,e),Sd(`close`,e);break;case`iframe`:case`object`:Sd(`load`,e);break;case`video`:case`audio`:for(r=0;r<yd.length;r++)Sd(yd[r],e);break;case`image`:Sd(`error`,e),Sd(`load`,e);break;case`details`:Sd(`toggle`,e);break;case`embed`:case`source`:case`link`:Sd(`error`,e),Sd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Id(e,t,u,r,n,null)}return;default:if(Ut(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Ld(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Id(e,t,c,r,n,null))}function zd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Id(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Id(e,t,p,m,r,f)}}Nt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Id(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Id(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?It(e,!!n,n?[]:``,!1):It(e,!!n,t,!0)):It(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Id(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Id(e,t,s,a,r,o)}Lt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Id(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Id(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Id(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Id(e,t,u,p,r,m)}return;default:if(Ut(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Ld(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Ld(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Id(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Id(e,t,f,p,r,m)}function Bd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Vd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Bd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Bd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Hd=null,Ud=null;function Wd(e){return e.nodeType===9?e:e.ownerDocument}function Gd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Kd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function qd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Jd=null;function Yd(){var e=window.event;return e&&e.type===`popstate`?e===Jd?!1:(Jd=e,!0):(Jd=null,!1)}var Xd=typeof setTimeout==`function`?setTimeout:void 0,Zd=typeof clearTimeout==`function`?clearTimeout:void 0,Qd=typeof Promise==`function`?Promise:void 0,$d=typeof queueMicrotask==`function`?queueMicrotask:Qd===void 0?Xd:function(e){return Qd.resolve(null).then(e).catch(ef)};function ef(e){setTimeout(function(){throw e})}function tf(e){return e===`head`}function nf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Ip(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_f(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_f(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[st]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_f(e.ownerDocument.body);n=i}while(n);Ip(t)}function rf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function af(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:af(n),ct(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function of(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[st])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=ff(e.nextSibling),e===null)break}return null}function sf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=ff(e.nextSibling),e===null))return null;return e}function cf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=ff(e.nextSibling),e===null))return null;return e}function lf(e){return e.data===`$?`||e.data===`$~`}function uf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function df(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function ff(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var pf=null;function mf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return ff(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function hf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function gf(e,t,n){switch(t=Wd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function _f(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ct(e)}var vf=new Map,yf=new Set;function bf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var xf=L.d;L.d={f:Sf,r:Cf,D:Ef,C:Df,L:Of,m:kf,X:jf,S:Af,M:Mf};function Sf(){var e=xf.f(),t=xu();return e||t}function Cf(e){var t=ut(e);t!==null&&t.tag===5&&t.type===`form`?bs(t):xf.r(e)}var wf=typeof document>`u`?null:document;function Tf(e,t,n){var r=wf;if(r&&typeof t==`string`&&t){var i=Mt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),yf.has(i)||(yf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Rd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function Ef(e){xf.D(e),Tf(`dns-prefetch`,e,null)}function Df(e,t){xf.C(e,t),Tf(`preconnect`,e,t)}function Of(e,t,n){xf.L(e,t,n);var r=wf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Mt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Mt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Mt(n.imageSizes)+`"]`)):i+=`[href="`+Mt(e)+`"]`;var a=i;switch(t){case`style`:a=Pf(e);break;case`script`:a=Rf(e)}vf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Ff(a))||t===`script`&&r.querySelector(zf(a))||(t=r.createElement(`link`),Rd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function kf(e,t){xf.m(e,t);var n=wf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Mt(r)+`"][href="`+Mt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rf(e)}if(!vf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),vf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zf(a)))return}r=n.createElement(`link`),Rd(r,`link`,e),pt(r),n.head.appendChild(r)}}}function Af(e,t,n){xf.S(e,t,n);var r=wf;if(r&&e){var i=ft(r).hoistableStyles,a=Pf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Ff(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vf.get(a))&&Hf(e,n);var c=o=r.createElement(`link`);pt(c),Rd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jf(e,t){xf.X(e,t);var n=wf;if(n&&e){var r=ft(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=m({src:e,async:!0},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),pt(a),Rd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mf(e,t){xf.M(e,t);var n=wf;if(n&&e){var r=ft(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),pt(a),Rd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nf(e,t,n,r){var a=(a=ie.current)?bf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Pf(n.href),n=ft(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pf(n.href);var o=ft(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Ff(e)))&&!o._p&&(s.instance=o,s.state.loading=5),vf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vf.set(e,n),o||Lf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Rf(n),n=ft(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pf(e){return`href="`+Mt(e)+`"`}function Ff(e){return`link[rel="stylesheet"][`+e+`]`}function If(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Lf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Rd(t,`link`,n),pt(t),e.head.appendChild(t))}function Rf(e){return`[src="`+Mt(e)+`"]`}function zf(e){return`script[async]`+e}function Bf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Mt(n.href)+`"]`);if(r)return t.instance=r,pt(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),pt(r),Rd(r,`style`,a),Vf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pf(n.href);var o=e.querySelector(Ff(a));if(o)return t.state.loading|=4,t.instance=o,pt(o),o;r=If(n),(a=vf.get(a))&&Hf(r,a),o=(e.ownerDocument||e).createElement(`link`),pt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Rd(o,`link`,r),t.state.loading|=4,Vf(o,n.precedence,e),t.instance=o;case`script`:return o=Rf(n.src),(a=e.querySelector(zf(o)))?(t.instance=a,pt(a),a):(r=n,(a=vf.get(o))&&(r=m({},n),Uf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),pt(a),Rd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vf(r,n.precedence,e));return t.instance}function Vf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Uf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wf=null;function Gf(e,t,n){if(Wf===null){var r=new Map,i=Wf=new Map;i.set(n,r)}else i=Wf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[st]||a[et]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Kf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Yf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pf(r.href),a=t.querySelector(Ff(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Qf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,pt(a);return}a=t.ownerDocument||t,r=If(r),(i=vf.get(i))&&Hf(r,i),a=a.createElement(`link`),pt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Rd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Qf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Xf=0;function Zf(e,t){return e.stylesheets&&e.count===0&&X(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&X(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Xf===0&&(Xf=62500*Vd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&X(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Xf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Qf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)X(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var $f=null;function X(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,$f=new Map,t.forEach(ep,e),$f=null,Qf.call(e))}function ep(e,t){if(!(t.state.loading&4)){var n=$f.get(e);if(n)var r=n.get(null);else{n=new Map,$f.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Qf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var tp={$$typeof:C,Provider:null,Consumer:null,_currentValue:ee,_currentValue2:ee,_threadCount:0};function np(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ue(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ue(0),this.hiddenUpdates=Ue(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function rp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new np(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Zr(3,null,null,t),e.current=a,a.stateNode=e,t=Qi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ja(a),e}function ip(e){return e?(e=Yr,e):Yr}function ap(e,t,n,r,i,a){i=ip(i),r.context===null?r.context=i:r.pendingContext=i,r=Na(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Pa(e,r,t),n!==null&&(gu(n,e,t),Fa(n,e,t))}function op(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function sp(e,t){op(e,t),(e=e.alternate)&&op(e,t)}function cp(e){if(e.tag===13||e.tag===31){var t=Kr(e,67108864);t!==null&&gu(t,e,67108864),sp(e,67108864)}}function lp(e){if(e.tag===13||e.tag===31){var t=mu();t=Ye(t);var n=Kr(e,t);n!==null&&gu(n,e,t),sp(e,t)}}var up=!0;function dp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=2,pp(e,t,n,r)}finally{L.p=a,I.T=i}}function fp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=8,pp(e,t,n,r)}finally{L.p=a,I.T=i}}function pp(e,t,n,r){if(up){var i=mp(r);if(i===null)Dd(e,t,r,hp,n),Ep(e,r);else if(Op(i,e,t,n,r))r.stopPropagation();else if(Ep(e,r),t&4&&-1<Tp.indexOf(e)){for(;i!==null;){var a=ut(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Re(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-je(o);s.entanglements[1]|=c,o&=~c}ad(a),!(Fl&6)&&(nu=xe()+500,od(0,!1))}}break;case 31:case 13:s=Kr(a,2),s!==null&&gu(s,a,2),xu(),sp(a,2)}if(a=mp(r),a===null&&Dd(e,t,r,hp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Dd(e,t,r,null,n)}}function mp(e){return e=Yt(e),gp(e)}var hp=null;function gp(e){if(hp=null,e=lt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return hp=e,null}function _p(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Se()){case U:return 2;case Ce:return 8;case we:case Te:return 32;case W:return 268435456;default:return 32}default:return 32}}var vp=!1,yp=null,bp=null,xp=null,Sp=new Map,Cp=new Map,wp=[],Tp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Ep(e,t){switch(e){case`focusin`:case`focusout`:yp=null;break;case`dragenter`:case`dragleave`:bp=null;break;case`mouseover`:case`mouseout`:xp=null;break;case`pointerover`:case`pointerout`:Sp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Cp.delete(t.pointerId)}}function Dp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=ut(t),t!==null&&cp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Op(e,t,n,r,i){switch(t){case`focusin`:return yp=Dp(yp,e,t,n,r,i),!0;case`dragenter`:return bp=Dp(bp,e,t,n,r,i),!0;case`mouseover`:return xp=Dp(xp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Sp.set(a,Dp(Sp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Cp.set(a,Dp(Cp.get(a)||null,e,t,n,r,i)),!0}return!1}function kp(e){var t=lt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Qe(e.priority,function(){lp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Qe(e.priority,function(){lp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ap(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=mp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Jt=r,n.target.dispatchEvent(r),Jt=null}else return t=ut(n),t!==null&&cp(t),e.blockedOn=n,!1;t.shift()}return!0}function jp(e,t,n){Ap(e)&&n.delete(t)}function Mp(){vp=!1,yp!==null&&Ap(yp)&&(yp=null),bp!==null&&Ap(bp)&&(bp=null),xp!==null&&Ap(xp)&&(xp=null),Sp.forEach(jp),Cp.forEach(jp)}function Np(e,n){e.blockedOn===n&&(e.blockedOn=null,vp||(vp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Mp)))}var Pp=null;function Fp(e){Pp!==e&&(Pp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Pp===e&&(Pp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(gp(r||n)===null)continue;break}var a=ut(n);a!==null&&(e.splice(t,3),t-=3,vs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Ip(e){function t(t){return Np(t,e)}yp!==null&&Np(yp,e),bp!==null&&Np(bp,e),xp!==null&&Np(xp,e),Sp.forEach(t),Cp.forEach(t);for(var n=0;n<wp.length;n++){var r=wp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<wp.length&&(n=wp[0],n.blockedOn===null);)kp(n),n.blockedOn===null&&wp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[tt]||null;if(typeof a==`function`)o||Fp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[tt]||null)s=o.formAction;else if(gp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Fp(n)}}}function Lp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Rp(e){this._internalRoot=e}zp.prototype.render=Rp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;ap(n,mu(),e,t,null,null)},zp.prototype.unmount=Rp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ap(e.current,2,null,e,null,null),xu(),t[nt]=null}};function zp(e){this._internalRoot=e}zp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ze();e={blockedOn:null,target:e,priority:t};for(var n=0;n<wp.length&&t!==0&&t<wp[n].priority;n++);wp.splice(n,0,e),n===0&&kp(e)}};var Bp=n.version;if(Bp!==`19.2.7`)throw Error(i(527,Bp,`19.2.7`));L.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Vp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Hp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hp.isDisabled&&Hp.supportsFiber)try{Oe=Hp.inject(Vp),ke=Hp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Vs,s=Hs,c=Us;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=rp(e,1,!1,null,null,n,r,null,o,s,c,Lp),e[nt]=t.current,Td(e),new Rp(t)}})),_=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=l(d(),1),y=l(_()),b={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},x={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},S=`attached`,C=`detached`,w=1e3,T=1001,E=1002,D=1003,O=1004,k=1004,A=1005,j=1005,M=1006,N=1007,P=1007,F=1008,I=1008,L=1009,ee=1010,R=1011,te=1012,z=1013,B=1014,V=1015,ne=1016,re=1017,ie=1018,ae=1020,oe=35902,se=35899,ce=1021,H=1022,le=1023,ue=1026,de=1027,fe=1028,pe=1029,me=1030,he=1031,ge=1032,_e=1033,ve=33776,ye=33777,be=33778,xe=33779,Se=35840,U=35841,Ce=35842,we=35843,Te=36196,W=37492,Ee=37496,De=37488,Oe=37489,ke=37490,Ae=37491,je=37808,Me=37809,Ne=37810,Pe=37811,Fe=37812,Ie=37813,Le=37814,Re=37815,ze=37816,Be=37817,Ve=37818,He=37819,Ue=37820,We=37821,Ge=36492,Ke=36494,qe=36495,Je=36283,Ye=36284,Xe=36285,Ze=36286,Qe=2200,$e=2201,et=2202,tt=2300,nt=2301,rt=2302,it=2303,at=2400,ot=2401,st=2402,ct=2500,lt=2501,ut=3200,dt=3201,ft=3202,pt=3203,mt=`srgb`,ht=`srgb-linear`,gt=`linear`,_t=`srgb`,vt=7680,yt=7681,bt=7682,xt=7683,St=34055,Ct=34056,wt=5386,Tt=35044,Et=35048,Dt=35040,Ot=35045,kt=35049,At=35041,jt=35046,Mt=35050,Nt=35042,Pt=`300 es`,Ft=2e3,It=2001,Lt={COMPUTE:`compute`,RENDER:`render`},Rt={PERSPECTIVE:`perspective`,LINEAR:`linear`,FLAT:`flat`},zt={NORMAL:`normal`,CENTROID:`centroid`,SAMPLE:`sample`,FIRST:`first`,EITHER:`either`},Bt={TEXTURE_COMPARE:`depthTextureCompare`};function Vt(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var Ht={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ut(e,t){return new Ht[e](t)}function Wt(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Gt(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function Kt(){let e=Gt(`canvas`);return e.style.display=`block`,e}var qt={},Jt=null;function Yt(e){Jt=e}function Xt(){return Jt}function Zt(...e){let t=`THREE.`+e.shift();Jt?Jt(`log`,t,...e):console.log(t,...e)}function Qt(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function G(...e){e=Qt(e);let t=`THREE.`+e.shift();if(Jt)Jt(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function $t(...e){e=Qt(e);let t=`THREE.`+e.shift();if(Jt)Jt(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function en(...e){let t=e.join(` `);t in qt||(qt[t]=!0,G(...e))}function tn(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var nn={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},rn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},an=`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`.split(`.`),on=1234567,sn=Math.PI/180,cn=180/Math.PI;function ln(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(an[e&255]+an[e>>8&255]+an[e>>16&255]+an[e>>24&255]+`-`+an[t&255]+an[t>>8&255]+`-`+an[t>>16&15|64]+an[t>>24&255]+`-`+an[n&63|128]+an[n>>8&255]+`-`+an[n>>16&255]+an[n>>24&255]+an[r&255]+an[r>>8&255]+an[r>>16&255]+an[r>>24&255]).toLowerCase()}function un(e,t,n){return Math.max(t,Math.min(n,e))}function dn(e,t){return(e%t+t)%t}function fn(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function pn(e,t,n){return e===t?0:(n-e)/(t-e)}function mn(e,t,n){return(1-n)*e+n*t}function hn(e,t,n,r){return mn(e,t,1-Math.exp(-n*r))}function gn(e,t=1){return t-Math.abs(dn(e,t*2)-t)}function _n(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function vn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function yn(e,t){return e+Math.floor(Math.random()*(t-e+1))}function bn(e,t){return e+Math.random()*(t-e)}function xn(e){return e*(.5-Math.random())}function Sn(e){e!==void 0&&(on=e);let t=on+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Cn(e){return e*sn}function wn(e){return e*cn}function Tn(e){return(e&e-1)==0&&e!==0}function En(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Dn(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function On(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:G(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function kn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function An(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var jn={DEG2RAD:sn,RAD2DEG:cn,generateUUID:ln,clamp:un,euclideanModulo:dn,mapLinear:fn,inverseLerp:pn,lerp:mn,damp:hn,pingpong:gn,smoothstep:_n,smootherstep:vn,randInt:yn,randFloat:bn,randFloatSpread:xn,seededRandom:Sn,degToRad:Cn,radToDeg:wn,isPowerOfTwo:Tn,ceilPowerOfTwo:En,floorPowerOfTwo:Dn,setQuaternionFromProperEuler:On,normalize:An,denormalize:kn},K=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw 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 Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=un(this.x,e.x,t.x),this.y=un(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=un(this.x,e,t),this.y=un(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(un(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(un(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Mn=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:G(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(un(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),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*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},q=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw 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 Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Pn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Pn.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=un(this.x,e.x,t.x),this.y=un(this.y,e.y,t.y),this.z=un(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=un(this.x,e,t),this.y=un(this.y,e,t),this.z=un(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(un(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Nn.copy(this).projectOnVector(e),this.sub(Nn)}reflect(e){return this.sub(Nn.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(un(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Nn=new q,Pn=new Mn,Fn=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(In.makeScale(e,t)),this}rotate(e){return this.premultiply(In.makeRotation(-e)),this}translate(e,t){return this.premultiply(In.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},In=new Fn,Ln=new Fn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Rn=new Fn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zn(){let e={enabled:!0,workingColorSpace:ht,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Vn(e.r),e.g=Vn(e.g),e.b=Vn(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Hn(e.r),e.g=Hn(e.g),e.b=Hn(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?gt:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return en(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return en(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[ht]:{primaries:t,whitePoint:r,transfer:gt,toXYZ:Ln,fromXYZ:Rn,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:mt},outputColorSpaceConfig:{drawingBufferColorSpace:mt}},[mt]:{primaries:t,whitePoint:r,transfer:_t,toXYZ:Ln,fromXYZ:Rn,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:mt}}}),e}var Bn=zn();function Vn(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Hn(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Un,Wn=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Un===void 0&&(Un=Gt(`canvas`)),Un.width=e.width,Un.height=e.height;let t=Un.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Un}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Gt(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Vn(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Vn(t[e]/255)*255):t[e]=Vn(t[e]);return{data:t,width:e.width,height:e.height}}else return G(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},Gn=0,Kn=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Gn++}),this.uuid=ln(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(qn(r[t].image)):e.push(qn(r[t]))}else e=qn(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function qn(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Wn.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(G(`Texture: Unable to serialize Texture.`),{})}var Jn=0,Yn=new q,Xn=class e extends rn{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=T,i=T,a=M,o=F,s=le,c=L,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Jn++}),this.uuid=ln(),this.name=``,this.source=new Kn(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new K(0,0),this.repeat=new K(1,1),this.center=new K(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Yn).x}get height(){return this.source.getSize(Yn).y}get depth(){return this.source.getSize(Yn).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){G(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){G(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case w:e.x-=Math.floor(e.x);break;case T:e.x=e.x<0?0:1;break;case E:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case w:e.y-=Math.floor(e.y);break;case T:e.y=e.y<0?0:1;break;case E:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(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++}};Xn.DEFAULT_IMAGE=null,Xn.DEFAULT_MAPPING=300,Xn.DEFAULT_ANISOTROPY=1;var Zn=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw 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 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?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,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);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=un(this.x,e.x,t.x),this.y=un(this.y,e.y,t.y),this.z=un(this.z,e.z,t.z),this.w=un(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=un(this.x,e,t),this.y=un(this.y,e,t),this.z=un(this.z,e,t),this.w=un(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(un(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Qn=class extends rn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:M,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Zn(0,0,e,t),this.scissorTest=!1,this.viewport=new Zn(0,0,e,t),this.textures=[];let r=new Xn({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:M,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}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 t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Kn(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this}dispose(){this.dispatchEvent({type:`dispose`})}},$n=class extends Qn{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},er=class extends Xn{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=D,this.minFilter=D,this.wrapR=T,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},tr=class extends $n{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new er(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},nr=class extends Xn{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=D,this.minFilter=D,this.wrapR=T,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},rr=class extends $n{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new nr(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},J=class e{static{e.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,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 e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/ir.setFromMatrixColumn(e,0).length(),i=1/ir.setFromMatrixColumn(e,1).length(),a=1/ir.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(or,e,sr)}lookAt(e,t,n){let r=this.elements;return ur.subVectors(e,t),ur.lengthSq()===0&&(ur.z=1),ur.normalize(),cr.crossVectors(n,ur),cr.lengthSq()===0&&(Math.abs(n.z)===1?ur.x+=1e-4:ur.z+=1e-4,ur.normalize(),cr.crossVectors(n,ur)),cr.normalize(),lr.crossVectors(ur,cr),r[0]=cr.x,r[4]=lr.x,r[8]=ur.x,r[1]=cr.y,r[5]=lr.y,r[9]=ur.y,r[2]=cr.z,r[6]=lr.z,r[10]=ur.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],F=r[11],I=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*F,i[12]=a*w+o*O+s*M+c*I,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*F,i[13]=l*w+u*O+d*M+f*I,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*F,i[14]=p*w+m*O+h*M+g*I,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*F,i[15]=_*w+v*O+y*M+b*I,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=ir.set(r[0],r[1],r[2]).length(),o=ir.set(r[4],r[5],r[6]).length(),s=ir.set(r[8],r[9],r[10]).length();i<0&&(a=-a),ar.copy(this);let c=1/a,l=1/o,u=1/s;return ar.elements[0]*=c,ar.elements[1]*=c,ar.elements[2]*=c,ar.elements[4]*=l,ar.elements[5]*=l,ar.elements[6]*=l,ar.elements[8]*=u,ar.elements[9]*=u,ar.elements[10]*=u,t.setFromRotationMatrix(ar),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=Ft,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Ft,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},ir=new q,ar=new J,or=new q(0,0,0),sr=new q(1,1,1),cr=new q,lr=new q,ur=new q,dr=new J,fr=new Mn,pr=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,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,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(un(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-un(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(un(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-un(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(un(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-un(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:G(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return dr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(dr,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return fr.setFromEuler(this),this.setFromQuaternion(fr,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};pr.DEFAULT_ORDER=`XYZ`;var mr=class{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}},hr=0,gr=new q,_r=new Mn,vr=new J,yr=new q,br=new q,xr=new q,Sr=new Mn,Cr=new q(1,0,0),wr=new q(0,1,0),Tr=new q(0,0,1),Er={type:`added`},Dr={type:`removed`},Or={type:`childadded`,child:null},kr={type:`childremoved`,child:null},Ar=class e extends rn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:hr++}),this.uuid=ln(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new q,n=new pr,r=new Mn,i=new q(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new J},normalMatrix:{value:new Fn}}),this.matrix=new J,this.matrixWorld=new J,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new mr,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return _r.setFromAxisAngle(e,t),this.quaternion.multiply(_r),this}rotateOnWorldAxis(e,t){return _r.setFromAxisAngle(e,t),this.quaternion.premultiply(_r),this}rotateX(e){return this.rotateOnAxis(Cr,e)}rotateY(e){return this.rotateOnAxis(wr,e)}rotateZ(e){return this.rotateOnAxis(Tr,e)}translateOnAxis(e,t){return gr.copy(e).applyQuaternion(this.quaternion),this.position.add(gr.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Cr,e)}translateY(e){return this.translateOnAxis(wr,e)}translateZ(e){return this.translateOnAxis(Tr,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(vr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?yr.copy(e):yr.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),br.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vr.lookAt(br,yr,this.up):vr.lookAt(yr,br,this.up),this.quaternion.setFromRotationMatrix(vr),r&&(vr.extractRotation(r.matrixWorld),_r.setFromRotationMatrix(vr),this.quaternion.premultiply(_r.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?($t(`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(Er),Or.child=e,this.dispatchEvent(Or),Or.child=null):$t(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Dr),kr.child=e,this.dispatchEvent(kr),kr.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),vr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),vr.multiply(e.parent.matrixWorld)),e.applyMatrix4(vr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Er),Or.child=e,this.dispatchEvent(Or),Or.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(br,e,xr),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(br,Sr,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}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);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.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)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};Ar.DEFAULT_UP=new q(0,1,0),Ar.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ar.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var jr=class extends Ar{constructor(){super(),this.isGroup=!0,this.type=`Group`}},Mr={type:`move`},Nr=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new jr,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 jr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new q,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new q),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new jr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new q,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new q,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Mr)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new jr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Pr={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},Fr={h:0,s:0,l:0},Ir={h:0,s:0,l:0};function Lr(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var Y=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=mt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Bn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Bn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Bn.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Bn.workingColorSpace){if(e=dn(e,1),t=un(t,0,1),n=un(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Lr(i,r,e+1/3),this.g=Lr(i,r,e),this.b=Lr(i,r,e-1/3)}return Bn.colorSpaceToWorking(this,r),this}setStyle(e,t=mt){function n(t){t!==void 0&&parseFloat(t)<1&&G(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:G(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);G(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=mt){let n=Pr[e.toLowerCase()];return n===void 0?G(`Color: Unknown color `+e):this.setHex(n,t),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=Vn(e.r),this.g=Vn(e.g),this.b=Vn(e.b),this}copyLinearToSRGB(e){return this.r=Hn(e.r),this.g=Hn(e.g),this.b=Hn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=mt){return Bn.workingToColorSpace(Rr.copy(this),e),Math.round(un(Rr.r*255,0,255))*65536+Math.round(un(Rr.g*255,0,255))*256+Math.round(un(Rr.b*255,0,255))}getHexString(e=mt){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Bn.workingColorSpace){Bn.workingToColorSpace(Rr.copy(this),t);let n=Rr.r,r=Rr.g,i=Rr.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Bn.workingColorSpace){return Bn.workingToColorSpace(Rr.copy(this),t),e.r=Rr.r,e.g=Rr.g,e.b=Rr.b,e}getStyle(e=mt){Bn.workingToColorSpace(Rr.copy(this),e);let t=Rr.r,n=Rr.g,r=Rr.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Fr),this.setHSL(Fr.h+e,Fr.s+t,Fr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.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,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Fr),e.getHSL(Ir);let n=mn(Fr.h,Ir.h,t),r=mn(Fr.s,Ir.s,t),i=mn(Fr.l,Ir.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Rr=new Y;Y.NAMES=Pr;var zr=class e{constructor(e,t=25e-5){this.isFogExp2=!0,this.name=``,this.color=new Y(e),this.density=t}clone(){return new e(this.color,this.density)}toJSON(){return{type:`FogExp2`,name:this.name,color:this.color.getHex(),density:this.density}}},Br=class e{constructor(e,t=1,n=1e3){this.isFog=!0,this.name=``,this.color=new Y(e),this.near=t,this.far=n}clone(){return new e(this.color,this.near,this.far)}toJSON(){return{type:`Fog`,name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Vr=class extends Ar{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 pr,this.environmentIntensity=1,this.environmentRotation=new pr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Hr=new q,Ur=new q,Wr=new q,Gr=new q,Kr=new q,qr=new q,Jr=new q,Yr=new q,Xr=new q,Zr=new q,Qr=new Zn,$r=new Zn,ei=new Zn,ti=class e{constructor(e=new q,t=new q,n=new q){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Hr.subVectors(e,t),r.cross(Hr);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Hr.subVectors(r,t),Ur.subVectors(n,t),Wr.subVectors(e,t);let a=Hr.dot(Hr),o=Hr.dot(Ur),s=Hr.dot(Wr),c=Ur.dot(Ur),l=Ur.dot(Wr),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Gr)===null?!1:Gr.x>=0&&Gr.y>=0&&Gr.x+Gr.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Gr)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Gr.x),s.addScaledVector(a,Gr.y),s.addScaledVector(o,Gr.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Qr.setScalar(0),$r.setScalar(0),ei.setScalar(0),Qr.fromBufferAttribute(e,t),$r.fromBufferAttribute(e,n),ei.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Qr,i.x),a.addScaledVector($r,i.y),a.addScaledVector(ei,i.z),a}static isFrontFacing(e,t,n,r){return Hr.subVectors(n,t),Ur.subVectors(e,t),Hr.cross(Ur).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 Hr.subVectors(this.c,this.b),Ur.subVectors(this.a,this.b),Hr.cross(Ur).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Kr.subVectors(r,n),qr.subVectors(i,n),Yr.subVectors(e,n);let s=Kr.dot(Yr),c=qr.dot(Yr);if(s<=0&&c<=0)return t.copy(n);Xr.subVectors(e,r);let l=Kr.dot(Xr),u=qr.dot(Xr);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Kr,a);Zr.subVectors(e,i);let f=Kr.dot(Zr),p=qr.dot(Zr);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(qr,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Jr.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Jr,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Kr,a).addScaledVector(qr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ni=class{constructor(e=new q(1/0,1/0,1/0),t=new q(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(ii.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(ii.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=ii.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}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,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,ii):ii.fromBufferAttribute(r,t),ii.applyMatrix4(e.matrixWorld),this.expandByPoint(ii);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),ai.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),ai.copy(e.boundingBox)),ai.applyMatrix4(e.matrixWorld),this.union(ai)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);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,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ii),ii.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(fi),pi.subVectors(this.max,fi),oi.subVectors(e.a,fi),si.subVectors(e.b,fi),ci.subVectors(e.c,fi),li.subVectors(si,oi),ui.subVectors(ci,si),di.subVectors(oi,ci);let t=[0,-li.z,li.y,0,-ui.z,ui.y,0,-di.z,di.y,li.z,0,-li.x,ui.z,0,-ui.x,di.z,0,-di.x,-li.y,li.x,0,-ui.y,ui.x,0,-di.y,di.x,0];return!gi(t,oi,si,ci,pi)||(t=[1,0,0,0,1,0,0,0,1],!gi(t,oi,si,ci,pi))?!1:(mi.crossVectors(li,ui),t=[mi.x,mi.y,mi.z],gi(t,oi,si,ci,pi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ii).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ii).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:(ri[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ri[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ri[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ri[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ri[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ri[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ri[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ri[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ri),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},ri=[new q,new q,new q,new q,new q,new q,new q,new q],ii=new q,ai=new ni,oi=new q,si=new q,ci=new q,li=new q,ui=new q,di=new q,fi=new q,pi=new q,mi=new q,hi=new q;function gi(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){hi.fromArray(e,a);let o=i.x*Math.abs(hi.x)+i.y*Math.abs(hi.y)+i.z*Math.abs(hi.z),s=t.dot(hi),c=n.dot(hi),l=r.dot(hi);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var _i=vi();function vi(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function yi(e){Math.abs(e)>65504&&G(`DataUtils.toHalfFloat(): Value out of range.`),e=un(e,-65504,65504),_i.floatView[0]=e;let t=_i.uint32View[0],n=t>>23&511;return _i.baseTable[n]+((t&8388607)>>_i.shiftTable[n])}function bi(e){let t=e>>10;return _i.uint32View[0]=_i.mantissaTable[_i.offsetTable[t]+(e&1023)]+_i.exponentTable[t],_i.floatView[0]}var xi=class{static toHalfFloat(e){return yi(e)}static fromHalfFloat(e){return bi(e)}},Si=new q,Ci=new K,wi=0,Ti=class extends rn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:wi++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Tt,this.updateRanges=[],this.gpuType=V,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ci.fromBufferAttribute(this,t),Ci.applyMatrix3(e),this.setXY(t,Ci.x,Ci.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Si.fromBufferAttribute(this,t),Si.applyMatrix3(e),this.setXYZ(t,Si.x,Si.y,Si.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Si.fromBufferAttribute(this,t),Si.applyMatrix4(e),this.setXYZ(t,Si.x,Si.y,Si.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Si.fromBufferAttribute(this,t),Si.applyNormalMatrix(e),this.setXYZ(t,Si.x,Si.y,Si.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Si.fromBufferAttribute(this,t),Si.transformDirection(e),this.setXYZ(t,Si.x,Si.y,Si.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=kn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=An(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=kn(t,this.array)),t}setX(e,t){return this.normalized&&(t=An(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=kn(t,this.array)),t}setY(e,t){return this.normalized&&(t=An(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=kn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=An(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=kn(t,this.array)),t}setW(e,t){return this.normalized&&(t=An(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=An(t,this.array),n=An(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=An(t,this.array),n=An(n,this.array),r=An(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=An(t,this.array),n=An(n,this.array),r=An(r,this.array),i=An(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==35044&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:`dispose`})}},Ei=class extends Ti{constructor(e,t,n){super(new Int8Array(e),t,n)}},Di=class extends Ti{constructor(e,t,n){super(new Uint8Array(e),t,n)}},Oi=class extends Ti{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},ki=class extends Ti{constructor(e,t,n){super(new Int16Array(e),t,n)}},Ai=class extends Ti{constructor(e,t,n){super(new Uint16Array(e),t,n)}},ji=class extends Ti{constructor(e,t,n){super(new Int32Array(e),t,n)}},Mi=class extends Ti{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Ni=class extends Ti{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=bi(this.array[e*this.itemSize]);return this.normalized&&(t=kn(t,this.array)),t}setX(e,t){return this.normalized&&(t=An(t,this.array)),this.array[e*this.itemSize]=yi(t),this}getY(e){let t=bi(this.array[e*this.itemSize+1]);return this.normalized&&(t=kn(t,this.array)),t}setY(e,t){return this.normalized&&(t=An(t,this.array)),this.array[e*this.itemSize+1]=yi(t),this}getZ(e){let t=bi(this.array[e*this.itemSize+2]);return this.normalized&&(t=kn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=An(t,this.array)),this.array[e*this.itemSize+2]=yi(t),this}getW(e){let t=bi(this.array[e*this.itemSize+3]);return this.normalized&&(t=kn(t,this.array)),t}setW(e,t){return this.normalized&&(t=An(t,this.array)),this.array[e*this.itemSize+3]=yi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=An(t,this.array),n=An(n,this.array)),this.array[e+0]=yi(t),this.array[e+1]=yi(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=An(t,this.array),n=An(n,this.array),r=An(r,this.array)),this.array[e+0]=yi(t),this.array[e+1]=yi(n),this.array[e+2]=yi(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=An(t,this.array),n=An(n,this.array),r=An(r,this.array),i=An(i,this.array)),this.array[e+0]=yi(t),this.array[e+1]=yi(n),this.array[e+2]=yi(r),this.array[e+3]=yi(i),this}},Pi=class extends Ti{constructor(e,t,n){super(new Float32Array(e),t,n)}},Fi=new ni,Ii=new q,Li=new q,Ri=class{constructor(e=new q,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Fi.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),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){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=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;Ii.subVectors(e,this.center);let t=Ii.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Ii,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Li.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ii.copy(e.center).add(Li)),this.expandByPoint(Ii.copy(e.center).sub(Li))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},zi=0,Bi=new J,Vi=new Ar,Hi=new q,Ui=new ni,Wi=new ni,Gi=new q,Ki=class e extends rn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zi++}),this.uuid=ln(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Vt(e)?Mi:Ai)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Fn().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Bi.makeRotationFromQuaternion(e),this.applyMatrix4(Bi),this}rotateX(e){return Bi.makeRotationX(e),this.applyMatrix4(Bi),this}rotateY(e){return Bi.makeRotationY(e),this.applyMatrix4(Bi),this}rotateZ(e){return Bi.makeRotationZ(e),this.applyMatrix4(Bi),this}translate(e,t,n){return Bi.makeTranslation(e,t,n),this.applyMatrix4(Bi),this}scale(e,t,n){return Bi.makeScale(e,t,n),this.applyMatrix4(Bi),this}lookAt(e){return Vi.lookAt(e),Vi.updateMatrix(),this.applyMatrix4(Vi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hi).negate(),this.translate(Hi.x,Hi.y,Hi.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Pi(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&G(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ni);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$t(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new q(-1/0,-1/0,-1/0),new q(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ui.setFromBufferAttribute(n),this.morphTargetsRelative?(Gi.addVectors(this.boundingBox.min,Ui.min),this.boundingBox.expandByPoint(Gi),Gi.addVectors(this.boundingBox.max,Ui.max),this.boundingBox.expandByPoint(Gi)):(this.boundingBox.expandByPoint(Ui.min),this.boundingBox.expandByPoint(Ui.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&$t(`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 Ri);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$t(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new q,1/0);return}if(e){let n=this.boundingSphere.center;if(Ui.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Wi.setFromBufferAttribute(n),this.morphTargetsRelative?(Gi.addVectors(Ui.min,Wi.min),Ui.expandByPoint(Gi),Gi.addVectors(Ui.max,Wi.max),Ui.expandByPoint(Gi)):(Ui.expandByPoint(Wi.min),Ui.expandByPoint(Wi.max))}Ui.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Gi.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Gi));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Gi.fromBufferAttribute(a,t),o&&(Hi.fromBufferAttribute(e,t),Gi.add(Hi)),r=Math.max(r,n.distanceToSquared(Gi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&$t(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){$t(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new Ti(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new q,s[e]=new q;let c=new q,l=new q,u=new q,d=new K,f=new K,p=new K,m=new q,h=new q;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new q,y=new q,b=new q,x=new q;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new Ti(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new q,i=new q,a=new q,o=new q,s=new q,c=new q,l=new q,u=new q;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gi.fromBufferAttribute(e,t),Gi.normalize(),e.setXYZ(t,Gi.x,Gi.y,Gi.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Ti(a,r,i)}if(this.index===null)return G(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,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){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},qi=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Tt,this.updateRanges=[],this.version=0,this.uuid=ln()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ln()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}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=ln()),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}}},Ji=new q,Yi=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Ji.fromBufferAttribute(this,t),Ji.applyMatrix4(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ji.fromBufferAttribute(this,t),Ji.applyNormalMatrix(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ji.fromBufferAttribute(this,t),Ji.transformDirection(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=kn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=An(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=An(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=An(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=An(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=An(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=kn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=kn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=kn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=kn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=An(t,this.array),n=An(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=An(t,this.array),n=An(n,this.array),r=An(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=An(t,this.array),n=An(n,this.array),r=An(r,this.array),i=An(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){Zt(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Ti(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Zt(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,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}}},Xi=0,Zi=class extends rn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Xi++}),this.uuid=ln(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Y(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=vt,this.stencilZFail=vt,this.stencilZPass=vt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){G(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){G(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}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;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Qi=class extends Zi{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new Y(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!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.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},$i,ea=new q,ta=new q,na=new q,ra=new K,ia=new K,aa=new J,oa=new q,sa=new q,ca=new q,la=new K,ua=new K,da=new K,fa=class extends Ar{constructor(e=new Qi){if(super(),this.isSprite=!0,this.type=`Sprite`,$i===void 0){$i=new Ki;let e=new qi(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);$i.setIndex([0,1,2,0,2,3]),$i.setAttribute(`position`,new Yi(e,3,0,!1)),$i.setAttribute(`uv`,new Yi(e,2,3,!1))}this.geometry=$i,this.material=e,this.center=new K(.5,.5),this.count=1}raycast(e,t){e.camera===null&&$t(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),ta.setFromMatrixScale(this.matrixWorld),aa.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),na.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ta.multiplyScalar(-na.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;pa(oa.set(-.5,-.5,0),na,a,ta,r,i),pa(sa.set(.5,-.5,0),na,a,ta,r,i),pa(ca.set(.5,.5,0),na,a,ta,r,i),la.set(0,0),ua.set(1,0),da.set(1,1);let o=e.ray.intersectTriangle(oa,sa,ca,!1,ea);if(o===null&&(pa(sa.set(-.5,.5,0),na,a,ta,r,i),ua.set(0,1),o=e.ray.intersectTriangle(oa,ca,sa,!1,ea),o===null))return;let s=e.ray.origin.distanceTo(ea);s<e.near||s>e.far||t.push({distance:s,point:ea.clone(),uv:ti.getInterpolation(ea,oa,sa,ca,la,ua,da,new K),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function pa(e,t,n,r,i,a){ra.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?ia.copy(ra):(ia.x=a*ra.x-i*ra.y,ia.y=i*ra.x+a*ra.y),e.copy(t),e.x+=ia.x,e.y+=ia.y,e.applyMatrix4(aa)}var ma=new q,ha=new q,ga=class extends Ar{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type=`LOD`,Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);let r=this.levels,i;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){let e=t.splice(n,1);return this.remove(e[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){ma.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(ma);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){ma.setFromMatrixPosition(e.matrixWorld),ha.setFromMatrixPosition(this.matrixWorld);let n=ma.distanceTo(ha)/e.zoom;t[0].object.visible=!0;let r,i;for(r=1,i=t.length;r<i;r++){let e=t[r].distance;if(t[r].object.visible&&(e-=e*t[r].hysteresis),n>=e)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let n=this.levels;for(let e=0,r=n.length;e<r;e++){let r=n[e];t.object.levels.push({object:r.object.uuid,distance:r.distance,hysteresis:r.hysteresis})}return t}},_a=new q,va=new q,ya=new q,ba=new q,xa=new q,Sa=new q,Ca=new q,wa=class{constructor(e=new q,t=new q(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_a)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=_a.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_a.copy(this.origin).addScaledVector(this.direction,t),_a.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){va.copy(e).add(t).multiplyScalar(.5),ya.copy(t).sub(e).normalize(),ba.copy(this.origin).sub(va);let i=e.distanceTo(t)*.5,a=-this.direction.dot(ya),o=ba.dot(this.direction),s=-ba.dot(ya),c=ba.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(va).addScaledVector(ya,d),f}intersectSphere(e,t){_a.subVectors(e.center,this.origin);let n=_a.dot(this.direction),r=_a.dot(_a)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,_a)!==null}intersectTriangle(e,t,n,r,i){xa.subVectors(t,e),Sa.subVectors(n,e),Ca.crossVectors(xa,Sa);let a=this.direction.dot(Ca),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ba.subVectors(this.origin,e);let s=o*this.direction.dot(Sa.crossVectors(ba,Sa));if(s<0)return null;let c=o*this.direction.dot(xa.cross(ba));if(c<0||s+c>a)return null;let l=-o*ba.dot(Ca);return l<0?null:this.at(l/a,i)}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)}},Ta=class extends Zi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Y(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 pr,this.combine=0,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}},Ea=new J,Da=new wa,Oa=new Ri,ka=new q,Aa=new q,ja=new q,Ma=new q,Na=new q,Pa=new q,Fa=new q,Ia=new q,La=class extends Ar{constructor(e=new Ki,t=new Ta){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),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(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Pa.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Na.fromBufferAttribute(s,e),a?Pa.addScaledVector(Na,r):Pa.addScaledVector(Na.sub(t),r))}t.add(Pa)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Oa.copy(n.boundingSphere),Oa.applyMatrix4(i),Da.copy(e.ray).recast(e.near),!(Oa.containsPoint(Da.origin)===!1&&(Da.intersectSphere(Oa,ka)===null||Da.origin.distanceToSquared(ka)>(e.far-e.near)**2))&&(Ea.copy(i).invert(),Da.copy(e.ray).applyMatrix4(Ea),!(n.boundingBox!==null&&Da.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Da)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=za(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=za(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=za(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=za(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function Ra(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Ia.copy(s),Ia.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ia);return l<n.near||l>n.far?null:{distance:l,point:Ia.clone(),object:e}}function za(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Aa),e.getVertexPosition(c,ja),e.getVertexPosition(l,Ma);let u=Ra(e,t,n,r,Aa,ja,Ma,Fa);if(u){let e=new q;ti.getBarycoord(Fa,Aa,ja,Ma,e),i&&(u.uv=ti.getInterpolatedAttribute(i,s,c,l,e,new K)),a&&(u.uv1=ti.getInterpolatedAttribute(a,s,c,l,e,new K)),o&&(u.normal=ti.getInterpolatedAttribute(o,s,c,l,e,new q),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new q,materialIndex:0};ti.getNormal(Aa,ja,Ma,t.normal),u.face=t,u.barycoord=e}return u}var Ba=new Zn,Va=new Zn,Ha=new Zn,Ua=new Zn,Wa=new J,Ga=new q,Ka=new Ri,qa=new J,Ja=new wa,Ya=class extends La{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=S,this.bindMatrix=new J,this.bindMatrixInverse=new J,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ni),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Ga),this.boundingBox.expandByPoint(Ga)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ri),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Ga),this.boundingSphere.expandByPoint(Ga)}copy(e,t){return super.copy(e,t),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,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ka.copy(this.boundingSphere),Ka.applyMatrix4(r),e.ray.intersectsSphere(Ka)!==!1&&(qa.copy(r).invert(),Ja.copy(e.ray).applyMatrix4(qa),!(this.boundingBox!==null&&Ja.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Ja)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Zn,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():G(`SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Va.fromBufferAttribute(r.attributes.skinIndex,e),Ha.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?(Ba.copy(t),t.set(0,0,0,0)):(Ba.set(...t,1),t.set(0,0,0)),Ba.applyMatrix4(this.bindMatrix);for(let e=0;e<4;e++){let r=Ha.getComponent(e);if(r!==0){let i=Va.getComponent(e);Wa.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(Ua.copy(Ba).applyMatrix4(Wa),r)}}return t.isVector4&&(t.w=Ba.w),t.applyMatrix4(this.bindMatrixInverse)}},Xa=class extends Ar{constructor(){super(),this.isBone=!0,this.type=`Bone`}},Za=class extends Xn{constructor(e=null,t=1,n=1,r,i,a,o,s,c=D,l=D,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Qa=new J,$a=new J,eo=class e{constructor(e=[],t=[]){this.uuid=ln(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){G(`Skeleton: Number of inverse bone matrices does not match amount of bones.`),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new J)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new J;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:$a;Qa.multiplyMatrices(i,t[r]),Qa.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Za(t,e,e,le,V);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(G(`Skeleton: No bone found with UUID:`,r),i=new Xa),this.bones.push(i),this.boneInverses.push(new J().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},to=class extends Ti{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},no=new J,ro=new J,io=[],ao=new ni,oo=new J,so=new La,co=new Ri,lo=class extends La{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new to(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,oo)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ni),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,no),ao.copy(e.boundingBox).applyMatrix4(no),this.boundingBox.union(ao)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ri),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,no),co.copy(e.boundingSphere).applyMatrix4(no),this.boundingSphere.union(co)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),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,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(so.geometry=this.geometry,so.material=this.material,so.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),co.copy(this.boundingSphere),co.applyMatrix4(n),e.ray.intersectsSphere(co)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,no),ro.multiplyMatrices(n,no),so.matrixWorld=ro,so.raycast(e,io);for(let e=0,n=io.length;e<n;e++){let n=io[e];n.instanceId=i,n.object=this,t.push(n)}io.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new to(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Za(new Float32Array(r*this.count),r,this.count,fe,V));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;return i[s]=o,i.set(n,s+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:`dispose`}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},uo=new q,fo=new q,po=new Fn,mo=class{constructor(e=new q(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=uo.subVectors(n,t).cross(fo.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(uo),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||po.getNormalMatrix(e),r=this.coplanarPoint(uo).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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)}},ho=new Ri,go=new K(.5,.5),_o=new q,vo=class{constructor(e=new mo,t=new mo,n=new mo,r=new mo,i=new mo,a=new mo){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ft,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ho.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ho.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ho)}intersectsSprite(e){return ho.center.set(0,0,0),ho.radius=.7071067811865476+go.distanceTo(e.center),ho.applyMatrix4(e.matrixWorld),this.intersectsSphere(ho)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(_o.x=r.normal.x>0?e.max.x:e.min.x,_o.y=r.normal.y>0?e.max.y:e.min.y,_o.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(_o)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},yo=new J,bo=new vo,xo=class e{constructor(){this.coordinateSystem=Ft}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,r.coordinateSystem,r.reversedDepth),bo.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,r.coordinateSystem,r.reversedDepth),bo.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,r.coordinateSystem,r.reversedDepth),bo.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,r.coordinateSystem,r.reversedDepth),bo.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,r.coordinateSystem,r.reversedDepth),bo.containsPoint(e))return!0}return!1}clone(){return new e}};function So(e,t){return e-t}function Co(e,t){return e.z-t.z}function wo(e,t){return t.z-e.z}var To=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){let i=this.pool,a=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});let o=i[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=r}reset(){this.list.length=0,this.index=0}},Eo=new J,Do=new Y(1,1,1),Oo=new vo,ko=new xo,Ao=new ni,jo=new Ri,Mo=new q,No=new q,Po=new q,Fo=new To,Io=new La,Lo=[];function Ro(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a<i;a++)for(let i=0;i<r;i++)t.setComponent(a+n,i,e.getComponent(a,i))}else t.array.set(e.array,n*r);t.needsUpdate=!0}function zo(e,t){if(e.constructor!==t.constructor){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)t[r]=e[r]}else{let n=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,n))}}var Bo=class extends La{constructor(e,t,n=t*2,r){super(new Ki,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Za(new Float32Array(e*e*4),e,e,le,V);this._matricesTexture=t}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Za(new Uint32Array(e*e),e,e,pe,B);this._indirectTexture=t}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Za(new Float32Array(e*e*4).fill(1),e,e,le,V);t.colorSpace=Bn.workingColorSpace,this._colorsTexture=t}_initializeGeometry(e){let t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(let r in e.attributes){let{array:i,itemSize:a,normalized:o}=e.getAttribute(r),s=new Ti(new i.constructor(n*a),a,o);t.setAttribute(r,s)}if(e.getIndex()!==null){let e=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new Ti(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`THREE.BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.`)}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ni);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Eo),this.getBoundingBoxAt(r,Ao).applyMatrix4(Eo),e.union(Ao)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ri);let e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Eo),this.getBoundingSphereAt(r,jo).applyMatrix4(Eo),e.union(jo)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw Error(`THREE.BatchedMesh: Maximum item count reached.`);let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(So),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));let r=this._matricesTexture;Eo.identity().toArray(r.image.data,n*16),r.needsUpdate=!0;let i=this._colorsTexture;return i&&(Do.toArray(i.image.data,n*4),i.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},i=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute(`position`).count:t;let a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error(`THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(So),o=this._availableGeometryIds.shift(),i[o]=r):(o=this._geometryCount,this._geometryCount++,i.push(r)),this.setGeometryAt(o,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error(`THREE.BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw Error(`THREE.BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute(`position`).count;for(let e in n.attributes){let r=t.getAttribute(e),i=n.getAttribute(e);Ro(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e<t;e++){let t=s+e;for(let e=0;e<a;e++)i.setComponent(t,e,0)}i.needsUpdate=!0,i.addUpdateRange(s*a,c*a)}if(r){let e=o.indexStart,n=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let t=0;t<a.count;t++)i.setX(e+t,s+a.getX(t));for(let t=a.count,r=n;t<r;t++)i.setX(e+t,s);i.needsUpdate=!0,i.addUpdateRange(e,o.reservedIndexCount)}return o.start=r?o.indexStart:o.vertexStart,o.count=r?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;let n=this._instanceInfo;for(let t=0,r=n.length;t<r;t++)n[t].active&&n[t].geometryIndex===e&&this.deleteInstance(t);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0,n=this._geometryInfo,r=n.map((e,t)=>t).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),i=this.geometry;for(let a=0,o=n.length;a<o;a++){let o=n[r[a]];if(o.active!==!1){if(i.index!==null){if(o.indexStart!==t){let{indexStart:n,vertexStart:r,reservedIndexCount:a}=o,s=i.index,c=s.array,l=e-r;for(let e=n;e<n+a;e++)c[e]=c[e]+l;s.array.copyWithin(t,n,n+a),s.addUpdateRange(t,a),s.needsUpdate=!0,o.indexStart=t}t+=o.reservedIndexCount}if(o.vertexStart!==e){let{vertexStart:t,reservedVertexCount:n}=o,r=i.attributes;for(let i in r){let a=r[i],{array:o,itemSize:s}=a;o.copyWithin(e*s,t*s,(t+n)*s),a.addUpdateRange(e*s,n*s),a.needsUpdate=!0}o.vertexStart=e}e+=o.reservedVertexCount,o.start=i.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){let e=new ni,t=n.index,i=n.attributes.position;for(let n=r.start,a=r.start+r.count;n<a;n++){let r=n;t&&(r=t.getX(r)),e.expandByPoint(Mo.fromBufferAttribute(i,r))}r.boundingBox=e}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){let t=new Ri;this.getBoundingBoxAt(e,Ao),Ao.getCenter(t.center);let i=n.index,a=n.attributes.position,o=0;for(let e=r.start,n=r.start+r.count;e<n;e++){let n=e;i&&(n=i.getX(n)),Mo.fromBufferAttribute(a,n),o=Math.max(o,t.center.distanceToSquared(Mo))}t.radius=Math.sqrt(o),r.boundingSphere=t}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);let n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null?t.isVector4?t.set(1,1,1,1):t.setRGB(1,1,1):t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);let n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){let t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(So);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);let r=new Int32Array(e),i=new Int32Array(e);zo(this._multiDrawCounts,r),zo(this._multiDrawStarts,i),this._multiDrawCounts=r,this._multiDrawStarts=i,this._maxInstanceCount=e;let a=this._indirectTexture,o=this._matricesTexture,s=this._colorsTexture;a.dispose(),this._initIndirectTexture(),zo(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),zo(o.image.data,this._matricesTexture.image.data),s&&(s.dispose(),this._initColorsTexture(),zo(s.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){let n=[...this._geometryInfo].filter(e=>e.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Ki,this._initializeGeometry(r));let i=this.geometry;r.index&&zo(r.index.array,i.index.array);for(let e in r.attributes)zo(r.attributes[e].array,i.attributes[e].array)}raycast(e,t){let n=this._instanceInfo,r=this._geometryInfo,i=this.matrixWorld,a=this.geometry;Io.material=this.material,Io.geometry.index=a.index,Io.geometry.attributes=a.attributes,Io.geometry.boundingBox===null&&(Io.geometry.boundingBox=new ni),Io.geometry.boundingSphere===null&&(Io.geometry.boundingSphere=new Ri);for(let a=0,o=n.length;a<o;a++){if(!n[a].visible||!n[a].active)continue;let o=n[a].geometryIndex,s=r[o];Io.geometry.setDrawRange(s.start,s.count),this.getMatrixAt(a,Io.matrixWorld).premultiply(i),this.getBoundingBoxAt(o,Io.geometry.boundingBox),this.getBoundingSphereAt(o,Io.geometry.boundingSphere),Io.raycast(e,Lo);for(let e=0,n=Lo.length;e<n;e++){let n=Lo[e];n.object=this,n.batchId=a,t.push(n)}Lo.length=0}Io.material=null,Io.geometry.index=null,Io.geometry.attributes={},Io.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox===null?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this._geometryInfo=e._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox===null?null:e.boundingBox.clone(),boundingSphere:e.boundingSphere===null?null:e.boundingSphere.clone()})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,r,i){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,s=1;i.wireframe&&(s=2,o=r.attributes.position.count>65535?4:2);let c=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,d=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data,h=n.isArrayCamera?ko:Oo;f&&!n.isArrayCamera&&(Eo.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Oo.setFromProjectionMatrix(Eo,n.coordinateSystem,n.reversedDepth));let g=0;if(this.sortObjects){Eo.copy(this.matrixWorld).invert(),Mo.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Eo),No.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Eo);for(let e=0,t=c.length;e<t;e++)if(c[e].visible&&c[e].active){let t=c[e].geometryIndex;this.getMatrixAt(e,Eo),this.getBoundingSphereAt(t,jo).applyMatrix4(Eo);let r=!1;if(f&&(r=!h.intersectsSphere(jo,n)),!r){let n=d[t],r=Po.subVectors(jo.center,Mo).dot(No);Fo.push(n.start,n.count,r,e)}}let e=Fo.list,t=this.customSort;t===null?e.sort(i.transparent?wo:Co):t.call(this,e,n);for(let t=0,n=e.length;t<n;t++){let n=e[t];l[g]=n.start*o*s,u[g]=n.count*s,m[g]=n.index,g++}Fo.reset()}else for(let e=0,t=c.length;e<t;e++)if(c[e].visible&&c[e].active){let t=c[e].geometryIndex,r=!1;if(f&&(this.getMatrixAt(e,Eo),this.getBoundingSphereAt(t,jo).applyMatrix4(Eo),r=!h.intersectsSphere(jo,n)),!r){let n=d[t];l[g]=n.start*o*s,u[g]=n.count*s,m[g]=e,g++}}p.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,i,a){this.onBeforeRender(e,null,r,i,a)}},Vo=class extends Zi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new Y(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}},Ho=new q,Uo=new q,Wo=new J,Go=new wa,Ko=new Ri,qo=new q,Jo=new q,Yo=class extends Ar{constructor(e=new Ki,t=new Vo){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)Ho.fromBufferAttribute(t,e-1),Uo.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Ho.distanceTo(Uo);e.setAttribute(`lineDistance`,new Pi(n,1))}else G(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ko.copy(n.boundingSphere),Ko.applyMatrix4(r),Ko.radius+=i,e.ray.intersectsSphere(Ko)===!1)return;Wo.copy(r).invert(),Go.copy(e.ray).applyMatrix4(Wo);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=Xo(this,e,Go,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=Xo(this,e,Go,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=Xo(this,e,Go,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=Xo(this,e,Go,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Xo(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(Ho.fromBufferAttribute(s,i),Uo.fromBufferAttribute(s,a),n.distanceSqToSegment(Ho,Uo,qo,Jo)>r)return;qo.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(qo);if(!(c<t.near||c>t.far))return{distance:c,point:Jo.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Zo=new q,Qo=new q,$o=class extends Yo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)Zo.fromBufferAttribute(t,e),Qo.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+Zo.distanceTo(Qo);e.setAttribute(`lineDistance`,new Pi(n,1))}else G(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},es=class extends Yo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},ts=class extends Zi{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new Y(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}},ns=new J,rs=new wa,is=new Ri,as=new q,os=class extends Ar{constructor(e=new Ki,t=new ts){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),is.copy(n.boundingSphere),is.applyMatrix4(r),is.radius+=i,e.ray.intersectsSphere(is)===!1)return;ns.copy(r).invert(),rs.copy(e.ray).applyMatrix4(ns);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);as.fromBufferAttribute(l,n),ss(as,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)as.fromBufferAttribute(l,a),ss(as,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function ss(e,t,n,r,i,a,o){let s=rs.distanceSqToPoint(e);if(s<n){let n=new q;rs.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var cs=class extends Xn{constructor(e,t,n,r,i=M,a=M,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let l=this;function u(){l.needsUpdate=!0,l._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u)}`requestVideoFrameCallback`in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!(`requestVideoFrameCallback`in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}},ls=class extends cs{constructor(e,t,n,r,i,a,o,s){super({},e,t,n,r,i,a,o,s),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},us=class extends Xn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=D,this.minFilter=D,this.generateMipmaps=!1,this.needsUpdate=!0}},ds=class extends Xn{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},fs=class extends ds{constructor(e,t,n,r,i,a){super(e,t,n,i,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=T,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},ps=class extends ds{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},ms=class extends Xn{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},hs=class extends Xn{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},gs=class extends Xn{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;let l=e?e.parentNode:null;l!==null&&`requestPaint`in l&&(l.onpaint=()=>{this.needsUpdate=!0},l.requestPaint())}dispose(){let e=this.image?this.image.parentNode:null;e!==null&&`onpaint`in e&&(e.onpaint=null),super.dispose()}},_s=class extends Xn{constructor(e,t,n=B,r,i,a,o=D,s=D,c,l=ue,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Kn(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},vs=class extends _s{constructor(e,t=B,n=301,r,i,a=D,o=D,s,c=ue){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ys=class extends Xn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},bs=class e extends Ki{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Pi(c,3)),this.setAttribute(`normal`,new Pi(l,3)),this.setAttribute(`uv`,new Pi(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new q;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},xs=class e extends Ki{constructor(e=1,t=1,n=4,r=8,i=1){super(),this.type=`CapsuleGeometry`,this.parameters={radius:e,height:t,capSegments:n,radialSegments:r,heightSegments:i},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),r=Math.max(3,Math.floor(r)),i=Math.max(1,Math.floor(i));let a=[],o=[],s=[],c=[],l=t/2,u=Math.PI/2*e,d=t,f=2*u+d,p=n*2+i,m=r+1,h=new q,g=new q;for(let _=0;_<=p;_++){let v=0,y=0,b=0,x=0;if(_<=n){let t=_/n,r=t*Math.PI/2;y=-l-e*Math.cos(r),b=e*Math.sin(r),x=-e*Math.cos(r),v=t*u}else if(_<=n+i){let r=(_-n)/i;y=-l+r*t,b=e,x=0,v=u+r*d}else{let t=(_-n-i)/n,r=t*Math.PI/2;y=l+e*Math.sin(r),b=e*Math.cos(r),x=e*Math.sin(r),v=u+d+t*u}let S=Math.max(0,Math.min(1,v/f)),C=0;_===0?C=.5/r:_===p&&(C=-.5/r);for(let e=0;e<=r;e++){let t=e/r,n=t*Math.PI*2,i=Math.sin(n),a=Math.cos(n);g.x=-b*a,g.y=y,g.z=b*i,o.push(g.x,g.y,g.z),h.set(-b*a,x,b*i),h.normalize(),s.push(h.x,h.y,h.z),c.push(t+C,S)}if(_>0){let e=(_-1)*m;for(let t=0;t<r;t++){let n=e+t,r=e+t+1,i=_*m+t,o=_*m+t+1;a.push(n,r,i),a.push(r,o,i)}}}this.setIndex(a),this.setAttribute(`position`,new Pi(o,3)),this.setAttribute(`normal`,new Pi(s,3)),this.setAttribute(`uv`,new Pi(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}},Ss=class e extends Ki{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type=`CircleGeometry`,this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);let i=[],a=[],o=[],s=[],c=new q,l=new K;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=t;i++,u+=3){let d=n+i/t*r;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),l.x=(a[u]/e+1)/2,l.y=(a[u+1]/e+1)/2,s.push(l.x,l.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute(`position`,new Pi(a,3)),this.setAttribute(`normal`,new Pi(o,3)),this.setAttribute(`uv`,new Pi(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.segments,t.thetaStart,t.thetaLength)}},Cs=class e extends Ki{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Pi(u,3)),this.setAttribute(`normal`,new Pi(d,3)),this.setAttribute(`uv`,new Pi(f,2));function _(){let a=new q,_=new q,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new K,m=new q,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ws=class e extends Cs{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Ts=class e extends Ki{constructor(e=[],t=[],n=1,r=0){super(),this.type=`PolyhedronGeometry`,this.parameters={vertices:e,indices:t,radius:n,detail:r};let i=[],a=[];o(r),c(n),l(),this.setAttribute(`position`,new Pi(i,3)),this.setAttribute(`normal`,new Pi(i.slice(),3)),this.setAttribute(`uv`,new Pi(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(e){let n=new q,r=new q,i=new q;for(let a=0;a<t.length;a+=3)f(t[a+0],n),f(t[a+1],r),f(t[a+2],i),s(n,r,i,e)}function s(e,t,n,r){let i=r+1,a=[];for(let r=0;r<=i;r++){a[r]=[];let o=e.clone().lerp(n,r/i),s=t.clone().lerp(n,r/i),c=i-r;for(let e=0;e<=c;e++)e===0&&r===i?a[r][e]=o:a[r][e]=o.clone().lerp(s,e/c)}for(let e=0;e<i;e++)for(let t=0;t<2*(i-e)-1;t++){let n=Math.floor(t/2);t%2==0?(d(a[e][n+1]),d(a[e+1][n]),d(a[e][n])):(d(a[e][n+1]),d(a[e+1][n+1]),d(a[e+1][n]))}}function c(e){let t=new q;for(let n=0;n<i.length;n+=3)t.x=i[n+0],t.y=i[n+1],t.z=i[n+2],t.normalize().multiplyScalar(e),i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z}function l(){let e=new q;for(let t=0;t<i.length;t+=3){e.x=i[t+0],e.y=i[t+1],e.z=i[t+2];let n=h(e)/2/Math.PI+.5,r=g(e)/Math.PI+.5;a.push(n,1-r)}p(),u()}function u(){for(let e=0;e<a.length;e+=6){let t=a[e+0],n=a[e+2],r=a[e+4];Math.max(t,n,r)>.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new q,t=new q,n=new q,r=new q,o=new K,s=new K,c=new K;for(let l=0,u=0;l<i.length;l+=9,u+=6){e.set(i[l+0],i[l+1],i[l+2]),t.set(i[l+3],i[l+4],i[l+5]),n.set(i[l+6],i[l+7],i[l+8]),o.set(a[u+0],a[u+1]),s.set(a[u+2],a[u+3]),c.set(a[u+4],a[u+5]),r.copy(e).add(t).add(n).divideScalar(3);let d=h(r);m(o,u+0,e,d),m(s,u+2,t,d),m(c,u+4,n,d)}}function m(e,t,n,r){r<0&&e.x===1&&(a[t]=e.x-1),n.x===0&&n.z===0&&(a[t]=r/2/Math.PI+.5)}function h(e){return Math.atan2(e.z,-e.x)}function g(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.vertices,t.indices,t.radius,t.detail)}},Es=class e extends Ts{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];super(i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type=`DodecahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},Ds=new q,Os=new q,ks=new q,As=new ti,js=class extends Ki{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=10**4,r=Math.cos(sn*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u={},d=[];for(let e=0;e<o;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);let{a:t,b:o,c:f}=As;if(t.fromBufferAttribute(a,s[0]),o.fromBufferAttribute(a,s[1]),f.fromBufferAttribute(a,s[2]),As.getNormal(ks),l[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,l[1]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,l[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,!(l[0]===l[1]||l[1]===l[2]||l[2]===l[0]))for(let e=0;e<3;e++){let t=(e+1)%3,n=l[e],i=l[t],a=As[c[e]],o=As[c[t]],f=`${n}_${i}`,p=`${i}_${n}`;p in u&&u[p]?(ks.dot(u[p].normal)<=r&&(d.push(a.x,a.y,a.z),d.push(o.x,o.y,o.z)),u[p]=null):f in u||(u[f]={index0:s[e],index1:s[t],normal:ks.clone()})}}for(let e in u)if(u[e]){let{index0:t,index1:n}=u[e];Ds.fromBufferAttribute(a,t),Os.fromBufferAttribute(a,n),d.push(Ds.x,Ds.y,Ds.z),d.push(Os.x,Os.y,Os.z)}this.setAttribute(`position`,new Pi(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Ms=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){G(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let 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;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new K:new q);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new q,r=[],i=[],a=[],o=new q,s=new J;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new q)}i[0]=new q,a[0]=new q;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(un(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(un(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Ns=class extends Ms{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new K){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Ps=class extends Ns{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Fs(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Is=new q,Ls=new q,Rs=new Fs,zs=new Fs,Bs=new Fs,Vs=class extends Ms{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new q){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Ls.subVectors(r[0],r[1]).add(r[0]),c=Ls);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(Is.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=Is),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),Rs.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),zs.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),Bs.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(Rs.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),zs.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),Bs.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(Rs.calc(s),zs.calc(s),Bs.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new q().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Hs(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function Us(e,t){let n=1-e;return n*n*t}function Ws(e,t){return 2*(1-e)*e*t}function Gs(e,t){return e*e*t}function Ks(e,t,n,r){return Us(e,t)+Ws(e,n)+Gs(e,r)}function qs(e,t){let n=1-e;return n*n*n*t}function Js(e,t){let n=1-e;return 3*n*n*e*t}function Ys(e,t){return 3*(1-e)*e*e*t}function Xs(e,t){return e*e*e*t}function Zs(e,t,n,r,i){return qs(e,t)+Js(e,n)+Ys(e,r)+Xs(e,i)}var Qs=class extends Ms{constructor(e=new K,t=new K,n=new K,r=new K){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new K){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Zs(e,r.x,i.x,a.x,o.x),Zs(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},$s=class extends Ms{constructor(e=new q,t=new q,n=new q,r=new q){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Zs(e,r.x,i.x,a.x,o.x),Zs(e,r.y,i.y,a.y,o.y),Zs(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ec=class extends Ms{constructor(e=new K,t=new K){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new K){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new K){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},tc=class extends Ms{constructor(e=new q,t=new q){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new q){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},nc=class extends Ms{constructor(e=new K,t=new K,n=new K){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new K){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Ks(e,r.x,i.x,a.x),Ks(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},rc=class extends Ms{constructor(e=new q,t=new q,n=new q){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Ks(e,r.x,i.x,a.x),Ks(e,r.y,i.y,a.y),Ks(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ic=class extends Ms{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new K){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Hs(o,s.x,c.x,l.x,u.x),Hs(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new K().fromArray(n))}return this}},ac=Object.freeze({__proto__:null,ArcCurve:Ps,CatmullRomCurve3:Vs,CubicBezierCurve:Qs,CubicBezierCurve3:$s,EllipseCurve:Ns,LineCurve:ec,LineCurve3:tc,QuadraticBezierCurve:nc,QuadraticBezierCurve3:rc,SplineCurve:ic}),oc=class extends Ms{constructor(){super(),this.type=`CurvePath`,this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new ac[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new ac[n.type]().fromJSON(n))}return this}},sc=class extends oc{constructor(e){super(),this.type=`Path`,this.currentPoint=new K,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new ec(this.currentPoint.clone(),new K(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new nc(this.currentPoint.clone(),new K(e,t),new K(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new Qs(this.currentPoint.clone(),new K(e,t),new K(n,r),new K(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=new ic([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new Ns(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},cc=class extends sc{constructor(e){super(e),this.uuid=ln(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new sc().fromJSON(n))}return this}};function lc(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=uc(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=_c(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return fc(a,o,n,s,c,l,0),o}function uc(e,t,n,r,i){let a;if(i===Vc(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=Rc(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=Rc(i/r|0,e[i],e[i+1],a);return a&&Ac(a,a.next)&&(zc(a),a=a.next),a}function dc(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Ac(n,n.next)||kc(n.prev,n,n.next)===0)){if(zc(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function fc(e,t,n,r,i,a,o){if(!e)return;!o&&a&&Sc(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?mc(e,r,i,a):pc(e)){t.push(c.i,e.i,l.i),zc(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=hc(dc(e),t),fc(e,t,n,r,i,a,2)):o===2&&gc(e,t,n,r,i,a):fc(dc(e),t,n,r,i,a,1);break}}}function pc(e){let t=e.prev,n=e,r=e.next;if(kc(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Dc(i,s,a,c,o,l,m.x,m.y)&&kc(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function mc(e,t,n,r){let i=e.prev,a=e,o=e.next;if(kc(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=wc(p,m,t,n,r),v=wc(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Dc(s,u,c,d,l,f,y.x,y.y)&&kc(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Dc(s,u,c,d,l,f,b.x,b.y)&&kc(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Dc(s,u,c,d,l,f,y.x,y.y)&&kc(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Dc(s,u,c,d,l,f,b.x,b.y)&&kc(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function hc(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Ac(r,i)&&jc(r,n,n.next,i)&&Fc(r,i)&&Fc(i,r)&&(t.push(r.i,n.i,i.i),zc(n),zc(n.next),n=e=i),n=n.next}while(n!==e);return dc(n)}function gc(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Oc(o,e)){let s=Lc(o,e);o=dc(o,o.next),s=dc(s,s.next),fc(o,t,n,r,i,a,0),fc(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function _c(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=uc(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(Tc(o))}i.sort(vc);for(let e=0;e<i.length;e++)n=yc(i[e],n);return n}function vc(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function yc(e,t){let n=bc(e,t);if(!n)return t;let r=Lc(n,e);return dc(r,r.next),dc(n,n.next)}function bc(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Ac(e,n))return n;do{if(Ac(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&Ec(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);Fc(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&xc(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function xc(e,t){return kc(e.prev,e,t.prev)<0&&kc(t.next,e,e.next)<0}function Sc(e,t,n,r){let i=e;do i.z===0&&(i.z=wc(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Cc(i)}function Cc(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function wc(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Tc(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Ec(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Dc(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Ec(e,t,n,r,i,a,o,s)}function Oc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Pc(e,t)&&(Fc(e,t)&&Fc(t,e)&&Ic(e,t)&&(kc(e.prev,e,t.prev)||kc(e,t.prev,t))||Ac(e,t)&&kc(e.prev,e,e.next)>0&&kc(t.prev,t,t.next)>0)}function kc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ac(e,t){return e.x===t.x&&e.y===t.y}function jc(e,t,n,r){let i=Nc(kc(e,t,n)),a=Nc(kc(e,t,r)),o=Nc(kc(n,r,e)),s=Nc(kc(n,r,t));return!!(i!==a&&o!==s||i===0&&Mc(e,n,t)||a===0&&Mc(e,r,t)||o===0&&Mc(n,e,r)||s===0&&Mc(n,t,r))}function Mc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Nc(e){return e>0?1:e<0?-1:0}function Pc(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&jc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Fc(e,t){return kc(e.prev,e,e.next)<0?kc(e,t,e.next)>=0&&kc(e,e.prev,t)>=0:kc(e,t,e.prev)<0||kc(e,e.next,t)<0}function Ic(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Lc(e,t){let n=Bc(e.i,e.x,e.y),r=Bc(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Rc(e,t,n,r){let i=Bc(e,t,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 zc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Bc(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Vc(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var Hc=class{static triangulate(e,t,n=2){return lc(e,t,n)}},Uc=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];Wc(e),Gc(n,e);let a=e.length;t.forEach(Wc);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Gc(n,t[e]);let o=Hc.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}};function Wc(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Gc(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var Kc=class e extends Ki{constructor(e=new cc([new K(.5,.5),new K(-.5,.5),new K(-.5,-.5),new K(.5,-.5)]),t={}){super(),this.type=`ExtrudeGeometry`,this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];a(n)}this.setAttribute(`position`,new Pi(r,3)),this.setAttribute(`uv`,new Pi(i,2)),this.computeVertexNormals();function a(e){let a=[],o=t.curveSegments===void 0?12:t.curveSegments,s=t.steps===void 0?1:t.steps,c=t.depth===void 0?1:t.depth,l=t.bevelEnabled===void 0?!0:t.bevelEnabled,u=t.bevelThickness===void 0?.2:t.bevelThickness,d=t.bevelSize===void 0?u-.1:t.bevelSize,f=t.bevelOffset===void 0?0:t.bevelOffset,p=t.bevelSegments===void 0?3:t.bevelSegments,m=t.extrudePath,h=t.UVGenerator===void 0?qc:t.UVGenerator,g,_=!1,v,y,b,x;if(m){g=m.getSpacedPoints(s),_=!0,l=!1;let e=m.isCatmullRomCurve3?m.closed:!1;v=m.computeFrenetFrames(s,e),y=new q,b=new q,x=new q}l||(p=0,u=0,d=0,f=0);let S=e.extractPoints(o),C=S.shape,w=S.holes;if(!Uc.isClockWise(C)){C=C.reverse();for(let e=0,t=w.length;e<t;e++){let t=w[e];Uc.isClockWise(t)&&(w[e]=t.reverse())}}function T(e){let t=e[0];for(let n=1;n<=e.length;n++){let r=n%e.length,i=e[r],a=i.x-t.x,o=i.y-t.y,s=a*a+o*o,c=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(t.x),Math.abs(t.y));if(s<=10000000000000001e-36*c*c){e.splice(r,1),n--;continue}t=i}}T(C),w.forEach(T);let E=w.length,D=C;for(let e=0;e<E;e++){let t=w[e];C=C.concat(t)}function O(e,t,n){return t||$t(`ExtrudeGeometry: vec does not exist`),e.clone().addScaledVector(t,n)}let k=C.length;function A(e,t,n){let r,i,a,o=e.x-t.x,s=e.y-t.y,c=n.x-e.x,l=n.y-e.y,u=o*o+s*s,d=o*l-s*c;if(Math.abs(d)>2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new K(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new K(r/a,i/a)}let j=[];for(let e=0,t=D.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),j[e]=A(D[e],D[n],D[r]);let M=[],N,P=j.concat();for(let e=0,t=E;e<t;e++){let t=w[e];N=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),N[e]=A(t[e],t[r],t[i]);M.push(N),P=P.concat(N)}let F;if(p===0)F=Uc.triangulateShape(D,w);else{let e=[],t=[];for(let n=0;n<p;n++){let r=n/p,i=u*Math.cos(r*Math.PI/2),a=d*Math.sin(r*Math.PI/2)+f;for(let t=0,n=D.length;t<n;t++){let n=O(D[t],j[t],a);z(n.x,n.y,-i),r===0&&e.push(n)}for(let e=0,n=E;e<n;e++){let n=w[e];N=M[e];let o=[];for(let e=0,t=n.length;e<t;e++){let t=O(n[e],N[e],a);z(t.x,t.y,-i),r===0&&o.push(t)}r===0&&t.push(o)}}F=Uc.triangulateShape(e,t)}let I=F.length,L=d+f;for(let e=0;e<k;e++){let t=l?O(C[e],P[e],L):C[e];_?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(b).add(y),z(x.x,x.y,x.z)):z(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<k;t++){let n=l?O(C[t],P[t],L):C[t];_?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),x.copy(g[e]).add(b).add(y),z(x.x,x.y,x.z)):z(n.x,n.y,c/s*e)}for(let e=p-1;e>=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=D.length;e<t;e++){let t=O(D[e],j[e],r);z(t.x,t.y,c+n)}for(let e=0,t=w.length;e<t;e++){let t=w[e];N=M[e];for(let e=0,i=t.length;e<i;e++){let i=O(t[e],N[e],r);_?z(i.x,i.y+g[s-1].y,g[s-1].x+n):z(i.x,i.y,c+n)}}}ee(),R();function ee(){let e=r.length/3;if(l){let e=0,t=k*e;for(let e=0;e<I;e++){let n=F[e];B(n[2]+t,n[1]+t,n[0]+t)}e=s+p*2,t=k*e;for(let e=0;e<I;e++){let n=F[e];B(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<I;e++){let t=F[e];B(t[2],t[1],t[0])}for(let e=0;e<I;e++){let t=F[e];B(t[0]+k*s,t[1]+k*s,t[2]+k*s)}}n.addGroup(e,r.length/3-e,0)}function R(){let e=r.length/3,t=0;te(D,t),t+=D.length;for(let e=0,n=w.length;e<n;e++){let n=w[e];te(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}function te(e,t){let n=e.length;for(;--n>=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e<n;e++){let n=k*e,a=k*(e+1);V(t+r+n,t+i+n,t+i+a,t+r+a)}}}function z(e,t,n){a.push(e),a.push(t),a.push(n)}function B(e,t,i){ne(e),ne(t),ne(i);let a=r.length/3,o=h.generateTopUV(n,r,a-3,a-2,a-1);re(o[0]),re(o[1]),re(o[2])}function V(e,t,i,a){ne(e),ne(t),ne(a),ne(t),ne(i),ne(a);let o=r.length/3,s=h.generateSideWallUV(n,r,o-6,o-3,o-2,o-1);re(s[0]),re(s[1]),re(s[3]),re(s[1]),re(s[2]),re(s[3])}function ne(e){r.push(a[e*3+0]),r.push(a[e*3+1]),r.push(a[e*3+2])}function re(e){i.push(e.x),i.push(e.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return Jc(t,n,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new ac[i.type]().fromJSON(i)),new e(r,t.options)}},qc={generateTopUV:function(e,t,n,r,i){let a=t[n*3],o=t[n*3+1],s=t[r*3],c=t[r*3+1],l=t[i*3],u=t[i*3+1];return[new K(a,o),new K(s,c),new K(l,u)]},generateSideWallUV:function(e,t,n,r,i,a){let o=t[n*3],s=t[n*3+1],c=t[n*3+2],l=t[r*3],u=t[r*3+1],d=t[r*3+2],f=t[i*3],p=t[i*3+1],m=t[i*3+2],h=t[a*3],g=t[a*3+1],_=t[a*3+2];return Math.abs(s-u)<Math.abs(o-l)?[new K(o,1-c),new K(l,1-d),new K(f,1-m),new K(h,1-_)]:[new K(s,1-c),new K(u,1-d),new K(p,1-m),new K(g,1-_)]}};function Jc(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);return n.options=Object.assign({},t),t.extrudePath!==void 0&&(n.options.extrudePath=t.extrudePath.toJSON()),n}var Yc=class e extends Ts{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];super(r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type=`IcosahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},Xc=class e extends Ki{constructor(e=[new K(0,-.5),new K(.5,0),new K(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type=`LatheGeometry`,this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=un(r,0,Math.PI*2);let i=[],a=[],o=[],s=[],c=[],l=1/t,u=new q,d=new K,f=new q,p=new q,m=new q,h=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,m.copy(f),f.normalize(),s.push(f.x,f.y,f.z);break;case e.length-1:s.push(m.x,m.y,m.z);break;default:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),s.push(f.x,f.y,f.z),m.copy(p)}for(let i=0;i<=t;i++){let f=n+i*l*r,p=Math.sin(f),m=Math.cos(f);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*m,a.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),o.push(d.x,d.y);let r=s[3*n+0]*p,l=s[3*n+1],f=s[3*n+0]*m;c.push(r,l,f)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){let r=t+n*e.length,a=r,o=r+e.length,s=r+e.length+1,c=r+1;i.push(a,o,c),i.push(s,c,o)}this.setIndex(i),this.setAttribute(`position`,new Pi(a,3)),this.setAttribute(`uv`,new Pi(o,2)),this.setAttribute(`normal`,new Pi(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.points,t.segments,t.phiStart,t.phiLength)}},Zc=class e extends Ts{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type=`OctahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},Qc=class e extends Ki{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new Pi(p,3)),this.setAttribute(`normal`,new Pi(m,3)),this.setAttribute(`uv`,new Pi(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},$c=class e extends Ki{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new q,p=new K;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new Pi(s,3)),this.setAttribute(`normal`,new Pi(c,3)),this.setAttribute(`uv`,new Pi(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},el=class e extends Ki{constructor(e=new cc([new K(0,.5),new K(-.5,-.5),new K(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new Pi(r,3)),this.setAttribute(`normal`,new Pi(i,3)),this.setAttribute(`uv`,new Pi(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;Uc.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];Uc.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=Uc.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return tl(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}};function tl(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}var nl=class e extends Ki{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new q,d=new q,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=0;f===0&&a===0?v=.5/t:f===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){let s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(r+s*i)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(s+v,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new Pi(p,3)),this.setAttribute(`normal`,new Pi(m,3)),this.setAttribute(`uv`,new Pi(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},rl=class e extends Ts{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type=`TetrahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},il=class e extends Ki{constructor(e=1,t=.4,n=12,r=48,i=Math.PI*2,a=0,o=Math.PI*2){super(),this.type=`TorusGeometry`,this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i,thetaStart:a,thetaLength:o},n=Math.floor(n),r=Math.floor(r);let s=[],c=[],l=[],u=[],d=new q,f=new q,p=new q;for(let s=0;s<=n;s++){let m=a+s/n*o;for(let a=0;a<=r;a++){let o=a/r*i;f.x=(e+t*Math.cos(m))*Math.cos(o),f.y=(e+t*Math.cos(m))*Math.sin(o),f.z=t*Math.sin(m),c.push(f.x,f.y,f.z),d.x=e*Math.cos(o),d.y=e*Math.sin(o),p.subVectors(f,d).normalize(),l.push(p.x,p.y,p.z),u.push(a/r),u.push(s/n)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*e+t-1,i=(r+1)*(e-1)+t-1,a=(r+1)*(e-1)+t,o=(r+1)*e+t;s.push(n,i,o),s.push(i,a,o)}this.setIndex(s),this.setAttribute(`position`,new Pi(c,3)),this.setAttribute(`normal`,new Pi(l,3)),this.setAttribute(`uv`,new Pi(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},al=class e extends Ki{constructor(e=1,t=.4,n=64,r=8,i=2,a=3){super(),this.type=`TorusKnotGeometry`,this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:a},n=Math.floor(n),r=Math.floor(r);let o=[],s=[],c=[],l=[],u=new q,d=new q,f=new q,p=new q,m=new q,h=new q,g=new q;for(let o=0;o<=n;++o){let v=o/n*i*Math.PI*2;_(v,i,a,e,f),_(v+.01,i,a,e,p),h.subVectors(p,f),g.addVectors(p,f),m.crossVectors(h,g),g.crossVectors(m,h),m.normalize(),g.normalize();for(let e=0;e<=r;++e){let i=e/r*Math.PI*2,a=-t*Math.cos(i),p=t*Math.sin(i);u.x=f.x+(a*g.x+p*m.x),u.y=f.y+(a*g.y+p*m.y),u.z=f.z+(a*g.z+p*m.z),s.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),l.push(o/n),l.push(e/r)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,s=(r+1)*(e-1)+t;o.push(n,i,s),o.push(i,a,s)}this.setIndex(o),this.setAttribute(`position`,new Pi(s,3)),this.setAttribute(`normal`,new Pi(c,3)),this.setAttribute(`uv`,new Pi(l,2));function _(e,t,n,r,i){let a=Math.cos(e),o=Math.sin(e),s=n/t*e,c=Math.cos(s);i.x=r*(2+c)*.5*a,i.y=r*(2+c)*o*.5,i.z=r*Math.sin(s)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}},ol=class e extends Ki{constructor(e=new rc(new q(-1,-1,0),new q(-1,1,0),new q(1,1,0)),t=64,n=1,r=8,i=!1){super(),this.type=`TubeGeometry`,this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};let a=e.computeFrenetFrames(t,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let o=new q,s=new q,c=new K,l=new q,u=[],d=[],f=[],p=[];m(),this.setIndex(p),this.setAttribute(`position`,new Pi(u,3)),this.setAttribute(`normal`,new Pi(d,3)),this.setAttribute(`uv`,new Pi(f,2));function m(){for(let e=0;e<t;e++)h(e);h(i===!1?t:0),_(),g()}function h(i){l=e.getPointAt(i/t,l);let c=a.normals[i],f=a.binormals[i];for(let e=0;e<=r;e++){let t=e/r*Math.PI*2,i=Math.sin(t),a=-Math.cos(t);s.x=a*c.x+i*f.x,s.y=a*c.y+i*f.y,s.z=a*c.z+i*f.z,s.normalize(),d.push(s.x,s.y,s.z),o.x=l.x+n*s.x,o.y=l.y+n*s.y,o.z=l.z+n*s.z,u.push(o.x,o.y,o.z)}}function g(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,o=(r+1)*(e-1)+t;p.push(n,i,o),p.push(i,a,o)}}function _(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)c.x=e/t,c.y=n/r,f.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(t){return new e(new ac[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}},sl=class extends Ki{constructor(e=null){if(super(),this.type=`WireframeGeometry`,this.parameters={geometry:e},e!==null){let t=[],n=new Set,r=new q,i=new q;if(e.index!==null){let a=e.attributes.position,o=e.index,s=e.groups;s.length===0&&(s=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,c=s.length;e<c;++e){let c=s[e],l=c.start,u=c.count;for(let e=l,s=l+u;e<s;e+=3)for(let s=0;s<3;s++){let c=o.getX(e+s),l=o.getX(e+(s+1)%3);r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,l),cl(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{let a=e.attributes.position;for(let e=0,o=a.count/3;e<o;e++)for(let o=0;o<3;o++){let s=3*e+o,c=3*e+(o+1)%3;r.fromBufferAttribute(a,s),i.fromBufferAttribute(a,c),cl(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute(`position`,new Pi(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function cl(e,t,n){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}var ll=Object.freeze({__proto__:null,BoxGeometry:bs,CapsuleGeometry:xs,CircleGeometry:Ss,ConeGeometry:ws,CylinderGeometry:Cs,DodecahedronGeometry:Es,EdgesGeometry:js,ExtrudeGeometry:Kc,IcosahedronGeometry:Yc,LatheGeometry:Xc,OctahedronGeometry:Zc,PlaneGeometry:Qc,PolyhedronGeometry:Ts,RingGeometry:$c,ShapeGeometry:el,SphereGeometry:nl,TetrahedronGeometry:rl,TorusGeometry:il,TorusKnotGeometry:al,TubeGeometry:ol,WireframeGeometry:sl}),ul=class extends Zi{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new Y(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}};function dl(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(pl(i))i.isRenderTargetTexture?(G(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i))if(pl(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice();else t[n][r]=i}}return t}function fl(e){let t={};for(let n=0;n<e.length;n++){let r=dl(e[n]);for(let e in r)t[e]=r[e]}return t}function pl(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function ml(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function hl(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Bn.workingColorSpace}var gl={clone:dl,merge:fl},_l=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,vl=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`,yl=class extends Zi{constructor(e){super(),this.isShaderMaterial=!0,this.type=`ShaderMaterial`,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_l,this.fragmentShader=vl,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=dl(e.uniforms),this.uniformsGroups=ml(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let n in this.uniforms){let r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:`t`,value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:`c`,value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:`v2`,value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:`v3`,value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:`v4`,value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:`m3`,value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:`m4`,value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},bl=class extends yl{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},xl=class extends Zi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new Y(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 Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(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 pr,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}},Sl=class extends xl{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:``,PHYSICAL:``},this.type=`MeshPhysicalMaterial`,this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new K(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return un(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Y(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 Y(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Y(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}},Cl=class extends Zi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new Y(16777215),this.specular=new Y(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pr,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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}},wl=class extends Zi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new Y(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Tl=class extends Zi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},El=class extends Zi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new Y(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pr,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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}},Dl=class extends Zi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=ut,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}},Ol=class extends Zi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},kl=class extends Zi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new Y(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:``},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}},Al=class extends Vo{constructor(e){super(),this.isLineDashedMaterial=!0,this.type=`LineDashedMaterial`,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function jl(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function Ml(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function Nl(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Pl(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0)if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}function Fl(e,t,n,r,i=30){let a=e.clone();a.name=t;let o=[];for(let e=0;e<a.tracks.length;++e){let t=a.tracks[e],s=t.getValueSize(),c=[],l=[];for(let e=0;e<t.times.length;++e){let a=t.times[e]*i;if(!(a<n||a>=r)){c.push(t.times[e]);for(let n=0;n<s;++n)l.push(t.values[e*s+n])}}c.length!==0&&(t.times=jl(c,t.times.constructor),t.values=jl(l,t.values.constructor),o.push(t))}a.tracks=o;let s=1/0;for(let e=0;e<a.tracks.length;++e)s>a.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*s);return a.resetDuration(),a}function Il(e,t=0,n=e,r=30){r<=0&&(r=30);let i=n.tracks.length,a=t/r;for(let t=0;t<i;++t){let r=n.tracks[t],i=r.ValueTypeName;if(i===`bool`||i===`string`)continue;let o=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===i});if(o===void 0)continue;let s=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=c/3);let l=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=u/3);let d=r.times.length-1,f;if(a<=r.times[0]){let e=s,t=c-s;f=r.values.slice(e,t)}else if(a>=r.times[d]){let e=d*c+s,t=e+c-s;f=r.values.slice(e,t)}else{let e=r.createInterpolant(),t=s,n=c-s;e.evaluate(a),f=e.resultBuffer.slice(t,n)}i===`quaternion`&&new Mn().fromArray(f).normalize().conjugate().toArray(f);let p=o.times.length;for(let e=0;e<p;++e){let t=e*u+l;if(i===`quaternion`)Mn.multiplyQuaternionsFlat(o.values,t,f,0,o.values,t);else{let e=u-l*2;for(let n=0;n<e;++n)o.values[t+n]-=f[n]}}}return e.blendMode=lt,e}var Ll=class{static convertArray(e,t){return jl(e,t)}static isTypedArray(e){return Wt(e)}static getKeyframeOrder(e){return Ml(e)}static sortedArray(e,t,n){return Nl(e,t,n)}static flattenJSON(e,t,n,r){Pl(e,t,n,r)}static subclip(e,t,n,r,i=30){return Fl(e,t,n,r,i)}static makeClipAdditive(e,t=0,n=e,r=30){return Il(e,t,n,r)}},Rl=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},zl=class extends Rl{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:at,endingEnd:at}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case ot:i=e,o=2*t-n;break;case st:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case ot:a=e,s=2*n-t;break;case st:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},Bl=class extends Rl{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},Vl=class extends Rl{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Hl=class extends Rl{interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this.settings||this.DefaultSettings_,u=l.inTangents,d=l.outTangents;if(!u||!d){let e=(n-t)/(r-t),l=1-e;for(let t=0;t!==o;++t)i[t]=a[c+t]*l+a[s+t]*e;return i}let f=o*2,p=e-1;for(let l=0;l!==o;++l){let o=a[c+l],m=a[s+l],h=p*f+l*2,g=d[h],_=d[h+1],v=e*f+l*2,y=u[v],b=u[v+1],x=(n-t)/(r-t),S,C,w,T,E;for(let e=0;e<8;e++){S=x*x,C=S*x,w=1-x,T=w*w,E=T*w;let e=E*t+3*T*x*g+3*w*S*y+C*r-n;if(Math.abs(e)<1e-10)break;let i=3*T*(g-t)+6*w*x*(y-g)+3*S*(r-y);if(Math.abs(i)<1e-10)break;x-=e/i,x=Math.max(0,Math.min(1,x))}i[l]=E*o+3*T*x*_+3*w*S*b+C*m}return i}},Ul=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=jl(t,this.TimeBufferType),this.values=jl(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:jl(e.times,Array),values:jl(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Vl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Bl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new zl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Hl(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case tt:t=this.InterpolantFactoryMethodDiscrete;break;case nt:t=this.InterpolantFactoryMethodLinear;break;case rt:t=this.InterpolantFactoryMethodSmooth;break;case it:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let t=`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 Error(t);return G(`KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return tt;case this.InterpolantFactoryMethodLinear:return nt;case this.InterpolantFactoryMethodSmooth:return rt;case this.InterpolantFactoryMethodBezier:return it}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&($t(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&($t(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){$t(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){$t(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&Wt(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){$t(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===rt,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Ul.prototype.ValueTypeName=``,Ul.prototype.TimeBufferType=Float32Array,Ul.prototype.ValueBufferType=Float32Array,Ul.prototype.DefaultInterpolation=nt;var Wl=class extends Ul{constructor(e,t,n){super(e,t,n)}};Wl.prototype.ValueTypeName=`bool`,Wl.prototype.ValueBufferType=Array,Wl.prototype.DefaultInterpolation=tt,Wl.prototype.InterpolantFactoryMethodLinear=void 0,Wl.prototype.InterpolantFactoryMethodSmooth=void 0;var Gl=class extends Ul{constructor(e,t,n,r){super(e,t,n,r)}};Gl.prototype.ValueTypeName=`color`;var Kl=class extends Ul{constructor(e,t,n,r){super(e,t,n,r)}};Kl.prototype.ValueTypeName=`number`;var ql=class extends Rl{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Mn.slerpFlat(i,0,a,c-o,a,c,s);return i}},Jl=class extends Ul{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new ql(this.times,this.values,this.getValueSize(),e)}};Jl.prototype.ValueTypeName=`quaternion`,Jl.prototype.InterpolantFactoryMethodSmooth=void 0;var Yl=class extends Ul{constructor(e,t,n){super(e,t,n)}};Yl.prototype.ValueTypeName=`string`,Yl.prototype.ValueBufferType=Array,Yl.prototype.DefaultInterpolation=tt,Yl.prototype.InterpolantFactoryMethodLinear=void 0,Yl.prototype.InterpolantFactoryMethodSmooth=void 0;var Xl=class extends Ul{constructor(e,t,n,r){super(e,t,n,r)}};Xl.prototype.ValueTypeName=`vector`;var Zl=class{constructor(e=``,t=-1,n=[],r=ct){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=ln(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push($l(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i.userData=JSON.parse(e.userData||`{}`),i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,r=n.length;e!==r;++e)t.push(Ul.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e<i;e++){let o=[],s=[];o.push((e+i-1)%i,e,(e+1)%i),s.push(0,1,0);let c=Ml(o);o=Nl(o,1,c),s=Nl(s,1,c),!r&&o[0]===0&&(o.push(i),s.push(s[0])),a.push(new Kl(`.morphTargetInfluences[`+t[e].name+`]`,o,s).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let r={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){let n=e[t],a=n.name.match(i);if(a&&a.length>1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}static parseAnimation(e,t){if(G(`AnimationClip: parseAnimation() is deprecated and will be removed with r185`),!e)return $t(`AnimationClip: No animation in JSONLoader data.`),null;let n=function(e,t,n,r,i){if(n.length!==0){let a=[],o=[];Pl(n,a,o,r),a.length!==0&&i.push(new e(t,a,o))}},r=[],i=e.name||`default`,a=e.fps||30,o=e.blendMode,s=e.length||-1,c=e.hierarchy||[];for(let e=0;e<c.length;e++){let i=c[e].keys;if(!(!i||i.length===0))if(i[0].morphTargets){let e={},t;for(t=0;t<i.length;t++)if(i[t].morphTargets)for(let n=0;n<i[t].morphTargets.length;n++)e[i[t].morphTargets[n]]=-1;for(let n in e){let e=[],a=[];for(let r=0;r!==i[t].morphTargets.length;++r){let r=i[t];e.push(r.time),a.push(+(r.morphTarget===n))}r.push(new Kl(`.morphTargetInfluence[`+n+`]`,e,a))}s=e.length*a}else{let a=`.bones[`+t[e].name+`]`;n(Xl,a+`.position`,i,`pos`,r),n(Jl,a+`.quaternion`,i,`rot`,r),n(Xl,a+`.scale`,i,`scl`,r)}}return r.length===0?null:new this(i,s,r,o)}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let e=this.tracks[n];t=Math.max(t,e.times[e.times.length-1])}return this.duration=t,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 t=0;t<this.tracks.length;t++)e&&=this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}};function Ql(e){switch(e.toLowerCase()){case`scalar`:case`double`:case`float`:case`number`:case`integer`:return Kl;case`vector`:case`vector2`:case`vector3`:case`vector4`:return Xl;case`color`:return Gl;case`quaternion`:return Jl;case`bool`:case`boolean`:return Wl;case`string`:return Yl}throw Error(`THREE.KeyframeTrack: Unsupported typeName: `+e)}function $l(e){if(e.type===void 0)throw Error(`THREE.KeyframeTrack: track type undefined, can not parse`);let t=Ql(e.type);if(e.times===void 0){let t=[],n=[];Pl(e.keys,t,n,`value`),e.times=t,e.values=n}return t.parse===void 0?new t(e.name,e.times,e.values,e.interpolation):t.parse(e)}var eu={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(tu(e)||(this.files[e]=t))},get:function(e){if(this.enabled!==!1&&!tu(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function tu(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch{return!1}}var nu=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||=new AbortController,this._abortController}},ru=new nu,iu=class{constructor(e){this.manager=e===void 0?ru:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}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}abort(){return this}};iu.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var au={},ou=class extends Error{constructor(e,t){super(e),this.response=t}},su=class extends iu{constructor(e){super(e),this.mimeType=``,this.responseType=``,this._abortController=new AbortController}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=eu.get(`file:${e}`);if(i!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(i),this.manager.itemEnd(e)},0);return}if(au[e]!==void 0){au[e].push({onLoad:t,onProgress:n,onError:r});return}au[e]=[],au[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`,signal:typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&G(`FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=au[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e<t;e++){let t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(i),t()}},t=>{e.error(t)})}}});return new Response(c)}else throw new ou(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===``)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{eu.add(`file:${e}`,t);let n=au[e];delete au[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onLoad&&r.onLoad(t)}}).catch(t=>{let n=au[e];if(n===void 0)throw this.manager.itemError(e),t;delete au[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onError&&r.onError(t)}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}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},cu=class extends iu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new su(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):$t(t),i.manager.itemError(e)}},n,r)}parse(e){let t=[];for(let n=0;n<e.length;n++){let r=Zl.parse(e[n]);t.push(r)}return t}},lu=class extends iu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=[],o=new ds,s=new su(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let c=0;function l(l){s.load(e[l],function(e){let n=i.parse(e,!0);a[l]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},c+=1,c===6&&(n.mipmapCount===1&&(o.minFilter=M),o.image=a,o.format=n.format,o.needsUpdate=!0,t&&t(o))},n,r)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)l(t);else s.load(e,function(e){let n=i.parse(e,!0);if(n.isCubemap){let e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){a[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)a[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),a[t].format=n.format,a[t].width=n.width,a[t].height=n.height}o.image=a}else o.image.width=n.width,o.image.height=n.height,o.mipmaps=n.mipmaps;n.mipmapCount===1&&(o.minFilter=M),o.format=n.format,o.needsUpdate=!0,t&&t(o)},n,r);return o}},uu=new WeakMap,du=class extends iu{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=eu.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);else{let e=uu.get(a);e===void 0&&(e=[],uu.set(a,e)),e.push({onLoad:t,onError:r})}return a}let o=Gt(`img`);function s(){l(),t&&t(this);let n=uu.get(this)||[];for(let e=0;e<n.length;e++){let t=n[e];t.onLoad&&t.onLoad(this)}uu.delete(this),i.manager.itemEnd(e)}function c(t){l(),r&&r(t),eu.remove(`image:${e}`);let n=uu.get(this)||[];for(let e=0;e<n.length;e++){let r=n[e];r.onError&&r.onError(t)}uu.delete(this),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1)}return o.addEventListener(`load`,s,!1),o.addEventListener(`error`,c,!1),e.slice(0,5)!==`data:`&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),eu.add(`image:${e}`,o),i.manager.itemStart(e),o.src=e,o}},fu=class extends iu{constructor(e){super(e)}load(e,t,n,r){let i=new ms;i.colorSpace=mt;let a=new du(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function s(n){a.load(e[n],function(e){i.images[n]=e,o++,o===6&&(i.needsUpdate=!0,t&&t(i))},void 0,r)}for(let t=0;t<e.length;++t)s(t);return i}},pu=class extends iu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new Za,o=new su(this.manager);return o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(i.withCredentials),o.load(e,function(e){let n;try{n=i.parse(e)}catch(e){r===void 0?$t(e):r(e);return}n.image===void 0?n.data!==void 0&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data):a.image=n.image,a.wrapS=n.wrapS===void 0?T:n.wrapS,a.wrapT=n.wrapT===void 0?T:n.wrapT,a.magFilter=n.magFilter===void 0?M:n.magFilter,a.minFilter=n.minFilter===void 0?M:n.minFilter,a.anisotropy=n.anisotropy===void 0?1:n.anisotropy,n.colorSpace!==void 0&&(a.colorSpace=n.colorSpace),n.flipY!==void 0&&(a.flipY=n.flipY),n.format!==void 0&&(a.format=n.format),n.type!==void 0&&(a.type=n.type),n.mipmaps!==void 0&&(a.mipmaps=n.mipmaps,a.minFilter=F),n.mipmapCount===1&&(a.minFilter=M),n.generateMipmaps!==void 0&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)},n,r),a}},mu=class extends iu{constructor(e){super(e)}load(e,t,n,r){let i=new Xn,a=new du(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){i.image=e,i.needsUpdate=!0,t!==void 0&&t(i)},n,r),i}},hu=class extends Ar{constructor(e,t=1){super(),this.isLight=!0,this.type=`Light`,this.color=new Y(e),this.intensity=t}dispose(){this.dispatchEvent({type:`dispose`})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},gu=class extends hu{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type=`HemisphereLight`,this.position.copy(Ar.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Y(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},_u=new J,vu=new q,yu=new q,bu=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new K(512,512),this.mapType=L,this.map=null,this.mapPass=null,this.matrix=new J,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new vo,this._frameExtents=new K(1,1),this._viewportCount=1,this._viewports=[new Zn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;vu.setFromMatrixPosition(e.matrixWorld),t.position.copy(vu),yu.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(yu),t.updateMatrixWorld(),_u.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_u,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===2001||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(_u)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let 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}},xu=new q,Su=new Mn,Cu=new q,wu=class extends Ar{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new J,this.projectionMatrix=new J,this.projectionMatrixInverse=new J,this.coordinateSystem=Ft,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(xu,Su,Cu),Cu.x===1&&Cu.y===1&&Cu.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xu,Su,Cu.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(xu,Su,Cu),Cu.x===1&&Cu.y===1&&Cu.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xu,Su,Cu.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},Tu=new q,Eu=new K,Du=new K,Ou=class extends wu{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=cn*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(sn*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return cn*2*Math.atan(Math.tan(sn*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Tu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Tu.x,Tu.y).multiplyScalar(-e/Tu.z),Tu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Tu.x,Tu.y).multiplyScalar(-e/Tu.z)}getViewSize(e,t){return this.getViewBounds(e,Eu,Du),t.subVectors(Du,Eu)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(sn*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},ku=class extends bu{constructor(){super(new Ou(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=cn*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,i=e.distance||t.far;(n!==t.fov||r!==t.aspect||i!==t.far)&&(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Au=class extends hu{constructor(e,t,n=0,r=Math.PI/3,i=0,a=2){super(e,t),this.isSpotLight=!0,this.type=`SpotLight`,this.position.copy(Ar.DEFAULT_UP),this.updateMatrix(),this.target=new Ar,this.distance=n,this.angle=r,this.penumbra=i,this.decay=a,this.map=null,this.shadow=new ku}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},ju=class extends bu{constructor(){super(new Ou(90,1,.5,500)),this.isPointLightShadow=!0}},Mu=class extends hu{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type=`PointLight`,this.distance=n,this.decay=r,this.shadow=new ju}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},Nu=class extends wu{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),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,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Pu=class extends bu{constructor(){super(new Nu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Fu=class extends hu{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type=`DirectionalLight`,this.position.copy(Ar.DEFAULT_UP),this.updateMatrix(),this.target=new Ar,this.shadow=new Pu}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},Iu=class extends hu{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type=`AmbientLight`}},Lu=class extends hu{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type=`RectAreaLight`,this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Ru=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new q)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*i),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*r*1.092548),t.addScaledVector(a[5],r*i*1.092548),t.addScaledVector(a[6],.315392*(3*i*i-1)),t.addScaledVector(a[7],n*i*1.092548),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*i),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*i),t.addScaledVector(a[6],.743125*i*i-.247708),t.addScaledVector(a[7],2*.429043*n*i),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}},zu=class extends hu{constructor(e=new Ru,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Bu=class e extends iu{constructor(e){super(e),this.textures={}}load(e,t,n,r){let i=this,a=new su(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):$t(t),i.manager.itemError(e)}},n,r)}parse(e){let t=this.textures;function n(e){return t[e]===void 0&&G(`MaterialLoader: Undefined texture`,e),t[e]}let r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new Y().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(r.allowOverride=e.allowOverride),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors==`number`?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let t in e.uniforms){let i=e.uniforms[t];switch(r.uniforms[t]={},i.type){case`t`:r.uniforms[t].value=n(i.value);break;case`c`:r.uniforms[t].value=new Y().setHex(i.value);break;case`v2`:r.uniforms[t].value=new K().fromArray(i.value);break;case`v3`:r.uniforms[t].value=new q().fromArray(i.value);break;case`v4`:r.uniforms[t].value=new Zn().fromArray(i.value);break;case`m3`:r.uniforms[t].value=new Fn().fromArray(i.value);break;case`m4`:r.uniforms[t].value=new J().fromArray(i.value);break;default:r.uniforms[t].value=i.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let t in e.extensions)r.extensions[t]=e.extensions[t];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),r.normalScale=new K().fromArray(t)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new K().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(t){return e.createMaterialFromType(t)}static createMaterialFromType(e){return new{ShadowMaterial:ul,SpriteMaterial:Qi,RawShaderMaterial:bl,ShaderMaterial:yl,PointsMaterial:ts,MeshPhysicalMaterial:Sl,MeshStandardMaterial:xl,MeshPhongMaterial:Cl,MeshToonMaterial:wl,MeshNormalMaterial:Tl,MeshLambertMaterial:El,MeshDepthMaterial:Dl,MeshDistanceMaterial:Ol,MeshBasicMaterial:Ta,MeshMatcapMaterial:kl,LineDashedMaterial:Al,LineBasicMaterial:Vo,Material:Zi}[e]}},Vu=class{static extractUrlBase(e){let t=e.lastIndexOf(`/`);return t===-1?`./`:e.slice(0,t+1)}static resolveURL(e,t){return typeof e!=`string`||e===``?``:(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,`$1`)),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Hu=class extends Ki{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type=`InstancedBufferGeometry`,this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Uu=class extends iu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new su(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):$t(t),i.manager.itemError(e)}},n,r)}parse(e){let t={},n={};function r(e,n){if(t[n]!==void 0)return t[n];let r=e.interleavedBuffers[n],a=i(e,r.buffer),o=new qi(Ut(r.type,a),r.stride);return o.uuid=r.uuid,t[n]=o,o}function i(e,t){if(n[t]!==void 0)return n[t];let r=e.arrayBuffers[t],i=new Uint32Array(r).buffer;return n[t]=i,i}let a=e.isInstancedBufferGeometry?new Hu:new Ki,o=e.data.index;if(o!==void 0){let e=Ut(o.type,o.array);a.setIndex(new Ti(e,1))}let s=e.data.attributes;for(let t in s){let n=s[t],i;if(n.isInterleavedBufferAttribute)i=new Yi(r(e.data,n.data),n.itemSize,n.offset,n.normalized);else{let e=Ut(n.type,n.array);i=new(n.isInstancedBufferAttribute?to:Ti)(e,n.itemSize,n.normalized)}n.name!==void 0&&(i.name=n.name),n.usage!==void 0&&i.setUsage(n.usage),a.setAttribute(t,i)}let c=e.data.morphAttributes;if(c)for(let t in c){let n=c[t],i=[];for(let t=0,a=n.length;t<a;t++){let a=n[t],o;o=a.isInterleavedBufferAttribute?new Yi(r(e.data,a.data),a.itemSize,a.offset,a.normalized):new Ti(Ut(a.type,a.array),a.itemSize,a.normalized),a.name!==void 0&&(o.name=a.name),i.push(o)}a.morphAttributes[t]=i}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(l!==void 0)for(let e=0,t=l.length;e!==t;++e){let t=l[e];a.addGroup(t.start,t.count,t.materialIndex)}let u=e.data.boundingSphere;return u!==void 0&&(a.boundingSphere=new Ri().fromJSON(u)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},Wu={},Gu=class extends iu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=this.path===``?Vu.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;let o=new su(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(n){let a=null;try{a=JSON.parse(n)}catch(t){r!==void 0&&r(t),$t(`ObjectLoader: Can't parse `+e+`.`,t.message);return}let o=a.metadata;if(o===void 0||o.type===void 0||o.type.toLowerCase()===`geometry`){r!==void 0&&r(Error(`THREE.ObjectLoader: Can't load `+e)),$t(`ObjectLoader: Can't load `+e);return}i.parse(a,t)},n,r)}async loadAsync(e,t){let n=this,r=this.path===``?Vu.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let i=new su(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);let a=await i.loadAsync(e,t),o;try{o=JSON.parse(a)}catch(t){throw Error(`ObjectLoader: Can't parse `+e+`. `+t.message)}let s=o.metadata;if(s===void 0||s.type===void 0||s.type.toLowerCase()===`geometry`)throw Error(`THREE.ObjectLoader: Can't load `+e);return await n.parseAsync(o)}parse(e,t){let n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),s=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,i,s,o,n),l=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,l),this.bindLightTargets(c),t!==void 0){let e=!1;for(let t in a)if(a[t].data instanceof HTMLImageElement){e=!0;break}e===!1&&t(c)}return c}async parseAsync(e){let t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),i=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,i),o=this.parseMaterials(e.materials,a),s=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,s);return this.bindSkeletons(s,c),this.bindLightTargets(s),s}static registerGeometry(e,t){Wu[e]=t}parseShapes(e){let t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){let r=new cc().fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){let n={},r={};if(t.traverse(function(e){e.isBone&&(r[e.uuid]=e)}),e!==void 0)for(let t=0,i=e.length;t<i;t++){let i=new eo().fromJSON(e[t],r);n[i.uuid]=i}return n}parseGeometries(e,t){let n={};if(e!==void 0){let r=new Uu;for(let i=0,a=e.length;i<a;i++){let a,o=e[i];switch(o.type){case`BufferGeometry`:case`InstancedBufferGeometry`:a=r.parse(o);break;default:o.type in ll?a=ll[o.type].fromJSON(o,t):o.type in Wu?a=Wu[o.type].fromJSON(o,t):G(`ObjectLoader: Unknown geometry type "${o.type}". Use .registerGeometry() before starting the deserialization process.`)}a.uuid=o.uuid,o.name!==void 0&&(a.name=o.name),o.userData!==void 0&&(a.userData=o.userData),n[o.uuid]=a}}return n}parseMaterials(e,t){let n={},r={};if(e!==void 0){let i=new Bu;i.setTextures(t);for(let t=0,a=e.length;t<a;t++){let a=e[t];n[a.uuid]===void 0&&(n[a.uuid]=i.parse(a)),r[a.uuid]=n[a.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let n=0;n<e.length;n++){let r=e[n],i=Zl.parse(r);t[i.uuid]=i}return t}parseImages(e,t){let n=this,r={},i;function a(e){return n.manager.itemStart(e),i.load(e,function(){n.manager.itemEnd(e)},void 0,function(){n.manager.itemError(e),n.manager.itemEnd(e)})}function o(e){if(typeof e==`string`){let t=e;return a(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}else if(e.data)return{data:Ut(e.type,e.data),width:e.width,height:e.height};else return null}if(e!==void 0&&e.length>0){i=new du(new nu(t)),i.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){let n=e[t],i=n.url;if(Array.isArray(i)){let e=[];for(let t=0,n=i.length;t<n;t++){let n=i[t],r=o(n);r!==null&&(r instanceof HTMLImageElement?e.push(r):e.push(new Za(r.data,r.width,r.height)))}r[n.uuid]=new Kn(e)}else{let e=o(n.url);r[n.uuid]=new Kn(e)}}}return r}async parseImagesAsync(e){let t=this,n={},r;async function i(e){if(typeof e==`string`){let n=e,i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await r.loadAsync(i)}else if(e.data)return{data:Ut(e.type,e.data),width:e.width,height:e.height};else return null}if(e!==void 0&&e.length>0){r=new du(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t<r;t++){let r=e[t],a=r.url;if(Array.isArray(a)){let e=[];for(let t=0,n=a.length;t<n;t++){let n=a[t],r=await i(n);r!==null&&(r instanceof HTMLImageElement?e.push(r):e.push(new Za(r.data,r.width,r.height)))}n[r.uuid]=new Kn(e)}else{let e=await i(r.url);n[r.uuid]=new Kn(e)}}}return n}parseTextures(e,t){function n(e,t){return typeof e==`number`?e:(G(`ObjectLoader.parseTexture: Constant should be in numeric form.`,e),t[e])}let r={};if(e!==void 0)for(let i=0,a=e.length;i<a;i++){let a=e[i];a.image===void 0&&G(`ObjectLoader: No "image" specified for`,a.uuid),t[a.image]===void 0&&G(`ObjectLoader: Undefined image`,a.image);let o=t[a.image],s=o.data,c;Array.isArray(s)?(c=new ms,s.length===6&&(c.needsUpdate=!0)):(c=s&&s.data?new Za:new Xn,s&&(c.needsUpdate=!0)),c.source=o,c.uuid=a.uuid,a.name!==void 0&&(c.name=a.name),a.mapping!==void 0&&(c.mapping=n(a.mapping,Ku)),a.channel!==void 0&&(c.channel=a.channel),a.offset!==void 0&&c.offset.fromArray(a.offset),a.repeat!==void 0&&c.repeat.fromArray(a.repeat),a.center!==void 0&&c.center.fromArray(a.center),a.rotation!==void 0&&(c.rotation=a.rotation),a.wrap!==void 0&&(c.wrapS=n(a.wrap[0],qu),c.wrapT=n(a.wrap[1],qu)),a.format!==void 0&&(c.format=a.format),a.internalFormat!==void 0&&(c.internalFormat=a.internalFormat),a.type!==void 0&&(c.type=a.type),a.colorSpace!==void 0&&(c.colorSpace=a.colorSpace),a.minFilter!==void 0&&(c.minFilter=n(a.minFilter,Ju)),a.magFilter!==void 0&&(c.magFilter=n(a.magFilter,Ju)),a.anisotropy!==void 0&&(c.anisotropy=a.anisotropy),a.flipY!==void 0&&(c.flipY=a.flipY),a.generateMipmaps!==void 0&&(c.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(c.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(c.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(c.compareFunction=a.compareFunction),a.normalized!==void 0&&(c.normalized=a.normalized),a.userData!==void 0&&(c.userData=a.userData),r[a.uuid]=c}return r}parseObject(e,t,n,r,i){let a;function o(e){return t[e]===void 0&&G(`ObjectLoader: Undefined geometry`,e),t[e]}function s(e){if(e!==void 0){if(Array.isArray(e)){let t=[];for(let r=0,i=e.length;r<i;r++){let i=e[r];n[i]===void 0&&G(`ObjectLoader: Undefined material`,i),t.push(n[i])}return t}return n[e]===void 0&&G(`ObjectLoader: Undefined material`,e),n[e]}}function c(e){return r[e]===void 0&&G(`ObjectLoader: Undefined texture`,e),r[e]}let l,u;switch(e.type){case`Scene`:a=new Vr,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new Y(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type===`Fog`?a.fog=new Br(e.fog.color,e.fog.near,e.fog.far):e.fog.type===`FogExp2`&&(a.fog=new zr(e.fog.color,e.fog.density)),e.fog.name!==``&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case`PerspectiveCamera`:a=new Ou(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case`OrthographicCamera`:a=new Nu(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case`AmbientLight`:a=new Iu(e.color,e.intensity);break;case`DirectionalLight`:a=new Fu(e.color,e.intensity),a.target=e.target||``;break;case`PointLight`:a=new Mu(e.color,e.intensity,e.distance,e.decay);break;case`RectAreaLight`:a=new Lu(e.color,e.intensity,e.width,e.height);break;case`SpotLight`:a=new Au(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||``;break;case`HemisphereLight`:a=new gu(e.color,e.groundColor,e.intensity);break;case`LightProbe`:a=new zu(new Ru().fromArray(e.sh),e.intensity);break;case`SkinnedMesh`:l=o(e.geometry),u=s(e.material),a=new Ya(l,u),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case`Mesh`:l=o(e.geometry),u=s(e.material),a=new La(l,u);break;case`InstancedMesh`:l=o(e.geometry),u=s(e.material);let t=e.count,n=e.instanceMatrix,r=e.instanceColor;a=new lo(l,u,t),a.instanceMatrix=new to(new Float32Array(n.array),16),r!==void 0&&(a.instanceColor=new to(new Float32Array(r.array),r.itemSize));break;case`BatchedMesh`:l=o(e.geometry),u=s(e.material),a=new Bo(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,u),a.geometry=l,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(e=>{let t=null,n=null;return e.boundingBox!==void 0&&(t=new ni().fromJSON(e.boundingBox)),e.boundingSphere!==void 0&&(n=new Ri().fromJSON(e.boundingSphere)),{...e,boundingBox:t,boundingSphere:n}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new Ri().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new ni().fromJSON(e.boundingBox));break;case`LOD`:a=new ga;break;case`Line`:a=new Yo(o(e.geometry),s(e.material));break;case`LineLoop`:a=new es(o(e.geometry),s(e.material));break;case`LineSegments`:a=new $o(o(e.geometry),s(e.material));break;case`PointCloud`:case`Points`:a=new os(o(e.geometry),s(e.material));break;case`Sprite`:a=new fa(s(e.material));break;case`Group`:a=new jr;break;case`Bone`:a=new Xa;break;default:a=new Ar}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix===void 0?(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)):(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.pivot!==void 0&&(a.pivot=new q().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){let o=e.children;for(let e=0;e<o.length;e++)a.add(this.parseObject(o[e],t,n,r,i))}if(e.animations!==void 0){let t=e.animations;for(let e=0;e<t.length;e++){let n=t[e];a.animations.push(i[n])}}if(e.type===`LOD`){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);let t=e.levels;for(let e=0;e<t.length;e++){let n=t[e],r=a.getObjectByProperty(`uuid`,n.object);r!==void 0&&a.addLevel(r,n.distance,n.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(e){if(e.isSkinnedMesh===!0&&e.skeleton!==void 0){let n=t[e.skeleton];n===void 0?G(`ObjectLoader: No skeleton found with UUID:`,e.skeleton):e.bind(n,e.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){let n=t.target,r=e.getObjectByProperty(`uuid`,n);r===void 0?t.target=new Ar:t.target=r}})}},Ku={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,CubeUVReflectionMapping:306},qu={RepeatWrapping:w,ClampToEdgeWrapping:T,MirroredRepeatWrapping:E},Ju={NearestFilter:D,NearestMipmapNearestFilter:O,NearestMipmapLinearFilter:A,LinearFilter:M,LinearMipmapNearestFilter:N,LinearMipmapLinearFilter:F},Yu=new WeakMap,Xu=class extends iu{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>`u`&&G(`ImageBitmapLoader: createImageBitmap() not supported.`),typeof fetch>`u`&&G(`ImageBitmapLoader: fetch() not supported.`),this.options={premultiplyAlpha:`none`},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=eu.get(`image-bitmap:${e}`);if(a!==void 0){if(i.manager.itemStart(e),a.then){a.then(n=>{Yu.has(a)===!0?(r&&r(Yu.get(a)),i.manager.itemError(e),i.manager.itemEnd(e)):(t&&t(n),i.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin===`anonymous`?`same-origin`:`include`,o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let s=fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:`none`}))}).then(function(n){eu.add(`image-bitmap:${e}`,n),t&&t(n),i.manager.itemEnd(e)}).catch(function(t){r&&r(t),Yu.set(s,t),eu.remove(`image-bitmap:${e}`),i.manager.itemError(e),i.manager.itemEnd(e)});eu.add(`image-bitmap:${e}`,s),i.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Zu,Qu=class{static getContext(){return Zu===void 0&&(Zu=new(window.AudioContext||window.webkitAudioContext)),Zu}static setContext(e){Zu=e}},$u=class extends iu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new su(this.manager);a.setResponseType(`arraybuffer`),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{let r=n.slice(0),a=Qu.getContext(),s=e+`#decode`;i.manager.itemStart(s),a.decodeAudioData(r,function(e){t(e),i.manager.itemEnd(s)}).catch(function(e){o(e),i.manager.itemEnd(s)})}catch(e){o(e)}},n,r);function o(t){r?r(t):$t(t),i.manager.itemError(e)}}},ed=new J,td=new J,nd=new J,rd=class{constructor(){this.type=`StereoCamera`,this.aspect=1,this.eyeSep=.064,this.cameraL=new Ou,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ou,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,nd.copy(e.projectionMatrix);let n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(sn*t.fov*.5)/t.zoom,a,o;td.elements[12]=-n,ed.elements[12]=n,a=-i*t.aspect+r,o=i*t.aspect+r,nd.elements[0]=2*t.near/(o-a),nd.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(nd),a=-i*t.aspect-r,o=i*t.aspect-r,nd.elements[0]=2*t.near/(o-a),nd.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(nd)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(td),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(ed)}},id=-90,ad=1,od=class extends Ar{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Ou(id,ad,e,t);r.layers=this.layers,this.add(r);let i=new Ou(id,ad,e,t);i.layers=this.layers,this.add(i);let a=new Ou(id,ad,e,t);a.layers=this.layers,this.add(a);let o=new Ou(id,ad,e,t);o.layers=this.layers,this.add(o);let s=new Ou(id,ad,e,t);s.layers=this.layers,this.add(s);let c=new Ou(id,ad,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let h=!1;h=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(n,0,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,i),e.setRenderTarget(n,1,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,4,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},sd=class extends Ou{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},cd=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=ld.bind(this),e.addEventListener(`visibilitychange`,this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener(`visibilitychange`,this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e===void 0?performance.now():e)-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function ld(){this._document.hidden===!1&&this.reset()}var ud=new q,dd=new Mn,fd=new q,pd=new q,md=new q,hd=class extends Ar{constructor(){super(),this.type=`AudioListener`,this.context=Qu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new cd}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter===null?this.gain.disconnect(this.context.destination):(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this._timer.update();let t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(ud,dd,fd),pd.set(0,0,-1).applyQuaternion(dd),md.set(0,1,0).applyQuaternion(dd),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(ud.x,e),t.positionY.linearRampToValueAtTime(ud.y,e),t.positionZ.linearRampToValueAtTime(ud.z,e),t.forwardX.linearRampToValueAtTime(pd.x,e),t.forwardY.linearRampToValueAtTime(pd.y,e),t.forwardZ.linearRampToValueAtTime(pd.z,e),t.upX.linearRampToValueAtTime(md.x,e),t.upY.linearRampToValueAtTime(md.y,e),t.upZ.linearRampToValueAtTime(md.z,e)}else t.setPosition(ud.x,ud.y,ud.z),t.setOrientation(pd.x,pd.y,pd.z,md.x,md.y,md.z)}},gd=class extends Ar{constructor(e){super(),this.type=`Audio`,this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType=`empty`,this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType=`audioNode`,this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType=`mediaNode`,this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType=`mediaStreamNode`,this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType=`buffer`,this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){G(`Audio: Audio is already playing.`);return}if(this.hasPlaybackControl===!1){G(`Audio: this Audio has no playback control.`);return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){G(`Audio: this Audio has no playback control.`);return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress%=this.duration||this.buffer.duration),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){G(`Audio: this Audio has no playback control.`);return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||=[],this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){G(`Audio: this Audio has no playback control.`);return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(G(`Audio: this Audio has no playback control.`),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){G(`Audio: this Audio has no playback control.`);return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType===`buffer`?(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this):(G(`Audio: Audio source type cannot be copied.`),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}},_d=new q,vd=new Mn,yd=new q,bd=new q,xd=class extends gd{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel=`HRTF`,this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(_d,vd,yd),bd.set(0,0,1).applyQuaternion(vd);let t=this.panner;if(t.positionX){let e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(_d.x,e),t.positionY.linearRampToValueAtTime(_d.y,e),t.positionZ.linearRampToValueAtTime(_d.z,e),t.orientationX.linearRampToValueAtTime(bd.x,e),t.orientationY.linearRampToValueAtTime(bd.y,e),t.orientationZ.linearRampToValueAtTime(bd.z,e)}else t.setPosition(_d.x,_d.y,_d.z),t.setOrientation(bd.x,bd.y,bd.z)}},Sd=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}},Cd=class{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,i,a;switch(t){case`quaternion`:r=this._slerp,i=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case`string`:case`bool`:r=this._select,i=this._select,a=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:r=this._lerp,i=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,r=this.valueSize,i=e*r+r,a=this.cumulativeWeight;if(a===0){for(let e=0;e!==r;++e)n[i+e]=n[e];a=t}else{a+=t;let e=t/a;this._mixBufferRegion(n,i,0,e,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){let e=t*this._origIndex;this._mixBufferRegion(n,r,e,1-i,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){o.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,i){if(r>=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){Mn.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){let a=this._workIndex*i;Mn.multiplyQuaternionsFlat(e,a,e,t,e,n),Mn.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,i){let a=1-r;for(let o=0;o!==i;++o){let i=t+o;e[i]=e[i]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,i){for(let a=0;a!==i;++a){let i=t+a;e[i]=e[i]+e[n+a]*r}}},wd=`\\[\\]\\.:\\/`,Td=RegExp(`[\\[\\]\\.:\\/]`,`g`),Ed=`[^\\[\\]\\.:\\/]`,Dd=`[^`+wd.replace(`\\.`,``)+`]`,Od=`((?:WC+[\\/:])*)`.replace(`WC`,Ed),kd=`(WCOD+)?`.replace(`WCOD`,Dd),Ad=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,Ed),jd=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,Ed),Md=RegExp(`^`+Od+kd+Ad+jd+`$`),Nd=[`material`,`materials`,`bones`,`map`],Pd=class{constructor(e,t,n){let r=n||Fd.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Fd=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(Td,``)}static parseTrackName(e){let t=Md.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);Nd.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){G(`PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){$t(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){$t(`PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){$t(`PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){$t(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){$t(`PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){$t(`PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){$t(`PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;$t(`PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){$t(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){$t(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Fd.Composite=Pd,Fd.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Fd.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Fd.prototype.GetterByBindingType=[Fd.prototype._getValue_direct,Fd.prototype._getValue_array,Fd.prototype._getValue_arrayElement,Fd.prototype._getValue_toArray],Fd.prototype.SetterByBindingTypeAndVersioning=[[Fd.prototype._setValue_direct,Fd.prototype._setValue_direct_setNeedsUpdate,Fd.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Fd.prototype._setValue_array,Fd.prototype._setValue_array_setNeedsUpdate,Fd.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Fd.prototype._setValue_arrayElement,Fd.prototype._setValue_arrayElement_setNeedsUpdate,Fd.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Fd.prototype._setValue_fromArray,Fd.prototype._setValue_fromArray_setNeedsUpdate,Fd.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Id=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=ln(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,i=this._bindings,a=i.length,o,s=e.length,c=this.nCachedObjects_;for(let l=0,u=arguments.length;l!==u;++l){let u=arguments[l],d=u.uuid,f=t[d];if(f===void 0){f=s++,t[d]=f,e.push(u);for(let e=0,t=a;e!==t;++e)i[e].push(new Fd(u,n[e],r[e]))}else if(f<c){o=e[f];let s=--c,l=e[s];t[l.uuid]=f,e[f]=l,t[d]=s,e[s]=u;for(let e=0,t=a;e!==t;++e){let t=i[e],a=t[s],o=t[f];t[f]=a,o===void 0&&(o=new Fd(u,n[e],r[e])),t[s]=o}}else e[f]!==o&&$t(`AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.`)}this.nCachedObjects_=c}remove(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){let o=arguments[a],s=o.uuid,c=t[s];if(c!==void 0&&c>=i){let a=i++,l=e[a];t[l.uuid]=c,e[c]=l,t[s]=a,e[a]=o;for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[a],i=t[c];t[c]=r,t[a]=i}}}this.nCachedObjects_=i}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){let s=arguments[o].uuid,c=t[s];if(c!==void 0)if(delete t[s],c<i){let o=--i,s=e[o],l=--a,u=e[l];t[s.uuid]=c,e[c]=s,t[u.uuid]=o,e[o]=u,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[o],i=t[l];t[c]=r,t[o]=i,t.pop()}}else{let i=--a,o=e[i];i>0&&(t[o.uuid]=c),e[c]=o,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e];t[c]=t[i],t.pop()}}}this.nCachedObjects_=i}subscribe_(e,t){let n=this._bindingsIndicesByPath,r=n[e],i=this._bindings;if(r!==void 0)return i[r];let a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,u=Array(c);r=i.length,n[e]=r,a.push(e),o.push(t),i.push(u);for(let n=l,r=s.length;n!==r;++n){let r=s[n];u[n]=new Fd(r,e,t)}return u}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],c=e[o];t[c]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}},Ld=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let i=t.tracks,a=i.length,o=Array(a),s={endingStart:at,endingEnd:at};for(let e=0;e!==a;++e){let t=i[e].createInterpolant(null);o[e]=t,t.settings&&Object.assign(s,t.settings),t.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=$e,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let n=this._clip.duration,r=e._clip.duration,i=r/n,a=n/r;e.warp(1,i,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let r=this._mixer,i=r.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);let s=o.parameterPositions,c=o.sampleValues;return s[0]=i,s[1]=i+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}let i=this._startTime;if(i!==null){let r=(e-i)*n;r<0||n===0?t=0:(this._startTime=null,t=n*r)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case lt:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case ct:default:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,i=this._loopCount,a=n===et;if(e===0)return i===-1?r:a&&(i&1)==1?t-r:r;if(n===2200){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));handle_stop:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break handle_stop}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e<0?-1:1})}}else{if(i===-1&&(e>=0?(i=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);let o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e>0?1:-1});else{if(o===1){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:`loop`,action:this,loopDelta:n})}}else this._loopCount=i,this.time=r;if(a&&(i&1)==1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=ot,r.endingEnd=ot):(e?r.endingStart=this.zeroSlopeAtStart?ot:at:r.endingStart=st,t?r.endingEnd=this.zeroSlopeAtEnd?ot:at:r.endingEnd=st)}_scheduleFading(e,t,n){let r=this._mixer,i=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}},Rd=new Float32Array(1),zd=class extends rn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];l===void 0&&(l={},c[s]=l);for(let e=0;e!==i;++e){let i=r[e],c=i.name,u=l[c];if(u!==void 0)++u.referenceCount,a[e]=u;else{if(u=a[e],u!==void 0){u._cacheIndex===null&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}let r=t&&t._propertyBindings[e].binding.parsedPath;u=new Cd(Fd.create(n,c,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let r=this._actions,i=this._actionsByClip,a=i[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=a;else{let t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;let i=e._clip.uuid,a=this._actionsByClip,o=a[i],s=o.knownActions,c=s[s.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,s[l]=c,s.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],s.length===0&&delete a[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.referenceCount===0&&this._removeInactiveBinding(n)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){let r=this._bindingsByRootAndName,i=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,o=a[r],s=t[t.length-1],c=e._cacheIndex;s._cacheIndex=c,t[c]=s,t.pop(),delete o[i],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new Bl(new Float32Array(2),new Float32Array(2),1,Rd),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){let r=t||this._root,i=r.uuid,a=typeof e==`string`?Zl.findByName(r,e):e,o=a===null?e:a.uuid,s=this._actionsByClip[o],c=null;if(n===void 0&&(n=a===null?ct:a.blendMode),s!==void 0){let e=s.actionByRoot[i];if(e!==void 0&&e.blendMode===n)return e;c=s.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;let l=new Ld(this,a,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,i),l}existingAction(e,t){let n=t||this._root,r=n.uuid,i=typeof e==`string`?Zl.findByName(n,e):e,a=i?i.uuid:e,o=this._actionsByClip[a];return o===void 0?null:o.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(r,e,i,a);let o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(i!==void 0){let e=i.knownActions;for(let n=0,r=e.length;n!==r;++n){let r=e[n];this._deactivateAction(r);let i=r._cacheIndex,a=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,a._cacheIndex=i,t[i]=a,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let e in n){let r=n[e].actionByRoot[t];r!==void 0&&(this._deactivateAction(r),this._removeInactiveAction(r))}let r=this._bindingsByRootAndName[t];if(r!==void 0)for(let e in r){let t=r[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Bd=class extends Qn{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=n,this.texture=new nr(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},Vd=class e{constructor(e){this.value=e}clone(){return new e(this.value.clone===void 0?this.value:this.value.clone())}},Hd=0,Ud=class extends rn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Hd++}),this.name=``,this.usage=Tt,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:`dispose`})}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let e=0,n=t.length;e<n;e++){let n=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0;e<n.length;e++)this.uniforms.push(n[e].clone())}return this}clone(){return new this.constructor().copy(this)}},Wd=class extends qi{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Gd=class{constructor(e,t,n,r,i,a=!1){this.isGLBufferAttribute=!0,this.name=``,this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,this.normalized=a,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Kd=new J,qd=class{constructor(e,t,n=0,r=1/0){this.ray=new wa(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new mr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):$t(`Raycaster: Unsupported camera type: `+t.type)}setFromXRController(e){return Kd.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Kd),this}intersectObject(e,t=!0,n=[]){return Yd(e,this,n,t),n.sort(Jd),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)Yd(e[r],this,n,t);return n.sort(Jd),n}};function Jd(e,t){return e.distance-t.distance}function Yd(e,t,n,r){let i=!0;if(e.layers.test(t.layers)&&e.raycast(t,n)===!1&&(i=!1),i===!0&&r===!0){let r=e.children;for(let e=0,i=r.length;e<i;e++)Yd(r[e],t,n,!0)}}var Xd=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,G(`Clock: This module has been deprecated. Please use THREE.Timer instead.`)}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}},Zd=class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){let e=1e-6;return this.phi=un(this.phi,e,Math.PI-e),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(un(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Qd=class{constructor(e=1,t=0,n=0){this.radius=e,this.theta=t,this.y=n}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}},$d=class e{static{e.prototype.isMatrix2=!0}constructor(e,t,n,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},ef=new K,tf=class{constructor(e=new K(1/0,1/0),t=new K(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=ef.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ef).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},nf=new q,rf=new q,af=new q,of=new q,sf=new q,cf=new q,lf=new q,uf=class{constructor(e=new q,t=new q){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){nf.subVectors(e,this.start),rf.subVectors(this.end,this.start);let n=rf.dot(rf);if(n===0)return 0;let r=rf.dot(nf)/n;return t&&(r=un(r,0,1)),r}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=cf,n=lf){let r=1e-8*1e-8,i,a,o=this.start,s=e.start,c=this.end,l=e.end;af.subVectors(c,o),of.subVectors(l,s),sf.subVectors(o,s);let u=af.dot(af),d=of.dot(of),f=of.dot(sf);if(u<=r&&d<=r)return t.copy(o),n.copy(s),t.sub(n),t.dot(t);if(u<=r)i=0,a=f/d,a=un(a,0,1);else{let e=af.dot(sf);if(d<=r)a=0,i=un(-e/u,0,1);else{let t=af.dot(of),n=u*d-t*t;i=n===0?0:un((t*f-e*d)/n,0,1),a=(t*i+f)/d,a<0?(a=0,i=un(-e/u,0,1)):a>1&&(a=1,i=un((t-e)/u,0,1))}}return t.copy(o).addScaledVector(af,i),n.copy(s).addScaledVector(of,a),t.distanceToSquared(n)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},df=new q,ff=class extends Ar{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type=`SpotLightHelper`;let n=new Ki,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1;e<32;e++,t++){let n=e/32*Math.PI*2,i=t/32*Math.PI*2;r.push(Math.cos(n),Math.sin(n),1,Math.cos(i),Math.sin(i),1)}n.setAttribute(`position`,new Pi(r,3));let i=new Vo({fog:!1,toneMapped:!1});this.cone=new $o(n,i),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),df.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(df),this.color===void 0?this.cone.material.color.copy(this.light.color):this.cone.material.color.set(this.color)}},pf=new q,mf=new J,hf=new J,gf=class extends $o{constructor(e){let t=_f(e),n=new Ki,r=[],i=[];for(let e=0;e<t.length;e++){let n=t[e];n.parent&&n.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(0,0,0),i.push(0,0,0))}n.setAttribute(`position`,new Pi(r,3)),n.setAttribute(`color`,new Pi(i,3));let a=new Vo({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,a),this.isSkeletonHelper=!0,this.type=`SkeletonHelper`,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;let o=new Y(255),s=new Y(65280);this.setColors(o,s)}updateMatrixWorld(e){let t=this.bones,n=this.geometry,r=n.getAttribute(`position`);hf.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){let i=t[e];i.parent&&i.parent.isBone&&(mf.multiplyMatrices(hf,i.matrixWorld),pf.setFromMatrixPosition(mf),r.setXYZ(n,pf.x,pf.y,pf.z),mf.multiplyMatrices(hf,i.parent.matrixWorld),pf.setFromMatrixPosition(mf),r.setXYZ(n+1,pf.x,pf.y,pf.z),n+=2)}n.getAttribute(`position`).needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){let n=this.geometry.getAttribute(`color`);for(let r=0;r<n.count;r+=2)n.setXYZ(r,e.r,e.g,e.b),n.setXYZ(r+1,t.r,t.g,t.b);return n.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};function _f(e){let t=[];e.isBone===!0&&t.push(e);for(let n=0;n<e.children.length;n++)t.push(..._f(e.children[n]));return t}var vf=class extends La{constructor(e,t,n){let r=new nl(t,4,2),i=new Ta({wireframe:!0,fog:!1,toneMapped:!1});super(r,i),this.light=e,this.color=n,this.type=`PointLightHelper`,this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color===void 0?this.material.color.copy(this.light.color):this.material.color.set(this.color)}},yf=new q,bf=new Y,xf=new Y,Sf=class extends Ar{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type=`HemisphereLightHelper`;let r=new Zc(t);r.rotateY(Math.PI*.5),this.material=new Ta({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let i=r.getAttribute(`position`),a=new Float32Array(i.count*3);r.setAttribute(`color`,new Ti(a,3)),this.add(new La(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute(`color`);bf.copy(this.light.color),xf.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){let r=e<n/2?bf:xf;t.setXYZ(e,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(yf.setFromMatrixPosition(this.light.matrixWorld).negate())}},Cf=class extends $o{constructor(e=10,t=10,n=4473924,r=8947848){n=new Y(n),r=new Y(r);let i=t/2,a=e/t,o=e/2,s=[],c=[];for(let e=0,l=0,u=-o;e<=t;e++,u+=a){s.push(-o,0,u,o,0,u),s.push(u,0,-o,u,0,o);let t=e===i?n:r;t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3}let l=new Ki;l.setAttribute(`position`,new Pi(s,3)),l.setAttribute(`color`,new Pi(c,3));let u=new Vo({vertexColors:!0,toneMapped:!1});super(l,u),this.type=`GridHelper`}dispose(){this.geometry.dispose(),this.material.dispose()}},wf=class extends $o{constructor(e=10,t=16,n=8,r=64,i=4473924,a=8947848){i=new Y(i),a=new Y(a);let o=[],s=[];if(t>1)for(let n=0;n<t;n++){let r=n/t*(Math.PI*2),c=Math.sin(r)*e,l=Math.cos(r)*e;o.push(0,0,0),o.push(c,0,l);let u=n&1?i:a;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let t=0;t<n;t++){let c=t&1?i:a,l=e-e/n*t;for(let e=0;e<r;e++){let t=e/r*(Math.PI*2),n=Math.sin(t)*l,i=Math.cos(t)*l;o.push(n,0,i),s.push(c.r,c.g,c.b),t=(e+1)/r*(Math.PI*2),n=Math.sin(t)*l,i=Math.cos(t)*l,o.push(n,0,i),s.push(c.r,c.g,c.b)}}let c=new Ki;c.setAttribute(`position`,new Pi(o,3)),c.setAttribute(`color`,new Pi(s,3));let l=new Vo({vertexColors:!0,toneMapped:!1});super(c,l),this.type=`PolarGridHelper`}dispose(){this.geometry.dispose(),this.material.dispose()}},Tf=new q,Ef=new q,Df=new q,Of=class extends Ar{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type=`DirectionalLightHelper`,t===void 0&&(t=1);let r=new Ki;r.setAttribute(`position`,new Pi([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let i=new Vo({fog:!1,toneMapped:!1});this.lightPlane=new Yo(r,i),this.add(this.lightPlane),r=new Ki,r.setAttribute(`position`,new Pi([0,0,0,0,0,1],3)),this.targetLine=new Yo(r,i),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Tf.setFromMatrixPosition(this.light.matrixWorld),Ef.setFromMatrixPosition(this.light.target.matrixWorld),Df.subVectors(Ef,Tf),this.lightPlane.lookAt(Ef),this.color===void 0?(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)):(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)),this.targetLine.lookAt(Ef),this.targetLine.scale.z=Df.length()}},kf=new q,Af=new wu,jf=class extends $o{constructor(e){let t=new Ki,n=new Vo({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],a={};o(`n1`,`n2`),o(`n2`,`n4`),o(`n4`,`n3`),o(`n3`,`n1`),o(`f1`,`f2`),o(`f2`,`f4`),o(`f4`,`f3`),o(`f3`,`f1`),o(`n1`,`f1`),o(`n2`,`f2`),o(`n3`,`f3`),o(`n4`,`f4`),o(`p`,`n1`),o(`p`,`n2`),o(`p`,`n3`),o(`p`,`n4`),o(`u1`,`u2`),o(`u2`,`u3`),o(`u3`,`u1`),o(`c`,`t`),o(`p`,`c`),o(`cn1`,`cn2`),o(`cn3`,`cn4`),o(`cf1`,`cf2`),o(`cf3`,`cf4`);function o(e,t){s(e),s(t)}function s(e){r.push(0,0,0),i.push(0,0,0),a[e]===void 0&&(a[e]=[]),a[e].push(r.length/3-1)}t.setAttribute(`position`,new Pi(r,3)),t.setAttribute(`color`,new Pi(i,3)),super(t,n),this.type=`CameraHelper`,this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let c=new Y(16755200),l=new Y(16711680),u=new Y(43775),d=new Y(16777215),f=new Y(3355443);this.setColors(c,l,u,d,f)}setColors(e,t,n,r,i){let a=this.geometry.getAttribute(`color`);return a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,i.r,i.g,i.b),a.setXYZ(41,i.r,i.g,i.b),a.setXYZ(42,i.r,i.g,i.b),a.setXYZ(43,i.r,i.g,i.b),a.setXYZ(44,i.r,i.g,i.b),a.setXYZ(45,i.r,i.g,i.b),a.setXYZ(46,i.r,i.g,i.b),a.setXYZ(47,i.r,i.g,i.b),a.setXYZ(48,i.r,i.g,i.b),a.setXYZ(49,i.r,i.g,i.b),a.needsUpdate=!0,this}update(){let e=this.geometry,t=this.pointMap,n,r;if(Af.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)n=1,r=0;else if(this.camera.coordinateSystem===2e3)n=-1,r=1;else if(this.camera.coordinateSystem===2001)n=0,r=1;else throw Error(`THREE.CameraHelper.update(): Invalid coordinate system: `+this.camera.coordinateSystem);Mf(`c`,t,e,Af,0,0,n),Mf(`t`,t,e,Af,0,0,r),Mf(`n1`,t,e,Af,-1,-1,n),Mf(`n2`,t,e,Af,1,-1,n),Mf(`n3`,t,e,Af,-1,1,n),Mf(`n4`,t,e,Af,1,1,n),Mf(`f1`,t,e,Af,-1,-1,r),Mf(`f2`,t,e,Af,1,-1,r),Mf(`f3`,t,e,Af,-1,1,r),Mf(`f4`,t,e,Af,1,1,r),Mf(`u1`,t,e,Af,1*.7,1*1.1,n),Mf(`u2`,t,e,Af,-1*.7,1*1.1,n),Mf(`u3`,t,e,Af,0,2,n),Mf(`cf1`,t,e,Af,-1,0,r),Mf(`cf2`,t,e,Af,1,0,r),Mf(`cf3`,t,e,Af,0,-1,r),Mf(`cf4`,t,e,Af,0,1,r),Mf(`cn1`,t,e,Af,-1,0,n),Mf(`cn2`,t,e,Af,1,0,n),Mf(`cn3`,t,e,Af,0,-1,n),Mf(`cn4`,t,e,Af,0,1,n),e.getAttribute(`position`).needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Mf(e,t,n,r,i,a,o){kf.set(i,a,o).unproject(r);let s=t[e];if(s!==void 0){let e=n.getAttribute(`position`);for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],kf.x,kf.y,kf.z)}}var Nf=new ni,Pf=class extends $o{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),i=new Ki;i.setIndex(new Ti(n,1)),i.setAttribute(`position`,new Ti(r,3)),super(i,new Vo({color:t,toneMapped:!1})),this.object=e,this.type=`BoxHelper`,this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Nf.setFromObject(this.object),Nf.isEmpty())return;let e=Nf.min,t=Nf.max,n=this.geometry.attributes.position,r=n.array;r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Ff=class extends $o{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],i=new Ki;i.setIndex(new Ti(n,1)),i.setAttribute(`position`,new Pi(r,3)),super(i,new Vo({color:t,toneMapped:!1})),this.box=e,this.type=`Box3Helper`,this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},If=class extends Yo{constructor(e,t=1,n=16776960){let r=n,i=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Ki;a.setAttribute(`position`,new Pi(i,3)),a.computeBoundingSphere(),super(a,new Vo({color:r,toneMapped:!1})),this.type=`PlaneHelper`,this.plane=e,this.size=t;let o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],s=new Ki;s.setAttribute(`position`,new Pi(o,3)),s.computeBoundingSphere(),this.add(new La(s,new Ta({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},Lf=new q,Rf,zf,Bf=class extends Ar{constructor(e=new q(0,0,1),t=new q(0,0,0),n=1,r=16776960,i=n*.2,a=i*.2){super(),this.type=`ArrowHelper`,Rf===void 0&&(Rf=new Ki,Rf.setAttribute(`position`,new Pi([0,0,0,0,1,0],3)),zf=new ws(.5,1,5,1),zf.translate(0,-.5,0)),this.position.copy(t),this.line=new Yo(Rf,new Vo({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new La(zf,new Ta({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,i,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Lf.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Lf,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},Vf=class extends $o{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ki;r.setAttribute(`position`,new Pi(t,3)),r.setAttribute(`color`,new Pi(n,3));let i=new Vo({vertexColors:!0,toneMapped:!1});super(r,i),this.type=`AxesHelper`}setColors(e,t,n){let r=new Y,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Hf=class{constructor(){this.type=`ShapePath`,this.color=new Y,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new sc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n],i=new cc;i.curves=r.curves,t.push(i)}return t}function n(e,t){let n=t.length,r=!1;for(let i=n-1,a=0;a<n;i=a++){let n=t[i],o=t[a],s=o.x-n.x,c=o.y-n.y;if(Math.abs(c)>2**-52){if(c<0&&(n=t[a],s=-s,o=t[i],c=-c),e.y<n.y||e.y>o.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=c*(e.x-n.x)-s*(e.y-n.y);if(t===0)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return r}let r=Uc.isClockWise,i=this.subPaths;if(i.length===0)return[];let a,o,s,c=[];if(i.length===1)return o=i[0],s=new cc,s.curves=o.curves,c.push(s),c;let l=!r(i[0].getPoints());l=e?!l:l;let u=[],d=[],f=[],p=0,m;d[p]=void 0,f[p]=[];for(let t=0,n=i.length;t<n;t++)o=i[t],m=o.getPoints(),a=r(m),a=e?!a:a,a?(!l&&d[p]&&p++,d[p]={s:new cc,p:m},d[p].s.curves=o.curves,l&&p++,f[p]=[]):f[p].push({h:o,p:m[0]});if(!d[0])return t(i);if(d.length>1){let e=!1,t=0;for(let e=0,t=d.length;e<t;e++)u[e]=[];for(let r=0,i=d.length;r<i;r++){let i=f[r];for(let a=0;a<i.length;a++){let o=i[a],s=!0;for(let i=0;i<d.length;i++)n(o.p,d[i].p)&&(r!==i&&t++,s?(s=!1,u[i].push(o)):e=!0);s&&u[r].push(o)}}t>0&&e===!1&&(f=u)}let h;for(let e=0,t=d.length;e<t;e++){s=d[e].s,c.push(s),h=f[e];for(let e=0,t=h.length;e<t;e++)s.holes.push(h[e].h)}return c}},Uf=class extends rn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){G(`Controls: connect() now requires an element.`);return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function Wf(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}function Gf(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}function Kf(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}function qf(e,t,n,r){let i=Jf(r);switch(n){case ce:return e*t;case fe:return e*t/i.components*i.byteLength;case pe:return e*t/i.components*i.byteLength;case me:return e*t*2/i.components*i.byteLength;case he:return e*t*2/i.components*i.byteLength;case H:return e*t*3/i.components*i.byteLength;case le:return e*t*4/i.components*i.byteLength;case _e:return e*t*4/i.components*i.byteLength;case ve:case ye:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case be:case xe:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case U:case we:return Math.max(e,16)*Math.max(t,8)/4;case Se:case Ce:return Math.max(e,8)*Math.max(t,8)/2;case Te:case W:case De:case Oe:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Ee:case ke:case Ae:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case je:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Me:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case Ne:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case Pe:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case Fe:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case Ie:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Le:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case Re:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case ze:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case Be:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case Ve:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case He:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case Ue:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case We:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case Ge:case Ke:case qe:return Math.ceil(e/4)*Math.ceil(t/4)*16;case Je:case Ye:return Math.ceil(e/4)*Math.ceil(t/4)*8;case Xe:case Ze:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function Jf(e){switch(e){case L:case ee:return{byteLength:1,components:1};case te:case R:case ne:return{byteLength:2,components:1};case re:case ie:return{byteLength:2,components:4};case B:case z:case V:return{byteLength:4,components:1};case oe:case se:return{byteLength:4,components:3}}throw Error(`Unknown texture type ${e}.`)}var Yf=class{static contain(e,t){return Wf(e,t)}static cover(e,t){return Gf(e,t)}static fill(e){return Kf(e)}static getByteLength(e,t,n,r){return qf(e,t,n,r)}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`184`}})),typeof window<`u`&&(window.__THREE__?G(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`184`);var Xf=s({ACESFilmicToneMapping:()=>4,AddEquation:()=>100,AddOperation:()=>2,AdditiveAnimationBlendMode:()=>lt,AdditiveBlending:()=>2,AgXToneMapping:()=>6,AlphaFormat:()=>ce,AlwaysCompare:()=>519,AlwaysDepth:()=>1,AlwaysStencilFunc:()=>519,AmbientLight:()=>Iu,AnimationAction:()=>Ld,AnimationClip:()=>Zl,AnimationLoader:()=>cu,AnimationMixer:()=>zd,AnimationObjectGroup:()=>Id,AnimationUtils:()=>Ll,ArcCurve:()=>Ps,ArrayCamera:()=>sd,ArrowHelper:()=>Bf,AttachedBindMode:()=>S,Audio:()=>gd,AudioAnalyser:()=>Sd,AudioContext:()=>Qu,AudioListener:()=>hd,AudioLoader:()=>$u,AxesHelper:()=>Vf,BackSide:()=>1,BasicDepthPacking:()=>ut,BasicShadowMap:()=>0,BatchedMesh:()=>Bo,BezierInterpolant:()=>Hl,Bone:()=>Xa,BooleanKeyframeTrack:()=>Wl,Box2:()=>tf,Box3:()=>ni,Box3Helper:()=>Ff,BoxGeometry:()=>bs,BoxHelper:()=>Pf,BufferAttribute:()=>Ti,BufferGeometry:()=>Ki,BufferGeometryLoader:()=>Uu,ByteType:()=>ee,Cache:()=>eu,Camera:()=>wu,CameraHelper:()=>jf,CanvasTexture:()=>hs,CapsuleGeometry:()=>xs,CatmullRomCurve3:()=>Vs,CineonToneMapping:()=>3,CircleGeometry:()=>Ss,ClampToEdgeWrapping:()=>T,Clock:()=>Xd,Color:()=>Y,ColorKeyframeTrack:()=>Gl,ColorManagement:()=>Bn,Compatibility:()=>Bt,CompressedArrayTexture:()=>fs,CompressedCubeTexture:()=>ps,CompressedTexture:()=>ds,CompressedTextureLoader:()=>lu,ConeGeometry:()=>ws,ConstantAlphaFactor:()=>213,ConstantColorFactor:()=>211,Controls:()=>Uf,CubeCamera:()=>od,CubeDepthTexture:()=>vs,CubeReflectionMapping:()=>301,CubeRefractionMapping:()=>302,CubeTexture:()=>ms,CubeTextureLoader:()=>fu,CubeUVReflectionMapping:()=>306,CubicBezierCurve:()=>Qs,CubicBezierCurve3:()=>$s,CubicInterpolant:()=>zl,CullFaceBack:()=>1,CullFaceFront:()=>2,CullFaceFrontBack:()=>3,CullFaceNone:()=>0,Curve:()=>Ms,CurvePath:()=>oc,CustomBlending:()=>5,CustomToneMapping:()=>5,CylinderGeometry:()=>Cs,Cylindrical:()=>Qd,Data3DTexture:()=>nr,DataArrayTexture:()=>er,DataTexture:()=>Za,DataTextureLoader:()=>pu,DataUtils:()=>xi,DecrementStencilOp:()=>xt,DecrementWrapStencilOp:()=>Ct,DefaultLoadingManager:()=>ru,DepthFormat:()=>ue,DepthStencilFormat:()=>de,DepthTexture:()=>_s,DetachedBindMode:()=>C,DirectionalLight:()=>Fu,DirectionalLightHelper:()=>Of,DiscreteInterpolant:()=>Vl,DodecahedronGeometry:()=>Es,DoubleSide:()=>2,DstAlphaFactor:()=>206,DstColorFactor:()=>208,DynamicCopyUsage:()=>Mt,DynamicDrawUsage:()=>Et,DynamicReadUsage:()=>kt,EdgesGeometry:()=>js,EllipseCurve:()=>Ns,EqualCompare:()=>514,EqualDepth:()=>4,EqualStencilFunc:()=>514,EquirectangularReflectionMapping:()=>303,EquirectangularRefractionMapping:()=>304,Euler:()=>pr,EventDispatcher:()=>rn,ExternalTexture:()=>ys,ExtrudeGeometry:()=>Kc,FileLoader:()=>su,Float16BufferAttribute:()=>Ni,Float32BufferAttribute:()=>Pi,FloatType:()=>V,Fog:()=>Br,FogExp2:()=>zr,FramebufferTexture:()=>us,FrontSide:()=>0,Frustum:()=>vo,FrustumArray:()=>xo,GLBufferAttribute:()=>Gd,GLSL1:()=>`100`,GLSL3:()=>Pt,GreaterCompare:()=>516,GreaterDepth:()=>6,GreaterEqualCompare:()=>518,GreaterEqualDepth:()=>5,GreaterEqualStencilFunc:()=>518,GreaterStencilFunc:()=>516,GridHelper:()=>Cf,Group:()=>jr,HTMLTexture:()=>gs,HalfFloatType:()=>ne,HemisphereLight:()=>gu,HemisphereLightHelper:()=>Sf,IcosahedronGeometry:()=>Yc,ImageBitmapLoader:()=>Xu,ImageLoader:()=>du,ImageUtils:()=>Wn,IncrementStencilOp:()=>bt,IncrementWrapStencilOp:()=>St,InstancedBufferAttribute:()=>to,InstancedBufferGeometry:()=>Hu,InstancedInterleavedBuffer:()=>Wd,InstancedMesh:()=>lo,Int16BufferAttribute:()=>ki,Int32BufferAttribute:()=>ji,Int8BufferAttribute:()=>Ei,IntType:()=>z,InterleavedBuffer:()=>qi,InterleavedBufferAttribute:()=>Yi,Interpolant:()=>Rl,InterpolateBezier:()=>it,InterpolateDiscrete:()=>tt,InterpolateLinear:()=>nt,InterpolateSmooth:()=>rt,InterpolationSamplingMode:()=>zt,InterpolationSamplingType:()=>Rt,InvertStencilOp:()=>wt,KeepStencilOp:()=>vt,KeyframeTrack:()=>Ul,LOD:()=>ga,LatheGeometry:()=>Xc,Layers:()=>mr,LessCompare:()=>513,LessDepth:()=>2,LessEqualCompare:()=>515,LessEqualDepth:()=>3,LessEqualStencilFunc:()=>515,LessStencilFunc:()=>513,Light:()=>hu,LightProbe:()=>zu,Line:()=>Yo,Line3:()=>uf,LineBasicMaterial:()=>Vo,LineCurve:()=>ec,LineCurve3:()=>tc,LineDashedMaterial:()=>Al,LineLoop:()=>es,LineSegments:()=>$o,LinearFilter:()=>M,LinearInterpolant:()=>Bl,LinearMipMapLinearFilter:()=>I,LinearMipMapNearestFilter:()=>P,LinearMipmapLinearFilter:()=>F,LinearMipmapNearestFilter:()=>N,LinearSRGBColorSpace:()=>ht,LinearToneMapping:()=>1,LinearTransfer:()=>gt,Loader:()=>iu,LoaderUtils:()=>Vu,LoadingManager:()=>nu,LoopOnce:()=>Qe,LoopPingPong:()=>et,LoopRepeat:()=>$e,MOUSE:()=>b,Material:()=>Zi,MaterialBlending:()=>6,MaterialLoader:()=>Bu,MathUtils:()=>jn,Matrix2:()=>$d,Matrix3:()=>Fn,Matrix4:()=>J,MaxEquation:()=>104,Mesh:()=>La,MeshBasicMaterial:()=>Ta,MeshDepthMaterial:()=>Dl,MeshDistanceMaterial:()=>Ol,MeshLambertMaterial:()=>El,MeshMatcapMaterial:()=>kl,MeshNormalMaterial:()=>Tl,MeshPhongMaterial:()=>Cl,MeshPhysicalMaterial:()=>Sl,MeshStandardMaterial:()=>xl,MeshToonMaterial:()=>wl,MinEquation:()=>103,MirroredRepeatWrapping:()=>E,MixOperation:()=>1,MultiplyBlending:()=>4,MultiplyOperation:()=>0,NearestFilter:()=>D,NearestMipMapLinearFilter:()=>j,NearestMipMapNearestFilter:()=>k,NearestMipmapLinearFilter:()=>A,NearestMipmapNearestFilter:()=>O,NeutralToneMapping:()=>7,NeverCompare:()=>512,NeverDepth:()=>0,NeverStencilFunc:()=>512,NoBlending:()=>0,NoColorSpace:()=>``,NoNormalPacking:()=>``,NoToneMapping:()=>0,NormalAnimationBlendMode:()=>ct,NormalBlending:()=>1,NormalGAPacking:()=>`ga`,NormalRGPacking:()=>`rg`,NotEqualCompare:()=>517,NotEqualDepth:()=>7,NotEqualStencilFunc:()=>517,NumberKeyframeTrack:()=>Kl,Object3D:()=>Ar,ObjectLoader:()=>Gu,ObjectSpaceNormalMap:()=>1,OctahedronGeometry:()=>Zc,OneFactor:()=>201,OneMinusConstantAlphaFactor:()=>214,OneMinusConstantColorFactor:()=>212,OneMinusDstAlphaFactor:()=>207,OneMinusDstColorFactor:()=>209,OneMinusSrcAlphaFactor:()=>205,OneMinusSrcColorFactor:()=>203,OrthographicCamera:()=>Nu,PCFShadowMap:()=>1,PCFSoftShadowMap:()=>2,PMREMGenerator:()=>bp,Path:()=>sc,PerspectiveCamera:()=>Ou,Plane:()=>mo,PlaneGeometry:()=>Qc,PlaneHelper:()=>If,PointLight:()=>Mu,PointLightHelper:()=>vf,Points:()=>os,PointsMaterial:()=>ts,PolarGridHelper:()=>wf,PolyhedronGeometry:()=>Ts,PositionalAudio:()=>xd,PropertyBinding:()=>Fd,PropertyMixer:()=>Cd,QuadraticBezierCurve:()=>nc,QuadraticBezierCurve3:()=>rc,Quaternion:()=>Mn,QuaternionKeyframeTrack:()=>Jl,QuaternionLinearInterpolant:()=>ql,R11_EAC_Format:()=>De,RED_GREEN_RGTC2_Format:()=>Xe,RED_RGTC1_Format:()=>Je,REVISION:()=>`184`,RG11_EAC_Format:()=>ke,RGBADepthPacking:()=>dt,RGBAFormat:()=>le,RGBAIntegerFormat:()=>_e,RGBA_ASTC_10x10_Format:()=>He,RGBA_ASTC_10x5_Format:()=>ze,RGBA_ASTC_10x6_Format:()=>Be,RGBA_ASTC_10x8_Format:()=>Ve,RGBA_ASTC_12x10_Format:()=>Ue,RGBA_ASTC_12x12_Format:()=>We,RGBA_ASTC_4x4_Format:()=>je,RGBA_ASTC_5x4_Format:()=>Me,RGBA_ASTC_5x5_Format:()=>Ne,RGBA_ASTC_6x5_Format:()=>Pe,RGBA_ASTC_6x6_Format:()=>Fe,RGBA_ASTC_8x5_Format:()=>Ie,RGBA_ASTC_8x6_Format:()=>Le,RGBA_ASTC_8x8_Format:()=>Re,RGBA_BPTC_Format:()=>Ge,RGBA_ETC2_EAC_Format:()=>Ee,RGBA_PVRTC_2BPPV1_Format:()=>we,RGBA_PVRTC_4BPPV1_Format:()=>Ce,RGBA_S3TC_DXT1_Format:()=>ye,RGBA_S3TC_DXT3_Format:()=>be,RGBA_S3TC_DXT5_Format:()=>xe,RGBDepthPacking:()=>ft,RGBFormat:()=>H,RGBIntegerFormat:()=>ge,RGB_BPTC_SIGNED_Format:()=>Ke,RGB_BPTC_UNSIGNED_Format:()=>qe,RGB_ETC1_Format:()=>Te,RGB_ETC2_Format:()=>W,RGB_PVRTC_2BPPV1_Format:()=>U,RGB_PVRTC_4BPPV1_Format:()=>Se,RGB_S3TC_DXT1_Format:()=>ve,RGDepthPacking:()=>pt,RGFormat:()=>me,RGIntegerFormat:()=>he,RawShaderMaterial:()=>bl,Ray:()=>wa,Raycaster:()=>qd,RectAreaLight:()=>Lu,RedFormat:()=>fe,RedIntegerFormat:()=>pe,ReinhardToneMapping:()=>2,RenderTarget:()=>Qn,RenderTarget3D:()=>Bd,RepeatWrapping:()=>w,ReplaceStencilOp:()=>yt,ReverseSubtractEquation:()=>102,RingGeometry:()=>$c,SIGNED_R11_EAC_Format:()=>Oe,SIGNED_RED_GREEN_RGTC2_Format:()=>Ze,SIGNED_RED_RGTC1_Format:()=>Ye,SIGNED_RG11_EAC_Format:()=>Ae,SRGBColorSpace:()=>mt,SRGBTransfer:()=>_t,Scene:()=>Vr,ShaderChunk:()=>$f,ShaderLib:()=>ep,ShaderMaterial:()=>yl,ShadowMaterial:()=>ul,Shape:()=>cc,ShapeGeometry:()=>el,ShapePath:()=>Hf,ShapeUtils:()=>Uc,ShortType:()=>R,Skeleton:()=>eo,SkeletonHelper:()=>gf,SkinnedMesh:()=>Ya,Source:()=>Kn,Sphere:()=>Ri,SphereGeometry:()=>nl,Spherical:()=>Zd,SphericalHarmonics3:()=>Ru,SplineCurve:()=>ic,SpotLight:()=>Au,SpotLightHelper:()=>ff,Sprite:()=>fa,SpriteMaterial:()=>Qi,SrcAlphaFactor:()=>204,SrcAlphaSaturateFactor:()=>210,SrcColorFactor:()=>202,StaticCopyUsage:()=>jt,StaticDrawUsage:()=>Tt,StaticReadUsage:()=>Ot,StereoCamera:()=>rd,StreamCopyUsage:()=>Nt,StreamDrawUsage:()=>Dt,StreamReadUsage:()=>At,StringKeyframeTrack:()=>Yl,SubtractEquation:()=>101,SubtractiveBlending:()=>3,TOUCH:()=>x,TangentSpaceNormalMap:()=>0,TetrahedronGeometry:()=>rl,Texture:()=>Xn,TextureLoader:()=>mu,TextureUtils:()=>Yf,Timer:()=>cd,TimestampQuery:()=>Lt,TorusGeometry:()=>il,TorusKnotGeometry:()=>al,Triangle:()=>ti,TriangleFanDrawMode:()=>2,TriangleStripDrawMode:()=>1,TrianglesDrawMode:()=>0,TubeGeometry:()=>ol,UVMapping:()=>300,Uint16BufferAttribute:()=>Ai,Uint32BufferAttribute:()=>Mi,Uint8BufferAttribute:()=>Di,Uint8ClampedBufferAttribute:()=>Oi,Uniform:()=>Vd,UniformsGroup:()=>Ud,UniformsLib:()=>X,UniformsUtils:()=>gl,UnsignedByteType:()=>L,UnsignedInt101111Type:()=>se,UnsignedInt248Type:()=>ae,UnsignedInt5999Type:()=>oe,UnsignedIntType:()=>B,UnsignedShort4444Type:()=>re,UnsignedShort5551Type:()=>ie,UnsignedShortType:()=>te,VSMShadowMap:()=>3,Vector2:()=>K,Vector3:()=>q,Vector4:()=>Zn,VectorKeyframeTrack:()=>Xl,VideoFrameTexture:()=>ls,VideoTexture:()=>cs,WebGL3DRenderTarget:()=>rr,WebGLArrayRenderTarget:()=>tr,WebGLCoordinateSystem:()=>Ft,WebGLCubeRenderTarget:()=>kp,WebGLRenderTarget:()=>$n,WebGLRenderer:()=>pg,WebGLUtils:()=>tg,WebGPUCoordinateSystem:()=>It,WebXRController:()=>Nr,WireframeGeometry:()=>sl,WrapAroundEnding:()=>st,ZeroCurvatureEnding:()=>at,ZeroFactor:()=>200,ZeroSlopeEnding:()=>ot,ZeroStencilOp:()=>0,createCanvasElement:()=>Kt,error:()=>$t,getConsoleFunction:()=>Xt,log:()=>Zt,setConsoleFunction:()=>Yt,warn:()=>G,warnOnce:()=>en});function Zf(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){t!==!0&&n!==null&&e!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e!==null&&e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Qf(e){let t=new WeakMap;function n(t,n){let r=t.array,i=t.usage,a=r.byteLength,o=e.createBuffer();e.bindBuffer(n,o),e.bufferData(n,r,i),t.onUploadCallback();let s;if(r instanceof Float32Array)s=e.FLOAT;else if(typeof Float16Array<`u`&&r instanceof Float16Array)s=e.HALF_FLOAT;else if(r instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)s=e.SHORT;else if(r instanceof Uint32Array)s=e.UNSIGNED_INT;else if(r instanceof Int32Array)s=e.INT;else if(r instanceof Int8Array)s=e.BYTE;else if(r instanceof Uint8Array)s=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)s=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+r);return{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:a}}function r(t,n,r){let i=n.array,a=n.updateRanges;if(e.bindBuffer(r,t),a.length===0)e.bufferSubData(r,0,i);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){let n=a[t],r=a[e];r.start<=n.start+n.count+1?n.count=Math.max(n.count,r.start+r.count-n.start):(++t,a[t]=r)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){let n=a[t];e.bufferSubData(r,n.start*i.BYTES_PER_ELEMENT,i,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)}function a(n){n.isInterleavedBufferAttribute&&(n=n.data);let r=t.get(n);r&&(e.deleteBuffer(r.buffer),t.delete(n))}function o(e,i){if(e.isInterleavedBufferAttribute&&(e=e.data),e.isGLBufferAttribute){let n=t.get(e);(!n||n.version<e.version)&&t.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version});return}let a=t.get(e);if(a===void 0)t.set(e,n(e,i));else if(a.version<e.version){if(a.size!==e.array.byteLength)throw 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(a.buffer,e,i),a.version=e.version}}return{get:i,remove:a,update:o}}var $f={alphahash_fragment:`#ifdef USE_ALPHAHASH
|
||
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
#endif`,alphahash_pars_fragment:`#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`,alphamap_fragment:`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
#endif`,alphamap_pars_fragment:`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,alphatest_fragment:`#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`,alphatest_pars_fragment:`#ifdef USE_ALPHATEST
|
||
uniform float alphaTest;
|
||
#endif`,aomap_fragment:`#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`,aomap_pars_fragment:`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,batching_pars_vertex:`#ifdef USE_BATCHING
|
||
#if ! defined( GL_ANGLE_multi_draw )
|
||
#define gl_DrawID _gl_DrawID
|
||
uniform int _gl_DrawID;
|
||
#endif
|
||
uniform highp sampler2D batchingTexture;
|
||
uniform highp usampler2D batchingIdTexture;
|
||
mat4 getBatchingMatrix( const in float i ) {
|
||
int size = textureSize( batchingTexture, 0 ).x;
|
||
int j = int( i ) * 4;
|
||
int x = j % size;
|
||
int y = j / size;
|
||
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
||
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
||
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
||
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
||
return mat4( v1, v2, v3, v4 );
|
||
}
|
||
float getIndirectIndex( const in int i ) {
|
||
int size = textureSize( batchingIdTexture, 0 ).x;
|
||
int x = i % size;
|
||
int y = i / size;
|
||
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
||
}
|
||
#endif
|
||
#ifdef USE_BATCHING_COLOR
|
||
uniform sampler2D batchingColorTexture;
|
||
vec4 getBatchingColor( const in float i ) {
|
||
int size = textureSize( batchingColorTexture, 0 ).x;
|
||
int j = int( i );
|
||
int x = j % size;
|
||
int y = j / size;
|
||
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
||
}
|
||
#endif`,batching_vertex:`#ifdef USE_BATCHING
|
||
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,begin_vertex:`vec3 transformed = vec3( position );
|
||
#ifdef USE_ALPHAHASH
|
||
vPosition = vec3( position );
|
||
#endif`,beginnormal_vertex:`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,bsdfs:`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`,iridescence_fragment:`#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`,bumpmap_pars_fragment:`#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`,clipping_planes_fragment:`#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`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
||
diffuseColor *= vColor;
|
||
#endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
varying vec4 vColor;
|
||
#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
vColor = vec4( 1.0 );
|
||
#endif
|
||
#ifdef USE_COLOR_ALPHA
|
||
vColor *= color;
|
||
#elif defined( USE_COLOR )
|
||
vColor.rgb *= color;
|
||
#endif
|
||
#ifdef USE_INSTANCING_COLOR
|
||
vColor.rgb *= instanceColor.rgb;
|
||
#endif
|
||
#ifdef USE_BATCHING_COLOR
|
||
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,common:`#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 );
|
||
}
|
||
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`,cube_uv_reflection_fragment:`#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`,defaultnormal_vertex:`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`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
#endif
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`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 );
|
||
}`,envmap_fragment:`#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 * reflectVec );
|
||
#ifdef ENVMAP_BLENDING_MULTIPLY
|
||
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
||
#elif defined( ENVMAP_BLENDING_MIX )
|
||
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
||
#elif defined( ENVMAP_BLENDING_ADD )
|
||
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
||
#endif
|
||
#endif
|
||
#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP
|
||
uniform float envMapIntensity;
|
||
uniform mat3 envMapRotation;
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
uniform samplerCube envMap;
|
||
#else
|
||
uniform sampler2D envMap;
|
||
#endif
|
||
#endif`,envmap_pars_fragment:`#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`,envmap_pars_vertex:`#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`,envmap_physical_pars_fragment:`#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, pow4( 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`,envmap_vertex:`#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`,fog_vertex:`#ifdef USE_FOG
|
||
vFogDepth = - mvPosition.z;
|
||
#endif`,fog_pars_vertex:`#ifdef USE_FOG
|
||
varying float vFogDepth;
|
||
#endif`,fog_fragment:`#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`,fog_pars_fragment:`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float vFogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,gradientmap_pars_fragment:`#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
|
||
}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,lights_lambert_fragment:`LambertMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`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`,lights_pars_begin:`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
|
||
#include <lightprobes_pars_fragment>`,lights_toon_fragment:`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`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`,lights_phong_fragment:`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`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`,lights_physical_fragment:`PhysicalMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
||
material.metalness = metalnessFactor;
|
||
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
||
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
||
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
||
material.roughness = min( material.roughness, 1.0 );
|
||
#ifdef IOR
|
||
material.ior = ior;
|
||
#ifdef USE_SPECULAR
|
||
float specularIntensityFactor = specularIntensity;
|
||
vec3 specularColorFactor = specularColor;
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
||
#endif
|
||
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
||
#else
|
||
float specularIntensityFactor = 1.0;
|
||
vec3 specularColorFactor = vec3( 1.0 );
|
||
material.specularF90 = 1.0;
|
||
#endif
|
||
material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
|
||
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
|
||
#else
|
||
material.specularColor = vec3( 0.04 );
|
||
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
|
||
material.specularF90 = 1.0;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
material.clearcoat = clearcoat;
|
||
material.clearcoatRoughness = clearcoatRoughness;
|
||
material.clearcoatF0 = vec3( 0.04 );
|
||
material.clearcoatF90 = 1.0;
|
||
#ifdef USE_CLEARCOATMAP
|
||
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
||
#endif
|
||
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
||
material.clearcoatRoughness += geometryRoughness;
|
||
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
||
#endif
|
||
#ifdef USE_DISPERSION
|
||
material.dispersion = dispersion;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
material.iridescence = iridescence;
|
||
material.iridescenceIOR = iridescenceIOR;
|
||
#ifdef USE_IRIDESCENCEMAP
|
||
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
||
#else
|
||
material.iridescenceThickness = iridescenceThicknessMaximum;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
material.sheenColor = sheenColor;
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
||
#endif
|
||
material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
#ifdef USE_ANISOTROPYMAP
|
||
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
||
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
||
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
||
#else
|
||
vec2 anisotropyV = anisotropyVector;
|
||
#endif
|
||
material.anisotropy = length( anisotropyV );
|
||
if( material.anisotropy == 0.0 ) {
|
||
anisotropyV = vec2( 1.0, 0.0 );
|
||
} else {
|
||
anisotropyV /= material.anisotropy;
|
||
material.anisotropy = saturate( material.anisotropy );
|
||
}
|
||
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
||
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
||
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
||
#endif`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT;
|
||
struct PhysicalMaterial {
|
||
vec3 diffuseColor;
|
||
vec3 diffuseContribution;
|
||
vec3 specularColor;
|
||
vec3 specularColorBlended;
|
||
float roughness;
|
||
float metalness;
|
||
float specularF90;
|
||
float dispersion;
|
||
#ifdef USE_CLEARCOAT
|
||
float clearcoat;
|
||
float clearcoatRoughness;
|
||
vec3 clearcoatF0;
|
||
float clearcoatF90;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
float iridescence;
|
||
float iridescenceIOR;
|
||
float iridescenceThickness;
|
||
vec3 iridescenceFresnel;
|
||
vec3 iridescenceF0;
|
||
vec3 iridescenceFresnelDielectric;
|
||
vec3 iridescenceFresnelMetallic;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
vec3 sheenColor;
|
||
float sheenRoughness;
|
||
#endif
|
||
#ifdef IOR
|
||
float ior;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
float transmission;
|
||
float transmissionAlpha;
|
||
float thickness;
|
||
float attenuationDistance;
|
||
vec3 attenuationColor;
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
float anisotropy;
|
||
float alphaT;
|
||
vec3 anisotropyT;
|
||
vec3 anisotropyB;
|
||
#endif
|
||
};
|
||
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
||
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
||
vec3 sheenSpecularDirect = vec3( 0.0 );
|
||
vec3 sheenSpecularIndirect = vec3(0.0 );
|
||
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
||
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
||
float x2 = x * x;
|
||
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
||
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
||
}
|
||
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||
float a2 = pow2( alpha );
|
||
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||
return 0.5 / max( gv + gl, EPSILON );
|
||
}
|
||
float D_GGX( const in float alpha, const in float dotNH ) {
|
||
float a2 = pow2( alpha );
|
||
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
||
return RECIPROCAL_PI * a2 / pow2( denom );
|
||
}
|
||
#ifdef USE_ANISOTROPY
|
||
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
||
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
||
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
||
return 0.5 / max( gv + gl, EPSILON );
|
||
}
|
||
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
||
float a2 = alphaT * alphaB;
|
||
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
||
highp float v2 = dot( v, v );
|
||
float w2 = a2 / v2;
|
||
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
||
}
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
||
vec3 f0 = material.clearcoatF0;
|
||
float f90 = material.clearcoatF90;
|
||
float roughness = material.clearcoatRoughness;
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
return F * ( V * D );
|
||
}
|
||
#endif
|
||
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
||
vec3 f0 = material.specularColorBlended;
|
||
float f90 = material.specularF90;
|
||
float roughness = material.roughness;
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||
#ifdef USE_IRIDESCENCE
|
||
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
float dotTL = dot( material.anisotropyT, lightDir );
|
||
float dotTV = dot( material.anisotropyT, viewDir );
|
||
float dotTH = dot( material.anisotropyT, halfDir );
|
||
float dotBL = dot( material.anisotropyB, lightDir );
|
||
float dotBV = dot( material.anisotropyB, viewDir );
|
||
float dotBH = dot( material.anisotropyB, halfDir );
|
||
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
||
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
||
#else
|
||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
#endif
|
||
return F * ( V * D );
|
||
}
|
||
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
||
const float LUT_SIZE = 64.0;
|
||
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||
float dotNV = saturate( dot( N, V ) );
|
||
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
||
uv = uv * LUT_SCALE + LUT_BIAS;
|
||
return uv;
|
||
}
|
||
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
||
float l = length( f );
|
||
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
||
}
|
||
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
||
float x = dot( v1, v2 );
|
||
float y = abs( x );
|
||
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
||
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
||
float v = a / b;
|
||
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
||
return cross( v1, v2 ) * theta_sintheta;
|
||
}
|
||
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
||
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
||
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
||
vec3 lightNormal = cross( v1, v2 );
|
||
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
||
vec3 T1, T2;
|
||
T1 = normalize( V - N * dot( V, N ) );
|
||
T2 = - cross( N, T1 );
|
||
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
|
||
vec3 coords[ 4 ];
|
||
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
||
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
||
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
||
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
||
coords[ 0 ] = normalize( coords[ 0 ] );
|
||
coords[ 1 ] = normalize( coords[ 1 ] );
|
||
coords[ 2 ] = normalize( coords[ 2 ] );
|
||
coords[ 3 ] = normalize( coords[ 3 ] );
|
||
vec3 vectorFormFactor = vec3( 0.0 );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
||
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
||
return vec3( result );
|
||
}
|
||
#if defined( USE_SHEEN )
|
||
float D_Charlie( float roughness, float dotNH ) {
|
||
float alpha = pow2( roughness );
|
||
float invAlpha = 1.0 / alpha;
|
||
float cos2h = dotNH * dotNH;
|
||
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
||
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
||
}
|
||
float V_Neubelt( float dotNV, float dotNL ) {
|
||
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
||
}
|
||
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float D = D_Charlie( sheenRoughness, dotNH );
|
||
float V = V_Neubelt( dotNV, dotNL );
|
||
return sheenColor * ( D * V );
|
||
}
|
||
#endif
|
||
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float r2 = roughness * roughness;
|
||
float rInv = 1.0 / ( roughness + 0.1 );
|
||
float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
|
||
float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
|
||
float DG = exp( a * dotNV + b );
|
||
return saturate( DG );
|
||
}
|
||
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
|
||
return specularColor * fab.x + specularF90 * fab.y;
|
||
}
|
||
#ifdef USE_IRIDESCENCE
|
||
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
#else
|
||
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
#endif
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
|
||
#ifdef USE_IRIDESCENCE
|
||
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
||
#else
|
||
vec3 Fr = specularColor;
|
||
#endif
|
||
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
||
float Ess = fab.x + fab.y;
|
||
float Ems = 1.0 - Ess;
|
||
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
||
singleScatter += FssEss;
|
||
multiScatter += Fms * Ems;
|
||
}
|
||
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
||
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
|
||
vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
|
||
vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
|
||
vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
|
||
float Ess_V = dfgV.x + dfgV.y;
|
||
float Ess_L = dfgL.x + dfgL.y;
|
||
float Ems_V = 1.0 - Ess_V;
|
||
float Ems_L = 1.0 - Ess_L;
|
||
vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
|
||
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
|
||
float compensationFactor = Ems_V * Ems_L;
|
||
vec3 multiScatter = Fms * compensationFactor;
|
||
return singleScatter + multiScatter;
|
||
}
|
||
#if NUM_RECT_AREA_LIGHTS > 0
|
||
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 normal = geometryNormal;
|
||
vec3 viewDir = geometryViewDir;
|
||
vec3 position = geometryPosition;
|
||
vec3 lightPos = rectAreaLight.position;
|
||
vec3 halfWidth = rectAreaLight.halfWidth;
|
||
vec3 halfHeight = rectAreaLight.halfHeight;
|
||
vec3 lightColor = rectAreaLight.color;
|
||
float roughness = material.roughness;
|
||
vec3 rectCoords[ 4 ];
|
||
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
||
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
||
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
||
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
||
vec4 t1 = texture2D( ltc_1, uv );
|
||
vec4 t2 = texture2D( ltc_2, uv );
|
||
mat3 mInv = mat3(
|
||
vec3( t1.x, 0, t1.y ),
|
||
vec3( 0, 1, 0 ),
|
||
vec3( t1.z, 0, t1.w )
|
||
);
|
||
vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );
|
||
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
||
reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
||
#ifdef USE_CLEARCOAT
|
||
vec3 Ncc = geometryClearcoatNormal;
|
||
vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );
|
||
vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );
|
||
vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );
|
||
mat3 mInvClearcoat = mat3(
|
||
vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),
|
||
vec3( 0, 1, 0 ),
|
||
vec3( t1Clearcoat.z, 0, t1Clearcoat.w )
|
||
);
|
||
vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;
|
||
clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );
|
||
#endif
|
||
}
|
||
#endif
|
||
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
||
vec3 irradiance = dotNL * directLight.color;
|
||
#ifdef USE_CLEARCOAT
|
||
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
||
vec3 ccIrradiance = dotNLcc * directLight.color;
|
||
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
|
||
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
||
|
||
float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
||
float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
|
||
|
||
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
|
||
|
||
irradiance *= sheenEnergyComp;
|
||
|
||
#endif
|
||
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
|
||
}
|
||
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
|
||
#ifdef USE_SHEEN
|
||
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
||
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
|
||
diffuse *= sheenEnergyComp;
|
||
#endif
|
||
reflectedLight.indirectDiffuse += diffuse;
|
||
}
|
||
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
||
#ifdef USE_CLEARCOAT
|
||
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
|
||
#endif
|
||
vec3 singleScatteringDielectric = vec3( 0.0 );
|
||
vec3 multiScatteringDielectric = vec3( 0.0 );
|
||
vec3 singleScatteringMetallic = vec3( 0.0 );
|
||
vec3 multiScatteringMetallic = vec3( 0.0 );
|
||
#ifdef USE_IRIDESCENCE
|
||
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
|
||
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
|
||
#else
|
||
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
|
||
computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
|
||
#endif
|
||
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
|
||
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
|
||
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
|
||
vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
|
||
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
||
vec3 indirectSpecular = radiance * singleScattering;
|
||
indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
||
vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
|
||
#ifdef USE_SHEEN
|
||
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
||
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
|
||
indirectSpecular *= sheenEnergyComp;
|
||
indirectDiffuse *= sheenEnergyComp;
|
||
#endif
|
||
reflectedLight.indirectSpecular += indirectSpecular;
|
||
reflectedLight.indirectDiffuse += indirectDiffuse;
|
||
}
|
||
#define RE_Direct RE_Direct_Physical
|
||
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
||
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
||
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
||
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
||
}`,lights_fragment_begin:`
|
||
vec3 geometryPosition = - vViewPosition;
|
||
vec3 geometryNormal = normal;
|
||
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
||
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
||
#ifdef USE_CLEARCOAT
|
||
geometryClearcoatNormal = clearcoatNormal;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
||
if ( material.iridescenceThickness == 0.0 ) {
|
||
material.iridescence = 0.0;
|
||
} else {
|
||
material.iridescence = saturate( material.iridescence );
|
||
}
|
||
if ( material.iridescence > 0.0 ) {
|
||
material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
||
material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
|
||
material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
|
||
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
||
}
|
||
#endif
|
||
IncidentLight directLight;
|
||
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
PointLight pointLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
||
PointLightShadow pointLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||
pointLight = pointLights[ i ];
|
||
getPointLightInfo( pointLight, geometryPosition, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
|
||
pointLightShadow = pointLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
SpotLight spotLight;
|
||
vec4 spotColor;
|
||
vec3 spotLightCoord;
|
||
bool inSpotLightMap;
|
||
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
||
SpotLightShadow spotLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||
spotLight = spotLights[ i ];
|
||
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
||
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
||
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
||
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
||
#else
|
||
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
||
#endif
|
||
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
||
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
||
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
||
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
||
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
||
#endif
|
||
#undef SPOT_LIGHT_MAP_INDEX
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
spotLightShadow = spotLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
||
DirectionalLight directionalLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
||
DirectionalLightShadow directionalLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||
directionalLight = directionalLights[ i ];
|
||
getDirectionalLightInfo( directionalLight, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
||
directionalLightShadow = directionalLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
||
RectAreaLight rectAreaLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
||
rectAreaLight = rectAreaLights[ i ];
|
||
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if defined( RE_IndirectDiffuse )
|
||
vec3 iblIrradiance = vec3( 0.0 );
|
||
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
||
#if defined( USE_LIGHT_PROBES )
|
||
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
||
#endif
|
||
#if ( NUM_HEMI_LIGHTS > 0 )
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#ifdef USE_LIGHT_PROBES_GRID
|
||
vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
|
||
vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );
|
||
irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );
|
||
#endif
|
||
#endif
|
||
#if defined( RE_IndirectSpecular )
|
||
vec3 radiance = vec3( 0.0 );
|
||
vec3 clearcoatRadiance = vec3( 0.0 );
|
||
#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse )
|
||
#ifdef USE_LIGHTMAP
|
||
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
||
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
||
irradiance += lightMapIrradiance;
|
||
#endif
|
||
#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )
|
||
#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )
|
||
iblIrradiance += getIBLIrradiance( geometryNormal );
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
||
#ifdef USE_ANISOTROPY
|
||
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
||
#else
|
||
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
||
#endif
|
||
#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse )
|
||
#if defined( LAMBERT ) || defined( PHONG )
|
||
irradiance += iblIrradiance;
|
||
#endif
|
||
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
#endif
|
||
#if defined( RE_IndirectSpecular )
|
||
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
#endif`,lightprobes_pars_fragment:`#ifdef USE_LIGHT_PROBES_GRID
|
||
uniform highp sampler3D probesSH;
|
||
uniform vec3 probesMin;
|
||
uniform vec3 probesMax;
|
||
uniform vec3 probesResolution;
|
||
vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
||
vec3 res = probesResolution;
|
||
vec3 gridRange = probesMax - probesMin;
|
||
vec3 resMinusOne = res - 1.0;
|
||
vec3 probeSpacing = gridRange / resMinusOne;
|
||
vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;
|
||
vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );
|
||
uvw = uvw * resMinusOne / res + 0.5 / res;
|
||
float nz = res.z;
|
||
float paddedSlices = nz + 2.0;
|
||
float atlasDepth = 7.0 * paddedSlices;
|
||
float uvZBase = uvw.z * nz + 1.0;
|
||
vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );
|
||
vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
|
||
vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
|
||
vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
|
||
vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
|
||
vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
|
||
vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
|
||
vec3 c0 = s0.xyz;
|
||
vec3 c1 = vec3( s0.w, s1.xy );
|
||
vec3 c2 = vec3( s1.zw, s2.x );
|
||
vec3 c3 = s2.yzw;
|
||
vec3 c4 = s3.xyz;
|
||
vec3 c5 = vec3( s3.w, s4.xy );
|
||
vec3 c6 = vec3( s4.zw, s5.x );
|
||
vec3 c7 = s5.yzw;
|
||
vec3 c8 = s6.xyz;
|
||
float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;
|
||
vec3 result = c0 * 0.886227;
|
||
result += c1 * 2.0 * 0.511664 * y;
|
||
result += c2 * 2.0 * 0.511664 * z;
|
||
result += c3 * 2.0 * 0.511664 * x;
|
||
result += c4 * 2.0 * 0.429043 * x * y;
|
||
result += c5 * 2.0 * 0.429043 * y * z;
|
||
result += c6 * ( 0.743125 * z * z - 0.247708 );
|
||
result += c7 * 2.0 * 0.429043 * x * z;
|
||
result += c8 * 0.429043 * ( x * x - y * y );
|
||
return max( result, vec3( 0.0 ) );
|
||
}
|
||
#endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#endif`,map_fragment:`#ifdef USE_MAP
|
||
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
#endif
|
||
diffuseColor *= sampledDiffuseColor;
|
||
#endif`,map_pars_fragment:`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,map_particle_fragment:`#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`,map_particle_pars_fragment:`#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`,metalnessmap_fragment:`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,morphinstance_vertex:`#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`,morphcolor_vertex:`#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`,morphnormal_vertex:`#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`,morphtarget_pars_vertex:`#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`,morphtarget_vertex:`#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`,normal_fragment_begin:`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;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE
|
||
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
||
#ifdef FLIP_SIDED
|
||
normal = - normal;
|
||
#endif
|
||
#ifdef DOUBLE_SIDED
|
||
normal = normal * faceDirection;
|
||
#endif
|
||
normal = normalize( normalMatrix * normal );
|
||
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
||
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
||
#if defined( USE_PACKED_NORMALMAP )
|
||
mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );
|
||
#endif
|
||
mapN.xy *= normalScale;
|
||
normal = normalize( tbn * mapN );
|
||
#elif defined( USE_BUMPMAP )
|
||
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
||
#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,normal_vertex:`#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif`,normalmap_pars_fragment:`#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`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT
|
||
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
#endif`,clearcoat_pars_fragment:`#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`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP
|
||
uniform sampler2D iridescenceMap;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform sampler2D iridescenceThicknessMap;
|
||
#endif`,opaque_fragment:`#ifdef OPAQUE
|
||
diffuseColor.a = 1.0;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
diffuseColor.a *= material.transmissionAlpha;
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) {
|
||
return normalize( normal ) * 0.5 + 0.5;
|
||
}
|
||
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
||
return 2.0 * rgb.xyz - 1.0;
|
||
}
|
||
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
|
||
const float Inv255 = 1. / 255.;
|
||
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
|
||
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
|
||
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
|
||
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
|
||
vec4 packDepthToRGBA( const in float v ) {
|
||
if( v <= 0.0 )
|
||
return vec4( 0., 0., 0., 0. );
|
||
if( v >= 1.0 )
|
||
return vec4( 1., 1., 1., 1. );
|
||
float vuf;
|
||
float af = modf( v * PackFactors.a, vuf );
|
||
float bf = modf( vuf * ShiftRight8, vuf );
|
||
float gf = modf( vuf * ShiftRight8, vuf );
|
||
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
|
||
}
|
||
vec3 packDepthToRGB( const in float v ) {
|
||
if( v <= 0.0 )
|
||
return vec3( 0., 0., 0. );
|
||
if( v >= 1.0 )
|
||
return vec3( 1., 1., 1. );
|
||
float vuf;
|
||
float bf = modf( v * PackFactors.b, vuf );
|
||
float gf = modf( vuf * ShiftRight8, vuf );
|
||
return vec3( vuf * Inv255, gf * PackUpscale, bf );
|
||
}
|
||
vec2 packDepthToRG( const in float v ) {
|
||
if( v <= 0.0 )
|
||
return vec2( 0., 0. );
|
||
if( v >= 1.0 )
|
||
return vec2( 1., 1. );
|
||
float vuf;
|
||
float gf = modf( v * 256., vuf );
|
||
return vec2( vuf * Inv255, gf );
|
||
}
|
||
float unpackRGBAToDepth( const in vec4 v ) {
|
||
return dot( v, UnpackFactors4 );
|
||
}
|
||
float unpackRGBToDepth( const in vec3 v ) {
|
||
return dot( v, UnpackFactors3 );
|
||
}
|
||
float unpackRGToDepth( const in vec2 v ) {
|
||
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
|
||
}
|
||
vec4 pack2HalfToRGBA( const in vec2 v ) {
|
||
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
||
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
||
}
|
||
vec2 unpackRGBATo2Half( const in vec4 v ) {
|
||
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
||
}
|
||
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
||
return ( viewZ + near ) / ( near - far );
|
||
}
|
||
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
|
||
return depth * ( far - near ) - far;
|
||
#else
|
||
return depth * ( near - far ) - near;
|
||
#endif
|
||
}
|
||
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
||
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
||
}
|
||
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
||
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
return ( near * far ) / ( ( near - far ) * depth - near );
|
||
#else
|
||
return ( near * far ) / ( ( far - near ) * depth - far );
|
||
#endif
|
||
}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,project_vertex:`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;`,dithering_fragment:`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,dithering_pars_fragment:`#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`,roughnessmap_fragment:`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0
|
||
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_MAPS > 0
|
||
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
||
#endif
|
||
#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#else
|
||
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#endif
|
||
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||
struct DirectionalLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#else
|
||
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#endif
|
||
struct SpotLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#elif defined( SHADOWMAP_TYPE_BASIC )
|
||
uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#endif
|
||
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||
struct PointLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
float shadowCameraNear;
|
||
float shadowCameraFar;
|
||
};
|
||
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
float interleavedGradientNoise( vec2 position ) {
|
||
return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
|
||
}
|
||
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
|
||
const float goldenAngle = 2.399963229728653;
|
||
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
|
||
float theta = float( sampleIndex ) * goldenAngle + phi;
|
||
return vec2( cos( theta ), sin( theta ) ) * r;
|
||
}
|
||
#endif
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
float shadow = 1.0;
|
||
shadowCoord.xyz /= shadowCoord.w;
|
||
shadowCoord.z += shadowBias;
|
||
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
||
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
||
if ( frustumTest ) {
|
||
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||
float radius = shadowRadius * texelSize.x;
|
||
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
|
||
shadow = (
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
|
||
) * 0.2;
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#elif defined( SHADOWMAP_TYPE_VSM )
|
||
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
float shadow = 1.0;
|
||
shadowCoord.xyz /= shadowCoord.w;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
shadowCoord.z -= shadowBias;
|
||
#else
|
||
shadowCoord.z += shadowBias;
|
||
#endif
|
||
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
||
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
||
if ( frustumTest ) {
|
||
vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
|
||
float mean = distribution.x;
|
||
float variance = distribution.y * distribution.y;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
float hard_shadow = step( mean, shadowCoord.z );
|
||
#else
|
||
float hard_shadow = step( shadowCoord.z, mean );
|
||
#endif
|
||
|
||
if ( hard_shadow == 1.0 ) {
|
||
shadow = 1.0;
|
||
} else {
|
||
variance = max( variance, 0.0000001 );
|
||
float d = shadowCoord.z - mean;
|
||
float p_max = variance / ( variance + d * d );
|
||
p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
|
||
shadow = max( hard_shadow, p_max );
|
||
}
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#else
|
||
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
float shadow = 1.0;
|
||
shadowCoord.xyz /= shadowCoord.w;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
shadowCoord.z -= shadowBias;
|
||
#else
|
||
shadowCoord.z += shadowBias;
|
||
#endif
|
||
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
||
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
||
if ( frustumTest ) {
|
||
float depth = texture2D( shadowMap, shadowCoord.xy ).r;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
shadow = step( depth, shadowCoord.z );
|
||
#else
|
||
shadow = step( shadowCoord.z, depth );
|
||
#endif
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
||
float shadow = 1.0;
|
||
vec3 lightToPosition = shadowCoord.xyz;
|
||
vec3 bd3D = normalize( lightToPosition );
|
||
vec3 absVec = abs( lightToPosition );
|
||
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
||
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
||
dp -= shadowBias;
|
||
#else
|
||
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
||
dp += shadowBias;
|
||
#endif
|
||
float texelSize = shadowRadius / shadowMapSize.x;
|
||
vec3 absDir = abs( bd3D );
|
||
vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
|
||
tangent = normalize( cross( bd3D, tangent ) );
|
||
vec3 bitangent = cross( bd3D, tangent );
|
||
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
|
||
vec2 sample0 = vogelDiskSample( 0, 5, phi );
|
||
vec2 sample1 = vogelDiskSample( 1, 5, phi );
|
||
vec2 sample2 = vogelDiskSample( 2, 5, phi );
|
||
vec2 sample3 = vogelDiskSample( 3, 5, phi );
|
||
vec2 sample4 = vogelDiskSample( 4, 5, phi );
|
||
shadow = (
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )
|
||
) * 0.2;
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#elif defined( SHADOWMAP_TYPE_BASIC )
|
||
float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
||
float shadow = 1.0;
|
||
vec3 lightToPosition = shadowCoord.xyz;
|
||
vec3 absVec = abs( lightToPosition );
|
||
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
||
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
||
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
||
dp += shadowBias;
|
||
vec3 bd3D = normalize( lightToPosition );
|
||
float depth = textureCube( shadowMap, bd3D ).r;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
depth = 1.0 - depth;
|
||
#endif
|
||
shadow = step( dp, depth );
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#endif
|
||
#endif
|
||
#endif`,shadowmap_pars_vertex:`#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`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
||
#ifdef HAS_NORMAL
|
||
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
||
#else
|
||
vec3 shadowWorldNormal = vec3( 0.0 );
|
||
#endif
|
||
vec4 shadowWorldPosition;
|
||
#endif
|
||
#if defined( USE_SHADOWMAP )
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
||
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
||
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_COORDS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
||
shadowWorldPosition = worldPosition;
|
||
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
||
#endif
|
||
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif`,shadowmask_pars_fragment:`float getShadowMask() {
|
||
float shadow = 1.0;
|
||
#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
DirectionalLightShadow directionalLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
directionalLight = directionalLightShadows[ i ];
|
||
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
SpotLightShadow spotLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||
spotLight = spotLightShadows[ i ];
|
||
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
|
||
PointLightShadow pointLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
pointLight = pointLightShadows[ i ];
|
||
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
return shadow;
|
||
}`,skinbase_vertex:`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,skinning_pars_vertex:`#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`,skinning_vertex:`#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`,skinnormal_vertex:`#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`,specularmap_fragment:`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,tonemapping_pars_fragment:`#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; }`,transmission_fragment:`#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.diffuseContribution, material.specularColorBlended, material.specularF90,
|
||
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
||
material.attenuationColor, material.attenuationDistance );
|
||
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
||
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
||
#endif`,transmission_pars_fragment:`#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`,uv_pars_fragment:`#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`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
||
varying vec2 vUv;
|
||
#endif
|
||
#ifdef USE_MAP
|
||
uniform mat3 mapTransform;
|
||
varying vec2 vMapUv;
|
||
#endif
|
||
#ifdef USE_ALPHAMAP
|
||
uniform mat3 alphaMapTransform;
|
||
varying vec2 vAlphaMapUv;
|
||
#endif
|
||
#ifdef USE_LIGHTMAP
|
||
uniform mat3 lightMapTransform;
|
||
varying vec2 vLightMapUv;
|
||
#endif
|
||
#ifdef USE_AOMAP
|
||
uniform mat3 aoMapTransform;
|
||
varying vec2 vAoMapUv;
|
||
#endif
|
||
#ifdef USE_BUMPMAP
|
||
uniform mat3 bumpMapTransform;
|
||
varying vec2 vBumpMapUv;
|
||
#endif
|
||
#ifdef USE_NORMALMAP
|
||
uniform mat3 normalMapTransform;
|
||
varying vec2 vNormalMapUv;
|
||
#endif
|
||
#ifdef USE_DISPLACEMENTMAP
|
||
uniform mat3 displacementMapTransform;
|
||
varying vec2 vDisplacementMapUv;
|
||
#endif
|
||
#ifdef USE_EMISSIVEMAP
|
||
uniform mat3 emissiveMapTransform;
|
||
varying vec2 vEmissiveMapUv;
|
||
#endif
|
||
#ifdef USE_METALNESSMAP
|
||
uniform mat3 metalnessMapTransform;
|
||
varying vec2 vMetalnessMapUv;
|
||
#endif
|
||
#ifdef USE_ROUGHNESSMAP
|
||
uniform mat3 roughnessMapTransform;
|
||
varying vec2 vRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_ANISOTROPYMAP
|
||
uniform mat3 anisotropyMapTransform;
|
||
varying vec2 vAnisotropyMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOATMAP
|
||
uniform mat3 clearcoatMapTransform;
|
||
varying vec2 vClearcoatMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
uniform mat3 clearcoatNormalMapTransform;
|
||
varying vec2 vClearcoatNormalMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
uniform mat3 clearcoatRoughnessMapTransform;
|
||
varying vec2 vClearcoatRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
uniform mat3 sheenColorMapTransform;
|
||
varying vec2 vSheenColorMapUv;
|
||
#endif
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
uniform mat3 sheenRoughnessMapTransform;
|
||
varying vec2 vSheenRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCEMAP
|
||
uniform mat3 iridescenceMapTransform;
|
||
varying vec2 vIridescenceMapUv;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform mat3 iridescenceThicknessMapTransform;
|
||
varying vec2 vIridescenceThicknessMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULARMAP
|
||
uniform mat3 specularMapTransform;
|
||
varying vec2 vSpecularMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
uniform mat3 specularColorMapTransform;
|
||
varying vec2 vSpecularColorMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
uniform mat3 specularIntensityMapTransform;
|
||
varying vec2 vSpecularIntensityMapUv;
|
||
#endif
|
||
#ifdef USE_TRANSMISSIONMAP
|
||
uniform mat3 transmissionMapTransform;
|
||
varying vec2 vTransmissionMapUv;
|
||
#endif
|
||
#ifdef USE_THICKNESSMAP
|
||
uniform mat3 thicknessMapTransform;
|
||
varying vec2 vThicknessMapUv;
|
||
#endif`,uv_vertex:`#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`,worldpos_vertex:`#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`,background_vert:`varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
void main() {
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
}`,background_frag:`uniform sampler2D t2D;
|
||
uniform float backgroundIntensity;
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vec4 texColor = texture2D( t2D, vUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
||
#endif
|
||
texColor.rgb *= backgroundIntensity;
|
||
gl_FragColor = texColor;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,backgroundCube_vert:`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE
|
||
uniform samplerCube envMap;
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
uniform sampler2D envMap;
|
||
#endif
|
||
uniform float backgroundBlurriness;
|
||
uniform float backgroundIntensity;
|
||
uniform mat3 backgroundRotation;
|
||
varying vec3 vWorldDirection;
|
||
#include <cube_uv_reflection_fragment>
|
||
void main() {
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
||
#else
|
||
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
||
#endif
|
||
texColor.rgb *= backgroundIntensity;
|
||
gl_FragColor = texColor;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,cube_vert:`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,cube_frag:`uniform samplerCube tCube;
|
||
uniform float tFlip;
|
||
uniform float opacity;
|
||
varying vec3 vWorldDirection;
|
||
void main() {
|
||
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
||
gl_FragColor = texColor;
|
||
gl_FragColor.a *= opacity;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,depth_vert:`#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;
|
||
}`,depth_frag:`#if DEPTH_PACKING == 3200
|
||
uniform float opacity;
|
||
#endif
|
||
#include <common>
|
||
#include <packing>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
varying vec2 vHighPrecisionZW;
|
||
void main() {
|
||
vec4 diffuseColor = vec4( 1.0 );
|
||
#include <clipping_planes_fragment>
|
||
#if DEPTH_PACKING == 3200
|
||
diffuseColor.a = opacity;
|
||
#endif
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
||
#else
|
||
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
||
#endif
|
||
#if DEPTH_PACKING == 3200
|
||
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
||
#elif DEPTH_PACKING == 3201
|
||
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
||
#elif DEPTH_PACKING == 3202
|
||
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
||
#elif DEPTH_PACKING == 3203
|
||
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
||
#endif
|
||
}`,distance_vert:`#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;
|
||
}`,distance_frag:`#define DISTANCE
|
||
uniform vec3 referencePosition;
|
||
uniform float nearDistance;
|
||
uniform float farDistance;
|
||
varying vec3 vWorldPosition;
|
||
#include <common>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main () {
|
||
vec4 diffuseColor = vec4( 1.0 );
|
||
#include <clipping_planes_fragment>
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
float dist = length( vWorldPosition - referencePosition );
|
||
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
||
dist = saturate( dist );
|
||
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
||
}`,equirect_vert:`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
}`,equirect_frag:`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>
|
||
}`,linedashed_vert:`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>
|
||
}`,linedashed_frag:`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>
|
||
}`,meshbasic_vert:`#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>
|
||
}`,meshbasic_frag:`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>
|
||
}`,meshlambert_vert:`#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>
|
||
}`,meshlambert_frag:`#define LAMBERT
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <envmap_physical_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_lambert_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <specularmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_lambert_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
||
#include <envmap_fragment>
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshmatcap_vert:`#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;
|
||
}`,meshmatcap_frag:`#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>
|
||
}`,meshnormal_vert:`#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
|
||
}`,meshnormal_frag:`#define NORMAL
|
||
uniform float opacity;
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
||
varying vec3 vViewPosition;
|
||
#endif
|
||
#include <uv_pars_fragment>
|
||
#include <normal_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
||
#include <clipping_planes_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
|
||
#ifdef OPAQUE
|
||
gl_FragColor.a = 1.0;
|
||
#endif
|
||
}`,meshphong_vert:`#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>
|
||
}`,meshphong_frag:`#define PHONG
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform vec3 specular;
|
||
uniform float shininess;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <envmap_physical_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_phong_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <specularmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_phong_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
||
#include <envmap_fragment>
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshphysical_vert:`#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
|
||
}`,meshphysical_frag:`#define STANDARD
|
||
#ifdef PHYSICAL
|
||
#define IOR
|
||
#define USE_SPECULAR
|
||
#endif
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float roughness;
|
||
uniform float metalness;
|
||
uniform float opacity;
|
||
#ifdef IOR
|
||
uniform float ior;
|
||
#endif
|
||
#ifdef USE_SPECULAR
|
||
uniform float specularIntensity;
|
||
uniform vec3 specularColor;
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
uniform sampler2D specularColorMap;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
uniform sampler2D specularIntensityMap;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
uniform float clearcoat;
|
||
uniform float clearcoatRoughness;
|
||
#endif
|
||
#ifdef USE_DISPERSION
|
||
uniform float dispersion;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
uniform float iridescence;
|
||
uniform float iridescenceIOR;
|
||
uniform float iridescenceThicknessMinimum;
|
||
uniform float iridescenceThicknessMaximum;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
uniform vec3 sheenColor;
|
||
uniform float sheenRoughness;
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
uniform sampler2D sheenColorMap;
|
||
#endif
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
uniform sampler2D sheenRoughnessMap;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
uniform vec2 anisotropyVector;
|
||
#ifdef USE_ANISOTROPYMAP
|
||
uniform sampler2D anisotropyMap;
|
||
#endif
|
||
#endif
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <iridescence_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_physical_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_physical_pars_fragment>
|
||
#include <transmission_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <clearcoat_pars_fragment>
|
||
#include <iridescence_pars_fragment>
|
||
#include <roughnessmap_pars_fragment>
|
||
#include <metalnessmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <roughnessmap_fragment>
|
||
#include <metalnessmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <clearcoat_normal_fragment_begin>
|
||
#include <clearcoat_normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_physical_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
||
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
||
#include <transmission_fragment>
|
||
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
||
#ifdef USE_SHEEN
|
||
|
||
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
|
||
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
||
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
||
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
||
#endif
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshtoon_vert:`#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>
|
||
}`,meshtoon_frag:`#define TOON
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <gradientmap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_toon_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_toon_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,points_vert:`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>
|
||
}`,points_frag:`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>
|
||
}`,shadow_vert:`#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>
|
||
}`,shadow_frag:`uniform vec3 color;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <shadowmask_pars_fragment>
|
||
void main() {
|
||
#include <logdepthbuf_fragment>
|
||
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
}`,sprite_vert:`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>
|
||
}`,sprite_frag:`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>
|
||
}`},X={common:{diffuse:{value:new Y(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Fn},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Fn}},envmap:{envMap:{value:null},envMapRotation:{value:new Fn},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Fn},normalScale:{value:new K(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Y(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new q},probesMax:{value:new q},probesResolution:{value:new q}},points:{diffuse:{value:new Y(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0},uvTransform:{value:new Fn}},sprite:{diffuse:{value:new Y(16777215)},opacity:{value:1},center:{value:new K(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Fn},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0}}},ep={basic:{uniforms:fl([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.fog]),vertexShader:$f.meshbasic_vert,fragmentShader:$f.meshbasic_frag},lambert:{uniforms:fl([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.fog,X.lights,{emissive:{value:new Y(0)},envMapIntensity:{value:1}}]),vertexShader:$f.meshlambert_vert,fragmentShader:$f.meshlambert_frag},phong:{uniforms:fl([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.fog,X.lights,{emissive:{value:new Y(0)},specular:{value:new Y(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$f.meshphong_vert,fragmentShader:$f.meshphong_frag},standard:{uniforms:fl([X.common,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.roughnessmap,X.metalnessmap,X.fog,X.lights,{emissive:{value:new Y(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$f.meshphysical_vert,fragmentShader:$f.meshphysical_frag},toon:{uniforms:fl([X.common,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.gradientmap,X.fog,X.lights,{emissive:{value:new Y(0)}}]),vertexShader:$f.meshtoon_vert,fragmentShader:$f.meshtoon_frag},matcap:{uniforms:fl([X.common,X.bumpmap,X.normalmap,X.displacementmap,X.fog,{matcap:{value:null}}]),vertexShader:$f.meshmatcap_vert,fragmentShader:$f.meshmatcap_frag},points:{uniforms:fl([X.points,X.fog]),vertexShader:$f.points_vert,fragmentShader:$f.points_frag},dashed:{uniforms:fl([X.common,X.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$f.linedashed_vert,fragmentShader:$f.linedashed_frag},depth:{uniforms:fl([X.common,X.displacementmap]),vertexShader:$f.depth_vert,fragmentShader:$f.depth_frag},normal:{uniforms:fl([X.common,X.bumpmap,X.normalmap,X.displacementmap,{opacity:{value:1}}]),vertexShader:$f.meshnormal_vert,fragmentShader:$f.meshnormal_frag},sprite:{uniforms:fl([X.sprite,X.fog]),vertexShader:$f.sprite_vert,fragmentShader:$f.sprite_frag},background:{uniforms:{uvTransform:{value:new Fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$f.background_vert,fragmentShader:$f.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Fn}},vertexShader:$f.backgroundCube_vert,fragmentShader:$f.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$f.cube_vert,fragmentShader:$f.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$f.equirect_vert,fragmentShader:$f.equirect_frag},distance:{uniforms:fl([X.common,X.displacementmap,{referencePosition:{value:new q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$f.distance_vert,fragmentShader:$f.distance_frag},shadow:{uniforms:fl([X.lights,X.fog,{color:{value:new Y(0)},opacity:{value:1}}]),vertexShader:$f.shadow_vert,fragmentShader:$f.shadow_frag}};ep.physical={uniforms:fl([ep.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Fn},clearcoatNormalScale:{value:new K(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Fn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Fn},sheen:{value:0},sheenColor:{value:new Y(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Fn},transmissionSamplerSize:{value:new K},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Fn},attenuationDistance:{value:0},attenuationColor:{value:new Y(0)},specularColor:{value:new Y(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Fn},anisotropyVector:{value:new K},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Fn}}]),vertexShader:$f.meshphysical_vert,fragmentShader:$f.meshphysical_frag};var tp={r:0,b:0,g:0},np=new J,rp=new Fn;rp.set(-1,0,0,0,1,0,0,0,1);function ip(e,t,n,r,i,a){let o=new Y(0),s=i===!0?0:1,c,l,u=null,d=0,f=null;function p(e){let n=e.isScene===!0?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t){let r=!1,i=p(t);i===null?g(o,s):i&&i.isColor&&(g(i,1),r=!0);let c=e.xr.getEnvironmentBlendMode();c===`additive`?n.buffers.color.setClear(0,0,0,1,a):c===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(e.autoClear||r)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function h(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(l===void 0&&(l=new La(new bs(1,1,1),new yl({name:`BackgroundCubeMaterial`,uniforms:dl(ep.backgroundCube.uniforms),vertexShader:ep.backgroundCube.vertexShader,fragmentShader:ep.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute(`normal`),l.geometry.deleteAttribute(`uv`),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=i,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(np.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(rp),l.material.toneMapped=Bn.getTransfer(i.colorSpace)!==_t,(u!==i||d!==i.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(c===void 0&&(c=new La(new Qc(2,2),new yl({name:`BackgroundMaterial`,uniforms:dl(ep.background.uniforms),vertexShader:ep.background.vertexShader,fragmentShader:ep.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=i,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.toneMapped=Bn.getTransfer(i.colorSpace)!==_t,i.matrixAutoUpdate===!0&&i.updateMatrix(),c.material.uniforms.uvTransform.value.copy(i.matrix),(u!==i||d!==i.version||f!==e.toneMapping)&&(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null))}function g(t,r){t.getRGB(tp,hl(e)),n.buffers.color.setClear(tp.r,tp.g,tp.b,r,a)}function _(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),s=t,g(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(e){s=e,g(o,s)},render:m,addToRenderList:h,dispose:_}}function ap(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e<n;e++)t[e]=0,r[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:i,object:e,attributes:{},index:null}}function p(e,t,n,r){let i=a.attributes,o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function g(e){_(e,0)}function _(t,n){let r=a.newAttributes,i=a.enabledAttributes,o=a.attributeDivisors;r[t]=1,i[t]===0&&(e.enableVertexAttribArray(t),i[t]=1),o[t]!==n&&(e.vertexAttribDivisor(t,n),o[t]=n)}function v(){let t=a.newAttributes,n=a.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function y(t,n,r,i,a,o,s){s===!0?e.vertexAttribIPointer(t,n,r,a,o):e.vertexAttribPointer(t,n,r,i,a,o)}function b(n,r,i,a){h();let o=a.attributes,s=i.getAttributes(),c=r.defaultAttributeValues;for(let r in s){let i=s[r];if(i.location>=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<i.locationSize;e++)_(i.location+e,t.meshPerAttribute);n.isInstancedMesh!==!0&&a._maxInstanceCount===void 0&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<i.locationSize;e++)g(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,l);for(let e=0;e<i.locationSize;e++)y(i.location+e,o/i.locationSize,u,r,c*d,(p+o/i.locationSize*e)*d,f)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<i.locationSize;e++)_(i.location+e,s.meshPerAttribute);n.isInstancedMesh!==!0&&a._maxInstanceCount===void 0&&(a._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<i.locationSize;e++)g(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,l);for(let e=0;e<i.locationSize;e++)y(i.location+e,o/i.locationSize,u,r,o*d,o/i.locationSize*e*d,f)}}else if(c!==void 0){let t=c[r];if(t!==void 0)switch(t.length){case 2:e.vertexAttrib2fv(i.location,t);break;case 3:e.vertexAttrib3fv(i.location,t);break;case 4:e.vertexAttrib4fv(i.location,t);break;default:e.vertexAttrib1fv(i.location,t)}}}}v()}function x(){T();for(let e in r){let t=r[e];for(let e in t){let n=t[e];for(let e in n){let t=n[e];for(let e in t)u(t[e].object),delete t[e];delete n[e]}}delete r[e]}}function S(e){if(r[e.id]===void 0)return;let t=r[e.id];for(let e in t){let n=t[e];for(let e in n){let t=n[e];for(let e in t)u(t[e].object),delete t[e];delete n[e]}}delete r[e.id]}function C(e){for(let t in r){let n=r[t];for(let t in n){let r=n[t];if(r[e.id]===void 0)continue;let i=r[e.id];for(let e in i)u(i[e].object),delete i[e];delete r[e.id]}}}function w(e){for(let t in r){let n=r[t],i=e.isInstancedMesh===!0?e.id:0,a=n[i];if(a!==void 0){for(let e in a){let t=a[e];for(let e in t)u(t[e].object),delete t[e];delete a[e]}delete n[i],Object.keys(n).length===0&&delete r[t]}}}function T(){E(),o=!0,a!==i&&(a=i,l(a.object))}function E(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:s,reset:T,resetDefaultState:E,dispose:x,releaseStatesOfGeometry:S,releaseStatesOfObject:w,releaseStatesOfProgram:C,initAttributes:h,enableAttribute:g,disableUnusedAttributes:v}}function op(e,t,n){let r;function i(e){r=e}function a(t,i){e.drawArrays(r,t,i),n.update(i,r,1)}function o(t,i,a){a!==0&&(e.drawArraysInstanced(r,t,i,a),n.update(i,r,a))}function s(e,i,a){if(a===0)return;t.get(`WEBGL_multi_draw`).multiDrawArraysWEBGL(r,e,0,i,0,a);let o=0;for(let e=0;e<a;e++)o+=i[e];n.update(o,r,1)}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=s}function sp(e,t,n,r){let i;function a(){if(i!==void 0)return i;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(t){return!(t!==1023&&r.convert(t)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))}function s(n){let i=n===1016&&(t.has(`EXT_color_buffer_half_float`)||t.has(`EXT_color_buffer_float`));return!(n!==1009&&r.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==1015&&!i)}function c(t){if(t===`highp`){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(G(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`);n.reversedDepthBuffer===!0&&f===!1&&G(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`);let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=e.getParameter(e.MAX_SAMPLES),S=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function cp(e){let t=this,n=null,r=0,i=!1,a=!1,o=new mo,s=new Fn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length<t)&&(l=new Float32Array(t));for(let t=0,n=r;t!==a;++t,n+=4)o.copy(e[t]).applyMatrix4(i,s),o.normal.toArray(l,n),l[n+3]=o.constant}c.value=l,c.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,l}}var lp=4,up=[.125,.215,.35,.446,.526,.582],dp=20,fp=256,pp=new Nu,mp=new Y,hp=null,gp=0,_p=0,vp=!1,yp=new q,bp=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=yp}=i;hp=this._renderer.getRenderTarget(),gp=this._renderer.getActiveCubeFace(),_p=this._renderer.getActiveMipmapLevel(),vp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s,o),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Dp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ep(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(hp,gp,_p),this._renderer.xr.enabled=vp,e.scissorTest=!1,Cp(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),hp=this._renderer.getRenderTarget(),gp=this._renderer.getActiveCubeFace(),_p=this._renderer.getActiveMipmapLevel(),vp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:M,minFilter:M,generateMipmaps:!1,type:ne,format:le,colorSpace:ht,depthBuffer:!1},r=Sp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Sp(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=xp(r)),this._blurMaterial=Tp(r,e,t),this._ggxMaterial=wp(r,e,t)}return r}_compileMaterial(e){let t=new La(new Ki,e);this._renderer.compile(t,pp)}_sceneToCubeUV(e,t,n,r,i){let a=new Ou(90,1,t,n),o=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],c=this._renderer,l=c.autoClear,u=c.toneMapping;c.getClearColor(mp),c.toneMapping=0,c.autoClear=!1,c.state.buffers.depth.getReversed()&&(c.setRenderTarget(r),c.clearDepth(),c.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new La(new bs,new Ta({name:`PMREM.Background`,side:1,depthWrite:!1,depthTest:!1})));let d=this._backgroundBox,f=d.material,p=!1,m=e.background;m?m.isColor&&(f.color.copy(m),e.background=null,p=!0):(f.color.copy(mp),p=!0);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;Cp(r,n*l,t>2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Dp()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ep());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;Cp(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,pp)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;t<r;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){let r=this._renderer,i=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let s=a.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l)*(0+c*1.25),{_lodMax:d}=this,f=this._sizeLods[n],p=3*f*(n>d-lp?n-d+lp:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,Cp(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,pp),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,Cp(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,pp)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&$t(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*dp-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):dp;m>dp&&G(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${dp}`);let h=[],g=0;for(let e=0;e<dp;++e){let t=e/p,n=Math.exp(-t*t/2);h.push(n),e===0?g+=n:e<m&&(g+=2*n)}for(let e=0;e<h.length;e++)h[e]=h[e]/g;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=h,u.latitudinal.value=a===`latitudinal`,o&&(u.poleAxis.value=o);let{_lodMax:_}=this;u.dTheta.value=f,u.mipInt.value=_-n;let v=this._sizeLods[r];Cp(t,3*v*(r>_-lp?r-_+lp:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,pp)}};function xp(e){let t=[],n=[],r=[],i=e,a=e-lp+1+up.length;for(let o=0;o<a;o++){let a=2**i;t.push(a);let s=1/a;o>e-lp?s=up[o-e+lp-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Ki;h.setAttribute(`position`,new Ti(f,3)),h.setAttribute(`uv`,new Ti(p,2)),h.setAttribute(`faceIndex`,new Ti(m,1)),r.push(new La(h,null)),i>lp&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function Sp(e,t,n){let r=new $n(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function Cp(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function wp(e,t,n){return new yl({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:fp,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Op(),fragmentShader:`
|
||
|
||
precision highp float;
|
||
precision highp int;
|
||
|
||
varying vec3 vOutputDirection;
|
||
|
||
uniform sampler2D envMap;
|
||
uniform float roughness;
|
||
uniform float mipInt;
|
||
|
||
#define ENVMAP_TYPE_CUBE_UV
|
||
#include <cube_uv_reflection_fragment>
|
||
|
||
#define PI 3.14159265359
|
||
|
||
// Van der Corput radical inverse
|
||
float radicalInverse_VdC(uint bits) {
|
||
bits = (bits << 16u) | (bits >> 16u);
|
||
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
||
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
||
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
||
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
||
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
||
}
|
||
|
||
// Hammersley sequence
|
||
vec2 hammersley(uint i, uint N) {
|
||
return vec2(float(i) / float(N), radicalInverse_VdC(i));
|
||
}
|
||
|
||
// GGX VNDF importance sampling (Eric Heitz 2018)
|
||
// "Sampling the GGX Distribution of Visible Normals"
|
||
// https://jcgt.org/published/0007/04/01/
|
||
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
|
||
float alpha = roughness * roughness;
|
||
|
||
// Section 4.1: Orthonormal basis
|
||
vec3 T1 = vec3(1.0, 0.0, 0.0);
|
||
vec3 T2 = cross(V, T1);
|
||
|
||
// Section 4.2: Parameterization of projected area
|
||
float r = sqrt(Xi.x);
|
||
float phi = 2.0 * PI * Xi.y;
|
||
float t1 = r * cos(phi);
|
||
float t2 = r * sin(phi);
|
||
float s = 0.5 * (1.0 + V.z);
|
||
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
|
||
|
||
// Section 4.3: Reprojection onto hemisphere
|
||
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
|
||
|
||
// Section 3.4: Transform back to ellipsoid configuration
|
||
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
|
||
}
|
||
|
||
void main() {
|
||
vec3 N = normalize(vOutputDirection);
|
||
vec3 V = N; // Assume view direction equals normal for pre-filtering
|
||
|
||
vec3 prefilteredColor = vec3(0.0);
|
||
float totalWeight = 0.0;
|
||
|
||
// For very low roughness, just sample the environment directly
|
||
if (roughness < 0.001) {
|
||
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
|
||
return;
|
||
}
|
||
|
||
// Tangent space basis for VNDF sampling
|
||
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||
vec3 tangent = normalize(cross(up, N));
|
||
vec3 bitangent = cross(N, tangent);
|
||
|
||
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
|
||
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
|
||
|
||
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
|
||
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
|
||
|
||
// Transform H back to world space
|
||
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
|
||
vec3 L = normalize(2.0 * dot(V, H) * H - V);
|
||
|
||
float NdotL = max(dot(N, L), 0.0);
|
||
|
||
if(NdotL > 0.0) {
|
||
// Sample environment at fixed mip level
|
||
// VNDF importance sampling handles the distribution filtering
|
||
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
|
||
|
||
// Weight by NdotL for the split-sum approximation
|
||
// VNDF PDF naturally accounts for the visible microfacet distribution
|
||
prefilteredColor += sampleColor * NdotL;
|
||
totalWeight += NdotL;
|
||
}
|
||
}
|
||
|
||
if (totalWeight > 0.0) {
|
||
prefilteredColor = prefilteredColor / totalWeight;
|
||
}
|
||
|
||
gl_FragColor = vec4(prefilteredColor, 1.0);
|
||
}
|
||
`,blending:0,depthTest:!1,depthWrite:!1})}function Tp(e,t,n){let r=new Float32Array(dp),i=new q(0,1,0);return new yl({name:`SphericalGaussianBlur`,defines:{n:dp,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Op(),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:0,depthTest:!1,depthWrite:!1})}function Ep(){return new yl({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:Op(),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:0,depthTest:!1,depthWrite:!1})}function Dp(){return new yl({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Op(),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:0,depthTest:!1,depthWrite:!1})}function Op(){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 );
|
||
|
||
}
|
||
`}var kp=class extends $n{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new ms(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={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 );
|
||
|
||
}
|
||
`},r=new bs(5,5,5),i=new yl({name:`CubemapFromEquirect`,uniforms:dl(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new La(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=M),new od(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}};function Ap(e){let t=new WeakMap,n=new WeakMap,r=null;function i(e,t=!1){return e==null?null:t?o(e):a(e)}function a(n){if(n&&n.isTexture){let r=n.mapping;if(r===303||r===304)if(t.has(n)){let e=t.get(n).texture;return s(e,n.mapping)}else{let r=n.image;if(r&&r.height>0){let i=new kp(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}else return null}}return n}function o(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,o=i===301||i===302;if(a||o){let i=n.get(t),s=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return r===null&&(r=new bp(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let s=t.image;return a&&s&&s.height>0||o&&s&&c(s)?(r===null&&(r=new bp(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,u),i.texture):null}}}return t}function s(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function c(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function l(e){let n=e.target;n.removeEventListener(`dispose`,l);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function u(e){let t=e.target;t.removeEventListener(`dispose`,u);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}function d(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}return{get:i,dispose:d}}function jp(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==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(e){let t=n(e);return t===null&&en(`WebGLRenderer: `+e+` extension not supported.`),t}}}function Mp(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0?t:(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++,t)}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t<r;t+=3){let r=e[t+0],i=e[t+1],a=e[t+2];n.push(r,i,i,a,a,r)}}else{let e=i.array;o=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){let e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}let s=new(i.count>=65535?Mi:Ai)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.version<n.version&&l(e)}else l(e);return a.get(e)}return{get:s,update:c,getWireframeAttribute:u}}function Np(e,t,n){let r;function i(e){r=e}let a,o;function s(e){a=e.type,o=e.bytesPerElement}function c(t,i){e.drawElements(r,i,a,t*o),n.update(i,r,1)}function l(t,i,s){s!==0&&(e.drawElementsInstanced(r,i,a,t*o,s),n.update(i,r,s))}function u(e,i,o){if(o===0)return;t.get(`WEBGL_multi_draw`).multiDrawElementsWEBGL(r,i,0,a,e,0,o);let s=0;for(let e=0;e<o;e++)s+=i[e];n.update(s,r,1)}this.setMode=i,this.setIndex=s,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function Pp(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(t,r,i){switch(n.calls++,r){case e.TRIANGLES:n.triangles+=t/3*i;break;case e.LINES:n.lines+=t/2*i;break;case e.LINE_STRIP:n.lines+=i*(t-1);break;case e.LINE_LOOP:n.lines+=i*t;break;case e.POINTS:n.points+=i*t;break;default:$t(`WebGLInfo: Unknown draw mode:`,r);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:i,update:r}}function Fp(e,t,n){let r=new WeakMap,i=new Zn;function a(a,o,s){let c=a.morphTargetInfluences,l=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=l===void 0?0:l.length,d=r.get(o);if(d===void 0||d.count!==u){d!==void 0&&d.texture.dispose();let e=o.morphAttributes.position!==void 0,n=o.morphAttributes.normal!==void 0,a=o.morphAttributes.color!==void 0,s=o.morphAttributes.position||[],c=o.morphAttributes.normal||[],l=o.morphAttributes.color||[],f=0;e===!0&&(f=1),n===!0&&(f=2),a===!0&&(f=3);let p=o.attributes.position.count*f,m=1;p>t.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new er(h,p,m,u);g.type=V,g.needsUpdate=!0;let _=f*4;for(let t=0;t<u;t++){let r=s[t],o=c[t],u=l[t],d=p*m*4*t;for(let t=0;t<r.count;t++){let s=t*_;e===!0&&(i.fromBufferAttribute(r,t),h[d+s+0]=i.x,h[d+s+1]=i.y,h[d+s+2]=i.z,h[d+s+3]=0),n===!0&&(i.fromBufferAttribute(o,t),h[d+s+4]=i.x,h[d+s+5]=i.y,h[d+s+6]=i.z,h[d+s+7]=0),a===!0&&(i.fromBufferAttribute(u,t),h[d+s+8]=i.x,h[d+s+9]=i.y,h[d+s+10]=i.z,h[d+s+11]=u.itemSize===4?i.w:1)}}d={count:u,texture:g,size:new K(p,m)},r.set(o,d);function v(){g.dispose(),r.delete(o),o.removeEventListener(`dispose`,v)}o.addEventListener(`dispose`,v)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)s.getUniforms().setValue(e,`morphTexture`,a.morphTexture,n);else{let t=0;for(let e=0;e<c.length;e++)t+=c[e];let n=o.morphTargetsRelative?1:1-t;s.getUniforms().setValue(e,`morphTargetBaseInfluence`,n),s.getUniforms().setValue(e,`morphTargetInfluences`,c)}s.getUniforms().setValue(e,`morphTargetsTexture`,d.texture,n),s.getUniforms().setValue(e,`morphTargetsTextureSize`,d.size)}return{update:a}}function Ip(e,t,n,r,i){let a=new WeakMap;function o(r){let o=i.render.frame,s=r.geometry,l=t.get(r,s);if(a.get(l)!==o&&(t.update(l),a.set(l,o)),r.isInstancedMesh&&(r.hasEventListener(`dispose`,c)===!1&&r.addEventListener(`dispose`,c),a.get(r)!==o&&(n.update(r.instanceMatrix,e.ARRAY_BUFFER),r.instanceColor!==null&&n.update(r.instanceColor,e.ARRAY_BUFFER),a.set(r,o))),r.isSkinnedMesh){let e=r.skeleton;a.get(e)!==o&&(e.update(),a.set(e,o))}return l}function s(){a=new WeakMap}function c(e){let t=e.target;t.removeEventListener(`dispose`,c),r.releaseStatesOfObject(t),n.remove(t.instanceMatrix),t.instanceColor!==null&&n.remove(t.instanceColor)}return{update:o,dispose:s}}var Lp={1:`LINEAR_TONE_MAPPING`,2:`REINHARD_TONE_MAPPING`,3:`CINEON_TONE_MAPPING`,4:`ACES_FILMIC_TONE_MAPPING`,6:`AGX_TONE_MAPPING`,7:`NEUTRAL_TONE_MAPPING`,5:`CUSTOM_TONE_MAPPING`};function Rp(e,t,n,r,i){let a=new $n(t,n,{type:e,depthBuffer:r,stencilBuffer:i,depthTexture:r?new _s(t,n):void 0}),o=new $n(t,n,{type:ne,depthBuffer:!1,stencilBuffer:!1}),s=new Ki;s.setAttribute(`position`,new Pi([-1,3,0,-1,-1,0,3,-1,0],3)),s.setAttribute(`uv`,new Pi([0,2,0,0,2,0],2));let c=new bl({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
||
precision highp float;
|
||
|
||
uniform mat4 modelViewMatrix;
|
||
uniform mat4 projectionMatrix;
|
||
|
||
attribute vec3 position;
|
||
attribute vec2 uv;
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`
|
||
precision highp float;
|
||
|
||
uniform sampler2D tDiffuse;
|
||
|
||
varying vec2 vUv;
|
||
|
||
#include <tonemapping_pars_fragment>
|
||
#include <colorspace_pars_fragment>
|
||
|
||
void main() {
|
||
gl_FragColor = texture2D( tDiffuse, vUv );
|
||
|
||
#ifdef LINEAR_TONE_MAPPING
|
||
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
||
#elif defined( REINHARD_TONE_MAPPING )
|
||
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
||
#elif defined( CINEON_TONE_MAPPING )
|
||
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
||
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
||
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
||
#elif defined( AGX_TONE_MAPPING )
|
||
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
||
#elif defined( NEUTRAL_TONE_MAPPING )
|
||
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
||
#elif defined( CUSTOM_TONE_MAPPING )
|
||
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
||
#endif
|
||
|
||
#ifdef SRGB_TRANSFER
|
||
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
||
#endif
|
||
}`,depthTest:!1,depthWrite:!1}),l=new La(s,c),u=new Nu(-1,1,1,-1,0,1),d=null,f=null,p=!1,m,h=null,g=[],_=!1;this.setSize=function(e,t){a.setSize(e,t),o.setSize(e,t);for(let n=0;n<g.length;n++){let r=g[n];r.setSize&&r.setSize(e,t)}},this.setEffects=function(e){g=e,_=g.length>0&&g[0].isRenderPass===!0;let t=a.width,n=a.height;for(let e=0;e<g.length;e++){let r=g[e];r.setSize&&r.setSize(t,n)}},this.begin=function(e,t){if(p||e.toneMapping===0&&g.length===0)return!1;if(h=t,t!==null){let e=t.width,n=t.height;(a.width!==e||a.height!==n)&&this.setSize(e,n)}return _===!1&&e.setRenderTarget(a),m=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return _},this.end=function(e,t){e.toneMapping=m,p=!0;let n=a,r=o;for(let i=0;i<g.length;i++){let a=g[i];if(a.enabled!==!1&&(a.render(e,r,n,t),a.needsSwap!==!1)){let e=n;n=r,r=e}}if(d!==e.outputColorSpace||f!==e.toneMapping){d=e.outputColorSpace,f=e.toneMapping,c.defines={},Bn.getTransfer(d)===`srgb`&&(c.defines.SRGB_TRANSFER=``);let t=Lp[f];t&&(c.defines[t]=``),c.needsUpdate=!0}c.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(h),e.render(l,u),h=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),s.dispose(),c.dispose()}}var zp=new Xn,Bp=new _s(1,1),Vp=new er,Hp=new nr,Up=new ms,Wp=[],Gp=[],Kp=new Float32Array(16),qp=new Float32Array(9),Jp=new Float32Array(4);function Yp(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=Wp[i];if(a===void 0&&(a=new Float32Array(i),Wp[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function Xp(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function Zp(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function Qp(e,t){let n=Gp[t];n===void 0&&(n=new Int32Array(t),Gp[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function $p(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function em(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Xp(n,t))return;e.uniform2fv(this.addr,t),Zp(n,t)}}function tm(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(t.r!==void 0)(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Xp(n,t))return;e.uniform3fv(this.addr,t),Zp(n,t)}}function nm(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Xp(n,t))return;e.uniform4fv(this.addr,t),Zp(n,t)}}function rm(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Xp(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Zp(n,t)}else{if(Xp(n,r))return;Jp.set(r),e.uniformMatrix2fv(this.addr,!1,Jp),Zp(n,r)}}function im(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Xp(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Zp(n,t)}else{if(Xp(n,r))return;qp.set(r),e.uniformMatrix3fv(this.addr,!1,qp),Zp(n,r)}}function am(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Xp(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Zp(n,t)}else{if(Xp(n,r))return;Kp.set(r),e.uniformMatrix4fv(this.addr,!1,Kp),Zp(n,r)}}function om(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function sm(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Xp(n,t))return;e.uniform2iv(this.addr,t),Zp(n,t)}}function cm(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Xp(n,t))return;e.uniform3iv(this.addr,t),Zp(n,t)}}function lm(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Xp(n,t))return;e.uniform4iv(this.addr,t),Zp(n,t)}}function um(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function dm(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Xp(n,t))return;e.uniform2uiv(this.addr,t),Zp(n,t)}}function fm(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Xp(n,t))return;e.uniform3uiv(this.addr,t),Zp(n,t)}}function pm(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Xp(n,t))return;e.uniform4uiv(this.addr,t),Zp(n,t)}}function mm(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i);let a;this.type===e.SAMPLER_2D_SHADOW?(Bp.compareFunction=n.isReversedDepthBuffer()?518:515,a=Bp):a=zp,n.setTexture2D(t||a,i)}function hm(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||Hp,i)}function gm(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||Up,i)}function _m(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||Vp,i)}function vm(e){switch(e){case 5126:return $p;case 35664:return em;case 35665:return tm;case 35666:return nm;case 35674:return rm;case 35675:return im;case 35676:return am;case 5124:case 35670:return om;case 35667:case 35671:return sm;case 35668:case 35672:return cm;case 35669:case 35673:return lm;case 5125:return um;case 36294:return dm;case 36295:return fm;case 36296:return pm;case 35678:case 36198:case 36298:case 36306:case 35682:return mm;case 35679:case 36299:case 36307:return hm;case 35680:case 36300:case 36308:case 36293:return gm;case 36289:case 36303:case 36311:case 36292:return _m}}function ym(e,t){e.uniform1fv(this.addr,t)}function bm(e,t){let n=Yp(t,this.size,2);e.uniform2fv(this.addr,n)}function xm(e,t){let n=Yp(t,this.size,3);e.uniform3fv(this.addr,n)}function Sm(e,t){let n=Yp(t,this.size,4);e.uniform4fv(this.addr,n)}function Cm(e,t){let n=Yp(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function wm(e,t){let n=Yp(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Tm(e,t){let n=Yp(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Em(e,t){e.uniform1iv(this.addr,t)}function Dm(e,t){e.uniform2iv(this.addr,t)}function Om(e,t){e.uniform3iv(this.addr,t)}function km(e,t){e.uniform4iv(this.addr,t)}function Am(e,t){e.uniform1uiv(this.addr,t)}function jm(e,t){e.uniform2uiv(this.addr,t)}function Mm(e,t){e.uniform3uiv(this.addr,t)}function Nm(e,t){e.uniform4uiv(this.addr,t)}function Pm(e,t,n){let r=this.cache,i=t.length,a=Qp(n,i);Xp(r,a)||(e.uniform1iv(this.addr,a),Zp(r,a));let o;o=this.type===e.SAMPLER_2D_SHADOW?Bp:zp;for(let e=0;e!==i;++e)n.setTexture2D(t[e]||o,a[e])}function Fm(e,t,n){let r=this.cache,i=t.length,a=Qp(n,i);Xp(r,a)||(e.uniform1iv(this.addr,a),Zp(r,a));for(let e=0;e!==i;++e)n.setTexture3D(t[e]||Hp,a[e])}function Im(e,t,n){let r=this.cache,i=t.length,a=Qp(n,i);Xp(r,a)||(e.uniform1iv(this.addr,a),Zp(r,a));for(let e=0;e!==i;++e)n.setTextureCube(t[e]||Up,a[e])}function Lm(e,t,n){let r=this.cache,i=t.length,a=Qp(n,i);Xp(r,a)||(e.uniform1iv(this.addr,a),Zp(r,a));for(let e=0;e!==i;++e)n.setTexture2DArray(t[e]||Vp,a[e])}function Rm(e){switch(e){case 5126:return ym;case 35664:return bm;case 35665:return xm;case 35666:return Sm;case 35674:return Cm;case 35675:return wm;case 35676:return Tm;case 5124:case 35670:return Em;case 35667:case 35671:return Dm;case 35668:case 35672:return Om;case 35669:case 35673:return km;case 5125:return Am;case 36294:return jm;case 36295:return Mm;case 36296:return Nm;case 35678:case 36198:case 36298:case 36306:case 35682:return Pm;case 35679:case 36299:case 36307:return Fm;case 35680:case 36300:case 36308:case 36293:return Im;case 36289:case 36303:case 36311:case 36292:return Lm}}var zm=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=vm(t.type)}},Bm=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Rm(t.type)}},Vm=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let r=this.seq;for(let i=0,a=r.length;i!==a;++i){let a=r[i];a.setValue(e,t[a.id],n)}}},Hm=/(\w+)(\])?(\[|\.)?/g;function Um(e,t){e.seq.push(t),e.map[t.id]=t}function Wm(e,t,n){let r=e.name,i=r.length;for(Hm.lastIndex=0;;){let a=Hm.exec(r),o=Hm.lastIndex,s=a[1],c=a[2]===`]`,l=a[3];if(c&&(s|=0),l===void 0||l===`[`&&o+2===i){Um(n,l===void 0?new zm(s,e,t):new Bm(s,e,t));break}else{let e=n.map[s];e===void 0&&(e=new Vm(s),Um(n,e)),n=e}}}var Gm=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let n=e.getActiveUniform(t,r);Wm(n,e.getUniformLocation(t,n.name),this)}let r=[],i=[];for(let t of this.seq)t.type===e.SAMPLER_2D_SHADOW||t.type===e.SAMPLER_CUBE_SHADOW||t.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(t):i.push(t);r.length>0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function Km(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var qm=37297,Jm=0;function Ym(e,t){let n=e.split(`
|
||
`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e<a;e++){let i=e+1;r.push(`${i===t?`>`:` `} ${i}: ${n[e]}`)}return r.join(`
|
||
`)}var Xm=new Fn;function Zm(e){Bn._getMatrix(Xm,Bn.workingColorSpace,e);let t=`mat3( ${Xm.elements.map(e=>e.toFixed(4))} )`;switch(Bn.getTransfer(e)){case gt:return[t,`LinearTransferOETF`];case _t:return[t,`sRGBTransferOETF`];default:return G(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function Qm(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+`
|
||
|
||
`+i+`
|
||
|
||
`+Ym(e.getShaderSource(t),r)}else return i}function $m(e,t){let n=Zm(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(`
|
||
`)}var eh={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function th(e,t){let n=eh[t];return n===void 0?(G(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var nh=new q;function rh(){return Bn.getLuminanceCoefficients(nh),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${nh.x.toFixed(4)}, ${nh.y.toFixed(4)}, ${nh.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(`
|
||
`)}function ih(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(sh).join(`
|
||
`)}function ah(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(`
|
||
`)}function oh(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){let r=e.getActiveAttrib(t,i),a=r.name,o=1;r.type===e.FLOAT_MAT2&&(o=2),r.type===e.FLOAT_MAT3&&(o=3),r.type===e.FLOAT_MAT4&&(o=4),n[a]={type:r.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function sh(e){return e!==``}function ch(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function lh(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var uh=/^[ \t]*#include +<([\w\d./]+)>/gm;function dh(e){return e.replace(uh,ph)}var fh=new Map;function ph(e,t){let n=$f[t];if(n===void 0){let e=fh.get(t);if(e!==void 0)n=$f[e],G(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return dh(n)}var mh=/#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 hh(e){return e.replace(mh,gh)}function gh(e,t,n,r){let i=``;for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,`[ `+e+` ]`).replace(/UNROLLED_LOOP_INDEX/g,e);return i}function _h(e){let t=`precision ${e.precision} float;
|
||
precision ${e.precision} int;
|
||
precision ${e.precision} sampler2D;
|
||
precision ${e.precision} samplerCube;
|
||
precision ${e.precision} sampler3D;
|
||
precision ${e.precision} sampler2DArray;
|
||
precision ${e.precision} sampler2DShadow;
|
||
precision ${e.precision} samplerCubeShadow;
|
||
precision ${e.precision} sampler2DArrayShadow;
|
||
precision ${e.precision} isampler2D;
|
||
precision ${e.precision} isampler3D;
|
||
precision ${e.precision} isamplerCube;
|
||
precision ${e.precision} isampler2DArray;
|
||
precision ${e.precision} usampler2D;
|
||
precision ${e.precision} usampler3D;
|
||
precision ${e.precision} usamplerCube;
|
||
precision ${e.precision} usampler2DArray;
|
||
`;return e.precision===`highp`?t+=`
|
||
#define HIGH_PRECISION`:e.precision===`mediump`?t+=`
|
||
#define MEDIUM_PRECISION`:e.precision===`lowp`&&(t+=`
|
||
#define LOW_PRECISION`),t}var vh={1:`SHADOWMAP_TYPE_PCF`,3:`SHADOWMAP_TYPE_VSM`};function yh(e){return vh[e.shadowMapType]||`SHADOWMAP_TYPE_BASIC`}var bh={301:`ENVMAP_TYPE_CUBE`,302:`ENVMAP_TYPE_CUBE`,306:`ENVMAP_TYPE_CUBE_UV`};function xh(e){return e.envMap===!1?`ENVMAP_TYPE_CUBE`:bh[e.envMapMode]||`ENVMAP_TYPE_CUBE`}var Sh={302:`ENVMAP_MODE_REFRACTION`};function Ch(e){return e.envMap===!1?`ENVMAP_MODE_REFLECTION`:Sh[e.envMapMode]||`ENVMAP_MODE_REFLECTION`}var wh={0:`ENVMAP_BLENDING_MULTIPLY`,1:`ENVMAP_BLENDING_MIX`,2:`ENVMAP_BLENDING_ADD`};function Th(e){return e.envMap===!1?`ENVMAP_BLENDING_NONE`:wh[e.combine]||`ENVMAP_BLENDING_NONE`}function Eh(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(2**n,112)),texelHeight:r,maxMip:n}}function Dh(e,t,n,r){let i=e.getContext(),a=n.defines,o=n.vertexShader,s=n.fragmentShader,c=yh(n),l=xh(n),u=Ch(n),d=Th(n),f=Eh(n),p=ih(n),m=ah(a),h=i.createProgram(),g,_,v=n.glslVersion?`#version `+n.glslVersion+`
|
||
`:``;n.isRawShaderMaterial?(g=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(sh).join(`
|
||
`),g.length>0&&(g+=`
|
||
`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(sh).join(`
|
||
`),_.length>0&&(_+=`
|
||
`)):(g=[_h(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 `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexNormals?`#define HAS_NORMAL`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,`
|
||
`].filter(sh).join(`
|
||
`),_=[_h(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 `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.packedNormalMap?`#define USE_PACKED_NORMALMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas||n.batchingColor?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.numLightProbeGrids>0?`#define USE_LIGHT_PROBES_GRID`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.decodeVideoTextureEmissive?`#define DECODE_VIDEO_TEXTURE_EMISSIVE`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:$f.tonemapping_pars_fragment,n.toneMapping===0?``:th(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,$f.colorspace_pars_fragment,$m(`linearToOutputTexel`,n.outputColorSpace),rh(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,`
|
||
`].filter(sh).join(`
|
||
`)),o=dh(o),o=ch(o,n),o=lh(o,n),s=dh(s),s=ch(s,n),s=lh(s,n),o=hh(o),s=hh(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es
|
||
`,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(`
|
||
`)+`
|
||
`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#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(`
|
||
`)+`
|
||
`+_);let y=v+g+o,b=v+_+s,x=Km(i,i.VERTEX_SHADER,y),S=Km(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=Qm(i,x,`vertex`),n=Qm(i,S,`fragment`);$t(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+`
|
||
|
||
Material Name: `+t.name+`
|
||
Material Type: `+t.type+`
|
||
|
||
Program Info Log: `+o+`
|
||
`+e+`
|
||
`+n)}else o===``?(s===``||c===``)&&(u=!1):G(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new Gm(i,h),T=oh(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,qm)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Jm++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var Oh=0,kh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.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){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Ah(e),t.set(e,n)),n}},Ah=class{constructor(e){this.id=Oh++,this.code=e,this.usedTimes=0}};function jh(e){return e===1030||e===37490||e===36285}function Mh(e,t,n,r,i,a){let o=new mr,s=new kh,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f=r.precision,p={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distance`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function m(e){return c.add(e),e===0?`uv`:`uv${e}`}function h(i,o,l,u,h,g){let _=u.fog,v=h.geometry,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,b=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,x=t.get(i.envMap||y,b),S=x&&x.mapping===306?x.image.height:null,C=p[i.type];i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&G(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let w=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=w===void 0?0:w.length,E=0;v.morphAttributes.position!==void 0&&(E=1),v.morphAttributes.normal!==void 0&&(E=2),v.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=ep[C];D=e.vertexShader,O=e.fragmentShader}else D=i.vertexShader,O=i.fragmentShader,s.update(i),k=s.getVertexShaderID(i),A=s.getFragmentShaderID(i);let j=e.getRenderTarget(),M=e.state.buffers.depth.getReversed(),N=h.isInstancedMesh===!0,P=h.isBatchedMesh===!0,F=!!i.map,I=!!i.matcap,L=!!x,ee=!!i.aoMap,R=!!i.lightMap,te=!!i.bumpMap,z=!!i.normalMap,B=!!i.displacementMap,V=!!i.emissiveMap,ne=!!i.metalnessMap,re=!!i.roughnessMap,ie=i.anisotropy>0,ae=i.clearcoat>0,oe=i.dispersion>0,se=i.iridescence>0,ce=i.sheen>0,H=i.transmission>0,le=ie&&!!i.anisotropyMap,ue=ae&&!!i.clearcoatMap,de=ae&&!!i.clearcoatNormalMap,fe=ae&&!!i.clearcoatRoughnessMap,pe=se&&!!i.iridescenceMap,me=se&&!!i.iridescenceThicknessMap,he=ce&&!!i.sheenColorMap,ge=ce&&!!i.sheenRoughnessMap,_e=!!i.specularMap,ve=!!i.specularColorMap,ye=!!i.specularIntensityMap,be=H&&!!i.transmissionMap,xe=H&&!!i.thicknessMap,Se=!!i.gradientMap,U=!!i.alphaMap,Ce=i.alphaTest>0,we=!!i.alphaHash,Te=!!i.extensions,W=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(W=e.toneMapping);let Ee={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:D,fragmentShader:O,defines:i.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,batching:P,batchingColor:P&&h._colorsTexture!==null,instancing:N,instancingColor:N&&h.instanceColor!==null,instancingMorph:N&&h.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Bn.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:F,matcap:I,envMap:L,envMapMode:L&&x.mapping,envMapCubeUVHeight:S,aoMap:ee,lightMap:R,bumpMap:te,normalMap:z,displacementMap:B,emissiveMap:V,normalMapObjectSpace:z&&i.normalMapType===1,normalMapTangentSpace:z&&i.normalMapType===0,packedNormalMap:z&&i.normalMapType===0&&jh(i.normalMap.format),metalnessMap:ne,roughnessMap:re,anisotropy:ie,anisotropyMap:le,clearcoat:ae,clearcoatMap:ue,clearcoatNormalMap:de,clearcoatRoughnessMap:fe,dispersion:oe,iridescence:se,iridescenceMap:pe,iridescenceThicknessMap:me,sheen:ce,sheenColorMap:he,sheenRoughnessMap:ge,specularMap:_e,specularColorMap:ve,specularIntensityMap:ye,transmission:H,transmissionMap:be,thicknessMap:xe,gradientMap:Se,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:U,alphaTest:Ce,alphaHash:we,combine:i.combine,mapUv:F&&m(i.map.channel),aoMapUv:ee&&m(i.aoMap.channel),lightMapUv:R&&m(i.lightMap.channel),bumpMapUv:te&&m(i.bumpMap.channel),normalMapUv:z&&m(i.normalMap.channel),displacementMapUv:B&&m(i.displacementMap.channel),emissiveMapUv:V&&m(i.emissiveMap.channel),metalnessMapUv:ne&&m(i.metalnessMap.channel),roughnessMapUv:re&&m(i.roughnessMap.channel),anisotropyMapUv:le&&m(i.anisotropyMap.channel),clearcoatMapUv:ue&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:de&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:fe&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:me&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:he&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:ge&&m(i.sheenRoughnessMap.channel),specularMapUv:_e&&m(i.specularMap.channel),specularColorMapUv:ve&&m(i.specularColorMap.channel),specularIntensityMapUv:ye&&m(i.specularIntensityMap.channel),transmissionMapUv:be&&m(i.transmissionMap.channel),thicknessMapUv:xe&&m(i.thicknessMap.channel),alphaMapUv:U&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(z||ie),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:h.isPoints===!0&&!!v.attributes.uv&&(F||U),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&z===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:M,skinning:h.isSkinnedMesh===!0,morphTargets:v.morphAttributes.position!==void 0,morphNormals:v.morphAttributes.normal!==void 0,morphColors:v.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:W,decodeVideoTexture:F&&i.map.isVideoTexture===!0&&Bn.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:V&&i.emissiveMap.isVideoTexture===!0&&Bn.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:Te&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(Te&&i.extensions.multiDraw===!0||P)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ee.vertexUv1s=c.has(1),Ee.vertexUv2s=c.has(2),Ee.vertexUv3s=c.has(3),c.clear(),Ee}function g(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(_(n,t),v(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function _(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function v(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=ep[t];n=gl.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new Dh(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function x(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function S(e){s.remove(e)}function C(){s.dispose()}return{getParameters:h,getProgramCacheKey:g,getUniforms:y,acquireProgram:b,releaseProgram:x,releaseShaderCache:S,programs:l,dispose:C}}function Nh(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function Ph(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function Fh(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function Ih(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||Ph),r.length>1&&r.sort(t||Fh),i.length>1&&i.sort(t||Fh)}function d(){for(let n=t,r=e.length;n<r;n++){let t=e[n];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:c,unshift:l,finish:d,sort:u}}function Lh(){let e=new WeakMap;function t(t,n){let r=e.get(t),i;return r===void 0?(i=new Ih,e.set(t,[i])):n>=r.length?(i=new Ih,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Rh(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new q,color:new Y};break;case`SpotLight`:n={position:new q,direction:new q,color:new Y,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new q,color:new Y,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new q,skyColor:new Y,groundColor:new Y};break;case`RectAreaLight`:n={color:new Y,position:new q,halfWidth:new q,halfHeight:new q};break}return e[t.id]=n,n}}}function zh(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var Bh=0;function Vh(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function Hh(e){let t=new Rh,n=zh(),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 e=0;e<9;e++)r.probe.push(new q);let i=new q,a=new J,o=new J;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;i.sort(Vh);for(let e=0,y=i.length;e<y;e++){let y=i[e],b=y.color,x=y.intensity,S=y.distance,C=null;if(y.shadow&&y.shadow.map&&(C=y.shadow.map.texture.format===1030?y.shadow.map.texture:y.shadow.map.depthTexture||y.shadow.map.texture),y.isAmbientLight)a+=b.r*x,o+=b.g*x,s+=b.b*x;else if(y.isLightProbe){for(let e=0;e<9;e++)r.probe[e].addScaledVector(y.sh.coefficients[e],x);v++}else if(y.isDirectionalLight){let e=t.get(y);if(e.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){let e=y.shadow,t=n.get(y);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,r.directionalShadow[c]=t,r.directionalShadowMap[c]=C,r.directionalShadowMatrix[c]=y.shadow.matrix,p++}r.directional[c]=e,c++}else if(y.isSpotLight){let e=t.get(y);e.position.setFromMatrixPosition(y.matrixWorld),e.color.copy(b).multiplyScalar(x),e.distance=S,e.coneCos=Math.cos(y.angle),e.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),e.decay=y.decay,r.spot[u]=e;let i=y.shadow;if(y.map&&(r.spotLightMap[g]=y.map,g++,i.updateMatrices(y),y.castShadow&&_++),r.spotLightMatrix[u]=i.matrix,y.castShadow){let e=n.get(y);e.shadowIntensity=i.intensity,e.shadowBias=i.bias,e.shadowNormalBias=i.normalBias,e.shadowRadius=i.radius,e.shadowMapSize=i.mapSize,r.spotShadow[u]=e,r.spotShadowMap[u]=C,h++}u++}else if(y.isRectAreaLight){let e=t.get(y);e.color.copy(b).multiplyScalar(x),e.halfWidth.set(y.width*.5,0,0),e.halfHeight.set(0,y.height*.5,0),r.rectArea[d]=e,d++}else if(y.isPointLight){let e=t.get(y);if(e.color.copy(y.color).multiplyScalar(y.intensity),e.distance=y.distance,e.decay=y.decay,y.castShadow){let e=y.shadow,t=n.get(y);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,r.pointShadow[l]=t,r.pointShadowMap[l]=C,r.pointShadowMatrix[l]=y.shadow.matrix,m++}r.point[l]=e,l++}else if(y.isHemisphereLight){let e=t.get(y);e.skyColor.copy(y.color).multiplyScalar(x),e.groundColor.copy(y.groundColor).multiplyScalar(x),r.hemi[f]=e,f++}}d>0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=X.LTC_FLOAT_1,r.rectAreaLTC2=X.LTC_FLOAT_2):(r.rectAreaLTC1=X.LTC_HALF_1,r.rectAreaLTC2=X.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let y=r.hash;(y.directionalLength!==c||y.pointLength!==l||y.spotLength!==u||y.rectAreaLength!==d||y.hemiLength!==f||y.numDirectionalShadows!==p||y.numPointShadows!==m||y.numSpotShadows!==h||y.numSpotMaps!==g||y.numLightProbes!==v)&&(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=h,r.spotShadowMap.length=h,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=h+g-_,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=_,r.numLightProbes=v,y.directionalLength=c,y.pointLength=l,y.spotLength=u,y.rectAreaLength=d,y.hemiLength=f,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=h,y.numSpotMaps=g,y.numLightProbes=v,r.version=Bh++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){let f=e[t];if(f.isDirectionalLight){let e=r.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),i.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(d),n++}else if(f.isSpotLight){let e=r.spot[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(f.matrixWorld),i.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(d),c++}else if(f.isRectAreaLight){let e=r.rectArea[l];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),o.identity(),a.copy(f.matrixWorld),a.premultiply(d),o.extractRotation(a),e.halfWidth.set(f.width*.5,0,0),e.halfHeight.set(0,f.height*.5,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),l++}else if(f.isPointLight){let e=r.point[s];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),s++}else if(f.isHemisphereLight){let e=r.hemi[u];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(d),u++}}}return{setup:s,setupView:c,state:r}}function Uh(e){let t=new Hh(e),n=[],r=[],i=[];function a(e){d.camera=e,n.length=0,r.length=0,i.length=0}function o(e){n.push(e)}function s(e){r.push(e)}function c(e){i.push(e)}function l(){t.setup(n)}function u(e){t.setupView(n,e)}let d={lightsArray:n,shadowsArray:r,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:d,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:s,pushLightProbeGrid:c}}function Wh(e){let t=new WeakMap;function n(n,r=0){let i=t.get(n),a;return i===void 0?(a=new Uh(e),t.set(n,[a])):r>=i.length?(a=new Uh(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var Gh=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,Kh=`uniform sampler2D shadow_pass;
|
||
uniform vec2 resolution;
|
||
uniform float radius;
|
||
void main() {
|
||
const float samples = float( VSM_SAMPLES );
|
||
float mean = 0.0;
|
||
float squared_mean = 0.0;
|
||
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
||
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
||
for ( float i = 0.0; i < samples; i ++ ) {
|
||
float uvOffset = uvStart + i * uvStride;
|
||
#ifdef HORIZONTAL_PASS
|
||
vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
|
||
mean += distribution.x;
|
||
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
||
#else
|
||
float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
|
||
mean += depth;
|
||
squared_mean += depth * depth;
|
||
#endif
|
||
}
|
||
mean = mean / samples;
|
||
squared_mean = squared_mean / samples;
|
||
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
||
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
||
}`,qh=[new q(1,0,0),new q(-1,0,0),new q(0,1,0),new q(0,-1,0),new q(0,0,1),new q(0,0,-1)],Jh=[new q(0,-1,0),new q(0,-1,0),new q(0,0,1),new q(0,0,-1),new q(0,-1,0),new q(0,-1,0)],Yh=new J,Xh=new q,Zh=new q;function Qh(e,t,n){let r=new vo,i=new K,a=new K,o=new Zn,s=new Dl,c=new Ol,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new yl({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new K},radius:{value:4}},vertexShader:Gh,fragmentShader:Kh}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Ki;m.setAttribute(`position`,new Ti(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new La(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(G(`WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;c<l;c++){let l=t[c],d=l.shadow;if(d===void 0){G(`WebGLShadowMap:`,l,`has no shadow.`);continue}if(d.autoUpdate===!1&&d.needsUpdate===!1)continue;i.copy(d.mapSize);let m=d.getFrameExtents();i.multiply(m),a.copy(d.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){G(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new $n(i.x,i.y,{format:me,type:ne,minFilter:M,magFilter:M,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new _s(i.x,i.y,V),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=ue,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=D,d.map.depthTexture.magFilter=D}else l.isPointLight?(d.map=new kp(i.x),d.map.depthTexture=new vs(i.x,B)):(d.map=new $n(i.x,i.y),d.map.depthTexture=new _s(i.x,i.y,B)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=ue,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=M,d.map.depthTexture.magFilter=M):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=D,d.map.depthTexture.magFilter=D);d.camera.updateProjectionMatrix()}let g=d.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<g;t++){if(d.map.isWebGLCubeRenderTarget)e.setRenderTarget(d.map,t),e.clear();else{t===0&&(e.setRenderTarget(d.map),e.clear());let n=d.getViewport(t);o.set(a.x*n.x,a.y*n.y,a.x*n.z,a.y*n.w),f.viewport(o)}if(l.isPointLight){let e=d.camera,n=d.matrix,r=l.distance||e.far;r!==e.far&&(e.far=r,e.updateProjectionMatrix()),Xh.setFromMatrixPosition(l.matrixWorld),e.position.copy(Xh),Zh.copy(e.position),Zh.add(qh[t]),e.up.copy(Jh[t]),e.lookAt(Zh),e.updateMatrixWorld(),n.makeTranslation(-Xh.x,-Xh.y,-Xh.z),Yh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),d._frustum.setFromProjectionMatrix(Yh,e.coordinateSystem,e.reversedDepth)}else d.updateMatrices(l);r=d.getFrustum(),b(n,s,d.camera,l,this.type)}d.isPointLightShadow!==!0&&this.type===3&&v(d,s),d.needsUpdate=!1}_=this.type,g.needsUpdate=!1,e.setRenderTarget(c,l,d)};function v(n,r){let a=t.update(h);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),n.mapPass===null&&(n.mapPass=new $n(i.x,i.y,{format:me,type:ne})),f.uniforms.shadow_pass.value=n.map.depthTexture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,a,f,h,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,a,p,h,null)}function y(t,n,r,i){let a=null,o=r.isPointLight===!0?t.customDistanceMaterial:t.customDepthMaterial;if(o!==void 0)a=o;else if(a=r.isPointLight===!0?c:s,e.localClippingEnabled&&n.clipShadows===!0&&Array.isArray(n.clippingPlanes)&&n.clippingPlanes.length!==0||n.displacementMap&&n.displacementScale!==0||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l<u;l++){let u=t[l],d=c[u.materialIndex];if(d&&d.visible){let t=y(n,d,o,s);n.onBeforeShadow(e,n,i,a,r,t,u),e.renderBufferDirect(a,null,r,t,n,u),n.onAfterShadow(e,n,i,a,r,t,u)}}}else if(c.visible){let t=y(n,c,o,s);n.onBeforeShadow(e,n,i,a,r,t,null),e.renderBufferDirect(a,null,r,t,n,null),n.onAfterShadow(e,n,i,a,r,t,null)}}let c=n.children;for(let e=0,t=c.length;e<t;e++)b(c[e],i,a,o,s)}function x(e){e.target.removeEventListener(`dispose`,x);for(let t in l){let n=l[t],r=e.target.uuid;r in n&&(n[r].dispose(),delete n[r])}}}function $h(e,t){function n(){let t=!1,n=new Zn,r=null,i=new Zn(0,0,0,0);return{setMask:function(n){r!==n&&!t&&(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){s===!0&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),i.equals(n)===!1&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}}function r(){let n=!1,r=!1,i=null,a=null,o=null;return{setReversed:function(e){if(r!==e){let n=t.get(`EXT_clip_control`);e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),r=e;let i=o;o=null,this.setClear(i)}},getReversed:function(){return r},setTest:function(t){t?ne(e.DEPTH_TEST):re(e.DEPTH_TEST)},setMask:function(t){i!==t&&!n&&(e.depthMask(t),i=t)},setFunc:function(t){if(r&&(t=nn[t]),a!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(o=t,r&&(t=1-t),e.clearDepth(t))},reset:function(){n=!1,i=null,a=null,o=null,r=!1}}}function i(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(n){t||(n?ne(e.STENCIL_TEST):re(e.STENCIL_TEST))},setMask:function(r){n!==r&&!t&&(e.stencilMask(r),n=r)},setFunc:function(t,n,o){(r!==t||i!==n||a!==o)&&(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){(o!==t||s!==n||c!==r)&&(e.stencilOp(t,n,r),o=t,s=n,c=r)},setLocked:function(e){t=e},setClear:function(t){l!==t&&(e.clearStencil(t),l=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}}let a=new n,o=new r,s=new i,c=new WeakMap,l=new WeakMap,u={},d={},f={},p=new WeakMap,m=[],h=null,g=!1,_=null,v=null,y=null,b=null,x=null,S=null,C=null,w=new Y(0,0,0),T=0,E=!1,D=null,O=null,k=null,A=null,j=null,M=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),N=!1,P=0,F=e.getParameter(e.VERSION);F.indexOf(`WebGL`)===-1?F.indexOf(`OpenGL ES`)!==-1&&(P=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),N=P>=2):(P=parseFloat(/^WebGL (\d)/.exec(F)[1]),N=P>=1);let I=null,L={},ee=e.getParameter(e.SCISSOR_BOX),R=e.getParameter(e.VIEWPORT),te=new Zn().fromArray(ee),z=new Zn().fromArray(R);function B(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<r;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,i,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}let V={};V[e.TEXTURE_2D]=B(e.TEXTURE_2D,e.TEXTURE_2D,1),V[e.TEXTURE_CUBE_MAP]=B(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),V[e.TEXTURE_2D_ARRAY]=B(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),V[e.TEXTURE_3D]=B(e.TEXTURE_3D,e.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),s.setClear(0),ne(e.DEPTH_TEST),o.setFunc(3),ue(!1),de(1),ne(e.CULL_FACE),H(0);function ne(t){u[t]!==!0&&(e.enable(t),u[t]=!0)}function re(t){u[t]!==!1&&(e.disable(t),u[t]=!1)}function ie(t,n){return f[t]===n?!1:(e.bindFramebuffer(t,n),f[t]=n,t===e.DRAW_FRAMEBUFFER&&(f[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(f[e.DRAW_FRAMEBUFFER]=n),!0)}function ae(t,n){let r=m,i=!1;if(t){r=p.get(n),r===void 0&&(r=[],p.set(n,r));let a=t.textures;if(r.length!==a.length||r[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)r[t]=e.COLOR_ATTACHMENT0+t;r.length=a.length,i=!0}}else r[0]!==e.BACK&&(r[0]=e.BACK,i=!0);i&&e.drawBuffers(r)}function oe(t){return h===t?!1:(e.useProgram(t),h=t,!0)}let se={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT};se[103]=e.MIN,se[104]=e.MAX;let ce={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA,211:e.CONSTANT_COLOR,212:e.ONE_MINUS_CONSTANT_COLOR,213:e.CONSTANT_ALPHA,214:e.ONE_MINUS_CONSTANT_ALPHA};function H(t,n,r,i,a,o,s,c,l,u){if(t===0){g===!0&&(re(e.BLEND),g=!1);return}if(g===!1&&(ne(e.BLEND),g=!0),t!==5){if(t!==_||u!==E){if((v!==100||x!==100)&&(e.blendEquation(e.FUNC_ADD),v=100,x=100),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:$t(`WebGLState: Invalid blending: `,t);break}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:$t(`WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true`);break;case 4:$t(`WebGLState: MultiplyBlending requires material.premultipliedAlpha = true`);break;default:$t(`WebGLState: Invalid blending: `,t);break}y=null,b=null,S=null,C=null,w.set(0,0,0),T=0,_=t,E=u}return}a||=n,o||=r,s||=i,(n!==v||a!==x)&&(e.blendEquationSeparate(se[n],se[a]),v=n,x=a),(r!==y||i!==b||o!==S||s!==C)&&(e.blendFuncSeparate(ce[r],ce[i],ce[o],ce[s]),y=r,b=i,S=o,C=s),(c.equals(w)===!1||l!==T)&&(e.blendColor(c.r,c.g,c.b,l),w.copy(c),T=l),_=t,E=!1}function le(t,n){t.side===2?re(e.CULL_FACE):ne(e.CULL_FACE);let r=t.side===1;n&&(r=!r),ue(r),t.blending===1&&t.transparent===!1?H(0):H(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),o.setFunc(t.depthFunc),o.setTest(t.depthTest),o.setMask(t.depthWrite),a.setMask(t.colorWrite);let i=t.stencilWrite;s.setTest(i),i&&(s.setMask(t.stencilWriteMask),s.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),s.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),pe(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),t.alphaToCoverage===!0?ne(e.SAMPLE_ALPHA_TO_COVERAGE):re(e.SAMPLE_ALPHA_TO_COVERAGE)}function ue(t){D!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),D=t)}function de(t){t===0?re(e.CULL_FACE):(ne(e.CULL_FACE),t!==O&&(t===1?e.cullFace(e.BACK):t===2?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))),O=t}function fe(t){t!==k&&(N&&e.lineWidth(t),k=t)}function pe(t,n,r){t?(ne(e.POLYGON_OFFSET_FILL),(A!==n||j!==r)&&(A=n,j=r,o.getReversed()&&(n=-n),e.polygonOffset(n,r))):re(e.POLYGON_OFFSET_FILL)}function me(t){t?ne(e.SCISSOR_TEST):re(e.SCISSOR_TEST)}function he(t){t===void 0&&(t=e.TEXTURE0+M-1),I!==t&&(e.activeTexture(t),I=t)}function ge(t,n,r){r===void 0&&(r=I===null?e.TEXTURE0+M-1:I);let i=L[r];i===void 0&&(i={type:void 0,texture:void 0},L[r]=i),(i.type!==t||i.texture!==n)&&(I!==r&&(e.activeTexture(r),I=r),e.bindTexture(t,n||V[t]),i.type=t,i.texture=n)}function _e(){let t=L[I];t!==void 0&&t.type!==void 0&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)}function ve(){try{e.compressedTexImage2D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function ye(){try{e.compressedTexImage3D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function be(){try{e.texSubImage2D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function xe(){try{e.texSubImage3D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function Se(){try{e.compressedTexSubImage2D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function U(){try{e.compressedTexSubImage3D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function Ce(){try{e.texStorage2D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function we(){try{e.texStorage3D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function Te(){try{e.texImage2D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function W(){try{e.texImage3D(...arguments)}catch(e){$t(`WebGLState:`,e)}}function Ee(t){return d[t]===void 0?e.getParameter(t):d[t]}function De(t,n){d[t]!==n&&(e.pixelStorei(t,n),d[t]=n)}function Oe(t){te.equals(t)===!1&&(e.scissor(t.x,t.y,t.z,t.w),te.copy(t))}function ke(t){z.equals(t)===!1&&(e.viewport(t.x,t.y,t.z,t.w),z.copy(t))}function Ae(t,n){let r=l.get(n);r===void 0&&(r=new WeakMap,l.set(n,r));let i=r.get(t);i===void 0&&(i=e.getUniformBlockIndex(n,t.name),r.set(t,i))}function je(t,n){let r=l.get(n).get(t);c.get(n)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),c.set(n,r))}function Me(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},I=null,L={},f={},p=new WeakMap,m=[],h=null,g=!1,_=null,v=null,y=null,b=null,x=null,S=null,C=null,w=new Y(0,0,0),T=0,E=!1,D=null,O=null,k=null,A=null,j=null,te.set(0,0,e.canvas.width,e.canvas.height),z.set(0,0,e.canvas.width,e.canvas.height),a.reset(),o.reset(),s.reset()}return{buffers:{color:a,depth:o,stencil:s},enable:ne,disable:re,bindFramebuffer:ie,drawBuffers:ae,useProgram:oe,setBlending:H,setMaterial:le,setFlipSided:ue,setCullFace:de,setLineWidth:fe,setPolygonOffset:pe,setScissorTest:me,activeTexture:he,bindTexture:ge,unbindTexture:_e,compressedTexImage2D:ve,compressedTexImage3D:ye,texImage2D:Te,texImage3D:W,pixelStorei:De,getParameter:Ee,updateUBOMapping:Ae,uniformBlockBinding:je,texStorage2D:Ce,texStorage3D:we,texSubImage2D:be,texSubImage3D:xe,compressedTexSubImage2D:Se,compressedTexSubImage3D:U,scissor:Oe,viewport:ke,reset:Me}}function eg(e,t,n,r,i,a,o){let s=t.has(`WEBGL_multisampled_render_to_texture`)?t.get(`WEBGL_multisampled_render_to_texture`):null,c=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new K,u=new WeakMap,d=new Set,f,p=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function h(e,t){return m?new OffscreenCanvas(e,t):Gt(`canvas`)}function g(e,t,n){let r=1,i=Ee(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=h(n,a));let o=t?h(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),G(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&G(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e;return e}function _(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];G(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||G(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?gt:Bn.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function x(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,G(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function S(e,t){return _(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),j(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function k(e){let t=e.target;t.removeEventListener(`dispose`,k),I(t)}function j(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&P(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function P(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function I(t){let n=r.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r<n.__webglFramebuffer[t].length;r++)e.deleteFramebuffer(n.__webglFramebuffer[t][r]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}let i=t.textures;for(let t=0,n=i.length;t<n;t++){let n=r.get(i[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),o.memory.textures--),r.remove(i[t])}r.remove(t)}let L=0;function ee(){L=0}function R(){return L}function te(e){L=e}function z(){let e=L;return e>=i.maxTextures&&G(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),L+=1,e}function B(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function V(t,i){let a=r.get(t);if(t.isVideoTexture&&Te(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)G(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)G(`WebGLRenderer: Texture marked for update but image is incomplete`);else{fe(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function ne(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){fe(a,t,i);return}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function re(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){fe(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function ie(t,i){let a=r.get(t);if(t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version){pe(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let ae={[w]:e.REPEAT,[T]:e.CLAMP_TO_EDGE,[E]:e.MIRRORED_REPEAT},oe={[D]:e.NEAREST,[O]:e.NEAREST_MIPMAP_NEAREST,[A]:e.NEAREST_MIPMAP_LINEAR,[M]:e.LINEAR,[N]:e.LINEAR_MIPMAP_NEAREST,[F]:e.LINEAR_MIPMAP_LINEAR},se={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function ce(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&G(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,ae[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,ae[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,ae[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,oe[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,oe[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,se[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function H(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=B(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&P(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function le(e,t,n){return Math.floor(Math.floor(e/n)/t)}function ue(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e<o.length;e++){let t=o[s],n=o[e],i=t.start+t.count,a=le(n.start,r.width,4),c=le(t.start,r.width,4);n.start<=i+1&&a===c&&le(n.start+n.count-1,r.width,4)===a?t.count=Math.max(t.count,n.start+n.count-t.start):(++s,o[s]=n)}o.length=s+1;let c=n.getParameter(e.UNPACK_ROW_LENGTH),l=n.getParameter(e.UNPACK_SKIP_PIXELS),u=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,r.width);for(let t=0,s=o.length;t<s;t++){let s=o[t],c=Math.floor(s.start/4),l=Math.ceil(s.count/4),u=c%r.width,d=Math.floor(c/r.width),f=l;n.pixelStorei(e.UNPACK_SKIP_PIXELS,u),n.pixelStorei(e.UNPACK_SKIP_ROWS,d),n.texSubImage2D(e.TEXTURE_2D,0,u,d,f,1,i,a,r.data)}t.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,c),n.pixelStorei(e.UNPACK_SKIP_PIXELS,l),n.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}function fe(t,o,s){let c=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(c=e.TEXTURE_3D);let l=H(t,o),u=o.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+s);let f=r.get(u);if(u.version!==f.__version||l===!0){if(n.activeTexture(e.TEXTURE0+s),!(typeof ImageBitmap<`u`&&o.image instanceof ImageBitmap)){let t=Bn.getPrimaries(Bn.workingColorSpace),r=o.colorSpace===``?null:Bn.getPrimaries(o.colorSpace),i=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,i)}n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment);let t=g(o.image,!1,i.maxTextureSize);t=W(o,t);let r=a.convert(o.format,o.colorSpace),p=a.convert(o.type),m=b(o.internalFormat,r,p,o.normalized,o.colorSpace,o.isVideoTexture);ce(c,o);let h,y=o.mipmaps,C=o.isVideoTexture!==!0,w=f.__version===void 0||l===!0,T=u.dataReady,E=S(o,t);if(o.isDepthTexture)m=x(o.format===de,o.type),w&&(C?n.texStorage2D(e.TEXTURE_2D,1,m,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,r,p,null));else if(o.isDataTexture)if(y.length>0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t<i;t++)h=y[t],C?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,p,h.data):n.texImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,r,p,h.data);o.generateMipmaps=!1}else C?(w&&n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height),T&&ue(o,t,r,p)):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,r,p,t.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){C&&w&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,y[0].width,y[0].height,t.depth);for(let i=0,a=y.length;i<a;i++)if(h=y[i],o.format!==1023)if(r!==null)if(C){if(T)if(o.layerUpdates.size>0){let t=qf(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0);else G(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`);else C?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data)}else{C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t<i;t++)h=y[t],o.format===1023?C?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,p,h.data):n.texImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,r,p,h.data):r===null?G(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`):C?T&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,h.data):n.compressedTexImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,h.data)}else if(o.isDataArrayTexture)if(C){if(w&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,t.width,t.height,t.depth),T)if(o.layerUpdates.size>0){let i=qf(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isData3DTexture)C?(w&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(w)if(C)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t<E;t++)n.texImage2D(e.TEXTURE_2D,t,m,i,a,0,r,p,null),i>>=1,a>>=1}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}let r=e.RGBA,i=e.RGBA,a=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,r,i,a,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(y.length>0){if(C&&w){let t=Ee(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t<i;t++)h=y[t],C?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,r,p,h):n.texImage2D(e.TEXTURE_2D,t,m,r,p,h);o.generateMipmaps=!1}else if(C){if(w){let r=Ee(t);n.texStorage2D(e.TEXTURE_2D,E,m,r.width,r.height)}T&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,r,p,t)}else n.texImage2D(e.TEXTURE_2D,0,m,r,p,t);_(o)&&v(c),f.__version=u.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function pe(t,o,s){if(o.image.length!==6)return;let c=H(t,o),l=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=r.get(l);if(l.version!==u.__version||c===!0){n.activeTexture(e.TEXTURE0+s);let t=Bn.getPrimaries(Bn.workingColorSpace),r=o.colorSpace===``?null:Bn.getPrimaries(o.colorSpace),d=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let f=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,m=[];for(let e=0;e<6;e++)!f&&!p?m[e]=g(o.image[e],!0,i.maxCubemapSize):m[e]=p?o.image[e].image:o.image[e],m[e]=W(o,m[e]);let h=m[0],y=a.convert(o.format,o.colorSpace),x=a.convert(o.type),C=b(o.internalFormat,y,x,o.normalized,o.colorSpace),w=o.isVideoTexture!==!0,T=u.__version===void 0||c===!0,E=l.dataReady,D=S(o,h);ce(e.TEXTURE_CUBE_MAP,o);let O;if(f){w&&T&&n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,h.width,h.height);for(let t=0;t<6;t++){O=m[t].mipmaps;for(let r=0;r<O.length;r++){let i=O[r];o.format===1023?w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,y,x,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,C,i.width,i.height,0,y,x,i.data):y===null?G(`WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()`):w?E&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,y,i.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,C,i.width,i.height,0,i.data)}}}else{if(O=o.mipmaps,w&&T){O.length>0&&D++;let t=Ee(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,y,x,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,y,x,m[t].data);for(let r=0;r<O.length;r++){let i=O[r].image[t].image;w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,i.width,i.height,y,x,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,C,i.width,i.height,0,y,x,i.data)}}else{w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,y,x,m[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,y,x,m[t]);for(let r=0;r<O.length;r++){let i=O[r];w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,y,x,i.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,C,y,x,i.image[t])}}}_(o)&&v(e.TEXTURE_CUBE_MAP),u.__version=l.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function me(t,i,o,c,l,u){let d=a.convert(o.format,o.colorSpace),f=a.convert(o.type),p=b(o.internalFormat,d,f,o.normalized,o.colorSpace),m=r.get(i),h=r.get(o);if(h.__renderTarget=i,!m.__hasExternalTextures){let t=Math.max(1,i.width>>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),we(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,Ce(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function he(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=x(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;we(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ce(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,Ce(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i<t.length;i++){let o=t[i],c=a.convert(o.format,o.colorSpace),l=a.convert(o.type),u=b(o.internalFormat,c,l,o.normalized,o.colorSpace);we(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ce(n),u,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,Ce(n),u,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,u,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ge(t,i,o){let c=i.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,t),!(i.depthTexture&&i.depthTexture.isDepthTexture))throw Error(`renderTarget.depthTexture must be an instance of THREE.DepthTexture`);let l=r.get(i.depthTexture);if(l.__renderTarget=i,(!l.__webglTexture||i.depthTexture.image.width!==i.width||i.depthTexture.image.height!==i.height)&&(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),c){if(l.__webglInit===void 0&&(l.__webglInit=!0,i.depthTexture.addEventListener(`dispose`,C)),l.__webglTexture===void 0){l.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),ce(e.TEXTURE_CUBE_MAP,i.depthTexture);let t=a.convert(i.depthTexture.format),r=a.convert(i.depthTexture.type),o;i.depthTexture.format===1026?o=e.DEPTH_COMPONENT24:i.depthTexture.format===1027&&(o=e.DEPTH24_STENCIL8);for(let n=0;n<6;n++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,o,i.width,i.height,0,t,r,null)}}else V(i.depthTexture,0);let u=l.__webglTexture,d=Ce(i),f=c?e.TEXTURE_CUBE_MAP_POSITIVE_X+o:e.TEXTURE_2D,p=i.depthTexture.format===1027?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(i.depthTexture.format===1026)we(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,u,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,u,0);else if(i.depthTexture.format===1027)we(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,u,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,u,0);else throw Error(`Unknown depthTexture format`)}function _e(t){let i=r.get(t),a=t.isWebGLCubeRenderTarget===!0;if(i.__boundDepthTexture!==t.depthTexture){let e=t.depthTexture;if(i.__depthDisposeCallback&&i.__depthDisposeCallback(),e){let t=()=>{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)ge(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?ge(i.__webglFramebuffer[0],t,0):ge(i.__webglFramebuffer,t,0)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),he(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let r=t.texture.mipmaps;if(r&&r.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),he(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ve(t,n,i){let a=r.get(t);n!==void 0&&me(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&_e(t)}function ye(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,k);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n<i.mipmaps.length;n++)s.__webglFramebuffer[t][n]=e.createFramebuffer()}else s.__webglFramebuffer[t]=e.createFramebuffer()}else{if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer=[];for(let t=0;t<i.mipmaps.length;t++)s.__webglFramebuffer[t]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(d)for(let t=0,n=l.length;t<n;t++){let n=r.get(l[t]);n.__webglTexture===void 0&&(n.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&we(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n<l.length;n++){let r=l[n];s.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[n]);let i=a.convert(r.format,r.colorSpace),o=a.convert(r.type),c=b(r.internalFormat,i,o,r.normalized,r.colorSpace,t.isXRRenderTarget===!0),u=Ce(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,c,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,s.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),he(s.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),ce(e.TEXTURE_CUBE_MAP,i);for(let n=0;n<6;n++)if(i.mipmaps&&i.mipmaps.length>0)for(let r=0;r<i.mipmaps.length;r++)me(s.__webglFramebuffer[n][r],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,r);else me(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);_(i)&&v(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let i=0,a=l.length;i<a;i++){let a=l[i],o=r.get(a),c=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(c=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(c,o.__webglTexture),ce(c,a),me(s.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+i,c,0),_(a)&&v(c)}n.unbindTexture()}else{let r=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(r,c.__webglTexture),ce(r,i),i.mipmaps&&i.mipmaps.length>0)for(let n=0;n<i.mipmaps.length;n++)me(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,r,n);else me(s.__webglFramebuffer,t,i,e.COLOR_ATTACHMENT0,r,0);_(i)&&v(r),n.unbindTexture()}t.depthBuffer&&_e(t)}function be(e){let t=e.textures;for(let i=0,a=t.length;i<a;i++){let a=t[i];if(_(a)){let t=y(e),i=r.get(a).__webglTexture;n.bindTexture(t,i),v(t),n.unbindTexture()}}}let xe=[],Se=[];function U(t){if(t.samples>0){if(we(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t<i.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer);let f=t.texture.mipmaps;f&&f.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<i.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),d){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]);let t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),c===!0&&(xe.length=0,Se.length=0,xe.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&t.resolveDepthBuffer===!1&&(xe.push(l),Se.push(l),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Se)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,xe))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),d)for(let t=0;t<i.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);let a=r.get(i[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&t.resolveDepthBuffer===!1&&c){let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}}}function Ce(e){return Math.min(i.maxSamples,e.samples)}function we(e){let n=r.get(e);return e.samples>0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function Te(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function W(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(Bn.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&G(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):$t(`WebGLTextures: Unsupported texture color space:`,n)),t}function Ee(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=z,this.resetTextureUnits=ee,this.getTextureUnits=R,this.setTextureUnits=te,this.setTexture2D=V,this.setTexture2DArray=ne,this.setTexture3D=re,this.setTextureCube=ie,this.rebindTextures=ve,this.setupRenderTarget=ye,this.updateRenderTargetMipmap=be,this.updateMultisampleRenderTarget=U,this.setupDepthRenderbuffer=_e,this.setupFrameBufferTexture=me,this.useMultisampledRTT=we,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function tg(e,t){function n(n,r=``){let i,a=Bn.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===`srgb`)if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491)if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var ng=`
|
||
void main() {
|
||
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}`,rg=`
|
||
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;
|
||
|
||
}
|
||
|
||
}`,ig=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ys(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new yl({vertexShader:ng,fragmentShader:rg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new La(new Qc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},ag=class extends rn{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new ig,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new K,C=null,w=new Ou;w.viewport=new Zn;let T=new Ou;T.viewport=new Zn;let E=[w,T],D=new sd,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Nr,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Nr,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Nr,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}O=null,k=null,h.reset();for(let e in g)delete g[e];e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,z.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,A),r.addEventListener(`selectstart`,A),r.addEventListener(`selectend`,A),r.addEventListener(`squeeze`,A),r.addEventListener(`squeezestart`,A),r.addEventListener(`squeezeend`,A),r.addEventListener(`end`,j),r.addEventListener(`inputsourceschange`,M),_.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?de:ue,a=_.stencil?ae:B);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new $n(d.textureWidth,d.textureHeight,{format:le,type:L,depthTexture:new _s(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new $n(f.framebufferWidth,f.framebufferHeight,{format:le,type:L,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),z.setContext(r),z.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function M(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let N=new q,P=new q;function F(e,t,n){N.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(n.matrixWorld);let r=N.distanceTo(P),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function I(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;I(D,i);for(let e=0;e<a.length;e++)I(a[e],i);a.length===2?F(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),ee(e,D,i)};function ee(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=cn*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(D)},this.getCameraTexture=function(e){return g[e]};let R=null;function te(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==D.cameras.length&&(D.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=E[n];o===void 0&&(o=new Ou,o.layers.enable(n),o.viewport=new Zn,E[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(D.matrix.copy(o.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),i===!0&&D.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&m){u=n.getBinding();let e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&h.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&m){e.state.unbindTexture(),u=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new ys,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}R&&R(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let z=new Zf;z.setAnimationLoop(te),this.setAnimationLoop=function(e){R=e},this.dispose=function(){}}},og=new J,sg=new Fn;sg.set(-1,0,0,0,1,0,0,0,1);function cg(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,hl(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isNodeMaterial?t.uniformsNeedUpdate=!1:t.isMeshBasicMaterial?a(e,t):t.isMeshLambertMaterial?(a(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(og.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(sg),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function lg(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e<s;e++)if(o.indexOf(e)===-1)return o.push(e),e;return $t(`WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.`),0}function f(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){let n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){let i=n[r];if(p(i,t,r,a)===!0){let t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value],r=0;for(let a=0;a<n.length;a++){let o=n[a],s=h(o);typeof o==`number`||typeof o==`boolean`?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):ArrayBuffer.isView(o)?i.__data.set(new o.constructor(o.buffer,o.byteOffset,i.__data.length)):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return typeof i==`number`||typeof i==`boolean`?r[a]=i:ArrayBuffer.isView(i)?r[a]=i.slice():r[a]=i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else if(ArrayBuffer.isView(i))return!0;else if(e.equals(i)===!1)return e.copy(i),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=i.length;e<r;e++){let r=i[e],a=h(r),o=n%16,s=o%a.boundary,c=o+s;n+=s,c!==0&&16-c<a.storage&&(n+=16-c),t.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=a.storage}}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?G(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):G(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var ug=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),dg=null;function fg(){return dg===null&&(dg=new Za(ug,16,16,me,ne),dg.name=`DFG_LUT`,dg.minFilter=M,dg.magFilter=M,dg.wrapS=T,dg.wrapT=T,dg.generateMipmaps=!1,dg.needsUpdate=!0),dg}var pg=class{constructor(e={}){let{canvas:t=Kt(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=L}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([_e,he,pe]),g=new Set([L,B,te,ae,re,ie]),_=new Uint32Array(4),v=new Int32Array(4),y=new q,b=null,x=null,S=[],C=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null;this._outputColorSpace=mt;let O=0,k=0,A=null,j=-1,M=null,N=new Zn,P=new Zn,I=null,ee=new Y(0),R=0,z=t.width,V=t.height,oe=1,se=null,ce=null,H=new Zn(0,0,z,V),le=new Zn(0,0,z,V),ue=!1,de=new vo,fe=!1,me=!1,ge=new J,ve=new q,ye=new Zn,be={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},xe=!1;function Se(){return A===null?oe:1}let U=n;function Ce(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r184`),t.addEventListener(`webglcontextlost`,Je,!1),t.addEventListener(`webglcontextrestored`,Ye,!1),t.addEventListener(`webglcontextcreationerror`,Xe,!1),U===null){let t=`webgl2`;if(U=Ce(t,e),U===null)throw Ce(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw $t(`WebGLRenderer: `+e.message),e}let we,Te,W,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge;function Ke(){we=new jp(U),we.init(),Ue=new tg(U,we),Te=new sp(U,we,e,Ue),W=new $h(U,we),Te.reversedDepthBuffer&&d&&W.buffers.depth.setReversed(!0),Ee=new Pp(U),De=new Nh,Oe=new eg(U,we,W,De,Te,Ue,Ee),ke=new Ap(T),Ae=new Qf(U),We=new ap(U,Ae),je=new Mp(U,Ae,Ee,We),Me=new Ip(U,je,Ae,We,Ee),Be=new Fp(U,Te,Oe),Le=new cp(De),Ne=new Mh(T,ke,we,Te,We,Le),Pe=new cg(T,De),Fe=new Lh,Ie=new Wh(we),ze=new ip(T,ke,W,Me,p,s),Re=new Qh(T,Me,Te),Ge=new lg(U,Ee,Te,W),Ve=new op(U,we,Ee),He=new Np(U,we,Ee),Ee.programs=Ne.programs,T.capabilities=Te,T.extensions=we,T.properties=De,T.renderLists=Fe,T.shadowMap=Re,T.state=W,T.info=Ee}Ke(),m!==1009&&(w=new Rp(m,t.width,t.height,r,i));let qe=new ag(T,U);this.xr=qe,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let e=we.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=we.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return oe},this.setPixelRatio=function(e){e!==void 0&&(oe=e,this.setSize(z,V,!1))},this.getSize=function(e){return e.set(z,V)},this.setSize=function(e,n,r=!0){if(qe.isPresenting){G(`WebGLRenderer: Can't change size while VR device is presenting.`);return}z=e,V=n,t.width=Math.floor(e*oe),t.height=Math.floor(n*oe),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(z*oe,V*oe).floor()},this.setDrawingBufferSize=function(e,n,r){z=e,V=n,oe=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){$t(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){G(`THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}w.setEffects(e||[])},this.getCurrentViewport=function(e){return e.copy(N)},this.getViewport=function(e){return e.copy(H)},this.setViewport=function(e,t,n,r){e.isVector4?H.set(e.x,e.y,e.z,e.w):H.set(e,t,n,r),W.viewport(N.copy(H).multiplyScalar(oe).round())},this.getScissor=function(e){return e.copy(le)},this.setScissor=function(e,t,n,r){e.isVector4?le.set(e.x,e.y,e.z,e.w):le.set(e,t,n,r),W.scissor(P.copy(le).multiplyScalar(oe).round())},this.getScissorTest=function(){return ue},this.setScissorTest=function(e){W.setScissorTest(ue=e)},this.setOpaqueSort=function(e){se=e},this.setTransparentSort=function(e){ce=e},this.getClearColor=function(e){return e.copy(ze.getClearColor())},this.setClearColor=function(){ze.setClearColor(...arguments)},this.getClearAlpha=function(){return ze.getClearAlpha()},this.setClearAlpha=function(){ze.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(A!==null){let t=A.texture.format;e=h.has(t)}if(e){let e=A.texture.type,t=g.has(e),n=ze.getClearColor(),r=ze.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,U.clearBufferuiv(U.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,U.clearBufferiv(U.COLOR,0,v))}else r|=U.COLOR_BUFFER_BIT}t&&(r|=U.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(r|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&U.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(e){e.setRenderer(this),D=e},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Je,!1),t.removeEventListener(`webglcontextrestored`,Ye,!1),t.removeEventListener(`webglcontextcreationerror`,Xe,!1),ze.dispose(),Fe.dispose(),Ie.dispose(),De.dispose(),ke.dispose(),Me.dispose(),We.dispose(),Ge.dispose(),Ne.dispose(),qe.dispose(),qe.removeEventListener(`sessionstart`,rt),qe.removeEventListener(`sessionend`,it),at.stop()};function Je(e){e.preventDefault(),Zt(`WebGLRenderer: Context Lost.`),E=!0}function Ye(){Zt(`WebGLRenderer: Context Restored.`),E=!1;let e=Ee.autoReset,t=Re.enabled,n=Re.autoUpdate,r=Re.needsUpdate,i=Re.type;Ke(),Ee.autoReset=e,Re.enabled=t,Re.autoUpdate=n,Re.needsUpdate=r,Re.type=i}function Xe(e){$t(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Ze(e){let t=e.target;t.removeEventListener(`dispose`,Ze),Qe(t)}function Qe(e){$e(e),De.remove(e)}function $e(e){let t=De.get(e).programs;t!==void 0&&(t.forEach(function(e){Ne.releaseProgram(e)}),e.isShaderMaterial&&Ne.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=be);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=gt(e,t,n,r,i);W.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=je.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;We.setup(i,r,s,n,c);let h,g=Ve;if(c!==null&&(h=Ae.get(c),g=He,g.setIndex(h)),i.isMesh)r.wireframe===!0?(W.setLineWidth(r.wireframeLinewidth*Se()),g.setMode(U.LINES)):g.setMode(U.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),W.setLineWidth(e*Se()),i.isLineSegments?g.setMode(U.LINES):i.isLineLoop?g.setMode(U.LINE_LOOP):g.setMode(U.LINE_STRIP)}else i.isPoints?g.setMode(U.POINTS):i.isSprite&&g.setMode(U.TRIANGLES);if(i.isBatchedMesh)if(we.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?Ae.get(c).bytesPerElement:1,o=De.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(U,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function et(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,dt(e,t,n),e.side=0,e.needsUpdate=!0,dt(e,t,n),e.side=2):dt(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),x=Ie.get(n),x.init(t),C.push(x),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),x.setupLights();let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];et(a,n,e),r.add(a)}else et(t,n,e),r.add(t)}),x=C.pop(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){if(r.forEach(function(e){De.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}we.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let tt=null;function nt(e){tt&&tt(e)}function rt(){at.stop()}function it(){at.start()}let at=new Zf;at.setAnimationLoop(nt),typeof self<`u`&&at.setContext(self),this.setAnimationLoop=function(e){tt=e,qe.setAnimationLoop(e),e===null?at.stop():at.start()},qe.addEventListener(`sessionstart`,rt),qe.addEventListener(`sessionend`,it),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){$t(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=qe.enabled===!0&&qe.isPresenting===!0,r=w!==null&&(A===null||n)&&w.begin(T,A);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),qe.enabled===!0&&qe.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(qe.cameraAutoUpdate===!0&&qe.updateCamera(t),t=qe.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,A),x=Ie.get(e,C.length),x.init(t),x.state.textureUnits=Oe.getTextureUnits(),C.push(x),ge.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),de.setFromProjectionMatrix(ge,Ft,t.reversedDepth),me=this.localClippingEnabled,fe=Le.init(this.clippingPlanes,me),b=Fe.get(e,S.length),b.init(),S.push(b),qe.enabled===!0&&qe.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&ot(e,t,-1/0,T.sortObjects)}ot(e,t,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(se,ce),xe=qe.enabled===!1||qe.isPresenting===!1||qe.hasDepthSensing()===!1,xe&&ze.addToRenderList(b,e),this.info.render.frame++,fe===!0&&Le.beginShadows();let i=x.state.shadowsArray;if(Re.render(i,e,t),fe===!0&&Le.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];ct(n,r,e,a)}xe&&ze.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];st(b,e,n,n.viewport)}}else r.length>0&&ct(n,r,e,t),xe&&ze.render(e),st(b,e,t)}A!==null&&k===0&&(Oe.updateMultisampleRenderTarget(A),Oe.updateRenderTargetMipmap(A)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),We.resetDefaultState(),j=-1,M=null,C.pop(),C.length>0?(x=C[C.length-1],Oe.setTextureUnits(x.state.textureUnits),fe===!0&&Le.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function ot(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLightProbeGrid)x.pushLightProbeGrid(e);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||de.intersectsSprite(e)){r&&ye.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ge);let t=Me.update(e),i=e.material;i.visible&&b.push(e,t,i,n,ye.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||de.intersectsObject(e))){let t=Me.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),ye.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ye.copy(e.boundingSphere.center)),ye.applyMatrix4(e.matrixWorld).applyMatrix4(ge)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&b.push(e,t,s,n,ye.z,o)}}else i.visible&&b.push(e,t,i,n,ye.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)ot(i[e],t,n,r)}function st(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;x.setupLightsView(n),fe===!0&&Le.setGlobalState(T.clippingPlanes,n),r&&W.viewport(N.copy(r)),i.length>0&<(i,t,n),a.length>0&<(a,t,n),o.length>0&<(o,t,n),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function ct(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=we.has(`EXT_color_buffer_half_float`)||we.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new $n(1,1,{generateMipmaps:!0,type:e?ne:L,minFilter:F,samples:Math.max(4,Te.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Bn.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||N;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(ee),R=T.getClearAlpha(),R<1&&T.setClearColor(16777215,.5),T.clear(),xe&&ze.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),fe===!0&&Le.setGlobalState(T.clippingPlanes,r),lt(e,n,r),Oe.updateMultisampleRenderTarget(a),Oe.updateRenderTargetMipmap(a),we.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let{object:a,geometry:o,material:s,group:c}=t[i];if(s.side===2&&a.layers.test(r.layers)){let t=s.side;s.side=1,s.needsUpdate=!0,ut(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(Oe.updateMultisampleRenderTarget(a),Oe.updateRenderTargetMipmap(a))}T.setRenderTarget(s,c,l),T.setClearColor(ee,R),d!==void 0&&(r.viewport=d),T.toneMapping=u}function lt(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],{object:o,geometry:s,group:c}=a,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&ut(o,t,n,s,l,c)}}function ut(e,t,n,r,i,a){e.onBeforeRender(T,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(T,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,T.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,T.renderBufferDirect(n,t,r,i,e,a),i.side=2):T.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(T,t,n,r,i,a)}function dt(e,t,n){t.isScene!==!0&&(t=be);let r=De.get(e),i=x.state.lights,a=x.state.shadowsArray,o=i.state.version,s=Ne.getParameters(e,i.state,a,t,n,x.state.lightProbeGridArray),c=Ne.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,r.fog=t.fog;let u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;r.envMap=ke.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Ze),l=new Map,r.programs=l);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return pt(e,s),d}else s.uniforms=Ne.getUniforms(e),D!==null&&e.isNodeMaterial&&D.build(e,n,s),e.onBeforeCompile(s,T),d=Ne.acquireProgram(s,c),l.set(c,d),r.uniforms=s.uniforms;let f=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(f.clippingPlanes=Le.uniform),pt(e,s),r.needsLights=vt(e),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotLightMatrix.value=i.state.spotLightMatrix,f.spotLightMap.value=i.state.spotLightMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix),r.lightProbeGrid=x.state.lightProbeGridArray.length>0,r.currentProgram=d,r.uniformsList=null,d}function ft(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Gm.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function pt(e,t){let n=De.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function ht(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];y.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n.texture!==null&&n.boundingBox.containsPoint(y))return n}return null}function gt(e,t,n,r,i){t.isScene!==!0&&(t=be),Oe.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?t.environment:null,s=A===null?T.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Bn.workingColorSpace,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=ke.get(r.envMap||o,c),u=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=De.get(r),y=x.state.lights;if(fe===!0&&(me===!0||e!==M)){let t=e===M&&r.id===j;Le.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Le.numPlanes||v.numIntersection!==Le.numIntersection)?b=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h&&v.morphTargetsCount===_?!!v.lightProbeGrid!=x.state.lightProbeGridArray.length>0&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let S=v.currentProgram;b===!0&&(S=dt(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,S,v));let C=!1,w=!1,E=!1,O=S.getUniforms(),k=v.uniforms;if(W.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==j&&(j=r.id,w=!0),v.needsLights){let e=ht(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||M!==e){W.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(U,`projectionMatrix`,e.projectionMatrix),O.setValue(U,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(U,ve.setFromMatrixPosition(e.matrixWorld)),Te.logarithmicDepthBuffer&&O.setValue(U,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(U,`isOrthographic`,e.isOrthographicCamera===!0),M!==e&&(M=e,w=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&O.setValue(U,`directionalShadowMap`,y.state.directionalShadowMap,Oe),y.state.spotShadowMap.length>0&&O.setValue(U,`spotShadowMap`,y.state.spotShadowMap,Oe),y.state.pointShadowMap.length>0&&O.setValue(U,`pointShadowMap`,y.state.pointShadowMap,Oe)),i.isSkinnedMesh){O.setOptional(U,i,`bindMatrix`),O.setOptional(U,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(U,`boneTexture`,e.boneTexture,Oe))}i.isBatchedMesh&&(O.setOptional(U,i,`batchingTexture`),O.setValue(U,`batchingTexture`,i._matricesTexture,Oe),O.setOptional(U,i,`batchingIdTexture`),O.setValue(U,`batchingIdTexture`,i._indirectTexture,Oe),O.setOptional(U,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(U,`batchingColorTexture`,i._colorsTexture,Oe));let N=n.morphAttributes;if((N.position!==void 0||N.normal!==void 0||N.color!==void 0)&&Be.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(U,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(k.envMapIntensity.value=t.environmentIntensity),k.dfgLUT!==void 0&&(k.dfgLUT.value=fg()),w){if(O.setValue(U,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&_t(k,E),a&&r.fog===!0&&Pe.refreshFogUniforms(k,a),Pe.refreshMaterialUniforms(k,r,oe,V,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;k.probesSH.value=e.texture,k.probesMin.value.copy(e.boundingBox.min),k.probesMax.value.copy(e.boundingBox.max),k.probesResolution.value.copy(e.resolution)}Gm.upload(U,ft(v),k,Oe)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Gm.upload(U,ft(v),k,Oe),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(U,`center`,i.center),O.setValue(U,`modelViewMatrix`,i.modelViewMatrix),O.setValue(U,`normalMatrix`,i.normalMatrix),O.setValue(U,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Ge.update(n,S),Ge.bind(n,S)}}return S}function _t(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function vt(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(e,t,n){let r=De.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),De.get(e.texture).__webglTexture=t,De.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=De.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0};let yt=U.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){A=e,O=t,k=n;let r=null,i=!1,a=!1;if(e){let o=De.get(e);if(o.__useDefaultFramebuffer!==void 0){W.bindFramebuffer(U.FRAMEBUFFER,o.__webglFramebuffer),N.copy(e.viewport),P.copy(e.scissor),I=e.scissorTest,W.viewport(N),W.scissor(P),W.setScissorTest(I),j=-1;return}else if(o.__webglFramebuffer===void 0)Oe.setupRenderTarget(e);else if(o.__hasExternalTextures)Oe.rebindTextures(e,De.get(e.texture).__webglTexture,De.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&De.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);Oe.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=De.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&Oe.useMultisampledRTT(e)===!1?De.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,N.copy(e.viewport),P.copy(e.scissor),I=e.scissorTest}else N.copy(H).multiplyScalar(oe).floor(),P.copy(le).multiplyScalar(oe).floor(),I=ue;if(n!==0&&(r=yt),W.bindFramebuffer(U.FRAMEBUFFER,r)&&W.drawBuffers(e,r),W.viewport(N),W.scissor(P),W.setScissorTest(I),i){let r=De.get(e.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=De.get(e.textures[t]);U.framebufferTextureLayer(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=De.get(e.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,t.__webglTexture,n)}j=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){$t(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=De.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){W.bindFramebuffer(U.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(e.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+s),!Te.textureFormatReadable(c)){$t(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!Te.textureTypeReadable(l)){$t(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&U.readPixels(t,n,r,i,Ue.convert(c),Ue.convert(l),a)}finally{let e=A===null?null:De.get(A).__webglFramebuffer;W.bindFramebuffer(U.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=De.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){W.bindFramebuffer(U.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+s),!Te.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!Te.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,d),U.bufferData(U.PIXEL_PACK_BUFFER,a.byteLength,U.STREAM_READ),U.readPixels(t,n,r,i,Ue.convert(l),Ue.convert(u),0);let f=A===null?null:De.get(A).__webglFramebuffer;W.bindFramebuffer(U.FRAMEBUFFER,f);let p=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await tn(U,p,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,d),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,a),U.deleteBuffer(d),U.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;Oe.setTexture2D(e,0),U.copyTexSubImage2D(U.TEXTURE_2D,n,0,0,o,s,i,a),W.unbindTexture()};let bt=U.createFramebuffer(),xt=U.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Ue.convert(t.format),_=Ue.convert(t.type),v;t.isData3DTexture?(Oe.setTexture3D(t,0),v=U.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Oe.setTexture2DArray(t,0),v=U.TEXTURE_2D_ARRAY):(Oe.setTexture2D(t,0),v=U.TEXTURE_2D),W.activeTexture(U.TEXTURE0),W.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,t.flipY),W.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),W.pixelStorei(U.UNPACK_ALIGNMENT,t.unpackAlignment);let y=W.getParameter(U.UNPACK_ROW_LENGTH),b=W.getParameter(U.UNPACK_IMAGE_HEIGHT),x=W.getParameter(U.UNPACK_SKIP_PIXELS),S=W.getParameter(U.UNPACK_SKIP_ROWS),C=W.getParameter(U.UNPACK_SKIP_IMAGES);W.pixelStorei(U.UNPACK_ROW_LENGTH,h.width),W.pixelStorei(U.UNPACK_IMAGE_HEIGHT,h.height),W.pixelStorei(U.UNPACK_SKIP_PIXELS,l),W.pixelStorei(U.UNPACK_SKIP_ROWS,u),W.pixelStorei(U.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=De.get(e),r=De.get(t),h=De.get(n.__renderTarget),g=De.get(r.__renderTarget);W.bindFramebuffer(U.READ_FRAMEBUFFER,h.__webglFramebuffer),W.bindFramebuffer(U.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,De.get(e).__webglTexture,i,d+n),U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,De.get(t).__webglTexture,a,m+n)),U.blitFramebuffer(l,u,o,s,f,p,o,s,U.DEPTH_BUFFER_BIT,U.NEAREST);W.bindFramebuffer(U.READ_FRAMEBUFFER,null),W.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||De.has(e)){let n=De.get(e),r=De.get(t);W.bindFramebuffer(U.READ_FRAMEBUFFER,bt),W.bindFramebuffer(U.DRAW_FRAMEBUFFER,xt);for(let e=0;e<c;e++)w?U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):U.framebufferTexture2D(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,n.__webglTexture,i),T?U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):U.framebufferTexture2D(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,r.__webglTexture,a),i===0?T?U.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):U.copyTexSubImage2D(v,a,f,p,l,u,o,s):U.blitFramebuffer(l,u,o,s,f,p,o,s,U.COLOR_BUFFER_BIT,U.NEAREST);W.bindFramebuffer(U.READ_FRAMEBUFFER,null),W.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?U.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?U.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):U.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?U.texSubImage2D(U.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?U.compressedTexSubImage2D(U.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):U.texSubImage2D(U.TEXTURE_2D,a,f,p,o,s,g,_,h);W.pixelStorei(U.UNPACK_ROW_LENGTH,y),W.pixelStorei(U.UNPACK_IMAGE_HEIGHT,b),W.pixelStorei(U.UNPACK_SKIP_PIXELS,x),W.pixelStorei(U.UNPACK_SKIP_ROWS,S),W.pixelStorei(U.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&U.generateMipmap(v),W.unbindTexture()},this.initRenderTarget=function(e){De.get(e).__webglFramebuffer===void 0&&Oe.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?Oe.setTextureCube(e,0):e.isData3DTexture?Oe.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Oe.setTexture2DArray(e,0):Oe.setTexture2D(e,0),W.unbindTexture()},this.resetState=function(){O=0,k=0,A=null,W.reset(),We.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Ft}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Bn._getDrawingBufferColorSpace(e),t.unpackColorSpace=Bn._getUnpackColorSpace()}},mg=o((e=>{var t=d();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),hg=o(((e,t)=>{t.exports=mg()})),gg=o((e=>{var t=d(),n=hg();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),_g=l(o(((e,t)=>{t.exports=gg()}))(),1),vg=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},yg=(e=>e?vg(e):vg),{useSyncExternalStoreWithSelector:bg}=_g.default,xg=e=>e;function Sg(e,t=xg,n){let r=bg(e.subscribe,e.getState,e.getInitialState,t,n);return v.useDebugValue(r),r}var Cg=(e,t)=>{let n=yg(e),r=(e,r=t)=>Sg(n,e,r);return Object.assign(r,n),r},wg=((e,t)=>e?Cg(e,t):Cg),Tg=e=>typeof e==`object`&&typeof e.then==`function`,Eg=[];function Dg(e,t,n=(e,t)=>e===t){if(e===t)return!0;if(!e||!t)return!1;let r=e.length;if(t.length!==r)return!1;for(let i=0;i<r;i++)if(!n(e[i],t[i]))return!1;return!0}function Og(e,t=null,n=!1,r={}){t===null&&(t=[e]);for(let e of Eg)if(Dg(t,e.keys,e.equal)){if(n)return;if(Object.prototype.hasOwnProperty.call(e,`error`))throw e.error;if(Object.prototype.hasOwnProperty.call(e,`response`))return r.lifespan&&r.lifespan>0&&(e.timeout&&clearTimeout(e.timeout),e.timeout=setTimeout(e.remove,r.lifespan)),e.response;if(!n)throw e.promise}let i={keys:t,equal:r.equal,remove:()=>{let e=Eg.indexOf(i);e!==-1&&Eg.splice(e,1)},promise:(Tg(e)?e:e(...t)).then(e=>{i.response=e,r.lifespan&&r.lifespan>0&&(i.timeout=setTimeout(i.remove,r.lifespan))}).catch(e=>i.error=e)};if(Eg.push(i),!n)throw i.promise}var kg=(e,t,n)=>Og(e,t,!1,n),Ag=(e,t,n)=>void Og(e,t,!0,n),jg=e=>{if(e===void 0||e.length===0)Eg.splice(0,Eg.length);else{let t=Eg.find(t=>Dg(e,t.keys,t.equal));t&&t.remove()}},Mg=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Ng=o(((e,t)=>{t.exports=Mg()})),Pg=l(p()),Z=Ng();typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?v.useLayoutEffect:v.useEffect;function Fg(e,t,n){if(!e)return;if(n(e)===!0)return e;let r=t?e.return:e.child;for(;r;){let e=Fg(r,t,n);if(e)return e;r=t?null:r.sibling}}function Ig(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}var Lg=Ig(v.createContext(null)),Rg=class extends v.Component{render(){return v.createElement(Lg.Provider,{value:this._reactInternals},this.props.children)}};function zg(){let e=v.useContext(Lg);if(e===null)throw Error(`its-fine: useFiber must be called within a <FiberProvider />!`);let t=v.useId();return v.useMemo(()=>{for(let n of[e,e?.alternate]){if(!n)continue;let e=Fg(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}var Bg=Symbol.for(`react.context`),Vg=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Bg;function Hg(){let e=zg(),[t]=v.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;Vg(e)&&e!==Lg&&!t.has(e)&&t.set(e,v.use(Ig(e))),n=n.return}return t}function Ug(){let e=Hg();return v.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>r=>v.createElement(t,null,v.createElement(n.Provider,{...r,value:e.get(n)})),e=>v.createElement(Rg,{...e})),[e])}function Wg(e){let t=e.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}var Gg=e=>e&&e.isOrthographicCamera,Kg=e=>e&&e.hasOwnProperty(`current`),qg=e=>e!=null&&(typeof e==`string`||typeof e==`number`||e.isColor),Jg=((e,t)=>typeof window<`u`&&((e=window.document)?.createElement||(t=window.navigator)?.product===`ReactNative`))()?v.useLayoutEffect:v.useEffect;function Yg(e){let t=v.useRef(e);return Jg(()=>void(t.current=e),[e]),t}function Xg(){let e=zg(),t=Ug();return v.useMemo(()=>({children:n})=>(0,Z.jsx)(Fg(e,!0,e=>e.type===v.StrictMode)?v.StrictMode:v.Fragment,{children:(0,Z.jsx)(t,{children:n})}),[e,t])}function Zg({set:e}){return Jg(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}var Qg=(e=>(e=class extends v.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}},e.getDerivedStateFromError=()=>({error:!0}),e))();function $g(e){let t=typeof window<`u`?window.devicePixelRatio??2:1;return Array.isArray(e)?Math.min(Math.max(e[0],t),e[1]):e}function e_(e){return e.__r3f?.root.getState()}var t_={obj:e=>e===Object(e)&&!t_.arr(e)&&typeof e!=`function`,fun:e=>typeof e==`function`,str:e=>typeof e==`string`,num:e=>typeof e==`number`,boo:e=>typeof e==`boolean`,und:e=>e===void 0,nul:e=>e===null,arr:e=>Array.isArray(e),equ(e,t,{arrays:n=`shallow`,objects:r=`reference`,strict:i=!0}={}){if(typeof e!=typeof t||!!e!=!!t)return!1;if(t_.str(e)||t_.num(e)||t_.boo(e))return e===t;let a=t_.obj(e);if(a&&r===`reference`)return e===t;let o=t_.arr(e);if(o&&n===`reference`)return e===t;if((o||a)&&e===t)return!0;let s;for(s in e)if(!(s in t))return!1;if(a&&n===`shallow`&&r===`shallow`){for(s in i?t:e)if(!t_.equ(e[s],t[s],{strict:i,objects:`reference`}))return!1}else for(s in i?t:e)if(e[s]!==t[s])return!1;if(t_.und(s)){if(o&&e.length===0&&t.length===0||a&&Object.keys(e).length===0&&Object.keys(t).length===0)return!0;if(e!==t)return!1}return!0}};function n_(e){let t={nodes:{},materials:{},meshes:{}};return e&&e.traverse(e=>{e.name&&(t.nodes[e.name]=e),e.material&&!t.materials[e.material.name]&&(t.materials[e.material.name]=e.material),e.isMesh&&!t.meshes[e.name]&&(t.meshes[e.name]=e)}),t}function r_(e){e.type!==`Scene`&&(e.dispose==null||e.dispose());for(let t in e){let n=e[t];n?.type!==`Scene`&&(n==null||n.dispose==null||n.dispose())}}var i_=[`children`,`key`,`ref`];function a_(e){let t={};for(let n in e)i_.includes(n)||(t[n]=e[n]);return t}function o_(e,t,n,r){let i=e,a=i?.__r3f;return a||(a={root:t,type:n,parent:null,children:[],props:a_(r),object:i,eventCount:0,handlers:{},isHidden:!1},i&&(i.__r3f=a)),a}function s_(e,t){if(!t.includes(`-`)||t in e)return{root:e,key:t,target:e[t]};let n=e,r=t.split(`-`);for(let i of r){if(typeof n!=`object`||!n){if(n!==void 0){let e=r.slice(r.indexOf(i)).join(`-`);return{root:n,key:e,target:void 0}}return{root:e,key:t,target:void 0}}t=i,e=n,n=n[t]}return{root:e,key:t,target:n}}var c_=/-\d+$/;function l_(e,t){if(t_.str(t.props.attach)){if(c_.test(t.props.attach)){let n=t.props.attach.replace(c_,``),{root:r,key:i}=s_(e.object,n);Array.isArray(r[i])||(r[i]=[])}let{root:n,key:r}=s_(e.object,t.props.attach);t.previousAttach=n[r],n[r]=t.object}else t_.fun(t.props.attach)&&(t.previousAttach=t.props.attach(e.object,t.object))}function u_(e,t){if(t_.str(t.props.attach)){let{root:n,key:r}=s_(e.object,t.props.attach),i=t.previousAttach;i===void 0?delete n[r]:n[r]=i}else t.previousAttach==null||t.previousAttach(e.object,t.object);delete t.previousAttach}var d_=[...i_,`args`,`dispose`,`attach`,`object`,`onUpdate`,`dispose`],f_=new Map;function p_(e){let t=f_.get(e.constructor);try{t||(t=new e.constructor,f_.set(e.constructor,t))}catch{}return t}function m_(e,t){let n={};for(let r in t)if(!d_.includes(r)&&!t_.equ(t[r],e.props[r])){n[r]=t[r];for(let e in t)e.startsWith(`${r}-`)&&(n[e]=t[e])}for(let r in e.props){if(d_.includes(r)||t.hasOwnProperty(r))continue;let{root:i,key:a}=s_(e.object,r);if(i.constructor&&i.constructor.length===0){let e=p_(i);t_.und(e)||(n[a]=e[a])}else n[a]=0}return n}var h_=[`map`,`emissiveMap`,`sheenColorMap`,`specularColorMap`,`envMap`],g_=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function __(e,t){var n;let r=e.__r3f,i=r&&Wg(r).getState(),a=r?.eventCount;for(let n in t){let a=t[n];if(d_.includes(n))continue;if(r&&g_.test(n)){typeof a==`function`?r.handlers[n]=a:delete r.handlers[n],r.eventCount=Object.keys(r.handlers).length;continue}if(a===void 0)continue;let{root:s,key:c,target:l}=s_(e,n);if(l===void 0&&(typeof s!=`object`||!s))throw Error(`R3F: Cannot set "${n}". Ensure it is an object before setting "${c}".`);if(l instanceof mr&&a instanceof mr)l.mask=a.mask;else if(l instanceof Y&&qg(a))l.set(a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&typeof l.copy==`function`&&a!=null&&a.constructor&&l.constructor===a.constructor)l.copy(a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&Array.isArray(a))typeof l.fromArray==`function`?l.fromArray(a):l.set(...a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&typeof a==`number`)typeof l.setScalar==`function`?l.setScalar(a):l.set(a);else if(s instanceof yl&&c===`uniforms`&&t_.obj(a)){t_.obj(s.uniforms)||(s.uniforms={});let e=s.uniforms,t=a;for(let n in t){let r=t[n],i=e[n];i?Object.assign(i,r):e[n]={...r}}}else{var o;s[c]=a,i&&!i.linear&&h_.includes(c)&&(o=s[c])!=null&&o.isTexture&&s[c].format===1023&&s[c].type===1009&&(s[c].colorSpace=mt)}}if(r!=null&&r.parent&&i!=null&&i.internal&&(n=r.object)!=null&&n.isObject3D&&a!==r.eventCount){let e=r.object,t=i.internal.interaction.indexOf(e);t>-1&&i.internal.interaction.splice(t,1),r.eventCount&&e.raycast!==null&&i.internal.interaction.push(e)}return r&&r.props.attach===void 0&&(r.object.isBufferGeometry?r.props.attach=`geometry`:r.object.isMaterial&&(r.props.attach=`material`)),r&&v_(r),e}function v_(e){var t;if(!e.parent)return;e.props.onUpdate==null||e.props.onUpdate(e.object);let n=(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function y_(e,t){e.manual||(Gg(e)?(e.left=t.width/-2,e.right=t.width/2,e.top=t.height/2,e.bottom=t.height/-2):e.aspect=t.width/t.height,e.updateProjectionMatrix())}var b_=e=>e?.isObject3D;function x_(e){return(e.eventObject||e.object).uuid+`/`+e.index+e.instanceId}function S_(e,t,n,r){let i=n.get(t);i&&(n.delete(t),n.size===0&&(e.delete(r),i.target.releasePointerCapture(r)))}function C_(e,t,n){let{internal:r}=e.getState();for(let e=0;e<r.interaction.length;e++)r.interaction[e]===t&&(r.interaction[e]=n);for(let e=0;e<r.initialHits.length;e++)r.initialHits[e]===t&&(r.initialHits[e]=n);r.hovered.forEach((e,i)=>{if(e.eventObject===t||e.object===t){r.hovered.delete(i);let a={...e,eventObject:e.eventObject===t?n:e.eventObject,object:e.object===t?n:e.object};r.hovered.set(x_(a),a)}}),r.capturedMap.forEach(e=>{let r=e.get(t);r&&(e.delete(t),e.set(n,r))})}function w_(e,t){let{internal:n}=e.getState();n.interaction=n.interaction.filter(e=>e!==t),n.initialHits=n.initialHits.filter(e=>e!==t),n.hovered.forEach((e,r)=>{(e.eventObject===t||e.object===t)&&n.hovered.delete(r)}),n.capturedMap.forEach((e,r)=>{S_(n.capturedMap,t,e,r)})}function T_(e){function t(t){let{internal:n}=e.getState(),r=t.offsetX-n.initialClick[0],i=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(r*r+i*i))}function n(e){return e.filter(e=>[`Move`,`Over`,`Enter`,`Out`,`Leave`].some(t=>e.__r3f?.handlers[`onPointer`+t]))}function r(t,n){let r=e.getState(),i=new Set,a=[],o=n?n(r.internal.interaction):r.internal.interaction;for(let e=0;e<o.length;e++){let t=e_(o[e]);t&&(t.raycaster.camera=void 0)}r.previousRoot||r.events.compute==null||r.events.compute(t,r);function s(e){let n=e_(e);return!n||!n.events.enabled||n.raycaster.camera===null?[]:(n.raycaster.camera===void 0&&(n.events.compute==null||n.events.compute(t,n,n.previousRoot?.getState()),n.raycaster.camera===void 0&&(n.raycaster.camera=null)),n.raycaster.camera?n.raycaster.intersectObject(e,!0):[])}let c=o.flatMap(s).sort((e,t)=>{let n=e_(e.object),r=e_(t.object);return!n||!r?e.distance-t.distance:r.events.priority-n.events.priority||e.distance-t.distance}).filter(e=>{let t=x_(e);return i.has(t)?!1:(i.add(t),!0)});r.events.filter&&(c=r.events.filter(c,r));for(let e of c){let t=e.object;for(;t;){var l;(l=t.__r3f)!=null&&l.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}if(`pointerId`in t&&r.internal.capturedMap.has(t.pointerId))for(let e of r.internal.capturedMap.get(t.pointerId).values())i.has(x_(e.intersection))||a.push(e.intersection);return a}function i(e,t,n,r){if(e.length){let i={stopped:!1};for(let o of e){let s=e_(o.object);if(s||o.object.traverseAncestors(e=>{let t=e_(e);if(t)return s=t,!1}),s){let{raycaster:c,pointer:l,camera:u,internal:d}=s,f=new q(l.x,l.y,0).unproject(u),p=e=>d.capturedMap.get(e)?.has(o.eventObject)??!1,m=e=>{let n={intersection:o,target:t.target};d.capturedMap.has(e)?d.capturedMap.get(e).set(o.eventObject,n):d.capturedMap.set(e,new Map([[o.eventObject,n]])),t.target.setPointerCapture(e)},h=e=>{let t=d.capturedMap.get(e);t&&S_(d.capturedMap,o.eventObject,t,e)},g={};for(let e in t){let n=t[e];typeof n!=`function`&&(g[e]=n)}let _={...o,...g,pointer:l,intersections:e,stopped:i.stopped,delta:n,unprojectedPoint:f,ray:c.ray,camera:u,stopPropagation(){let n=`pointerId`in t&&d.capturedMap.get(t.pointerId);(!n||n.has(o.eventObject))&&(_.stopped=i.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find(e=>e.eventObject===o.eventObject)&&a([...e.slice(0,e.indexOf(o)),o]))},target:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},currentTarget:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},nativeEvent:t};if(r(_),i.stopped===!0)break}}}return e}function a(t){let{internal:n}=e.getState();for(let e of n.hovered.values())if(!t.length||!t.find(t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId)){let r=e.eventObject.__r3f;if(n.hovered.delete(x_(e)),r!=null&&r.eventCount){let n=r.handlers,i={...e,intersections:t};n.onPointerOut==null||n.onPointerOut(i),n.onPointerLeave==null||n.onPointerLeave(i)}}}function o(e,t){for(let n=0;n<t.length;n++){let r=t[n].__r3f;r==null||r.handlers.onPointerMissed==null||r.handlers.onPointerMissed(e)}}function s(s){switch(s){case`onPointerLeave`:case`onPointerCancel`:return()=>a([]);case`onLostPointerCapture`:return t=>{let{internal:n}=e.getState();`pointerId`in t&&n.capturedMap.has(t.pointerId)&&requestAnimationFrame(()=>{n.capturedMap.has(t.pointerId)&&(n.capturedMap.delete(t.pointerId),a([]))})}}return function(c){let{onPointerMissed:l,internal:u}=e.getState();u.lastEvent.current=c;let d=s===`onPointerMove`,f=s===`onClick`||s===`onContextMenu`||s===`onDoubleClick`,p=r(c,d?n:void 0),m=f?t(c):0;s===`onPointerDown`&&(u.initialClick=[c.offsetX,c.offsetY],u.initialHits=p.map(e=>e.eventObject)),f&&!p.length&&m<=2&&(o(c,u.interaction),l&&l(c)),d&&a(p);function h(e){let t=e.eventObject,n=t.__r3f;if(!(n!=null&&n.eventCount))return;let r=n.handlers;if(d){if(r.onPointerOver||r.onPointerEnter||r.onPointerOut||r.onPointerLeave){let t=x_(e),n=u.hovered.get(t);n?n.stopped&&e.stopPropagation():(u.hovered.set(t,e),r.onPointerOver==null||r.onPointerOver(e),r.onPointerEnter==null||r.onPointerEnter(e))}r.onPointerMove==null||r.onPointerMove(e)}else{let n=r[s];n?(!f||u.initialHits.includes(t))&&(o(c,u.interaction.filter(e=>!u.initialHits.includes(e))),n(e)):f&&u.initialHits.includes(t)&&o(c,u.interaction.filter(e=>!u.initialHits.includes(e)))}}i(p,c,m,h)}}return{handlePointer:s}}var E_=e=>!!(e!=null&&e.render),D_=v.createContext(null),O_=(e,t)=>{let n=wg((n,r)=>{let i=new q,a=new q,o=new q;function s(e=r().camera,t=a,n=r().size){let{width:s,height:c,top:l,left:u}=n,d=s/c;t.isVector3?o.copy(t):o.set(...t);let f=e.getWorldPosition(i).distanceTo(o);if(Gg(e))return{width:s/e.zoom,height:c/e.zoom,top:l,left:u,factor:1,distance:f,aspect:d};{let t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*f,r=s/c*n;return{width:r,height:n,top:l,left:u,factor:s/r,distance:f,aspect:d}}}let c,l=e=>n(t=>({performance:{...t.performance,current:e}})),u=new K;return{set:n,get:r,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(t=1)=>e(r(),t),advance:(e,n)=>t(e,n,r()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Xd,pointer:u,mouse:u,frameloop:`always`,onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{let e=r();c&&clearTimeout(c),e.performance.current!==e.performance.min&&l(e.performance.min),c=setTimeout(()=>l(r().performance.max),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:s},setEvents:e=>n(t=>({...t,events:{...t.events,...e}})),setSize:(e,t,i=0,o=0)=>{let c=r().camera,l={width:e,height:t,top:i,left:o};n(e=>({size:l,viewport:{...e.viewport,...s(c,a,l)}}))},setDpr:e=>n(t=>{let n=$g(e);return{viewport:{...t.viewport,dpr:n,initialDpr:t.viewport.initialDpr||n}}}),setFrameloop:(e=`always`)=>{let t=r().clock;t.stop(),t.elapsedTime=0,e!==`never`&&(t.start(),t.elapsedTime=0),n(()=>({frameloop:e}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:v.createRef(),active:!1,frames:0,priority:0,subscribe:(e,t,n)=>{let i=r().internal;return i.priority+=+(t>0),i.subscribers.push({ref:e,priority:t,store:n}),i.subscribers=i.subscribers.sort((e,t)=>e.priority-t.priority),()=>{let n=r().internal;n!=null&&n.subscribers&&(n.priority-=+(t>0),n.subscribers=n.subscribers.filter(t=>t.ref!==e))}}}}}),r=n.getState(),i=r.size,a=r.viewport.dpr,o=r.camera;return n.subscribe(()=>{let{camera:e,size:t,viewport:r,gl:s,set:c}=n.getState();if(t.width!==i.width||t.height!==i.height||r.dpr!==a){i=t,a=r.dpr,y_(e,t),r.dpr>0&&s.setPixelRatio(r.dpr);let n=typeof HTMLCanvasElement<`u`&&s.domElement instanceof HTMLCanvasElement;s.setSize(t.width,t.height,n)}e!==o&&(o=e,c(t=>({viewport:{...t.viewport,...t.viewport.getCurrentViewport(e)}})))}),n.subscribe(t=>e(t)),n};function k_(){let e=v.useContext(D_);if(!e)throw Error(`R3F: Hooks can only be used within the Canvas component!`);return e}function A_(e=e=>e,t){return k_()(e,t)}function j_(e,t=0){let n=k_(),r=n.getState().internal.subscribe,i=Yg(e);return Jg(()=>r(i,t,n),[t,r,n]),null}var M_=new WeakMap,N_=e=>typeof e==`function`&&e?.prototype?.constructor===e;function P_(e,t){return function(n,...r){let i;return N_(n)?(i=M_.get(n),i||(i=new n,M_.set(n,i))):i=n,e&&e(i),Promise.all(r.map(e=>new Promise((n,r)=>i.load(e,e=>{b_(e?.scene)&&Object.assign(e,n_(e.scene)),n(e)},t,t=>r(Error(`Could not load ${e}: ${t?.message}`))))))}}function F_(e,t,n,r){let i=Array.isArray(t)?t:[t],a=kg(P_(n,r),[e,...i],{equal:t_.equ});return Array.isArray(t)?a:a[0]}F_.preload=function(e,t,n){let r=Array.isArray(t)?t:[t];return Ag(P_(n),[e,...r])},F_.clear=function(e,t){return jg([e,...Array.isArray(t)?t:[t]])};var I_=1,L_=8,R_=32,z_=2,B_={name:`@react-three/fiber`,version:`9.6.1`,description:`A React renderer for Threejs`,keywords:[`react`,`renderer`,`fiber`,`three`,`threejs`],author:`Paul Henschel (https://github.com/drcmda)`,license:`MIT`,maintainers:[`Josh Ellis (https://github.com/joshuaellis)`,`Cody Bennett (https://github.com/codyjasonbennett)`,`Kris Baumgarter (https://github.com/krispya)`],bugs:{url:`https://github.com/pmndrs/react-three-fiber/issues`},homepage:`https://github.com/pmndrs/react-three-fiber#readme`,repository:{type:`git`,url:`git+https://github.com/pmndrs/react-three-fiber.git`},collective:{type:`opencollective`,url:`https://opencollective.com/react-three-fiber`},main:`dist/react-three-fiber.cjs.js`,module:`dist/react-three-fiber.esm.js`,types:`dist/react-three-fiber.cjs.d.ts`,"react-native":`native/dist/react-three-fiber-native.cjs.js`,sideEffects:!1,preconstruct:{entrypoints:[`index.tsx`,`native.tsx`]},scripts:{prebuild:`cp ../../readme.md readme.md`},devDependencies:{"@types/react-reconciler":`^0.32.3`,"react-reconciler":`^0.33.0`},dependencies:{"@babel/runtime":`^7.17.8`,"@types/webxr":`*`,"base64-js":`^1.5.1`,buffer:`^6.0.3`,"its-fine":`^2.0.0`,"react-use-measure":`^2.1.7`,scheduler:`^0.27.0`,"suspend-react":`^0.1.3`,"use-sync-external-store":`^1.4.0`,zustand:`^5.0.3`},peerDependencies:{expo:`>=43.0`,"expo-asset":`>=8.4`,"expo-file-system":`>=11.0`,"expo-gl":`>=11.0`,react:`>=19 <19.3`,"react-dom":`>=19 <19.3`,"react-native":`>=0.78`,three:`>=0.156`},peerDependenciesMeta:{"react-dom":{optional:!0},"react-native":{optional:!0},expo:{optional:!0},"expo-asset":{optional:!0},"expo-file-system":{optional:!0},"expo-gl":{optional:!0}}};function V_(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var H_={exports:{}},U_={exports:{}};U_.exports;var W_;function G_(){return W_||(W_=1,function(e){e.exports=function(e){function t(e,t,n,r){return new aa(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function a(e){if(i(e)!==e)throw Error(r(188))}function o(e){var t=e.alternate;if(!t){if(t=i(e),t===null)throw Error(r(188));return t===e?e:null}for(var n=e,o=t;;){var s=n.return;if(s===null)break;var c=s.alternate;if(c===null){if(o=s.return,o!==null){n=o;continue}break}if(s.child===c.child){for(c=s.child;c;){if(c===n)return a(s),e;if(c===o)return a(s),t;c=c.sibling}throw Error(r(188))}if(n.return!==o.return)n=s,o=c;else{for(var l=!1,u=s.child;u;){if(u===n){l=!0,n=s,o=c;break}if(u===o){l=!0,o=s,n=c;break}u=u.sibling}if(!l){for(u=c.child;u;){if(u===n){l=!0,n=c,o=s;break}if(u===o){l=!0,o=c,n=s;break}u=u.sibling}if(!l)throw Error(r(189))}}if(n.alternate!==o)throw Error(r(190))}if(n.tag!==3)throw Error(r(188));return n.stateNode.current===n?e:t}function s(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=s(e),t!==null)return t;e=e.sibling}return null}function c(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(e.tag!==4&&(t=c(e),t!==null))return t;e=e.sibling}return null}function l(e){return typeof e!=`object`||!e?null:(e=Ba&&e[Ba]||e[`@@iterator`],typeof e==`function`?e:null)}function u(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===Va?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case Oa:return`Fragment`;case Aa:return`Profiler`;case ka:return`StrictMode`;case Pa:return`Suspense`;case Fa:return`SuspenseList`;case Ra:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case Da:return`Portal`;case Ma:return e.displayName||`Context`;case ja:return(e._context.displayName||`Context`)+`.Consumer`;case Na:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case Ia:return t=e.displayName||null,t===null?u(e.type)||`Memo`:t;case La:t=e._payload,e=e._init;try{return u(e(t))}catch{}}return null}function d(e){return{current:e}}function f(e){0>lc||(e.current=cc[lc],cc[lc]=null,lc--)}function p(e,t){lc++,cc[lc]=e.current,e.current=t}function m(e){return e>>>=0,e===0?32:31-(fc(e)/pc|0)|0}function h(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function g(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=h(n))):i=h(o):i=h(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=h(n))):i=h(o)):i=h(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function _(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function y(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function b(){var e=gc;return gc<<=1,!(gc&62914560)&&(gc=4194304),e}function x(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function S(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function C(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-dc(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&w(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function w(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-dc(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function T(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-dc(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function E(e,t){var n=t&-t;return n=n&42?1:D(n),(n&(e.suspendedLanes|t))===0?n:0}function D(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function O(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function k(e){if(typeof Ec==`function`&&Dc(e),kc&&typeof kc.setStrictMode==`function`)try{kc.setStrictMode(Oc,e)}catch{}}function A(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function j(e){if(Nc===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Nc=t&&t[1]||``,Pc=-1<e.stack.indexOf(`
|
||
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
||
`+Nc+e+Pc}function M(e,t){if(!e||Fc)return``;Fc=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
||
`),l=s.split(`
|
||
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
||
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Fc=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?j(n):``}function N(e,t){switch(e.tag){case 26:case 27:case 5:return j(e.type);case 16:return j(`Lazy`);case 13:return e.child!==t&&t!==null?j(`Suspense Fallback`):j(`Suspense`);case 19:return j(`SuspenseList`);case 0:case 15:return M(e.type,!1);case 11:return M(e.type.render,!1);case 1:return M(e.type,!0);case 31:return j(`Activity`);default:return``}}function P(e){try{var t=``,n=null;do t+=N(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
||
Error generating stack: `+e.message+`
|
||
`+e.stack}}function F(e,t){if(typeof e==`object`&&e){var n=Ic.get(e);return n===void 0?(t={value:e,source:t,stack:P(t)},Ic.set(e,t),t):n}return{value:e,source:t,stack:P(t)}}function I(e,t){Lc[Rc++]=Bc,Lc[Rc++]=zc,zc=e,Bc=t}function L(e,t,n){Vc[Hc++]=Wc,Vc[Hc++]=Gc,Vc[Hc++]=Uc,Uc=e;var r=Wc;e=Gc;var i=32-dc(r)-1;r&=~(1<<i),n+=1;var a=32-dc(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Wc=1<<32-dc(t)+i|n<<i|r,Gc=a+e}else Wc=1<<a|n<<i|r,Gc=e}function ee(e){e.return!==null&&(I(e,1),L(e,1,0))}function R(e){for(;e===zc;)zc=Lc[--Rc],Lc[Rc]=null,Bc=Lc[--Rc],Lc[Rc]=null;for(;e===Uc;)Uc=Vc[--Hc],Vc[Hc]=null,Gc=Vc[--Hc],Vc[Hc]=null,Wc=Vc[--Hc],Vc[Hc]=null}function te(e,t){Vc[Hc++]=Wc,Vc[Hc++]=Gc,Vc[Hc++]=Uc,Wc=t.id,Gc=t.overflow,Uc=e}function z(e,t){p(Jc,t),p(qc,e),p(Kc,null),e=Ja(t),f(Kc),p(Kc,e)}function B(){f(Kc),f(qc),f(Jc)}function V(e){e.memoizedState!==null&&p(Yc,e);var t=Kc.current,n=Ya(t,e.type);t!==n&&(p(qc,e),p(Kc,n))}function ne(e){qc.current===e&&(f(Kc),f(qc)),Yc.current===e&&(f(Yc),oo?Eo._currentValue=To:Eo._currentValue2=To)}function re(e){throw H(F(Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),tl}function ie(e,t){if(!lo)throw Error(r(175));Cs(e.stateNode,e.type,e.memoizedProps,t,e)||re(e,!0)}function ae(e){for(Xc=e.return;Xc;)switch(Xc.tag){case 5:case 31:case 13:el=!1;return;case 27:case 3:el=!0;return;default:Xc=Xc.return}}function oe(e){if(!lo||e!==Xc)return!1;if(!Qc)return ae(e),Qc=!0,!1;var t=e.tag;if(nc?t!==3&&t!==27&&(t!==5||zs(e.type)&&!to(e.type,e.memoizedProps))&&Zc&&re(e):t!==3&&(t!==5||zs(e.type)&&!to(e.type,e.memoizedProps))&&Zc&&re(e),ae(e),t===13){if(!lo)throw Error(r(316));if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));Zc=Os(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));Zc=Ds(e)}else Zc=nc&&t===27?ps(e.type,Zc):Xc?fs(e.stateNode):null;return!0}function se(){lo&&(Zc=Xc=null,Qc=!1)}function ce(){var e=$c;return e!==null&&(zu===null?zu=e:zu.push.apply(zu,e),$c=null),e}function H(e){$c===null?$c=[e]:$c.push(e)}function le(e,t,n){oo?(p(nl,t._currentValue),t._currentValue=n):(p(nl,t._currentValue2),t._currentValue2=n)}function ue(e){var t=nl.current;oo?e._currentValue=t:e._currentValue2=t,f(nl)}function de(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function fe(e,t,n,i){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;e:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),de(o.return,n,e),i||(s=null);break e}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(r(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),de(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function pe(e,t,n,i){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(r(387));if(s=s.memoizedProps,s!==null){var c=a.type;Ac(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===Yc.current){if(s=a.alternate,s===null)throw Error(r(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Eo]:e.push(Eo))}a=a.return}e!==null&&fe(t,e,n,i),t.flags|=262144}function me(e){for(e=e.firstContext;e!==null;){var t=e.context;if(!Ac(oo?t._currentValue:t._currentValue2,e.memoizedValue))return!0;e=e.next}return!1}function he(e){rl=e,il=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ge(e){return ve(rl,e)}function _e(e,t){return rl===null&&he(e),ve(e,t)}function ve(e,t){var n=oo?t._currentValue:t._currentValue2;if(t={context:t,memoizedValue:n,next:null},il===null){if(e===null)throw Error(r(308));il=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else il=il.next=t;return n}function ye(){return{controller:new al,data:new Map,refCount:0}}function be(e){e.refCount--,e.refCount===0&&ol(sl,function(){e.controller.abort()})}function xe(){}function Se(e){e!==ul&&e.next===null&&(ul===null?ll=ul=e:ul=ul.next=e),fl=!0,dl||(dl=!0,De())}function U(e,t){if(!pl&&fl){pl=!0;do for(var n=!1,r=ll;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-dc(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Ee(r,a))}else a=Tu,a=g(r,r===Cu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==ao),!(a&3)||_(r,a)||(n=!0,Ee(r,a));r=r.next}while(n);pl=!1}}function Ce(){we()}function we(){fl=dl=!1;var e=0;ml!==0&&go()&&(e=ml);for(var t=xc(),n=null,r=ll;r!==null;){var i=r.next,a=Te(r,t);a===0?(r.next=null,n===null?ll=i:n.next=i,i===null&&(ul=n)):(n=r,(e!==0||a&3)&&(fl=!0)),r=i}Ku!==0&&Ku!==5||U(e,!1),ml!==0&&(ml=0)}function Te(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-dc(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=y(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Cu,n=Tu,n=g(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==ao),r=e.callbackNode,n===0||e===t&&(Eu===2||Eu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&vc(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||_(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&vc(r),O(n)){case 2:case 8:n=Cc;break;case 32:n=wc;break;case 268435456:n=Tc;break;default:n=wc}return r=W.bind(null,e),n=_c(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&vc(r),e.callbackPriority=2,e.callbackNode=null,2}function W(e,t){if(Ku!==0&&Ku!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Yi()&&e.callbackNode!==n)return null;var r=Tu;return r=g(e,e===Cu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==ao),r===0?null:(Ci(e,r,t),Te(e,xc()),e.callbackNode!=null&&e.callbackNode===n?W.bind(null,e):null)}function Ee(e,t){if(Yi())return null;Ci(e,t,!0)}function De(){Oo?ko(function(){Su&6?_c(Sc,Ce):we()}):_c(Sc,Ce)}function Oe(){if(ml===0){var e=_l;e===0&&(e=mc,mc<<=1,!(mc&261888)&&(mc=256)),ml=e}return ml}function ke(e,t){if(hl===null){var n=hl=[];gl=0,_l=Oe(),vl={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return gl++,t.then(Ae,Ae),t}function Ae(){if(--gl===0&&hl!==null){vl!==null&&(vl.status=`fulfilled`);var e=hl;hl=null,_l=0,vl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function je(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}function Me(){var e=bl.current;return e===null?Cu.pooledCache:e}function Ne(e,t){t===null?p(bl,bl.current):p(bl,t.pool)}function Pe(){var e=Me();return e===null?null:{parent:oo?cl._currentValue:cl._currentValue2,pool:e}}function Fe(e,t){if(Ac(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Mc.call(t,i)||!Ac(e[i],t[i]))return!1}return!0}function Ie(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Le(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(xe,xe),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Be(e),e;default:if(typeof t.status==`string`)t.then(xe,xe);else{if(e=Cu,e!==null&&100<e.shellSuspendCounter)throw Error(r(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Be(e),e}throw Tl=t,xl}}function Re(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Tl=e,xl):e}}function ze(){if(Tl===null)throw Error(r(459));var e=Tl;return Tl=null,e}function Be(e){if(e===xl||e===Cl)throw Error(r(483))}function Ve(e){var t=Dl;return Dl+=1,El===null&&(El=[]),Le(El,e,t)}function He(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ue(e,t){throw t.$$typeof===Ta?Error(r(525)):(e=Object.prototype.toString.call(t),Error(r(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function We(e){function n(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function i(t,r){if(!e)return null;for(;r!==null;)n(t,r),r=r.sibling;return null}function a(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function o(e,t){return e=sa(e,t),e.index=0,e.sibling=null,e}function s(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function c(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function u(e,t,n,r){return t===null||t.tag!==6?(t=da(n,e.mode,r),t.return=e,t):(t=o(t,n),t.return=e,t)}function d(e,t,n,r){var i=n.type;return i===Oa?p(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===La&&Re(i)===t.type)?(t=o(t,n.props),He(t,n),t.return=e,t):(t=la(n.type,n.key,n.props,null,e.mode,r),He(t,n),t.return=e,t)}function f(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=pa(n,e.mode,r),t.return=e,t):(t=o(t,n.children||[]),t.return=e,t)}function p(e,t,n,r,i){return t===null||t.tag!==7?(t=ua(n,e.mode,r,i),t.return=e,t):(t=o(t,n),t.return=e,t)}function m(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=da(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case Ea:return n=la(t.type,t.key,t.props,null,e.mode,n),He(n,t),n.return=e,n;case Da:return t=pa(t,e.mode,n),t.return=e,t;case La:return t=Re(t),m(e,t,n)}if(Ha(t)||l(t))return t=ua(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return m(e,Ve(t),n);if(t.$$typeof===Ma)return m(e,_e(e,t),n);Ue(e,t)}return null}function h(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?u(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case Ea:return n.key===i?d(e,t,n,r):null;case Da:return n.key===i?f(e,t,n,r):null;case La:return n=Re(n),h(e,t,n,r)}if(Ha(n)||l(n))return i===null?p(e,t,n,r,null):null;if(typeof n.then==`function`)return h(e,t,Ve(n),r);if(n.$$typeof===Ma)return h(e,t,_e(e,n),r);Ue(e,n)}return null}function g(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,u(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case Ea:return e=e.get(r.key===null?n:r.key)||null,d(t,e,r,i);case Da:return e=e.get(r.key===null?n:r.key)||null,f(t,e,r,i);case La:return r=Re(r),g(e,t,n,r,i)}if(Ha(r)||l(r))return e=e.get(n)||null,p(t,e,r,i,null);if(typeof r.then==`function`)return g(e,t,n,Ve(r),i);if(r.$$typeof===Ma)return g(e,t,n,_e(t,r),i);Ue(t,r)}return null}function _(t,r,o,c){for(var l=null,u=null,d=r,f=r=0,p=null;d!==null&&f<o.length;f++){d.index>f?(p=d,d=null):p=d.sibling;var _=h(t,d,o[f],c);if(_===null){d===null&&(d=p);break}e&&d&&_.alternate===null&&n(t,d),r=s(_,r,f),u===null?l=_:u.sibling=_,u=_,d=p}if(f===o.length)return i(t,d),Qc&&I(t,f),l;if(d===null){for(;f<o.length;f++)d=m(t,o[f],c),d!==null&&(r=s(d,r,f),u===null?l=d:u.sibling=d,u=d);return Qc&&I(t,f),l}for(d=a(d);f<o.length;f++)p=g(d,t,f,o[f],c),p!==null&&(e&&p.alternate!==null&&d.delete(p.key===null?f:p.key),r=s(p,r,f),u===null?l=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return n(t,e)}),Qc&&I(t,f),l}function v(t,o,c,l){if(c==null)throw Error(r(151));for(var u=null,d=null,f=o,p=o=0,_=null,v=c.next();f!==null&&!v.done;p++,v=c.next()){f.index>p?(_=f,f=null):_=f.sibling;var y=h(t,f,v.value,l);if(y===null){f===null&&(f=_);break}e&&f&&y.alternate===null&&n(t,f),o=s(y,o,p),d===null?u=y:d.sibling=y,d=y,f=_}if(v.done)return i(t,f),Qc&&I(t,p),u;if(f===null){for(;!v.done;p++,v=c.next())v=m(t,v.value,l),v!==null&&(o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return Qc&&I(t,p),u}for(f=a(f);!v.done;p++,v=c.next())v=g(f,t,p,v.value,l),v!==null&&(e&&v.alternate!==null&&f.delete(v.key===null?p:v.key),o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return n(t,e)}),Qc&&I(t,p),u}function y(e,t,a,s){if(typeof a==`object`&&a&&a.type===Oa&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case Ea:e:{for(var u=a.key;t!==null;){if(t.key===u){if(u=a.type,u===Oa){if(t.tag===7){i(e,t.sibling),s=o(t,a.props.children),s.return=e,e=s;break e}}else if(t.elementType===u||typeof u==`object`&&u&&u.$$typeof===La&&Re(u)===t.type){i(e,t.sibling),s=o(t,a.props),He(s,a),s.return=e,e=s;break e}i(e,t);break}else n(e,t);t=t.sibling}a.type===Oa?(s=ua(a.props.children,e.mode,s,a.key),s.return=e,e=s):(s=la(a.type,a.key,a.props,null,e.mode,s),He(s,a),s.return=e,e=s)}return c(e);case Da:e:{for(u=a.key;t!==null;){if(t.key===u)if(t.tag===4&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),s=o(t,a.children||[]),s.return=e,e=s;break e}else{i(e,t);break}else n(e,t);t=t.sibling}s=pa(a,e.mode,s),s.return=e,e=s}return c(e);case La:return a=Re(a),y(e,t,a,s)}if(Ha(a))return _(e,t,a,s);if(l(a)){if(u=l(a),typeof u!=`function`)throw Error(r(150));return a=u.call(a),v(e,t,a,s)}if(typeof a.then==`function`)return y(e,t,Ve(a),s);if(a.$$typeof===Ma)return y(e,t,_e(e,a),s);Ue(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,t!==null&&t.tag===6?(i(e,t.sibling),s=o(t,a),s.return=e,e=s):(i(e,t),s=da(a,e.mode,s),s.return=e,e=s),c(e)):i(e,t)}return function(e,n,r,i){try{Dl=0;var a=y(e,n,r,i);return El=null,a}catch(n){if(n===xl||n===Cl)throw n;var o=t(29,n,null,e.mode);return o.lanes=i,o.return=e,o}}}function Ge(){for(var e=jl,t=Ml=jl=0;t<e;){var n=Al[t];Al[t++]=null;var r=Al[t];Al[t++]=null;var i=Al[t];Al[t++]=null;var a=Al[t];if(Al[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Ye(n,i,a)}}function Ke(e,t,n,r){Al[jl++]=e,Al[jl++]=t,Al[jl++]=n,Al[jl++]=r,Ml|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function qe(e,t,n,r){return Ke(e,t,n,r),Xe(e)}function Je(e,t){return Ke(e,null,null,t),Xe(e)}function Ye(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-dc(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Xe(e){if(50<$u)throw $u=0,ed=null,Error(r(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}function Ze(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Qe(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function $e(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function et(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Su&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Xe(e),Ye(e,null,n),t}return Ke(e,r,t,n),Xe(e)}function tt(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,T(e,n)}}function nt(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function rt(){if(Pl){var e=vl;if(e!==null)throw e}}function it(e,t,n,r){Pl=!1;var i=e.updateQueue;Nl=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Tu&f)===f:(r&f)===f){f!==0&&f===_l&&(Pl=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break e}d=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break e;d=wa({},d,f);break e;case 2:Nl=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(!0);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Nu|=o,e.lanes=o,e.memoizedState=d}}function at(e,t){if(typeof e!=`function`)throw Error(r(191,e));e.call(t)}function ot(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)at(n[e],t)}function st(e,t){e=ju,p(Il,e),p(Fl,t),ju=e|t.baseLanes}function ct(){p(Il,ju),p(Fl,Fl.current)}function lt(){ju=Il.current,f(Fl),f(Il)}function ut(e){var t=e.alternate;p(zl,zl.current&1),p(Ll,e),Rl===null&&(t===null||Fl.current!==null||t.memoizedState!==null)&&(Rl=e)}function dt(e){p(zl,zl.current),p(Ll,e),Rl===null&&(Rl=e)}function ft(e){e.tag===22?(p(zl,zl.current),p(Ll,e),Rl===null&&(Rl=e)):pt()}function pt(){p(zl,zl.current),p(Ll,Ll.current)}function mt(e){f(Ll),Rl===e&&(Rl=null),f(zl)}function ht(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||os(n)||ss(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function gt(){throw Error(r(321))}function _t(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ac(e[n],t[n]))return!1;return!0}function vt(e,t,n,r,i,a){return Bl=a,Vl=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ua.H=e===null||e.memoizedState===null?Ql:$l,Kl=!1,a=n(r,i),Kl=!1,Gl&&(a=bt(t,n,r,i)),yt(e),a}function yt(e){Ua.H=Zl;var t=Hl!==null&&Hl.next!==null;if(Bl=0,Ul=Hl=Vl=null,Wl=!1,Jl=0,Yl=null,t)throw Error(r(300));e===null||ru||(e=e.dependencies,e!==null&&me(e)&&(ru=!0))}function bt(e,t,n,i){Vl=e;var a=0;do{if(Gl&&(Yl=null),Jl=0,Gl=!1,25<=a)throw Error(r(301));if(a+=1,Ul=Hl=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}Ua.H=eu,o=t(n,i)}while(Gl);return o}function xt(){var e=Ua.H,t=e.useState()[0];return t=typeof t.then==`function`?Ot(t):t,e=e.useState()[0],(Hl===null?null:Hl.memoizedState)!==e&&(Vl.flags|=1024),t}function St(){var e=ql!==0;return ql=0,e}function Ct(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function wt(e){if(Wl){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Wl=!1}Bl=0,Ul=Hl=Vl=null,Gl=!1,Jl=ql=0,Yl=null}function Tt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ul===null?Vl.memoizedState=Ul=e:Ul=Ul.next=e,Ul}function Et(){if(Hl===null){var e=Vl.alternate;e=e===null?null:e.memoizedState}else e=Hl.next;var t=Ul===null?Vl.memoizedState:Ul.next;if(t!==null)Ul=t,Hl=e;else{if(e===null)throw Vl.alternate===null?Error(r(467)):Error(r(310));Hl=e,e={memoizedState:Hl.memoizedState,baseState:Hl.baseState,baseQueue:Hl.baseQueue,queue:Hl.queue,next:null},Ul===null?Vl.memoizedState=Ul=e:Ul=Ul.next=e}return Ul}function Dt(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ot(e){var t=Jl;return Jl+=1,Yl===null&&(Yl=[]),e=Le(Yl,e,t),t=Vl,(Ul===null?t.memoizedState:Ul.next)===null&&(t=t.alternate,Ua.H=t===null||t.memoizedState===null?Ql:$l),e}function kt(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Ot(e);if(e.$$typeof===Ma)return ge(e)}throw Error(r(438,String(e)))}function At(e){var t=null,n=Vl.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Vl.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Dt(),Vl.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=za;return t.index++,n}function jt(e,t){return typeof t==`function`?t(e):t}function Mt(e){return Nt(Et(),Hl,e)}function Nt(e,t,n){var i=e.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=n;var a=e.baseQueue,o=i.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,i.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Bl&f)===f:(Tu&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===_l&&(d=!0);else if((Bl&p)===p){u=u.next,p===_l&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Vl.lanes|=p,Nu|=p;f=u.action,Kl&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Vl.lanes|=f,Nu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Ac(o,e.memoizedState)&&(ru=!0,d&&(n=vl,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,i.lastRenderedState=o}return a===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Pt(e){var t=Et(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Ac(o,t.memoizedState)||(ru=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,i]}function Ft(e,t,n){var i=Vl,a=Et(),o=Qc;if(o){if(n===void 0)throw Error(r(407));n=n()}else n=t();var s=!Ac((Hl||a).memoizedState,n);if(s&&(a.memoizedState=n,ru=!0),a=a.queue,on(Rt.bind(null,i,a,e),[e]),a.getSnapshot!==t||s||Ul!==null&&Ul.memoizedState.tag&1){if(i.flags|=2048,en(9,{destroy:void 0},Lt.bind(null,i,a,n,t),null),Cu===null)throw Error(r(349));o||Bl&127||It(i,t,n)}return n}function It(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Vl.updateQueue,t===null?(t=Dt(),Vl.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Lt(e,t,n,r){t.value=n,t.getSnapshot=r,zt(t)&&Bt(e)}function Rt(e,t,n){return n(function(){zt(t)&&Bt(e)})}function zt(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ac(e,n)}catch{return!0}}function Bt(e){var t=Je(e,2);t!==null&&Si(t,e,2)}function Vt(e){var t=Tt();if(typeof e==`function`){var n=e;if(e=n(),Kl){k(!0);try{n()}finally{k(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:jt,lastRenderedState:e},t}function Ht(e,t,n,r){return e.baseState=n,Nt(e,Hl,typeof r==`function`?r:jt)}function Ut(e,t,n,i,a){if(On(e))throw Error(r(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};Ua.T===null?o.isTransition=!1:n(!0),i(o),n=t.pending,n===null?(o.next=t.pending=o,Wt(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Wt(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=Ua.T,o={};Ua.T=o;try{var s=n(i,r),c=Ua.S;c!==null&&c(o,s),Gt(e,t,s)}catch(n){qt(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),Ua.T=a}}else try{a=n(i,r),Gt(e,t,a)}catch(n){qt(e,t,n)}}function Gt(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Kt(e,t,n)},function(n){return qt(e,t,n)}):Kt(e,t,n)}function Kt(e,t,n){t.status=`fulfilled`,t.value=n,Jt(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Wt(e,n)))}function qt(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Jt(t),t=t.next;while(t!==r)}e.action=null}function Jt(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Yt(e,t){return t}function Xt(e,t){if(Qc){var n=Cu.formState;if(n!==null){e:{var r=Vl;if(Qc){if(Zc){var i=us(Zc,el);if(i){Zc=fs(i),r=ds(i);break e}}re(r)}r=!1}r&&(t=n[0])}}n=Tt(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yt,lastRenderedState:t},n.queue=r,n=Tn.bind(null,Vl,r),r.dispatch=n,r=Vt(!1);var a=Dn.bind(null,Vl,!1,r.queue);return r=Tt(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Ut.bind(null,Vl,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Zt(e){return Qt(Et(),Hl,e)}function Qt(e,t,n){if(t=Nt(e,t,Yt)[0],e=Mt(jt)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Ot(t)}catch(e){throw e===xl?Cl:e}else r=t;t=Et();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Vl.flags|=2048,en(9,{destroy:void 0},G.bind(null,i,n),null)),[r,a,e]}function G(e,t){e.action=t}function $t(e){var t=Et(),n=Hl;if(n!==null)return Qt(t,n,e);Et(),t=t.memoizedState,n=Et();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function en(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Vl.updateQueue,t===null&&(t=Dt(),Vl.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function tn(){return Et().memoizedState}function nn(e,t,n,r){var i=Tt();Vl.flags|=e,i.memoizedState=en(1|t,{destroy:void 0},n,r===void 0?null:r)}function rn(e,t,n,r){var i=Et();r=r===void 0?null:r;var a=i.memoizedState.inst;Hl!==null&&r!==null&&_t(r,Hl.memoizedState.deps)?i.memoizedState=en(t,a,n,r):(Vl.flags|=e,i.memoizedState=en(1|t,a,n,r))}function an(e,t){nn(8390656,8,e,t)}function on(e,t){rn(2048,8,e,t)}function sn(e){Vl.flags|=4;var t=Vl.updateQueue;if(t===null)t=Dt(),Vl.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function cn(e){var t=Et().memoizedState;return sn({ref:t,nextImpl:e}),function(){if(Su&2)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function ln(e,t){return rn(4,2,e,t)}function un(e,t){return rn(4,4,e,t)}function dn(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function fn(e,t,n){n=n==null?null:n.concat([e]),rn(4,4,dn.bind(null,t,e),n)}function pn(){}function mn(e,t){var n=Et();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&_t(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function hn(e,t){var n=Et();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&_t(t,r[1]))return r[0];if(r=e(),Kl){k(!0);try{e()}finally{k(!1)}}return n.memoizedState=[r,t],r}function gn(e,t,n){return n===void 0||Bl&1073741824&&!(Tu&261930)?e.memoizedState=t:(e.memoizedState=n,e=xi(),Vl.lanes|=e,Nu|=e,n)}function _n(e,t,n,r){return Ac(n,t)?n:Fl.current===null?!(Bl&42)||Bl&1073741824&&!(Tu&261930)?(ru=!0,e.memoizedState=n):(e=xi(),Vl.lanes|=e,Nu|=e,t):(e=gn(e,n,r),Ac(e,t)||(ru=!0),e)}function vn(e,t,n,r,i){var a=mo();po(a!==0&&8>a?a:8);var o=Ua.T,s={};Ua.T=s,Dn(e,!1,t,n);try{var c=i(),l=Ua.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?En(e,t,je(c,r),bi(e)):En(e,t,r,bi(e))}catch(n){En(e,t,{then:function(){},status:`rejected`,reason:n},bi())}finally{po(a),o!==null&&s.types!==null&&(o.types=s.types),Ua.T=o}}function yn(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:To,baseState:To,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jt,lastRenderedState:To},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jt,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function bn(){return ge(Eo)}function xn(){return Et().memoizedState}function Sn(){return Et().memoizedState}function Cn(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=bi();e=$e(n);var r=et(t,e,n);r!==null&&(Si(r,t,n),tt(r,t,n)),t={cache:ye()},e.payload=t;return}t=t.return}}function wn(e,t,n){var r=bi();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},On(e)?kn(t,n):(n=qe(e,t,n,r),n!==null&&(Si(n,e,r),An(n,t,r)))}function Tn(e,t,n){En(e,t,n,bi())}function En(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(On(e))kn(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Ac(s,o))return Ke(e,t,i,0),Cu===null&&Ge(),!1}catch{}if(n=qe(e,t,i,r),n!==null)return Si(n,e,r),An(n,t,r),!0}return!1}function Dn(e,t,n,i){if(i={lane:2,revertLane:Oe(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},On(e)){if(t)throw Error(r(479))}else t=qe(e,n,i,2),t!==null&&Si(t,e,2)}function On(e){var t=e.alternate;return e===Vl||t!==null&&t===Vl}function kn(e,t){Gl=Wl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function An(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,T(e,n)}}function jn(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:wa({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}function K(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Fe(n,r)||!Fe(i,a):!0}function Mn(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&tu.enqueueReplaceState(t,t.state,null)}function q(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=wa({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Nn(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Pn(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Fn(e,t,n){return n=$e(n),n.tag=3,n.payload={element:null},n.callback=function(){Nn(e,t)},n}function In(e){return e=$e(e),e.tag=3,e}function Ln(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Pn(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Pn(t,n,r),typeof i!=`function`&&(Gu===null?Gu=new Set([this]):Gu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Rn(e,t,n,i,a){if(n.flags|=32768,typeof i==`object`&&i&&typeof i.then==`function`){if(t=n.alternate,t!==null&&pe(t,n,a,!0),n=Ll.current,n!==null){switch(n.tag){case 31:case 13:return Rl===null?Pi():n.alternate===null&&Mu===0&&(Mu=3),n.flags&=-257,n.flags|=65536,n.lanes=a,i===wl?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([i]):t.add(i),$i(e,i,a)),!1;case 22:return n.flags|=65536,i===wl?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([i]):n.add(i)),$i(e,i,a)),!1}throw Error(r(435,n.tag))}return $i(e,i,a),Pi(),!1}if(Qc)return t=Ll.current,t===null?(i!==tl&&(t=Error(r(423),{cause:i}),H(F(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,i=F(i,n),a=Fn(e.stateNode,i,a),nt(e,a),Mu!==4&&(Mu=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,i!==tl&&(e=Error(r(422),{cause:i}),H(F(e,n)))),!1;var o=Error(r(520),{cause:i});if(o=F(o,n),Ru===null?Ru=[o]:Ru.push(o),Mu!==4&&(Mu=2),t===null)return!0;i=F(i,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Fn(n.stateNode,i,e),nt(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(Gu===null||!Gu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=In(a),Ln(a,e,n,i),nt(n,a),!1}n=n.return}while(n!==null);return!1}function zn(e,t,n,r){t.child=e===null?kl(t,null,n,r):Ol(t,e.child,n,r)}function Bn(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return he(t),r=vt(e,t,n,o,a,i),s=St(),e!==null&&!ru?(Ct(e,t,i),cr(e,t,i)):(Qc&&s&&ee(t),t.flags|=1,zn(e,t,r,i),t.child)}function Vn(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!oa(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Hn(e,t,a,r,i)):(e=la(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!lr(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Fe:n,n(o,r)&&e.ref===t.ref)return cr(e,t,i)}return t.flags|=1,e=sa(a,r),e.ref=t.ref,e.return=t,t.child=e}function Hn(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Fe(a,r)&&e.ref===t.ref)if(ru=!1,t.pendingProps=r=a,lr(e,i))e.flags&131072&&(ru=!0);else return t.lanes=e.lanes,cr(e,t,i)}return Xn(e,t,n,r,i)}function Un(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Gn(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ne(t,a===null?null:a.cachePool),a===null?ct():st(t,a),ft(t);else return r=t.lanes=536870912,Gn(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ne(t,null),ct(),pt()):(Ne(t,a.cachePool),st(t,a),pt(),t.memoizedState=null);return zn(e,t,i,n),t.child}function Wn(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Gn(e,t,n,r,i){var a=Me();return a=a===null?null:{parent:oo?cl._currentValue:cl._currentValue2,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ne(t,null),ct(),ft(t),e!==null&&pe(e,t,r,!0),t.childLanes=i,null}function Kn(e,t){return t=J({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function qn(e,t,n){return Ol(t,e.child,null,n),e=Kn(t,t.pendingProps),e.flags|=2,mt(t),t.memoizedState=null,e}function Jn(e,t,n){var i=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Qc){if(i.mode===`hidden`)return e=Kn(t,i),t.lanes=536870912,Wn(null,e);if(dt(t),(e=Zc)?(e=xs(e,el),e!==null&&(t.memoizedState={dehydrated:e,treeContext:Uc===null?null:{id:Wc,overflow:Gc},retryLane:536870912,hydrationErrors:null},n=fa(e),n.return=t,t.child=n,Xc=t,Zc=null)):e=null,e===null)throw re(t);return t.lanes=536870912,null}return Kn(t,i)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(dt(t),a)if(t.flags&256)t.flags&=-257,t=qn(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(ru||pe(e,t,n,!1),a=(n&e.childLanes)!==0,ru||a){if(i=Cu,i!==null&&(s=E(i,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Je(e,s),Si(i,e,s),nu;Pi(),t=qn(e,t,n)}else e=o.treeContext,lo&&(Zc=gs(s),Xc=t,Qc=!0,$c=null,el=!1,e!==null&&te(t,e)),t=Kn(t,i),t.flags|=4096;return t}return e=sa(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Yn(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Xn(e,t,n,r,i){return he(t),n=vt(e,t,n,r,void 0,i),r=St(),e!==null&&!ru?(Ct(e,t,i),cr(e,t,i)):(Qc&&r&&ee(t),t.flags|=1,zn(e,t,n,i),t.child)}function Zn(e,t,n,r,i,a){return he(t),t.updateQueue=null,n=bt(t,r,n,i),yt(e),r=St(),e!==null&&!ru?(Ct(e,t,a),cr(e,t,a)):(Qc&&r&&ee(t),t.flags|=1,zn(e,t,n,a),t.child)}function Qn(e,t,n,r,i){if(he(t),t.stateNode===null){var a=uc,o=n.contextType;typeof o==`object`&&o&&(a=ge(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=tu,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ze(t),o=n.contextType,a.context=typeof o==`object`&&o?ge(o):uc,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(jn(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&tu.enqueueReplaceState(a,a.state,null),it(t,r,a,i),rt(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=q(n,s);a.props=c;var l=a.context,u=n.contextType;o=uc,typeof u==`object`&&u&&(o=ge(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Mn(t,a,r,o),Nl=!1;var f=t.memoizedState;a.state=f,it(t,r,a,i),rt(),l=t.memoizedState,s||f!==l||Nl?(typeof d==`function`&&(jn(t,n,d,r),l=t.memoizedState),(c=Nl||K(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Qe(e,t),o=t.memoizedProps,u=q(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=uc,typeof l==`object`&&l&&(c=ge(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Mn(t,a,r,c),Nl=!1,f=t.memoizedState,a.state=f,it(t,r,a,i),rt();var p=t.memoizedState;o!==d||f!==p||Nl||e!==null&&e.dependencies!==null&&me(e.dependencies)?(typeof s==`function`&&(jn(t,n,s,r),p=t.memoizedState),(u=Nl||K(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&me(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Yn(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ol(t,e.child,null,i),t.child=Ol(t,null,n,i)):zn(e,t,n,i),t.memoizedState=a.state,e=t.child):e=cr(e,t,i),e}function $n(e,t,n,r){return se(),t.flags|=256,zn(e,t,n,r),t.child}function er(e){return{baseLanes:e,cachePool:Pe()}}function tr(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Iu),e}function nr(e,t,n){var i=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(zl.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Qc){if(a?ut(t):pt(),(e=Zc)?(e=Ss(e,el),e!==null&&(t.memoizedState={dehydrated:e,treeContext:Uc===null?null:{id:Wc,overflow:Gc},retryLane:536870912,hydrationErrors:null},n=fa(e),n.return=t,t.child=n,Xc=t,Zc=null)):e=null,e===null)throw re(t);return ss(e)?t.lanes=32:t.lanes=536870912,null}var c=i.children;return i=i.fallback,a?(pt(),a=t.mode,c=J({mode:`hidden`,children:c},a),i=ua(i,a,n,null),c.return=t,i.return=t,c.sibling=i,t.child=c,i=t.child,i.memoizedState=er(n),i.childLanes=tr(e,s,n),t.memoizedState=iu,Wn(null,i)):(ut(t),rr(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(ut(t),t.flags&=-257,t=ir(e,t,n)):t.memoizedState===null?(pt(),c=i.fallback,a=t.mode,i=J({mode:`visible`,children:i.children},a),c=ua(c,a,n,null),c.flags|=2,i.return=t,c.return=t,i.sibling=c,t.child=i,Ol(t,e.child,null,n),i=t.child,i.memoizedState=er(n),i.childLanes=tr(e,s,n),t.memoizedState=iu,t=Wn(null,i)):(pt(),t.child=e.child,t.flags|=128,t=null);else if(ut(t),ss(c))s=cs(c).digest,i=Error(r(419)),i.stack=``,i.digest=s,H({value:i,source:null,stack:null}),t=ir(e,t,n);else if(ru||pe(e,t,n,!1),s=(n&e.childLanes)!==0,ru||s){if(s=Cu,s!==null&&(i=E(s,n),i!==0&&i!==l.retryLane))throw l.retryLane=i,Je(e,i),Si(s,e,i),nu;os(c)||Pi(),t=ir(e,t,n)}else os(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,lo&&(Zc=_s(c),Xc=t,Qc=!0,$c=null,el=!1,e!==null&&te(t,e)),t=rr(t,i.children),t.flags|=4096);return t}return a?(pt(),c=i.fallback,a=t.mode,l=e.child,o=l.sibling,i=sa(l,{mode:`hidden`,children:i.children}),i.subtreeFlags=l.subtreeFlags&65011712,o===null?(c=ua(c,a,n,null),c.flags|=2):c=sa(o,c),c.return=t,i.return=t,i.sibling=c,t.child=i,Wn(null,i),i=t.child,c=e.child.memoizedState,c===null?c=er(n):(a=c.cachePool,a===null?a=Pe():(l=oo?cl._currentValue:cl._currentValue2,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),i.memoizedState=c,i.childLanes=tr(e,s,n),t.memoizedState=iu,Wn(e.child,i)):(ut(t),n=e.child,e=n.sibling,n=sa(n,{mode:`visible`,children:i.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function rr(e,t){return t=J({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function J(e,n){return e=t(22,e,null,n),e.lanes=0,e}function ir(e,t,n){return Ol(t,e.child,null,n),e=rr(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ar(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),de(e.return,t,n)}function or(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function sr(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=zl.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,p(zl,o),zn(e,t,r,n),r=Qc?Bc:0,!s&&e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ar(e,n,t);else if(e.tag===19)ar(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&ht(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),or(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ht(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}or(t,!0,n,null,a,r);break;case`together`:or(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function cr(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Nu|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(pe(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=sa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=sa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function lr(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&me(e))):!0}function ur(e,t,n){switch(t.tag){case 3:z(t,t.stateNode.containerInfo),le(t,cl,e.memoizedState.cache),se();break;case 27:case 5:V(t);break;case 4:z(t,t.stateNode.containerInfo);break;case 10:le(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,dt(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(ut(t),e=cr(e,t,n),e===null?null:e.sibling):nr(e,t,n):(ut(t),t.flags|=128,null);ut(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(pe(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return sr(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),p(zl,zl.current),r)break;return null;case 22:return t.lanes=0,Un(e,t,n,t.pendingProps);case 24:le(t,cl,e.memoizedState.cache)}return cr(e,t,n)}function dr(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)ru=!0;else{if(!lr(e,n)&&!(t.flags&128))return ru=!1,ur(e,t,n);ru=(e.flags&131072)!=0}else ru=!1,Qc&&t.flags&1048576&&L(t,Bc,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=Re(t.elementType),t.type=e,typeof e==`function`)oa(e)?(i=q(e,i),t.tag=1,t=Qn(null,t,e,i,n)):(t.tag=0,t=Xn(null,t,e,i,n));else{if(e!=null){var a=e.$$typeof;if(a===Na){t.tag=11,t=Bn(null,t,e,i,n);break e}else if(a===Ia){t.tag=14,t=Vn(null,t,e,i,n);break e}}throw t=u(e)||e,Error(r(306,t,``))}}return t;case 0:return Xn(e,t,t.type,t.pendingProps,n);case 1:return i=t.type,a=q(i,t.pendingProps),Qn(e,t,i,a,n);case 3:e:{if(z(t,t.stateNode.containerInfo),e===null)throw Error(r(387));var o=t.pendingProps;a=t.memoizedState,i=a.element,Qe(e,t),it(t,o,null,n);var s=t.memoizedState;if(o=s.cache,le(t,cl,o),o!==a.cache&&fe(t,[cl],n,!0),rt(),o=s.element,lo&&a.isDehydrated)if(a={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=$n(e,t,o,n);break e}else if(o!==i){i=F(Error(r(424)),t),H(i),t=$n(e,t,o,n);break e}else for(lo&&(Zc=hs(t.stateNode.containerInfo),Xc=t,Qc=!0,$c=null,el=!0),n=kl(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(se(),o===i){t=cr(e,t,n);break e}zn(e,t,o,n)}t=t.child}return t;case 26:if(Hs)return Yn(e,t),e===null?(n=Gs(t.type,null,t.pendingProps,null))?t.memoizedState=n:Qc||(t.stateNode=Zs(t.type,t.pendingProps,Jc.current,t)):t.memoizedState=Gs(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:if(nc)return V(t),e===null&&nc&&Qc&&(i=t.stateNode=rc(t.type,t.pendingProps,Jc.current,Kc.current,!1),Xc=t,el=!0,Zc=vs(t.type,i,Zc)),zn(e,t,t.pendingProps.children,n),Yn(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Qc&&(Bs(t.type,t.pendingProps,Kc.current),(a=i=Zc)&&(i=ys(i,t.type,t.pendingProps,el),i===null?a=!1:(t.stateNode=i,Xc=t,Zc=ms(i),el=!1,a=!0)),a||re(t)),V(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,i=o.children,to(a,o)?i=null:s!==null&&to(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=vt(e,t,xt,null,null,n),oo?Eo._currentValue=a:Eo._currentValue2=a),Yn(e,t),zn(e,t,i,n),t.child;case 6:return e===null&&Qc&&(Vs(t.pendingProps,Kc.current),(e=n=Zc)&&(n=bs(n,t.pendingProps,el),n===null?e=!1:(t.stateNode=n,Xc=t,Zc=null,e=!0)),e||re(t)),null;case 13:return nr(e,t,n);case 4:return z(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ol(t,null,i,n):zn(e,t,i,n),t.child;case 11:return Bn(e,t,t.type,t.pendingProps,n);case 7:return zn(e,t,t.pendingProps,n),t.child;case 8:return zn(e,t,t.pendingProps.children,n),t.child;case 12:return zn(e,t,t.pendingProps.children,n),t.child;case 10:return i=t.pendingProps,le(t,t.type,i.value),zn(e,t,i.children,n),t.child;case 9:return a=t.type._context,i=t.pendingProps.children,he(t),a=ge(a),i=i(a),t.flags|=1,zn(e,t,i,n),t.child;case 14:return Vn(e,t,t.type,t.pendingProps,n);case 15:return Hn(e,t,t.type,t.pendingProps,n);case 19:return sr(e,t,n);case 31:return Jn(e,t,n);case 22:return Un(e,t,n,t.pendingProps);case 24:return he(t),i=ge(cl),e===null?(a=Me(),a===null&&(a=Cu,o=ye(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:i,cache:a},Ze(t),le(t,cl,a)):((e.lanes&n)!==0&&(Qe(e,t),it(t,null,null,n),rt()),a=e.memoizedState,o=t.memoizedState,a.parent===i?(i=o.cache,le(t,cl,i),i!==a.cache&&fe(t,[cl],n,!0)):(a={parent:i,cache:i},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),le(t,cl,i))),zn(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function fr(e){e.flags|=4}function pr(e){co&&(e.flags|=8)}function mr(e,t){if(e!==null&&e.child===t.child)return!1;if(t.flags&16)return!0;for(e=t.child;e!==null;){if(e.flags&8218||e.subtreeFlags&8218)return!0;e=e.sibling}return!1}function hr(e,t,n,r){if(so)for(n=t.child;n!==null;){if(n.tag===5||n.tag===6)$a(e,n.stateNode);else if(!(n.tag===4||nc&&n.tag===27)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}else if(co)for(var i=t.child;i!==null;){if(i.tag===5){var a=i.stateNode;n&&r&&(a=is(a,i.type,i.memoizedProps)),$a(e,a)}else if(i.tag===6)a=i.stateNode,n&&r&&(a=as(a,i.memoizedProps)),$a(e,a);else if(i.tag!==4){if(i.tag===22&&i.memoizedState!==null)a=i.child,a!==null&&(a.return=i),hr(e,i,!0,!0);else if(i.child!==null){i.child.return=i,i=i.child;continue}}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}}function gr(e,t,n,r){var i=!1;if(co)for(var a=t.child;a!==null;){if(a.tag===5){var o=a.stateNode;n&&r&&(o=is(o,a.type,a.memoizedProps)),ts(e,o)}else if(a.tag===6)o=a.stateNode,n&&r&&(o=as(o,a.memoizedProps)),ts(e,o);else if(a.tag!==4){if(a.tag===22&&a.memoizedState!==null)i=a.child,i!==null&&(i.return=a),gr(e,a,!0,!0),i=!0;else if(a.child!==null){a.child.return=a,a=a.child;continue}}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return i;a=a.return}a.sibling.return=a.return,a=a.sibling}return i}function _r(e,t){if(co&&mr(e,t)){e=t.stateNode;var n=e.containerInfo,r=es();gr(r,t,!1,!1),e.pendingChildren=r,fr(t),ns(n,r)}}function vr(e,t,n,r){if(so)e.memoizedProps!==r&&fr(t);else if(co){var i=e.stateNode,a=e.memoizedProps;if((e=mr(e,t))||a!==r){var o=Kc.current;a=$o(i,n,a,r,!e,null),a===i?t.stateNode=i:(pr(t),eo(a,n,r,o)&&fr(t),t.stateNode=a,e&&hr(a,t,!1,!1))}else t.stateNode=i}}function yr(e,t,n,r,i){if(e.mode&32&&(n===null?vo(t,r):yo(t,n,r))){if(e.flags|=16777216,(i&335544128)===i||bo(t,r))if(xo(e.stateNode,t,r))e.flags|=8192;else if(ji())e.flags|=8192;else throw Tl=wl,Sl}else e.flags&=-16777217}function br(e,t){if($s(t)){if(e.flags|=16777216,!ec(t))if(ji())e.flags|=8192;else throw Tl=wl,Sl}else e.flags&=-16777217}function xr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:b(),e.lanes|=t,Lu|=t)}function Sr(e,t){if(!Qc)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Cr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function wr(e,t,n){var i=t.pendingProps;switch(R(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Cr(t),null;case 1:return Cr(t),null;case 3:return n=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),ue(cl),B(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(oe(t)?fr(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ce())),_r(e,t),Cr(t),null;case 26:if(Hs){var a=t.type,o=t.memoizedState;return e===null?(fr(t),o===null?(Cr(t),yr(t,a,null,i,n)):(Cr(t),br(t,o))):o?o===e.memoizedState?(Cr(t),t.flags&=-16777217):(fr(t),Cr(t),br(t,o)):(o=e.memoizedProps,so?o!==i&&fr(t):vr(e,t,a,i),Cr(t),yr(t,a,o,i,n)),null}case 27:if(nc){if(ne(t),n=Jc.current,a=t.type,e!==null&&t.stateNode!=null)so?e.memoizedProps!==i&&fr(t):vr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Cr(t),null}e=Kc.current,oe(t)?ie(t,e):(e=rc(a,i,n,e,!0),t.stateNode=e,fr(t))}return Cr(t),null}case 5:if(ne(t),a=t.type,e!==null&&t.stateNode!=null)vr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Cr(t),null}if(o=Kc.current,oe(t))ie(t,o),Ns(t.stateNode,a,i,o)&&(t.flags|=64);else{var s=Qa(a,i,Jc.current,o,t);pr(t),hr(s,t,!1,!1),t.stateNode=s,eo(s,a,i,o)&&fr(t)}}return Cr(t),yr(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)n=e.memoizedProps,so?n!==i&&fr(t):co&&(n===i?t.stateNode=e.stateNode:(e=Jc.current,n=Kc.current,pr(t),t.stateNode=no(i,e,n,t)));else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(e=Jc.current,n=Kc.current,oe(t)){if(!lo)throw Error(r(176));if(e=t.stateNode,n=t.memoizedProps,i=null,a=Xc,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}ws(e,n,t,i)||re(t,!0)}else pr(t),t.stateNode=no(i,e,n,t)}return Cr(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=oe(t),n!==null){if(e===null){if(!i)throw Error(r(318));if(!lo)throw Error(r(556));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(557));Ts(e,t)}else se(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Cr(t),e=!1}else n=ce(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(mt(t),t):(mt(t),null);if(t.flags&128)throw Error(r(558))}return Cr(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=oe(t),i!==null&&i.dehydrated!==null){if(e===null){if(!a)throw Error(r(318));if(!lo)throw Error(r(344));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(r(317));Es(a,t)}else se(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Cr(t),a=!1}else a=ce(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(mt(t),t):(mt(t),null)}return mt(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==a&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),xr(t,t.updateQueue),Cr(t),null);case 4:return B(),_r(e,t),e===null&&fo(t.stateNode.containerInfo),Cr(t),null;case 10:return ue(t.type),Cr(t),null;case 19:if(f(zl),i=t.memoizedState,i===null)return Cr(t),null;if(a=(t.flags&128)!=0,o=i.rendering,o===null)if(a)Sr(i,!1);else{if(Mu!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=ht(e),o!==null){for(t.flags|=128,Sr(i,!1),e=o.updateQueue,t.updateQueue=e,xr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ca(n,e),n=n.sibling;return p(zl,zl.current&1|2),Qc&&I(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&xc()>Uu&&(t.flags|=128,a=!0,Sr(i,!1),t.lanes=4194304)}else{if(!a)if(e=ht(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,xr(t,e),Sr(i,!0),i.tail===null&&i.tailMode===`hidden`&&!o.alternate&&!Qc)return Cr(t),null}else 2*xc()-i.renderingStartTime>Uu&&n!==536870912&&(t.flags|=128,a=!0,Sr(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e===null?t.child=o:e.sibling=o,i.last=o)}return i.tail===null?(Cr(t),null):(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=xc(),e.sibling=null,n=zl.current,p(zl,a?n&1|2:n&1),Qc&&I(t,i.treeForkCount),e);case 22:case 23:return mt(t),lt(),i=t.memoizedState!==null,e===null?i&&(t.flags|=8192):e.memoizedState!==null!==i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(Cr(t),t.subtreeFlags&6&&(t.flags|=8192)):Cr(t),n=t.updateQueue,n!==null&&xr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&f(bl),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ue(cl),Cr(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Tr(e,t){switch(R(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ue(cl),B(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ne(t),null;case 31:if(t.memoizedState!==null){if(mt(t),t.alternate===null)throw Error(r(340));se()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(mt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));se()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return f(zl),null;case 4:return B(),null;case 10:return ue(t.type),null;case 22:case 23:return mt(t),lt(),e!==null&&f(bl),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ue(cl),null;case 25:return null;default:return null}}function Er(e,t){switch(R(t),t.tag){case 3:ue(cl),B();break;case 26:case 27:case 5:ne(t);break;case 4:B();break;case 31:t.memoizedState!==null&&mt(t);break;case 13:mt(t);break;case 19:f(zl);break;case 10:ue(t.type);break;case 22:case 23:mt(t),lt(),e!==null&&f(bl);break;case 24:ue(cl)}}function Dr(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Qi(t,t.return,e)}}function Or(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Qi(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Qi(t,t.return,e)}}function kr(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ot(t,n)}catch(t){Qi(e,e.return,t)}}}function Ar(e,t,n){n.props=q(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Qi(e,t,n)}}function jr(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=qa(e.stateNode);break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Qi(e,t,n)}}function Mr(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Qi(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Qi(e,t,n)}else n.current=null}function Nr(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{Vo(r,t,n,e)}catch(t){Qi(e,e.return,t)}}function Pr(e,t,n){try{Ho(e.stateNode,e.type,n,t,e)}catch(t){Qi(e,e.return,t)}}function Fr(e){return e.tag===5||e.tag===3||(Hs?e.tag===26:!1)||(nc?e.tag===27&&sc(e.type):!1)||e.tag===4}function Ir(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Fr(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(nc&&e.tag===27&&sc(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Lr(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?Wo(n,e,t):zo(n,e);else if(r!==4&&(nc&&r===27&&sc(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Lr(e,t,n),e=e.sibling;e!==null;)Lr(e,t,n),e=e.sibling}function Y(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?Uo(n,e,t):Ro(n,e);else if(r!==4&&(nc&&r===27&&sc(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Y(e,t,n),e=e.sibling;e!==null;)Y(e,t,n),e=e.sibling}function Rr(e,t,n){e=e.containerInfo;try{rs(e,n)}catch(e){Qi(t,t.return,e)}}function zr(e){var t=e.stateNode,n=e.memoizedProps;try{ic(e.type,n,t,e)}catch(t){Qi(e,e.return,t)}}function Br(e,t){for(Xa(e.containerInfo),lu=t;lu!==null;)if(e=lu,t=e.child,e.subtreeFlags&1028&&t!==null)t.return=e,lu=t;else for(;lu!==null;){e=lu;var n=e.alternate;switch(t=e.flags,e.tag){case 0:if(t&4&&(t=e.updateQueue,t=t===null?null:t.events,t!==null))for(var i=0;i<t.length;i++){var a=t[i];a.ref.impl=a.nextImpl}break;case 11:case 15:break;case 1:if(t&1024&&n!==null){t=void 0,i=e,a=n.memoizedProps,n=n.memoizedState;var o=i.stateNode;try{var s=q(i.type,a);t=o.getSnapshotBeforeUpdate(s,n),o.__reactInternalSnapshotBeforeUpdate=t}catch(e){Qi(i,i.return,e)}}break;case 3:t&1024&&so&&Qo(e.stateNode.containerInfo);break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(t&1024)throw Error(r(163))}if(t=e.sibling,t!==null){t.return=e.return,lu=t;break}lu=e.return}}function Vr(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:$r(e,n),r&4&&Dr(5,n);break;case 1:if($r(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Qi(n,n.return,e)}else{var i=q(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Qi(n,n.return,e)}}r&64&&kr(n),r&512&&jr(n,n.return);break;case 3:if($r(e,n),r&64&&(r=n.updateQueue,r!==null)){if(e=null,n.child!==null)switch(n.child.tag){case 27:case 5:e=qa(n.child.stateNode);break;case 1:e=n.child.stateNode}try{ot(r,e)}catch(e){Qi(n,n.return,e)}}break;case 27:nc&&t===null&&r&4&&zr(n);case 26:case 5:if($r(e,n),t===null){if(r&4)Nr(n);else if(r&64){e=n.type,t=n.memoizedProps,i=n.stateNode;try{ks(i,e,t,n)}catch(e){Qi(n,n.return,e)}}}r&512&&jr(n,n.return);break;case 12:$r(e,n);break;case 31:$r(e,n),r&4&&Gr(e,n);break;case 13:$r(e,n),r&4&&Kr(e,n),r&64&&(r=n.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(n=na.bind(null,n),ls(r,n))));break;case 22:if(r=n.memoizedState!==null||au,!r){t=t!==null&&t.memoizedState!==null||ou,i=au;var a=ou;au=r,(ou=t)&&!a?ti(e,n,(n.subtreeFlags&8772)!=0):$r(e,n),au=i,ou=a}break;case 30:break;default:$r(e,n)}}function Hr(e){var t=e.alternate;t!==null&&(e.alternate=null,Hr(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&_o(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ur(e,t,n){for(n=n.child;n!==null;)Wr(e,t,n),n=n.sibling}function Wr(e,t,n){if(kc&&typeof kc.onCommitFiberUnmount==`function`)try{kc.onCommitFiberUnmount(Oc,n)}catch{}switch(n.tag){case 26:if(Hs){ou||Mr(n,t),Ur(e,t,n),n.memoizedState?qs(n.memoizedState):n.stateNode&&Xs(n.stateNode);break}case 27:if(nc){ou||Mr(n,t);var r=uu,i=du;sc(n.type)&&(uu=n.stateNode,du=!1),Ur(e,t,n),ac(n.stateNode),uu=r,du=i;break}case 5:ou||Mr(n,t);case 6:if(so){if(r=uu,i=du,uu=null,Ur(e,t,n),uu=r,du=i,uu!==null)if(du)try{Ko(uu,n.stateNode)}catch(e){Qi(n,t,e)}else try{Go(uu,n.stateNode)}catch(e){Qi(n,t,e)}}else Ur(e,t,n);break;case 18:so&&uu!==null&&(du?Is(uu,n.stateNode):Fs(uu,n.stateNode));break;case 4:so?(r=uu,i=du,uu=n.stateNode.containerInfo,du=!0,Ur(e,t,n),uu=r,du=i):(co&&Rr(n.stateNode,n,es()),Ur(e,t,n));break;case 0:case 11:case 14:case 15:Or(2,n,t),ou||Or(4,n,t),Ur(e,t,n);break;case 1:ou||(Mr(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Ar(n,t,r)),Ur(e,t,n);break;case 21:Ur(e,t,n);break;case 22:ou=(r=ou)||n.memoizedState!==null,Ur(e,t,n),ou=r;break;default:Ur(e,t,n)}}function Gr(e,t){if(lo&&t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{js(e)}catch(e){Qi(t,t.return,e)}}}function Kr(e,t){if(lo&&t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ms(e)}catch(e){Qi(t,t.return,e)}}function qr(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new cu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new cu),t;default:throw Error(r(435,e.tag))}}function Jr(e,t){var n=qr(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=ra.bind(null,e,t);t.then(r,r)}})}function Yr(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i],o=e,s=t;if(so){var c=s;e:for(;c!==null;){switch(c.tag){case 27:if(nc){if(sc(c.type)){uu=c.stateNode,du=!1;break e}break}case 5:uu=c.stateNode,du=!1;break e;case 3:case 4:uu=c.stateNode.containerInfo,du=!0;break e}c=c.return}if(uu===null)throw Error(r(160));Wr(o,s,a),uu=null,du=!1}else Wr(o,s,a);o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Xr(t,e),t=t.sibling}function Xr(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Yr(t,e),Zr(e),i&4&&(Or(3,e,e.return),Dr(3,e),Or(5,e,e.return));break;case 1:Yr(t,e),Zr(e),i&512&&(ou||n===null||Mr(n,n.return)),i&64&&au&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?i:n.concat(i))));break;case 26:if(Hs){var a=fu;if(Yr(t,e),Zr(e),i&512&&(ou||n===null||Mr(n,n.return)),i&4){i=n===null?null:n.memoizedState;var o=e.memoizedState;n===null?o===null?e.stateNode===null?e.stateNode=Js(a,e.type,e.memoizedProps,e):Ys(a,e.type,e.stateNode):e.stateNode=Ks(a,o,e.memoizedProps):i===o?o===null&&e.stateNode!==null&&Pr(e,e.memoizedProps,n.memoizedProps):(i===null?n.stateNode!==null&&Xs(n.stateNode):qs(i),o===null?Ys(a,e.type,e.stateNode):Ks(a,o,e.memoizedProps))}break}case 27:if(nc){Yr(t,e),Zr(e),i&512&&(ou||n===null||Mr(n,n.return)),n!==null&&i&4&&Pr(e,e.memoizedProps,n.memoizedProps);break}case 5:if(Yr(t,e),Zr(e),i&512&&(ou||n===null||Mr(n,n.return)),so){if(e.flags&32){a=e.stateNode;try{qo(a)}catch(t){Qi(e,e.return,t)}}i&4&&e.stateNode!=null&&(a=e.memoizedProps,Pr(e,a,n===null?a:n.memoizedProps)),i&1024&&(su=!0)}else co&&e.alternate!==null&&(e.alternate.stateNode=e.stateNode);break;case 6:if(Yr(t,e),Zr(e),i&4&&so){if(e.stateNode===null)throw Error(r(162));i=e.memoizedProps,n=n===null?i:n.memoizedProps,a=e.stateNode;try{Bo(a,n,i)}catch(t){Qi(e,e.return,t)}}break;case 3:if(Hs?(Qs(),a=fu,fu=Ws(t.containerInfo),Yr(t,e),fu=a):Yr(t,e),Zr(e),i&4){if(so&&lo&&n!==null&&n.memoizedState.isDehydrated)try{As(t.containerInfo)}catch(t){Qi(e,e.return,t)}if(co){i=t.containerInfo,n=t.pendingChildren;try{rs(i,n)}catch(t){Qi(e,e.return,t)}}}su&&(su=!1,Qr(e));break;case 4:Hs?(n=fu,fu=Ws(e.stateNode.containerInfo),Yr(t,e),Zr(e),fu=n):(Yr(t,e),Zr(e)),i&4&&co&&Rr(e.stateNode,e,e.stateNode.pendingChildren);break;case 12:Yr(t,e),Zr(e);break;case 31:Yr(t,e),Zr(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Jr(e,i)));break;case 13:Yr(t,e),Zr(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Vu=xc()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Jr(e,i)));break;case 22:a=e.memoizedState!==null;var s=n!==null&&n.memoizedState!==null,c=au,l=ou;if(au=c||a,ou=l||s,Yr(t,e),ou=l,au=c,Zr(e),i&8192&&(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||s||au||ou||ei(e)),so)){e:if(n=null,so)for(t=e;;){if(t.tag===5||Hs&&t.tag===26){if(n===null){s=n=t;try{o=s.stateNode,a?Jo(o):Xo(s.stateNode,s.memoizedProps)}catch(e){Qi(s,s.return,e)}}}else if(t.tag===6){if(n===null){s=t;try{var u=s.stateNode;a?Yo(u):Zo(u,s.memoizedProps)}catch(e){Qi(s,s.return,e)}}}else if(t.tag===18){if(n===null){s=t;try{var d=s.stateNode;a?Ls(d):Rs(s.stateNode)}catch(e){Qi(s,s.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&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;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}}i&4&&(i=e.updateQueue,i!==null&&(n=i.retryQueue,n!==null&&(i.retryQueue=null,Jr(e,n))));break;case 19:Yr(t,e),Zr(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Jr(e,i)));break;case 30:break;case 21:break;default:Yr(t,e),Zr(e)}}function Zr(e){var t=e.flags;if(t&2){try{for(var n,i=e.return;i!==null;){if(Fr(i)){n=i;break}i=i.return}if(so){if(n==null)throw Error(r(160));switch(n.tag){case 27:if(nc){var a=n.stateNode;Y(e,Ir(e),a);break}case 5:var o=n.stateNode;n.flags&32&&(qo(o),n.flags&=-33),Y(e,Ir(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Lr(e,Ir(e),s);break;default:throw Error(r(161))}}}catch(t){Qi(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Qr(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Qr(t),t.tag===5&&t.flags&1024&&Do(t.stateNode),e=e.sibling}}function $r(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Vr(e,t.alternate,t),t=t.sibling}function ei(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Or(4,t,t.return),ei(t);break;case 1:Mr(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Ar(t,t.return,n),ei(t);break;case 27:nc&&ac(t.stateNode);case 26:case 5:Mr(t,t.return),ei(t);break;case 22:t.memoizedState===null&&ei(t);break;case 30:ei(t);break;default:ei(t)}e=e.sibling}}function ti(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:ti(i,a,n),Dr(4,a);break;case 1:if(ti(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Qi(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)at(c[i],s)}catch(e){Qi(r,r.return,e)}}n&&o&64&&kr(a),jr(a,a.return);break;case 27:nc&&zr(a);case 26:case 5:ti(i,a,n),n&&r===null&&o&4&&Nr(a),jr(a,a.return);break;case 12:ti(i,a,n);break;case 31:ti(i,a,n),n&&o&4&&Gr(i,a);break;case 13:ti(i,a,n),n&&o&4&&Kr(i,a);break;case 22:a.memoizedState===null&&ti(i,a,n),jr(a,a.return);break;case 30:break;default:ti(i,a,n)}t=t.sibling}}function ni(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&be(n))}function ri(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&be(e))}function ii(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)ai(e,t,n,r),t=t.sibling}function ai(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:ii(e,t,n,r),i&2048&&Dr(9,t);break;case 1:ii(e,t,n,r);break;case 3:ii(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&be(e)));break;case 12:if(i&2048){ii(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Qi(t,t.return,e)}}else ii(e,t,n,r);break;case 31:ii(e,t,n,r);break;case 13:ii(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?ii(e,t,n,r):(a._visibility|=2,oi(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?ii(e,t,n,r):si(e,t),i&2048&&ni(o,t);break;case 24:ii(e,t,n,r),i&2048&&ri(t.alternate,t);break;default:ii(e,t,n,r)}}function oi(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:oi(a,o,s,c,i),Dr(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,oi(a,o,s,c,i)):u._visibility&2?oi(a,o,s,c,i):si(a,o),i&&l&2048&&ni(o.alternate,o);break;case 24:oi(a,o,s,c,i),i&&l&2048&&ri(o.alternate,o);break;default:oi(a,o,s,c,i)}t=t.sibling}}function si(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:si(n,r),i&2048&&ni(r.alternate,r);break;case 24:si(n,r),i&2048&&ri(r.alternate,r);break;default:si(n,r)}t=t.sibling}}function ci(e,t,n){if(e.subtreeFlags&pu)for(e=e.child;e!==null;)li(e,t,n),e=e.sibling}function li(e,t,n){switch(e.tag){case 26:if(ci(e,t,n),e.flags&pu)if(e.memoizedState!==null)tc(n,fu,e.memoizedState,e.memoizedProps);else{var r=e.stateNode,i=e.type;e=e.memoizedProps,((t&335544128)===t||bo(i,e))&&Co(n,r,i,e)}break;case 5:ci(e,t,n),e.flags&pu&&(r=e.stateNode,i=e.type,e=e.memoizedProps,((t&335544128)===t||bo(i,e))&&Co(n,r,i,e));break;case 3:case 4:Hs?(r=fu,fu=Ws(e.stateNode.containerInfo),ci(e,t,n),fu=r):ci(e,t,n);break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=pu,pu=16777216,ci(e,t,n),pu=r):ci(e,t,n));break;default:ci(e,t,n)}}function ui(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function di(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];lu=r,mi(r,e)}ui(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)fi(e),e=e.sibling}function fi(e){switch(e.tag){case 0:case 11:case 15:di(e),e.flags&2048&&Or(9,e,e.return);break;case 3:di(e);break;case 12:di(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,pi(e)):di(e);break;default:di(e)}}function pi(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];lu=r,mi(r,e)}ui(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Or(8,t,t.return),pi(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,pi(t));break;default:pi(t)}e=e.sibling}}function mi(e,t){for(;lu!==null;){var n=lu;switch(n.tag){case 0:case 11:case 15:Or(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:be(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,lu=r;else e:for(n=e;lu!==null;){r=lu;var i=r.sibling,a=r.return;if(Hr(r),r===n){lu=null;break e}if(i!==null){i.return=a,lu=i;break e}lu=a}}}function hi(e){var t=uo(e);if(t!=null){if(typeof t.memoizedProps[`data-testname`]!=`string`)throw Error(r(364));return t}if(e=jo(e),e===null)throw Error(r(362));return e.stateNode.current}function gi(e,t){var n=e.tag;switch(t.$$typeof){case hu:if(e.type===t.value)return!0;break;case gu:e:{for(t=t.value,e=[e,0],n=0;n<e.length;){var i=e[n++],a=i.tag,o=e[n++],s=t[o];if(a!==5&&a!==26&&a!==27||!Po(i)){for(;s!=null&&gi(i,s);)o++,s=t[o];if(o===t.length){t=!0;break e}else for(i=i.child;i!==null;)e.push(i,o),i=i.sibling}}t=!1}return t;case _u:if((n===5||n===26||n===27)&&Fo(e.stateNode,t.value))return!0;break;case yu:if((n===5||n===6||n===26||n===27)&&(e=No(e),e!==null&&0<=e.indexOf(t.value)))return!0;break;case vu:if((n===5||n===26||n===27)&&(e=e.memoizedProps[`data-testname`],typeof e==`string`&&e.toLowerCase()===t.value.toLowerCase()))return!0;break;default:throw Error(r(365))}return!1}function _i(e){switch(e.$$typeof){case hu:return`<`+(u(e.value)||`Unknown`)+`>`;case gu:return`:has(`+(_i(e)||``)+`)`;case _u:return`[role="`+e.value+`"]`;case yu:return`"`+e.value+`"`;case vu:return`[data-testname="`+e.value+`"]`;default:throw Error(r(365))}}function vi(e,t){var n=[];e=[e,0];for(var r=0;r<e.length;){var i=e[r++],a=i.tag,o=e[r++],s=t[o];if(a!==5&&a!==26&&a!==27||!Po(i)){for(;s!=null&&gi(i,s);)o++,s=t[o];if(o===t.length)n.push(i);else for(i=i.child;i!==null;)e.push(i,o),i=i.sibling}}return n}function yi(e,t){if(!Ao)throw Error(r(363));e=hi(e),e=vi(e,t),t=[],e=Array.from(e);for(var n=0;n<e.length;){var i=e[n++],a=i.tag;if(a===5||a===26||a===27)Po(i)||t.push(i.stateNode);else for(i=i.child;i!==null;)e.push(i),i=i.sibling}return t}function bi(){return Su&2&&Tu!==0?Tu&-Tu:Ua.T===null?ho():Oe()}function xi(){if(Iu===0)if(!(Tu&536870912)||Qc){var e=hc;hc<<=1,!(hc&3932160)&&(hc=262144),Iu=e}else Iu=536870912;return e=Ll.current,e!==null&&(e.flags|=32),Iu}function Si(e,t,n){(e===Cu&&(Eu===2||Eu===9)||e.cancelPendingCommit!==null)&&(ki(e,0),Ei(e,Tu,Iu,!1)),S(e,n),(!(Su&2)||e!==Cu)&&(e===Cu&&(!(Su&2)&&(Pu|=n),Mu===4&&Ei(e,Tu,Iu,!1)),Se(e))}function Ci(e,t,n){if(Su&6)throw Error(r(327));var i=!n&&(t&127)==0&&(t&e.expiredLanes)===0||_(e,t),a=i?Li(e,t):Fi(e,t,!0),o=i;do{if(a===0){ku&&!i&&Ei(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!Ti(n)){a=Fi(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;e:{var c=e;a=Ru;var l=lo&&c.current.memoizedState.isDehydrated;if(l&&(ki(c,s).flags|=256),s=Fi(c,s,!1),s!==2){if(Au&&!l){c.errorRecoveryDisabledLanes|=o,Pu|=o,a=4;break e}o=zu,zu=a,o!==null&&(zu===null?zu=o:zu.push.apply(zu,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){ki(e,0),Ei(e,t,0,!0);break}e:{switch(i=e,o=a,o){case 0:case 1:throw Error(r(345));case 4:if((t&4194048)!==t)break;case 6:Ei(i,t,Iu,!Ou);break e;case 2:zu=null;break;case 3:case 5:break;default:throw Error(r(329))}if((t&62914560)===t&&(a=Vu+300-xc(),10<a)){if(Ei(i,t,Iu,!Ou),g(i,0,!0)!==0)break e;Yu=t,i.timeoutHandle=ro(wi.bind(null,i,n,zu,Wu,Bu,t,Iu,Pu,Lu,Ou,o,`Throttled`,-0,0),a);break e}wi(i,n,zu,Wu,Bu,t,Iu,Pu,Lu,Ou,o,null,-0,0)}}break}while(!0);Se(e)}function wi(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=ao,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d=So(),li(t,a,d);var m=(a&62914560)===a?Vu-xc():(a&4194048)===a?Hu-xc():0;if(m=wo(d,m),m!==null){Yu=a,e.cancelPendingCommit=m(Wi.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Ei(e,a,o,!l);return}}Wi(e,t,a,n,r,i,o,s,c)}function Ti(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Ac(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ei(e,t,n,r){t&=~Fu,t&=~Pu,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-dc(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&w(e,n,t)}function Di(){return Su&6?!0:(U(0,!1),!1)}function Oi(){if(wu!==null){if(Eu===0)var e=wu.return;else e=wu,il=rl=null,wt(e),El=null,Dl=0,e=wu;for(;e!==null;)Er(e.alternate,e),e=e.return;wu=null}}function ki(e,t){var n=e.timeoutHandle;n!==ao&&(e.timeoutHandle=ao,io(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Yu=0,Oi(),Cu=e,wu=n=sa(e.current,null),Tu=t,Eu=0,Du=null,Ou=!1,ku=_(e,t),Au=!1,Lu=Iu=Fu=Pu=Nu=Mu=0,zu=Ru=null,Bu=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-dc(r),a=1<<i;t|=e[i],r&=~a}return ju=t,Ge(),n}function Ai(e,t){Vl=null,Ua.H=Zl,t===xl||t===Cl?(t=ze(),Eu=3):t===Sl?(t=ze(),Eu=4):Eu=t===nu?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Du=t,wu===null&&(Mu=1,Nn(e,F(t,e.current)))}function ji(){var e=Ll.current;return e===null?!0:(Tu&4194048)===Tu?Rl===null:(Tu&62914560)===Tu||Tu&536870912?e===Rl:!1}function Mi(){var e=Ua.H;return Ua.H=Zl,e===null?Zl:e}function Ni(){var e=Ua.A;return Ua.A=mu,e}function Pi(){Mu=4,Ou||(Tu&4194048)!==Tu&&Ll.current!==null||(ku=!0),!(Nu&134217727)&&!(Pu&134217727)||Cu===null||Ei(Cu,Tu,Iu,!1)}function Fi(e,t,n){var r=Su;Su|=2;var i=Mi(),a=Ni();(Cu!==e||Tu!==t)&&(Wu=null,ki(e,t)),t=!1;var o=Mu;e:do try{if(Eu!==0&&wu!==null){var s=wu,c=Du;switch(Eu){case 8:Oi(),o=6;break e;case 3:case 2:case 9:case 6:Ll.current===null&&(t=!0);var l=Eu;if(Eu=0,Du=null,Vi(e,s,c,l),n&&ku){o=0;break e}break;default:l=Eu,Eu=0,Du=null,Vi(e,s,c,l)}}Ii(),o=Mu;break}catch(t){Ai(e,t)}while(!0);return t&&e.shellSuspendCounter++,il=rl=null,Su=r,Ua.H=i,Ua.A=a,wu===null&&(Cu=null,Tu=0,Ge()),o}function Ii(){for(;wu!==null;)zi(wu)}function Li(e,t){var n=Su;Su|=2;var i=Mi(),a=Ni();Cu!==e||Tu!==t?(Wu=null,Uu=xc()+500,ki(e,t)):ku=_(e,t);e:do try{if(Eu!==0&&wu!==null){t=wu;var o=Du;n:switch(Eu){case 1:Eu=0,Du=null,Vi(e,t,o,1);break;case 2:case 9:if(Ie(o)){Eu=0,Du=null,Bi(t);break}t=function(){Eu!==2&&Eu!==9||Cu!==e||(Eu=7),Se(e)},o.then(t,t);break e;case 3:Eu=7;break e;case 4:Eu=5;break e;case 7:Ie(o)?(Eu=0,Du=null,Bi(t)):(Eu=0,Du=null,Vi(e,t,o,7));break;case 5:var s=null;switch(wu.tag){case 26:s=wu.memoizedState;case 5:case 27:var c=wu,l=c.type,u=c.pendingProps;if(s?ec(s):xo(c.stateNode,l,u)){Eu=0,Du=null;var d=c.sibling;if(d!==null)wu=d;else{var f=c.return;f===null?wu=null:(wu=f,Hi(f))}break n}}Eu=0,Du=null,Vi(e,t,o,5);break;case 6:Eu=0,Du=null,Vi(e,t,o,6);break;case 8:Oi(),Mu=6;break e;default:throw Error(r(462))}}Ri();break}catch(t){Ai(e,t)}while(!0);return il=rl=null,Ua.H=i,Ua.A=a,Su=n,wu===null?(Cu=null,Tu=0,Ge(),Mu):0}function Ri(){for(;wu!==null&&!yc();)zi(wu)}function zi(e){var t=dr(e.alternate,e,ju);e.memoizedProps=e.pendingProps,t===null?Hi(e):wu=t}function Bi(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Zn(n,t,t.pendingProps,t.type,void 0,Tu);break;case 11:t=Zn(n,t,t.pendingProps,t.type.render,t.ref,Tu);break;case 5:wt(t);default:Er(n,t),t=wu=ca(t,ju),t=dr(n,t,ju)}e.memoizedProps=e.pendingProps,t===null?Hi(e):wu=t}function Vi(e,t,n,r){il=rl=null,wt(t),El=null,Dl=0;var i=t.return;try{if(Rn(e,i,t,n,Tu)){Mu=1,Nn(e,F(n,e.current)),wu=null;return}}catch(t){if(i!==null)throw wu=i,t;Mu=1,Nn(e,F(n,e.current)),wu=null;return}t.flags&32768?(Qc||r===1?e=!0:ku||Tu&536870912?e=!1:(Ou=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ll.current,r!==null&&r.tag===13&&(r.flags|=16384))),Ui(t,e)):Hi(t)}function Hi(e){var t=e;do{if(t.flags&32768){Ui(t,Ou);return}e=t.return;var n=wr(t.alternate,t,ju);if(n!==null){wu=n;return}if(t=t.sibling,t!==null){wu=t;return}wu=t=e}while(t!==null);Mu===0&&(Mu=5)}function Ui(e,t){do{var n=Tr(e.alternate,e);if(n!==null){n.flags&=32767,wu=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){wu=e;return}wu=e=n}while(e!==null);Mu=6,wu=null}function Wi(e,t,n,i,a,o,s,c,l){e.cancelPendingCommit=null;do Yi();while(Ku!==0);if(Su&6)throw Error(r(327));if(t!==null){if(t===e.current)throw Error(r(177));if(o=t.lanes|t.childLanes,o|=Ml,C(e,n,o,s,c,l),e===Cu&&(wu=Cu=null,Tu=0),Ju=t,qu=e,Yu=n,Xu=o,Zu=a,Qu=i,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,ia(wc,function(){return Xi(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(t.flags&13878)!=0,t.subtreeFlags&13878||i){i=Ua.T,Ua.T=null,a=mo(),po(2),s=Su,Su|=4;try{Br(e,t,n)}finally{Su=s,po(a),Ua.T=i}}Ku=1,Gi(),Ki(),qi()}}function Gi(){if(Ku===1){Ku=0;var e=qu,t=Ju,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=Ua.T,Ua.T=null;var r=mo();po(2);var i=Su;Su|=4;try{Xr(t,e),Za(e.containerInfo)}finally{Su=i,po(r),Ua.T=n}}e.current=t,Ku=2}}function Ki(){if(Ku===2){Ku=0;var e=qu,t=Ju,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=Ua.T,Ua.T=null;var r=mo();po(2);var i=Su;Su|=4;try{Vr(e,t.alternate,t)}finally{Su=i,po(r),Ua.T=n}}Ku=3}}function qi(){if(Ku===4||Ku===3){Ku=0,bc();var e=qu,t=Ju,n=Yu,r=Qu;t.subtreeFlags&10256||t.flags&10256?Ku=5:(Ku=0,Ju=qu=null,Ji(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(Gu=null),O(n),t=t.stateNode,kc&&typeof kc.onCommitFiberRoot==`function`)try{kc.onCommitFiberRoot(Oc,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=Ua.T,i=mo(),po(2),Ua.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{Ua.T=t,po(i)}}Yu&3&&Yi(),Se(e),i=e.pendingLanes,n&261930&&i&42?e===ed?$u++:($u=0,ed=e):$u=0,lo&&Ps(),U(0,!1)}}function Ji(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,be(t)))}function Yi(){return Gi(),Ki(),qi(),Xi()}function Xi(){if(Ku!==5)return!1;var e=qu,t=Xu;Xu=0;var n=O(Yu),i=32>n?32:n;n=Ua.T;var a=mo();try{po(i),Ua.T=null,i=Zu,Zu=null;var o=qu,s=Yu;if(Ku=0,Ju=qu=null,Yu=0,Su&6)throw Error(r(331));var c=Su;if(Su|=4,fi(o.current),ai(o,o.current,s,i),Su=c,U(0,!1),kc&&typeof kc.onPostCommitFiberRoot==`function`)try{kc.onPostCommitFiberRoot(Oc,o)}catch{}return!0}finally{po(a),Ua.T=n,Ji(e,t)}}function Zi(e,t,n){t=F(n,t),t=Fn(e.stateNode,t,2),e=et(e,t,2),e!==null&&(S(e,2),Se(e))}function Qi(e,t,n){if(e.tag===3)Zi(e,e,n);else for(;t!==null;){if(t.tag===3){Zi(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(Gu===null||!Gu.has(r))){e=F(n,e),n=In(2),r=et(t,n,2),r!==null&&(Ln(n,r,t,e),S(r,2),Se(r));break}}t=t.return}}function $i(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new xu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Au=!0,i.add(n),e=ea.bind(null,e,t,n),t.then(e,e))}function ea(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Cu===e&&(Tu&n)===n&&(Mu===4||Mu===3&&(Tu&62914560)===Tu&&300>xc()-Vu?!(Su&2)&&ki(e,0):Fu|=n,Lu===Tu&&(Lu=0)),Se(e)}function ta(e,t){t===0&&(t=b()),e=Je(e,t),e!==null&&(S(e,t),Se(e))}function na(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ta(e,n)}function ra(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(r(314))}i!==null&&i.delete(t),ta(e,n)}function ia(e,t){return _c(e,t)}function aa(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,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 oa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function sa(e,n){var r=e.alternate;return r===null?(r=t(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function ca(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function la(e,n,i,a,o,s){var c=0;if(a=e,typeof e==`function`)oa(e)&&(c=1);else if(typeof e==`string`)c=Hs&&nc?Us(e,i,Kc.current)?26:oc(e)?27:5:Hs?Us(e,i,Kc.current)?26:5:nc&&oc(e)?27:5;else e:switch(e){case Ra:return e=t(31,i,n,o),e.elementType=Ra,e.lanes=s,e;case Oa:return ua(i.children,o,s,n);case ka:c=8,o|=24;break;case Aa:return e=t(12,i,n,o|2),e.elementType=Aa,e.lanes=s,e;case Pa:return e=t(13,i,n,o),e.elementType=Pa,e.lanes=s,e;case Fa:return e=t(19,i,n,o),e.elementType=Fa,e.lanes=s,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case Ma:c=10;break e;case ja:c=9;break e;case Na:c=11;break e;case Ia:c=14;break e;case La:c=16,a=null;break e}c=29,i=Error(r(130,e===null?`null`:typeof e,``)),a=null}return n=t(c,i,n,o),n.elementType=e,n.type=a,n.lanes=s,n}function ua(e,n,r,i){return e=t(7,e,i,n),e.lanes=r,e}function da(e,n,r){return e=t(6,e,null,n),e.lanes=r,e}function fa(e){var n=t(18,null,null,0);return n.stateNode=e,n}function pa(e,n,r){return n=t(4,e.children===null?[]:e.children,e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function ma(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=ao,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=x(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=x(0),this.hiddenUpdates=x(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ha(e,n,r,i,a,o,s,c,l,u,d,f){return e=new ma(e,n,r,s,l,u,d,f,c),n=1,o===!0&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,n=ye(),n.refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:i,isDehydrated:r,cache:n},Ze(o),e}function ga(e){return e?(e=uc,e):uc}function _a(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=o(t),e=e===null?null:s(e),e===null?null:qa(e.stateNode)}function va(e,t,n,r,i,a){i=ga(i),r.context===null?r.context=i:r.pendingContext=i,r=$e(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=et(e,r,t),n!==null&&(Si(n,e,t),tt(n,e,t))}function ya(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ba(e,t){ya(e,t),(e=e.alternate)&&ya(e,t)}var xa={},Sa=v.default,Ca=Pg.default,wa=Object.assign,Ta=Symbol.for(`react.element`),Ea=Symbol.for(`react.transitional.element`),Da=Symbol.for(`react.portal`),Oa=Symbol.for(`react.fragment`),ka=Symbol.for(`react.strict_mode`),Aa=Symbol.for(`react.profiler`),ja=Symbol.for(`react.consumer`),Ma=Symbol.for(`react.context`),Na=Symbol.for(`react.forward_ref`),Pa=Symbol.for(`react.suspense`),Fa=Symbol.for(`react.suspense_list`),Ia=Symbol.for(`react.memo`),La=Symbol.for(`react.lazy`),Ra=Symbol.for(`react.activity`),za=Symbol.for(`react.memo_cache_sentinel`),Ba=Symbol.iterator,Va=Symbol.for(`react.client.reference`),Ha=Array.isArray,Ua=Sa.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Wa=e.rendererVersion,Ga=e.rendererPackageName,Ka=e.extraDevToolsConfig,qa=e.getPublicInstance,Ja=e.getRootHostContext,Ya=e.getChildHostContext,Xa=e.prepareForCommit,Za=e.resetAfterCommit,Qa=e.createInstance;e.cloneMutableInstance;var $a=e.appendInitialChild,eo=e.finalizeInitialChildren,to=e.shouldSetTextContent,no=e.createTextInstance;e.cloneMutableTextInstance;var ro=e.scheduleTimeout,io=e.cancelTimeout,ao=e.noTimeout,oo=e.isPrimaryRenderer;e.warnsIfNotActing;var so=e.supportsMutation,co=e.supportsPersistence,lo=e.supportsHydration,uo=e.getInstanceFromNode;e.beforeActiveInstanceBlur;var fo=e.preparePortalMount;e.prepareScopeUpdate,e.getInstanceFromScope;var po=e.setCurrentUpdatePriority,mo=e.getCurrentUpdatePriority,ho=e.resolveUpdatePriority;e.trackSchedulerEvent,e.resolveEventType,e.resolveEventTimeStamp;var go=e.shouldAttemptEagerTransition,_o=e.detachDeletedInstance;e.requestPostPaintCallback;var vo=e.maySuspendCommit,yo=e.maySuspendCommitOnUpdate,bo=e.maySuspendCommitInSyncRender,xo=e.preloadInstance,So=e.startSuspendingCommit,Co=e.suspendInstance;e.suspendOnActiveViewTransition;var wo=e.waitForCommitToBeReady;e.getSuspendedCommitReason;var To=e.NotPendingTransition,Eo=e.HostTransitionContext,Do=e.resetFormInstance;e.bindToConsole;var Oo=e.supportsMicrotasks,ko=e.scheduleMicrotask,Ao=e.supportsTestSelectors,jo=e.findFiberRoot,Mo=e.getBoundingRect,No=e.getTextContent,Po=e.isHiddenSubtree,Fo=e.matchAccessibilityRole,Io=e.setFocusIfFocusable,Lo=e.setupIntersectionObserver,Ro=e.appendChild,zo=e.appendChildToContainer,Bo=e.commitTextUpdate,Vo=e.commitMount,Ho=e.commitUpdate,Uo=e.insertBefore,Wo=e.insertInContainerBefore,Go=e.removeChild,Ko=e.removeChildFromContainer,qo=e.resetTextContent,Jo=e.hideInstance,Yo=e.hideTextInstance,Xo=e.unhideInstance,Zo=e.unhideTextInstance;e.cancelViewTransitionName,e.cancelRootViewTransitionName,e.restoreRootViewTransitionName,e.cloneRootViewTransitionContainer,e.removeRootViewTransitionClone,e.measureClonedInstance,e.hasInstanceChanged,e.hasInstanceAffectedParent,e.startViewTransition,e.startGestureTransition,e.stopViewTransition,e.getCurrentGestureOffset,e.createViewTransitionInstance;var Qo=e.clearContainer;e.createFragmentInstance,e.updateFragmentInstanceFiber,e.commitNewChildToFragmentInstance,e.deleteChildFromFragmentInstance;var $o=e.cloneInstance,es=e.createContainerChildSet,ts=e.appendChildToContainerChildSet,ns=e.finalizeContainerChildren,rs=e.replaceContainerChildren,is=e.cloneHiddenInstance,as=e.cloneHiddenTextInstance,os=e.isSuspenseInstancePending,ss=e.isSuspenseInstanceFallback,cs=e.getSuspenseInstanceFallbackErrorDetails,ls=e.registerSuspenseInstanceRetry,us=e.canHydrateFormStateMarker,ds=e.isFormStateMarkerMatching,fs=e.getNextHydratableSibling,ps=e.getNextHydratableSiblingAfterSingleton,ms=e.getFirstHydratableChild,hs=e.getFirstHydratableChildWithinContainer,gs=e.getFirstHydratableChildWithinActivityInstance,_s=e.getFirstHydratableChildWithinSuspenseInstance,vs=e.getFirstHydratableChildWithinSingleton,ys=e.canHydrateInstance,bs=e.canHydrateTextInstance,xs=e.canHydrateActivityInstance,Ss=e.canHydrateSuspenseInstance,Cs=e.hydrateInstance,ws=e.hydrateTextInstance,Ts=e.hydrateActivityInstance,Es=e.hydrateSuspenseInstance,Ds=e.getNextHydratableInstanceAfterActivityInstance,Os=e.getNextHydratableInstanceAfterSuspenseInstance,ks=e.commitHydratedInstance,As=e.commitHydratedContainer,js=e.commitHydratedActivityInstance,Ms=e.commitHydratedSuspenseInstance,Ns=e.finalizeHydratedChildren,Ps=e.flushHydrationEvents;e.clearActivityBoundary;var Fs=e.clearSuspenseBoundary;e.clearActivityBoundaryFromContainer;var Is=e.clearSuspenseBoundaryFromContainer,Ls=e.hideDehydratedBoundary,Rs=e.unhideDehydratedBoundary,zs=e.shouldDeleteUnhydratedTailInstances;e.diffHydratedPropsForDevWarnings,e.diffHydratedTextForDevWarnings,e.describeHydratableInstanceForDevWarnings;var Bs=e.validateHydratableInstance,Vs=e.validateHydratableTextInstance,Hs=e.supportsResources,Us=e.isHostHoistableType,Ws=e.getHoistableRoot,Gs=e.getResource,Ks=e.acquireResource,qs=e.releaseResource,Js=e.hydrateHoistable,Ys=e.mountHoistable,Xs=e.unmountHoistable,Zs=e.createHoistableInstance,Qs=e.prepareToCommitHoistables,$s=e.mayResourceSuspendCommit,ec=e.preloadResource,tc=e.suspendResource,nc=e.supportsSingletons,rc=e.resolveSingletonInstance,ic=e.acquireSingletonInstance,ac=e.releaseSingletonInstance,oc=e.isHostSingletonType,sc=e.isSingletonScope,cc=[],lc=-1,uc={},dc=Math.clz32?Math.clz32:m,fc=Math.log,pc=Math.LN2,mc=256,hc=262144,gc=4194304,_c=Ca.unstable_scheduleCallback,vc=Ca.unstable_cancelCallback,yc=Ca.unstable_shouldYield,bc=Ca.unstable_requestPaint,xc=Ca.unstable_now,Sc=Ca.unstable_ImmediatePriority,Cc=Ca.unstable_UserBlockingPriority,wc=Ca.unstable_NormalPriority,Tc=Ca.unstable_IdlePriority,Ec=Ca.log,Dc=Ca.unstable_setDisableYieldValue,Oc=null,kc=null,Ac=typeof Object.is==`function`?Object.is:A,jc=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Mc=Object.prototype.hasOwnProperty,Nc,Pc,Fc=!1,Ic=new WeakMap,Lc=[],Rc=0,zc=null,Bc=0,Vc=[],Hc=0,Uc=null,Wc=1,Gc=``,Kc=d(null),qc=d(null),Jc=d(null),Yc=d(null),Xc=null,Zc=null,Qc=!1,$c=null,el=!1,tl=Error(r(519)),nl=d(null),rl=null,il=null,al=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ol=Ca.unstable_scheduleCallback,sl=Ca.unstable_NormalPriority,cl={$$typeof:Ma,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},ll=null,ul=null,dl=!1,fl=!1,pl=!1,ml=0,hl=null,gl=0,_l=0,vl=null,yl=Ua.S;Ua.S=function(e,t){Hu=xc(),typeof t==`object`&&t&&typeof t.then==`function`&&ke(e,t),yl!==null&&yl(e,t)};var bl=d(null),xl=Error(r(460)),Sl=Error(r(474)),Cl=Error(r(542)),wl={then:function(){}},Tl=null,El=null,Dl=0,Ol=We(!0),kl=We(!1),Al=[],jl=0,Ml=0,Nl=!1,Pl=!1,Fl=d(null),Il=d(0),Ll=d(null),Rl=null,zl=d(0),Bl=0,Vl=null,Hl=null,Ul=null,Wl=!1,Gl=!1,Kl=!1,ql=0,Jl=0,Yl=null,Xl=0,Zl={readContext:ge,use:kt,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useLayoutEffect:gt,useInsertionEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useSyncExternalStore:gt,useId:gt,useHostTransitionStatus:gt,useFormState:gt,useActionState:gt,useOptimistic:gt,useMemoCache:gt,useCacheRefresh:gt};Zl.useEffectEvent=gt;var Ql={readContext:ge,use:kt,useCallback:function(e,t){return Tt().memoizedState=[e,t===void 0?null:t],e},useContext:ge,useEffect:an,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),nn(4194308,4,dn.bind(null,t,e),n)},useLayoutEffect:function(e,t){return nn(4194308,4,e,t)},useInsertionEffect:function(e,t){nn(4,2,e,t)},useMemo:function(e,t){var n=Tt();t=t===void 0?null:t;var r=e();if(Kl){k(!0);try{e()}finally{k(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Tt();if(n!==void 0){var i=n(t);if(Kl){k(!0);try{n(t)}finally{k(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=wn.bind(null,Vl,e),[r.memoizedState,e]},useRef:function(e){var t=Tt();return e={current:e},t.memoizedState=e},useState:function(e){e=Vt(e);var t=e.queue,n=Tn.bind(null,Vl,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:pn,useDeferredValue:function(e,t){return gn(Tt(),e,t)},useTransition:function(){var e=Vt(!1);return e=vn.bind(null,Vl,e.queue,!0,!1),Tt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var i=Vl,a=Tt();if(Qc){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Cu===null)throw Error(r(349));Tu&127||It(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,an(Rt.bind(null,i,o,e),[e]),i.flags|=2048,en(9,{destroy:void 0},Lt.bind(null,i,o,n,t),null),n},useId:function(){var e=Tt(),t=Cu.identifierPrefix;if(Qc){var n=Gc,r=Wc;n=(r&~(1<<32-dc(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=ql++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Xl++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:bn,useFormState:Xt,useActionState:Xt,useOptimistic:function(e){var t=Tt();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Dn.bind(null,Vl,!0,n),n.dispatch=t,[e,t]},useMemoCache:At,useCacheRefresh:function(){return Tt().memoizedState=Cn.bind(null,Vl)},useEffectEvent:function(e){var t=Tt(),n={impl:e};return t.memoizedState=n,function(){if(Su&2)throw Error(r(440));return n.impl.apply(void 0,arguments)}}},$l={readContext:ge,use:kt,useCallback:mn,useContext:ge,useEffect:on,useImperativeHandle:fn,useInsertionEffect:ln,useLayoutEffect:un,useMemo:hn,useReducer:Mt,useRef:tn,useState:function(){return Mt(jt)},useDebugValue:pn,useDeferredValue:function(e,t){return _n(Et(),Hl.memoizedState,e,t)},useTransition:function(){var e=Mt(jt)[0],t=Et().memoizedState;return[typeof e==`boolean`?e:Ot(e),t]},useSyncExternalStore:Ft,useId:xn,useHostTransitionStatus:bn,useFormState:Zt,useActionState:Zt,useOptimistic:function(e,t){return Ht(Et(),Hl,e,t)},useMemoCache:At,useCacheRefresh:Sn};$l.useEffectEvent=cn;var eu={readContext:ge,use:kt,useCallback:mn,useContext:ge,useEffect:on,useImperativeHandle:fn,useInsertionEffect:ln,useLayoutEffect:un,useMemo:hn,useReducer:Pt,useRef:tn,useState:function(){return Pt(jt)},useDebugValue:pn,useDeferredValue:function(e,t){var n=Et();return Hl===null?gn(n,e,t):_n(n,Hl.memoizedState,e,t)},useTransition:function(){var e=Pt(jt)[0],t=Et().memoizedState;return[typeof e==`boolean`?e:Ot(e),t]},useSyncExternalStore:Ft,useId:xn,useHostTransitionStatus:bn,useFormState:$t,useActionState:$t,useOptimistic:function(e,t){var n=Et();return Hl===null?(n.baseState=e,[e,n.queue.dispatch]):Ht(n,Hl,e,t)},useMemoCache:At,useCacheRefresh:Sn};eu.useEffectEvent=cn;var tu={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=bi(),i=$e(r);i.payload=t,n!=null&&(i.callback=n),t=et(e,i,r),t!==null&&(Si(t,e,r),tt(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=bi(),i=$e(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=et(e,i,r),t!==null&&(Si(t,e,r),tt(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=bi(),r=$e(n);r.tag=2,t!=null&&(r.callback=t),t=et(e,r,n),t!==null&&(Si(t,e,n),tt(t,e,n))}},nu=Error(r(461)),ru=!1,iu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},au=!1,ou=!1,su=!1,cu=typeof WeakSet==`function`?WeakSet:Set,lu=null,uu=null,du=!1,fu=null,pu=8192,mu={getCacheForType:function(e){var t=ge(cl),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ge(cl).controller.signal}},hu=0,gu=1,_u=2,vu=3,yu=4;if(typeof Symbol==`function`&&Symbol.for){var bu=Symbol.for;hu=bu(`selector.component`),gu=bu(`selector.has_pseudo_class`),_u=bu(`selector.role`),vu=bu(`selector.test_id`),yu=bu(`selector.text`)}var xu=typeof WeakMap==`function`?WeakMap:Map,Su=0,Cu=null,wu=null,Tu=0,Eu=0,Du=null,Ou=!1,ku=!1,Au=!1,ju=0,Mu=0,Nu=0,Pu=0,Fu=0,Iu=0,Lu=0,Ru=null,zu=null,Bu=!1,Vu=0,Hu=0,Uu=1/0,Wu=null,Gu=null,Ku=0,qu=null,Ju=null,Yu=0,Xu=0,Zu=null,Qu=null,$u=0,ed=null;return xa.attemptContinuousHydration=function(e){if(e.tag===13||e.tag===31){var t=Je(e,67108864);t!==null&&Si(t,e,67108864),ba(e,67108864)}},xa.attemptHydrationAtCurrentPriority=function(e){if(e.tag===13||e.tag===31){var t=bi();t=D(t);var n=Je(e,t);n!==null&&Si(n,e,t),ba(e,t)}},xa.attemptSynchronousHydration=function(e){switch(e.tag){case 3:if(e=e.stateNode,e.current.memoizedState.isDehydrated){var t=h(e.pendingLanes);if(t!==0){for(e.pendingLanes|=2,e.entangledLanes|=2;t;){var n=1<<31-dc(t);e.entanglements[1]|=n,t&=~n}Se(e),!(Su&6)&&(Uu=xc()+500,U(0,!1))}}break;case 31:case 13:t=Je(e,2),t!==null&&Si(t,e,2),Di(),ba(e,2)}},xa.batchedUpdates=function(e,t){return e(t)},xa.createComponentSelector=function(e){return{$$typeof:hu,value:e}},xa.createContainer=function(e,t,n,r,i,a,o,s,c,l){return ha(e,t,!1,null,n,r,a,null,o,s,c,l)},xa.createHasPseudoClassSelector=function(e){return{$$typeof:gu,value:e}},xa.createHydrationContainer=function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){return e=ha(n,r,!0,e,i,a,s,p,c,l,u,d),e.context=ga(null),n=e.current,r=bi(),r=D(r),i=$e(r),i.callback=t??null,et(n,i,r),t=r,e.current.lanes=t,S(e,t),Se(e),e},xa.createPortal=function(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Da,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}},xa.createRoleSelector=function(e){return{$$typeof:_u,value:e}},xa.createTestNameSelector=function(e){return{$$typeof:vu,value:e}},xa.createTextSelector=function(e){return{$$typeof:yu,value:e}},xa.defaultOnCaughtError=function(e){console.error(e)},xa.defaultOnRecoverableError=function(e){jc(e)},xa.defaultOnUncaughtError=function(e){jc(e)},xa.deferredUpdates=function(e){var t=Ua.T,n=mo();try{return po(32),Ua.T=null,e()}finally{po(n),Ua.T=t}},xa.discreteUpdates=function(e,t,n,r,i){var a=Ua.T,o=mo();try{return po(2),Ua.T=null,e(t,n,r,i)}finally{po(o),Ua.T=a,Su===0&&(Uu=xc()+500)}},xa.findAllNodes=yi,xa.findBoundingRects=function(e,t){if(!Ao)throw Error(r(363));t=yi(e,t),e=[];for(var n=0;n<t.length;n++)e.push(Mo(t[n]));for(t=e.length-1;0<t;t--){n=e[t];for(var i=n.x,a=i+n.width,o=n.y,s=o+n.height,c=t-1;0<=c;c--)if(t!==c){var l=e[c],u=l.x,d=u+l.width,f=l.y,p=f+l.height;if(i>=u&&o>=f&&a<=d&&s<=p){e.splice(t,1);break}else if(i!==u||n.width!==l.width||p<o||f>s){if(!(o!==f||n.height!==l.height||d<i||u>a)){u>i&&(l.width+=u-i,l.x=i),d<a&&(l.width=a-u),e.splice(t,1);break}}else{f>o&&(l.height+=f-o,l.y=o),p<s&&(l.height=s-f),e.splice(t,1);break}}}return e},xa.findHostInstance=_a,xa.findHostInstanceWithNoPortals=function(e){return e=o(e),e=e===null?null:c(e),e===null?null:qa(e.stateNode)},xa.findHostInstanceWithWarning=function(e){return _a(e)},xa.flushPassiveEffects=Yi,xa.flushSyncFromReconciler=function(e){var t=Su;Su|=1;var n=Ua.T,r=mo();try{if(po(2),Ua.T=null,e)return e()}finally{po(r),Ua.T=n,Su=t,!(Su&6)&&U(0,!1)}},xa.flushSyncWork=Di,xa.focusWithin=function(e,t){if(!Ao)throw Error(r(363));for(e=hi(e),t=vi(e,t),t=Array.from(t),e=0;e<t.length;){var n=t[e++],i=n.tag;if(!Po(n)){if((i===5||i===26||i===27)&&Io(n.stateNode))return!0;for(n=n.child;n!==null;)t.push(n),n=n.sibling}}return!1},xa.getFindAllNodesFailureDescription=function(e,t){if(!Ao)throw Error(r(363));var n=0,i=[];e=[hi(e),0];for(var a=0;a<e.length;){var o=e[a++],s=o.tag,c=e[a++],l=t[c];if((s!==5&&s!==26&&s!==27||!Po(o))&&(gi(o,l)&&(i.push(_i(l)),c++,c>n&&(n=c)),c<t.length))for(o=o.child;o!==null;)e.push(o,c),o=o.sibling}if(n<t.length){for(e=[];n<t.length;n++)e.push(_i(t[n]));return`findAllNodes was able to match part of the selector:
|
||
`+(i.join(` > `)+`
|
||
|
||
No matching component was found for:
|
||
`)+e.join(` > `)}return null},xa.getPublicRootInstance=function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 27:case 5:return qa(e.child.stateNode);default:return e.child.stateNode}},xa.injectIntoDevTools=function(){var e={bundleType:0,version:Wa,rendererPackageName:Ga,currentDispatcherRef:Ua,reconcilerVersion:`19.2.0`};if(Ka!==null&&(e.rendererConfig=Ka),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`)e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{Oc=t.inject(e),kc=t}catch{}e=!!t.checkDCE}}return e},xa.isAlreadyRendering=function(){return(Su&6)!=0},xa.observeVisibleRects=function(e,t,n,i){if(!Ao)throw Error(r(363));e=yi(e,t);var a=Lo(e,n,i).disconnect;return{disconnect:function(){a()}}},xa.shouldError=function(){return null},xa.shouldSuspend=function(){return!1},xa.startHostTransition=function(e,t,i,a){if(e.tag!==5)throw Error(r(476));var o=yn(e).queue;vn(e,o,t,To,i===null?n:function(){var t=yn(e);return t.next===null&&(t=e.alternate.memoizedState),En(e,t.next.queue,{},bi()),i(a)})},xa.updateContainer=function(e,t,n,r){var i=t.current,a=bi();return va(i,a,e,t,n,r),a},xa.updateContainerSync=function(e,t,n,r){return va(t.current,2,e,t,n,r),2},xa},e.exports.default=e.exports,Object.defineProperty(e.exports,"__esModule",{value:!0})}(U_)),U_.exports}({exports:{}}).exports;var K_;function q_(){return K_||(K_=1,H_.exports=G_()),H_.exports}var J_=V_(q_());function Y_(e){let t=J_(e);return t.injectIntoDevTools(),t}var X_=0,Z_={},Q_=/^three(?=[A-Z])/,$_=e=>`${e[0].toUpperCase()}${e.slice(1)}`,ev=0,tv=e=>typeof e==`function`;function nv(e){if(tv(e)){let t=`${ev++}`;return Z_[t]=e,t}else Object.assign(Z_,e)}function rv(e,t){let n=$_(e),r=Z_[n];if(e!==`primitive`&&!r)throw Error(`R3F: ${n} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(e===`primitive`&&!t.object)throw Error(`R3F: Primitives without 'object' are invalid!`);if(t.args!==void 0&&!Array.isArray(t.args))throw Error(`R3F: The args prop must be an array!`)}function iv(e,t,n){var r;return e=$_(e)in Z_?e:e.replace(Q_,``),rv(e,t),e===`primitive`&&(r=t.object)!=null&&r.__r3f&&delete t.object.__r3f,o_(t.object,n,e,t)}function av(e){if(!e.isHidden){var t;e.props.attach&&(t=e.parent)!=null&&t.object?u_(e.parent,e):b_(e.object)&&(e.object.visible=!1),e.isHidden=!0,v_(e)}}function ov(e){if(e.isHidden){var t;e.props.attach&&(t=e.parent)!=null&&t.object?l_(e.parent,e):b_(e.object)&&e.props.visible!==!1&&(e.object.visible=!0),e.isHidden=!1,v_(e)}}function sv(e,t,n){let r=t.root.getState();if(!(!e.parent&&e.object!==r.scene)){if(!t.object){let e=Z_[$_(t.type)];t.object=t.props.object??new e(...t.props.args??[]),t.object.__r3f=t}if(__(t.object,t.props),t.props.attach)l_(e,t);else if(b_(t.object)&&b_(e.object)){let r=e.object.children.indexOf(n?.object);if(n&&r!==-1){let n=e.object.children.indexOf(t.object);if(n!==-1){e.object.children.splice(n,1);let i=n<r?r-1:r;e.object.children.splice(i,0,t.object)}else t.object.parent=e.object,e.object.children.splice(r,0,t.object),t.object.dispatchEvent({type:`added`}),e.object.dispatchEvent({type:`childadded`,child:t.object})}else e.object.add(t.object)}for(let e of t.children)sv(t,e);v_(t)}}function cv(e,t){t&&(t.parent=e,e.children.push(t),sv(e,t))}function lv(e,t,n){if(!t||!n)return;t.parent=e;let r=e.children.indexOf(n);r===-1?e.children.push(t):e.children.splice(r,0,t),sv(e,t,n)}function uv(e){if(typeof e.dispose==`function`){let t=()=>{try{e.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<`u`?t():(0,Pg.unstable_scheduleCallback)(Pg.unstable_IdlePriority,t)}}function dv(e,t,n){if(!t)return;t.parent=null;let r=e.children.indexOf(t);r!==-1&&e.children.splice(r,1),t.props.attach?u_(e,t):b_(t.object)&&b_(e.object)&&(e.object.remove(t.object),w_(Wg(t),t.object));let i=t.props.dispose!==null&&n!==!1;for(let e=t.children.length-1;e>=0;e--){let n=t.children[e];dv(t,n,i)}t.children.length=0,delete t.object.__r3f,i&&t.type!==`primitive`&&t.object.type!==`Scene`&&uv(t.object),n===void 0&&v_(t)}function fv(e,t){for(let n of[e,e.alternate])if(n!==null)if(typeof n.ref==`function`){n.refCleanup==null||n.refCleanup();let e=n.ref(t);typeof e==`function`&&(n.refCleanup=e)}else n.ref&&(n.ref.current=t)}var pv=[];function mv(){for(let[e]of pv){let t=e.parent;if(t){e.props.attach?u_(t,e):b_(e.object)&&b_(t.object)&&t.object.remove(e.object);for(let t of e.children)t.props.attach?u_(e,t):b_(t.object)&&b_(e.object)&&e.object.remove(t.object)}e.isHidden&&ov(e),e.object.__r3f&&delete e.object.__r3f,e.type!==`primitive`&&uv(e.object)}for(let[e,t,n]of pv){e.props=t;let r=e.parent;if(r){let t=Z_[$_(e.type)],i=e.object;e.object=e.props.object??new t(...e.props.args??[]),e.object.__r3f=e,fv(n,e.object),C_(Wg(e),i,e.object),__(e.object,e.props),e.props.attach?l_(r,e):b_(e.object)&&b_(r.object)&&r.object.add(e.object);for(let t of e.children)t.props.attach?l_(e,t):b_(t.object)&&b_(e.object)&&e.object.add(t.object);v_(e)}}pv.length=0}var hv=()=>{},gv={},_v=X_,vv=0,yv=4,bv=Y_({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:iv,removeChild:dv,appendChild:cv,appendInitialChild:cv,insertBefore:lv,appendChildToContainer(e,t){let n=e.getState().scene.__r3f;!t||!n||cv(n,t)},removeChildFromContainer(e,t){let n=e.getState().scene.__r3f;!t||!n||dv(n,t)},insertInContainerBefore(e,t,n){let r=e.getState().scene.__r3f;!t||!n||!r||lv(r,t,n)},getRootHostContext:()=>gv,getChildHostContext:()=>gv,commitUpdate(e,t,n,r,i){var a;rv(t,r);let o=!1;if(e.type===`primitive`&&n.object!==r.object?o=!0:r.args?.length===n.args?.length?(a=r.args)!=null&&a.some((e,t)=>e!==n.args?.[t])&&(o=!0):o=!0,o)pv.push([e,{...r},i]);else{let t=m_(e,r);Object.keys(t).length&&(Object.assign(e.props,t),__(e.object,t))}(i.sibling===null||(i.flags&yv)===vv)&&mv()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:e=>e?.object,prepareForCommit:()=>null,preparePortalMount:e=>o_(e.getState().scene,e,``,{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:av,unhideInstance:ov,createTextInstance:hv,hideTextInstance:hv,unhideTextInstance:hv,scheduleTimeout:typeof setTimeout==`function`?setTimeout:void 0,cancelTimeout:typeof clearTimeout==`function`?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:v.createContext(null),setCurrentUpdatePriority(e){_v=e},getCurrentUpdatePriority(){return _v},resolveUpdatePriority(){if(_v!==X_)return _v;switch(typeof window<`u`&&window.event?.type){case`click`:case`contextmenu`:case`dblclick`:case`pointercancel`:case`pointerdown`:case`pointerup`:return z_;case`pointermove`:case`pointerout`:case`pointerover`:case`pointerenter`:case`pointerleave`:case`wheel`:return L_;default:return R_}},resetFormInstance(){},rendererPackageName:`@react-three/fiber`,rendererVersion:B_.version,applyViewTransitionName(e,t,n){},restoreViewTransitionName(e,t){},cancelViewTransitionName(e,t,n){},cancelRootViewTransitionName(e){},restoreRootViewTransitionName(e){},InstanceMeasurement:null,measureInstance:e=>null,wasInstanceInViewport:e=>!0,hasInstanceChanged:(e,t)=>!1,hasInstanceAffectedParent:(e,t)=>!1,suspendOnActiveViewTransition(e,t){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(e){},createViewTransitionInstance:e=>null,getCurrentGestureOffset(e){throw Error(`startGestureTransition is not yet supported in react-three-fiber.`)},cloneMutableInstance(e,t){return e},cloneMutableTextInstance(e){return e},cloneRootViewTransitionContainer(e){throw Error(`Not implemented.`)},removeRootViewTransitionClone(e,t){throw Error(`Not implemented.`)},createFragmentInstance:e=>null,updateFragmentInstanceFiber(e,t){},commitNewChildToFragmentInstance(e,t){},deleteChildFromFragmentInstance(e,t){},measureClonedInstance:e=>null,maySuspendCommitOnUpdate:(e,t,n)=>!1,maySuspendCommitInSyncRender:(e,t)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(e,t)=>null}),xv=new Map,Sv={objects:`shallow`,strict:!1};function Cv(e,t){if(!t&&typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement&&e.parentElement){let{width:t,height:n,top:r,left:i}=e.parentElement.getBoundingClientRect();return{width:t,height:n,top:r,left:i}}else if(!t&&typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...t}}function wv(e){let t=xv.get(e),n=t?.fiber,r=t?.store;t&&console.warn(`R3F.createRoot should only be called once!`);let i=typeof reportError==`function`?reportError:console.error,a=r||O_(Uv,Wv),o=n||bv.createContainer(a,I_,null,!1,null,``,i,i,i,null);t||xv.set(e,{fiber:o,store:a});let s,c,l=!1,u=null;return{async configure(t={}){let n;u=new Promise(e=>n=e);let{gl:r,size:i,scene:o,events:d,onCreated:f,shadows:p=!1,linear:m=!1,flat:h=!1,legacy:g=!1,orthographic:_=!1,frameloop:v=`always`,dpr:y=[1,2],performance:b,raycaster:x,camera:S,onPointerMissed:C}=t,w=a.getState(),T=w.gl;if(!w.gl){let t={canvas:e,powerPreference:`high-performance`,antialias:!0,alpha:!0},n=typeof r==`function`?await r(t):r;T=E_(n)?n:new pg({...t,...r}),w.set({gl:T})}let E=w.raycaster;E||w.set({raycaster:E=new qd});let{params:D,...O}=x||{};if(t_.equ(O,E,Sv)||__(E,{...O}),t_.equ(D,E.params,Sv)||__(E,{params:{...E.params,...D}}),!w.camera||w.camera===c&&!t_.equ(c,S,Sv)){c=S;let e=S?.isCamera,t=e?S:_?new Nu(0,0,0,0,.1,1e3):new Ou(75,0,.1,1e3);e||(t.position.z=5,S&&(__(t,S),t.manual||(`aspect`in S||`left`in S||`right`in S||`bottom`in S||`top`in S)&&(t.manual=!0,t.updateProjectionMatrix())),!w.camera&&!(S!=null&&S.rotation)&&t.lookAt(0,0,0)),w.set({camera:t}),E.camera=t}if(!w.scene){let e;o!=null&&o.isScene?(e=o,o_(e,a,``,{})):(e=new Vr,o_(e,a,``,{}),o&&__(e,o)),w.set({scene:e})}d&&!w.events.handlers&&w.set({events:d(a)});let k=Cv(e,i);if(t_.equ(k,w.size,Sv)||w.setSize(k.width,k.height,k.top,k.left),y&&w.viewport.dpr!==$g(y)&&w.setDpr(y),w.frameloop!==v&&w.setFrameloop(v),w.onPointerMissed||w.set({onPointerMissed:C}),b&&!t_.equ(b,w.performance,Sv)&&w.set(e=>({performance:{...e.performance,...b}})),!w.xr){let e=(e,t)=>{let n=a.getState();n.frameloop!==`never`&&Wv(e,!0,n,t)},t=()=>{let t=a.getState();t.gl.xr.enabled=t.gl.xr.isPresenting,t.gl.xr.setAnimationLoop(t.gl.xr.isPresenting?e:null),t.gl.xr.isPresenting||Uv(t)},n={connect(){let e=a.getState().gl;e.xr.addEventListener(`sessionstart`,t),e.xr.addEventListener(`sessionend`,t)},disconnect(){let e=a.getState().gl;e.xr.removeEventListener(`sessionstart`,t),e.xr.removeEventListener(`sessionend`,t)}};typeof T.xr?.addEventListener==`function`&&n.connect(),w.set({xr:n})}if(T.shadowMap){let e=T.shadowMap.enabled,t=T.shadowMap.type;if(T.shadowMap.enabled=!!p,t_.boo(p))T.shadowMap.type=2;else if(t_.str(p)){let e={basic:0,percentage:1,soft:2,variance:3};T.shadowMap.type=e[p]??2}else t_.obj(p)&&Object.assign(T.shadowMap,p);(e!==T.shadowMap.enabled||t!==T.shadowMap.type)&&(T.shadowMap.needsUpdate=!0)}return Bn.enabled=!g,l||(T.outputColorSpace=m?ht:mt,T.toneMapping=h?0:4),w.legacy!==g&&w.set(()=>({legacy:g})),w.linear!==m&&w.set(()=>({linear:m})),w.flat!==h&&w.set(()=>({flat:h})),r&&!t_.fun(r)&&!E_(r)&&!t_.equ(r,T,Sv)&&__(T,r),s=f,l=!0,n(),this},render(t){return!l&&!u&&this.configure(),u.then(()=>{bv.updateContainer((0,Z.jsx)(Tv,{store:a,children:t,onCreated:s,rootElement:e}),o,null,()=>void 0)}),a},unmount(){Ev(e)}}}function Tv({store:e,children:t,onCreated:n,rootElement:r}){return Jg(()=>{let t=e.getState();t.set(e=>({internal:{...e.internal,active:!0}})),n&&n(t),e.getState().events.connected||t.events.connect==null||t.events.connect(r)},[]),(0,Z.jsx)(D_.Provider,{value:e,children:t})}function Ev(e,t){let n=xv.get(e),r=n?.fiber;if(r){let i=n?.store.getState();i&&(i.internal.active=!1),bv.updateContainer(null,r,null,()=>{i&&setTimeout(()=>{try{var n,r,a,o;i.events.disconnect==null||i.events.disconnect(),(n=i.gl)==null||(r=n.renderLists)==null||r.dispose==null||r.dispose(),(a=i.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(o=i.gl)!=null&&o.xr&&i.xr.disconnect(),r_(i.scene),xv.delete(e),t&&t(e)}catch{}},500)})}}function Dv(e,t,n){return(0,Z.jsx)(Ov,{children:e,container:t,state:n})}function Ov({state:e={},children:t,container:n}){let{events:r,size:i,...a}=e,o=k_(),[s]=v.useState(()=>new qd),[c]=v.useState(()=>new K),l=Yg((e,t)=>{let a;if(t.camera&&i){let n=t.camera;a=e.viewport.getCurrentViewport(n,new q,i),n!==e.camera&&y_(n,i)}return{...e,...t,scene:n,raycaster:s,pointer:c,mouse:c,previousRoot:o,events:{...e.events,...t.events,...r},size:{...e.size,...i},viewport:{...e.viewport,...a},setEvents:e=>t.set(t=>({...t,events:{...t.events,...e}}))}}),u=v.useMemo(()=>{let e=wg((e,t)=>({...a,set:e,get:t})),t=t=>e.setState(e=>l.current(t,e));return t(o.getState()),o.subscribe(t),e},[o,n]);return(0,Z.jsx)(Z.Fragment,{children:bv.createPortal((0,Z.jsx)(D_.Provider,{value:u,children:t}),u,null)})}var kv=new Set,Av=new Set,jv=new Set;function Mv(e,t){if(e.size)for(let{callback:n}of e.values())n(t)}function Nv(e,t){switch(e){case`before`:return Mv(kv,t);case`after`:return Mv(Av,t);case`tail`:return Mv(jv,t)}}var Pv,Fv;function Iv(e,t,n){let r=t.clock.getDelta();t.frameloop===`never`&&typeof e==`number`&&(r=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),Pv=t.internal.subscribers;for(let e=0;e<Pv.length;e++)Fv=Pv[e],Fv.ref.current(Fv.store.getState(),r,n);return!t.internal.priority&&t.gl.render&&t.gl.render(t.scene,t.camera),t.internal.frames=Math.max(0,t.internal.frames-1),t.frameloop===`always`?1:t.internal.frames}var Lv=!1,Rv=!1,zv,Bv,Vv;function Hv(e){Bv=requestAnimationFrame(Hv),Lv=!0,zv=0,Nv(`before`,e),Rv=!0;for(let n of xv.values()){var t;Vv=n.store.getState(),Vv.internal.active&&(Vv.frameloop===`always`||Vv.internal.frames>0)&&!((t=Vv.gl.xr)!=null&&t.isPresenting)&&(zv+=Iv(e,Vv))}if(Rv=!1,Nv(`after`,e),zv===0)return Nv(`tail`,e),Lv=!1,cancelAnimationFrame(Bv)}function Uv(e,t=1){var n;if(!e)return xv.forEach(e=>Uv(e.store.getState(),t));(n=e.gl.xr)!=null&&n.isPresenting||!e.internal.active||e.frameloop===`never`||(t>1?e.internal.frames=Math.min(60,e.internal.frames+t):Rv?e.internal.frames=2:e.internal.frames=1,Lv||(Lv=!0,requestAnimationFrame(Hv)))}function Wv(e,t=!0,n,r){if(t&&Nv(`before`,e),n)Iv(e,n,r);else for(let t of xv.values())Iv(e,t.store.getState());t&&Nv(`after`,e)}var Gv={onClick:[`click`,!1],onContextMenu:[`contextmenu`,!1],onDoubleClick:[`dblclick`,!1],onWheel:[`wheel`,!0],onPointerDown:[`pointerdown`,!0],onPointerUp:[`pointerup`,!0],onPointerLeave:[`pointerleave`,!0],onPointerMove:[`pointermove`,!0],onPointerCancel:[`pointercancel`,!0],onLostPointerCapture:[`lostpointercapture`,!0]};function Kv(e){let{handlePointer:t}=T_(e);return{priority:1,enabled:!0,compute(e,t,n){t.pointer.set(e.offsetX/t.size.width*2-1,-(e.offsetY/t.size.height)*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)},connected:void 0,handlers:Object.keys(Gv).reduce((e,n)=>({...e,[n]:t(n)}),{}),update:()=>{var t;let{events:n,internal:r}=e.getState();(t=r.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{let{set:n,events:r}=e.getState();if(r.disconnect==null||r.disconnect(),n(e=>({events:{...e.events,connected:t}})),r.handlers)for(let e in r.handlers){let n=r.handlers[e],[i,a]=Gv[e];t.addEventListener(i,n,{passive:a})}},disconnect:()=>{let{set:t,events:n}=e.getState();if(n.connected){if(n.handlers)for(let e in n.handlers){let t=n.handlers[e],[r]=Gv[e];n.connected.removeEventListener(r,t)}t(e=>({events:{...e.events,connected:void 0}}))}}}}function qv(e,t){let n;return(...r)=>{window.clearTimeout(n),n=window.setTimeout(()=>e(...r),t)}}function Jv({debounce:e,scroll:t,polyfill:n,offsetSize:r}={debounce:0,scroll:!1,offsetSize:!1}){let i=n||(typeof window>`u`?class{}:window.ResizeObserver);if(!i)throw Error(`This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills`);let[a,o]=(0,v.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),s=(0,v.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),c=e?typeof e==`number`?e:e.scroll:null,l=e?typeof e==`number`?e:e.resize:null,u=(0,v.useRef)(!1);(0,v.useEffect)(()=>(u.current=!0,()=>void(u.current=!1)));let[d,f,p]=(0,v.useMemo)(()=>{let e=()=>{if(!s.current.element)return;let{left:e,top:t,width:n,height:i,bottom:a,right:c,x:l,y:d}=s.current.element.getBoundingClientRect(),f={left:e,top:t,width:n,height:i,bottom:a,right:c,x:l,y:d};s.current.element instanceof HTMLElement&&r&&(f.height=s.current.element.offsetHeight,f.width=s.current.element.offsetWidth),Object.freeze(f),u.current&&!$v(s.current.lastBounds,f)&&o(s.current.lastBounds=f)};return[e,l?qv(e,l):e,c?qv(e,c):e]},[o,r,c,l]);function m(){s.current.scrollContainers&&(s.current.scrollContainers.forEach(e=>e.removeEventListener(`scroll`,p,!0)),s.current.scrollContainers=null),s.current.resizeObserver&&(s.current.resizeObserver.disconnect(),s.current.resizeObserver=null),s.current.orientationHandler&&(`orientation`in screen&&`removeEventListener`in screen.orientation?screen.orientation.removeEventListener(`change`,s.current.orientationHandler):`onorientationchange`in window&&window.removeEventListener(`orientationchange`,s.current.orientationHandler))}function h(){s.current.element&&(s.current.resizeObserver=new i(p),s.current.resizeObserver.observe(s.current.element),t&&s.current.scrollContainers&&s.current.scrollContainers.forEach(e=>e.addEventListener(`scroll`,p,{capture:!0,passive:!0})),s.current.orientationHandler=()=>{p()},`orientation`in screen&&`addEventListener`in screen.orientation?screen.orientation.addEventListener(`change`,s.current.orientationHandler):`onorientationchange`in window&&window.addEventListener(`orientationchange`,s.current.orientationHandler))}return Xv(p,!!t),Yv(f),(0,v.useEffect)(()=>{m(),h()},[t,p,f]),(0,v.useEffect)(()=>m,[]),[e=>{!e||e===s.current.element||(m(),s.current.element=e,s.current.scrollContainers=Zv(e),h())},a,d]}function Yv(e){(0,v.useEffect)(()=>{let t=e;return window.addEventListener(`resize`,t),()=>void window.removeEventListener(`resize`,t)},[e])}function Xv(e,t){(0,v.useEffect)(()=>{if(t){let t=e;return window.addEventListener(`scroll`,t,{capture:!0,passive:!0}),()=>void window.removeEventListener(`scroll`,t,!0)}},[e,t])}function Zv(e){let t=[];if(!e||e===document.body)return t;let{overflow:n,overflowX:r,overflowY:i}=window.getComputedStyle(e);return[n,r,i].some(e=>e===`auto`||e===`scroll`)&&t.push(e),[...t,...Zv(e.parentElement)]}var Qv=[`x`,`y`,`top`,`bottom`,`left`,`right`,`width`,`height`],$v=(e,t)=>Qv.every(n=>e[n]===t[n]);function ey({ref:e,children:t,fallback:n,resize:r,style:i,gl:a,events:o=Kv,eventSource:s,eventPrefix:c,shadows:l,linear:u,flat:d,legacy:f,orthographic:p,frameloop:m,dpr:h,performance:g,raycaster:_,camera:y,scene:b,onPointerMissed:x,onCreated:S,...C}){v.useMemo(()=>nv(Xf),[]);let w=Xg(),[T,E]=Jv({scroll:!0,debounce:{scroll:50,resize:0},...r}),D=v.useRef(null),O=v.useRef(null);v.useImperativeHandle(e,()=>D.current);let k=Yg(x),[A,j]=v.useState(!1),[M,N]=v.useState(!1);if(A)throw A;if(M)throw M;let P=v.useRef(null);return Jg(()=>{let e=D.current;if(E.width>0&&E.height>0&&e){P.current||=wv(e);async function n(){await P.current.configure({gl:a,scene:b,events:o,shadows:l,linear:u,flat:d,legacy:f,orthographic:p,frameloop:m,dpr:h,performance:g,raycaster:_,camera:y,size:E,onPointerMissed:(...e)=>k.current==null?void 0:k.current(...e),onCreated:e=>{e.events.connect==null||e.events.connect(s?Kg(s)?s.current:s:O.current),c&&e.setEvents({compute:(e,t)=>{let n=e[c+`X`],r=e[c+`Y`];t.pointer.set(n/t.size.width*2-1,-(r/t.size.height)*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),S?.(e)}}),P.current.render((0,Z.jsx)(w,{children:(0,Z.jsx)(Qg,{set:N,children:(0,Z.jsx)(v.Suspense,{fallback:(0,Z.jsx)(Zg,{set:j}),children:t??null})})}))}n()}}),v.useEffect(()=>{let e=D.current;if(e)return()=>Ev(e)},[]),(0,Z.jsx)(`div`,{ref:O,style:{position:`relative`,width:`100%`,height:`100%`,overflow:`hidden`,pointerEvents:s?`none`:`auto`,...i},...C,children:(0,Z.jsx)(`div`,{ref:T,style:{width:`100%`,height:`100%`},children:(0,Z.jsx)(`canvas`,{ref:D,style:{display:`block`},children:n})})})}function ty(e){return(0,Z.jsx)(Rg,{children:(0,Z.jsx)(ey,{...e})})}function ny(){return ny=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ny.apply(null,arguments)}var ry=new q,iy=new q,ay=new q,oy=new K;function sy(e,t,n){let r=ry.setFromMatrixPosition(e.matrixWorld);r.project(t);let i=n.width/2,a=n.height/2;return[r.x*i+i,-(r.y*a)+a]}function cy(e,t){let n=ry.setFromMatrixPosition(e.matrixWorld),r=iy.setFromMatrixPosition(t.matrixWorld),i=n.sub(r),a=t.getWorldDirection(ay);return i.angleTo(a)>Math.PI/2}function ly(e,t,n,r){let i=ry.setFromMatrixPosition(e.matrixWorld),a=i.clone();a.project(t),oy.set(a.x,a.y),n.setFromCamera(oy,t);let o=n.intersectObjects(r,!0);if(o.length){let e=o[0].distance;return i.distanceTo(n.ray.origin)<e}return!0}function uy(e,t){if(t instanceof Nu)return t.zoom;if(t instanceof Ou){let n=ry.setFromMatrixPosition(e.matrixWorld),r=iy.setFromMatrixPosition(t.matrixWorld),i=t.fov*Math.PI/180,a=n.distanceTo(r);return 1/(2*Math.tan(i/2)*a)}else return 1}function dy(e,t,n){if(t instanceof Ou||t instanceof Nu){let r=ry.setFromMatrixPosition(e.matrixWorld),i=iy.setFromMatrixPosition(t.matrixWorld),a=r.distanceTo(i),o=(n[1]-n[0])/(t.far-t.near),s=n[1]-o*t.far;return Math.round(o*a+s)}}var fy=e=>Math.abs(e)<1e-10?0:e;function py(e,t,n=``){let r=`matrix3d(`;for(let n=0;n!==16;n++)r+=fy(t[n]*e.elements[n])+(n===15?`)`:`,`);return n+r}var my=(e=>t=>py(t,e))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),hy=(e=>(t,n)=>py(t,e(n),`translate(-50%,-50%)`))(e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1]);function gy(e){return e&&typeof e==`object`&&`current`in e}var _y=v.forwardRef(({children:e,eps:t=.001,style:n,className:r,prepend:i,center:a,fullscreen:o,portal:s,distanceFactor:c,sprite:l=!1,transform:u=!1,occlude:d,onOcclude:f,castShadow:p,receiveShadow:m,material:h,geometry:g,zIndexRange:_=[16777271,0],calculatePosition:b=sy,as:x=`div`,wrapperClass:S,pointerEvents:C=`auto`,...w},T)=>{let{gl:E,camera:D,scene:O,size:k,raycaster:A,events:j,viewport:M}=A_(),[N]=v.useState(()=>document.createElement(x)),P=v.useRef(null),F=v.useRef(null),I=v.useRef(0),L=v.useRef([0,0]),ee=v.useRef(null),R=v.useRef(null),te=s?.current||j.connected||E.domElement.parentNode,z=v.useRef(null),B=v.useRef(!1),V=v.useMemo(()=>d&&d!==`blending`||Array.isArray(d)&&d.length&&gy(d[0]),[d]);v.useLayoutEffect(()=>{let e=E.domElement;d&&d===`blending`?(e.style.zIndex=`${Math.floor(_[0]/2)}`,e.style.position=`absolute`,e.style.pointerEvents=`none`):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)},[d]),v.useLayoutEffect(()=>{if(F.current){let e=P.current=y.createRoot(N);if(O.updateMatrixWorld(),u)N.style.cssText=`position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;`;else{let e=b(F.current,D,k);N.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return te&&(i?te.prepend(N):te.appendChild(N)),()=>{te&&te.removeChild(N),e.unmount()}}},[te,u]),v.useLayoutEffect(()=>{S&&(N.className=S)},[S]);let ne=v.useMemo(()=>u?{position:`absolute`,top:0,left:0,width:k.width,height:k.height,transformStyle:`preserve-3d`,pointerEvents:`none`}:{position:`absolute`,transform:a?`translate3d(-50%,-50%,0)`:`none`,...o&&{top:-k.height/2,left:-k.width/2,width:k.width,height:k.height},...n},[n,a,o,k,u]),re=v.useMemo(()=>({position:`absolute`,pointerEvents:C}),[C]);v.useLayoutEffect(()=>{if(B.current=!1,u){var t;(t=P.current)==null||t.render(v.createElement(`div`,{ref:ee,style:ne},v.createElement(`div`,{ref:R,style:re},v.createElement(`div`,{ref:T,className:r,style:n,children:e}))))}else{var i;(i=P.current)==null||i.render(v.createElement(`div`,{ref:T,style:ne,className:r,children:e}))}});let ie=v.useRef(!0);j_(e=>{if(F.current){D.updateMatrixWorld(),F.current.updateWorldMatrix(!0,!1);let e=u?L.current:b(F.current,D,k);if(u||Math.abs(I.current-D.zoom)>t||Math.abs(L.current[0]-e[0])>t||Math.abs(L.current[1]-e[1])>t){let t=cy(F.current,D),n=!1;V&&(Array.isArray(d)?n=d.map(e=>e.current):d!==`blending`&&(n=[O]));let r=ie.current;n?ie.current=ly(F.current,D,A,n)&&!t:ie.current=!t,r!==ie.current&&(f?f(!ie.current):N.style.display=ie.current?`block`:`none`);let i=Math.floor(_[0]/2),a=d?V?[_[0],i]:[i-1,0]:_;if(N.style.zIndex=`${dy(F.current,D,a)}`,u){let[e,t]=[k.width/2,k.height/2],n=D.projectionMatrix.elements[5]*t,{isOrthographicCamera:r,top:i,left:a,bottom:o,right:s}=D,u=my(D.matrixWorldInverse),d=r?`scale(${n})translate(${fy(-(s+a)/2)}px,${fy((i+o)/2)}px)`:`translateZ(${n}px)`,f=F.current.matrixWorld;l&&(f=D.matrixWorldInverse.clone().transpose().copyPosition(f).scale(F.current.scale),f.elements[3]=f.elements[7]=f.elements[11]=0,f.elements[15]=1),N.style.width=k.width+`px`,N.style.height=k.height+`px`,N.style.perspective=r?``:`${n}px`,ee.current&&R.current&&(ee.current.style.transform=`${d}${u}translate(${e}px,${t}px)`,R.current.style.transform=hy(f,1/((c||10)/400)))}else{let t=c===void 0?1:uy(F.current,D)*c;N.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}L.current=e,I.current=D.zoom}}if(!V&&z.current&&!B.current)if(u){if(ee.current){let e=ee.current.children[0];if(e!=null&&e.clientWidth&&e!=null&&e.clientHeight){let{isOrthographicCamera:t}=D;if(t||g)w.scale&&(Array.isArray(w.scale)?w.scale instanceof q?z.current.scale.copy(w.scale.clone().divideScalar(1)):z.current.scale.set(1/w.scale[0],1/w.scale[1],1/w.scale[2]):z.current.scale.setScalar(1/w.scale));else{let t=(c||10)/400,n=e.clientWidth*t,r=e.clientHeight*t;z.current.scale.set(n,r,1)}B.current=!0}}}else{let t=N.children[0];if(t!=null&&t.clientWidth&&t!=null&&t.clientHeight){let e=1/M.factor,n=t.clientWidth*e,r=t.clientHeight*e;z.current.scale.set(n,r,1),B.current=!0}z.current.lookAt(e.camera.position)}});let ae=v.useMemo(()=>({vertexShader:u?void 0:`
|
||
/*
|
||
This shader is from the THREE's SpriteMaterial.
|
||
We need to turn the backing plane into a Sprite
|
||
(make it always face the camera) if "transfrom"
|
||
is false.
|
||
*/
|
||
#include <common>
|
||
|
||
void main() {
|
||
vec2 center = vec2(0., 1.);
|
||
float rotation = 0.0;
|
||
|
||
// This is somewhat arbitrary, but it seems to work well
|
||
// Need to figure out how to derive this dynamically if it even matters
|
||
float size = 0.03;
|
||
|
||
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
||
vec2 scale;
|
||
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
||
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
||
|
||
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
||
if ( isPerspective ) scale *= - mvPosition.z;
|
||
|
||
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
|
||
vec2 rotatedPosition;
|
||
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
||
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
||
mvPosition.xy += rotatedPosition;
|
||
|
||
gl_Position = projectionMatrix * mvPosition;
|
||
}
|
||
`,fragmentShader:`
|
||
void main() {
|
||
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||
}
|
||
`}),[u]);return v.createElement(`group`,ny({},w,{ref:F}),d&&!V&&v.createElement(`mesh`,{castShadow:p,receiveShadow:m,ref:z},g||v.createElement(`planeGeometry`,null),h||v.createElement(`shaderMaterial`,{side:2,vertexShader:ae.vertexShader,fragmentShader:ae.fragmentShader})))});function vy(e,t=`pointer`,n=`auto`,r=document.body){v.useEffect(()=>{if(e)return r.style.cursor=t,()=>void(r.style.cursor=n)},[e])}var yy=e=>e;function by(e,t=yy){let n=v.useSyncExternalStore(e.subscribe,v.useCallback(()=>t(e.getState()),[e,t]),v.useCallback(()=>t(e.getInitialState()),[e,t]));return v.useDebugValue(n),n}var xy=e=>{let t=yg(e),n=e=>by(t,e);return Object.assign(n,t),n},Sy=(e=>e?xy(e):xy),Cy=parseInt(`184`.replace(/\D+/g,``)),wy=Cy>=125?`uv1`:`uv2`,Ty=Object.defineProperty,Ey=(e,t,n)=>t in e?Ty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dy=(e,t,n)=>(Ey(e,typeof t==`symbol`?t:t+``,n),n),Oy=class{constructor(){Dy(this,`_listeners`)}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);e.target=null}}},ky=Object.defineProperty,Ay=(e,t,n)=>t in e?ky(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jy=(e,t,n)=>(Ay(e,typeof t==`symbol`?t:t+``,n),n),My=new wa,Ny=new mo,Py=Math.cos(Math.PI/180*70),Fy=(e,t)=>(e%t+t)%t,Iy=class extends Oy{constructor(e,t){super(),jy(this,`object`),jy(this,`domElement`),jy(this,`enabled`,!0),jy(this,`target`,new q),jy(this,`minDistance`,0),jy(this,`maxDistance`,1/0),jy(this,`minZoom`,0),jy(this,`maxZoom`,1/0),jy(this,`minPolarAngle`,0),jy(this,`maxPolarAngle`,Math.PI),jy(this,`minAzimuthAngle`,-1/0),jy(this,`maxAzimuthAngle`,1/0),jy(this,`enableDamping`,!1),jy(this,`dampingFactor`,.05),jy(this,`enableZoom`,!0),jy(this,`zoomSpeed`,1),jy(this,`enableRotate`,!0),jy(this,`rotateSpeed`,1),jy(this,`enablePan`,!0),jy(this,`panSpeed`,1),jy(this,`screenSpacePanning`,!0),jy(this,`keyPanSpeed`,7),jy(this,`zoomToCursor`,!1),jy(this,`autoRotate`,!1),jy(this,`autoRotateSpeed`,2),jy(this,`reverseOrbit`,!1),jy(this,`reverseHorizontalOrbit`,!1),jy(this,`reverseVerticalOrbit`,!1),jy(this,`keys`,{LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`}),jy(this,`mouseButtons`,{LEFT:b.ROTATE,MIDDLE:b.DOLLY,RIGHT:b.PAN}),jy(this,`touches`,{ONE:x.ROTATE,TWO:x.DOLLY_PAN}),jy(this,`target0`),jy(this,`position0`),jy(this,`zoom0`),jy(this,`_domElementKeyEvents`,null),jy(this,`getPolarAngle`),jy(this,`getAzimuthalAngle`),jy(this,`setPolarAngle`),jy(this,`setAzimuthalAngle`),jy(this,`getDistance`),jy(this,`getZoomScale`),jy(this,`listenToKeyEvents`),jy(this,`stopListenToKeyEvents`),jy(this,`saveState`),jy(this,`reset`),jy(this,`update`),jy(this,`connect`),jy(this,`dispose`),jy(this,`dollyIn`),jy(this,`dollyOut`),jy(this,`getScale`),jy(this,`setScale`),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>l.phi,this.getAzimuthalAngle=()=>l.theta,this.setPolarAngle=e=>{let t=Fy(e,2*Math.PI),r=l.phi;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i<i&&(t<r?t+=2*Math.PI:r+=2*Math.PI),u.phi=t-r,n.update()},this.setAzimuthalAngle=e=>{let t=Fy(e,2*Math.PI),r=l.theta;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i<i&&(t<r?t+=2*Math.PI:r+=2*Math.PI),u.theta=t-r,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=e=>{e.addEventListener(`keydown`,Se),this._domElementKeyEvents=e},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener(`keydown`,Se),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),s=o.NONE},this.update=(()=>{let t=new q,i=new q(0,1,0),a=new Mn().setFromUnitVectors(e.up,i),p=a.clone().invert(),m=new q,h=new Mn,g=2*Math.PI;return function(){let _=n.object.position;a.setFromUnitVectors(e.up,i),p.copy(a).invert(),t.copy(_).sub(n.target),t.applyQuaternion(a),l.setFromVector3(t),n.autoRotate&&s===o.NONE&&j(k()),n.enableDamping?(l.theta+=u.theta*n.dampingFactor,l.phi+=u.phi*n.dampingFactor):(l.theta+=u.theta,l.phi+=u.phi);let v=n.minAzimuthAngle,y=n.maxAzimuthAngle;isFinite(v)&&isFinite(y)&&(v<-Math.PI?v+=g:v>Math.PI&&(v-=g),y<-Math.PI?y+=g:y>Math.PI&&(y-=g),v<=y?l.theta=Math.max(v,Math.min(y,l.theta)):l.theta=l.theta>(v+y)/2?Math.max(v,l.theta):Math.min(y,l.theta)),l.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,l.phi)),l.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(f,n.dampingFactor):n.target.add(f),n.zoomToCursor&&E||n.object.isOrthographicCamera?l.radius=te(l.radius):l.radius=te(l.radius*d),t.setFromSpherical(l),t.applyQuaternion(p),_.copy(n.target).add(t),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(u.theta*=1-n.dampingFactor,u.phi*=1-n.dampingFactor,f.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),f.set(0,0,0));let b=!1;if(n.zoomToCursor&&E){let r=null;if(n.object instanceof Ou&&n.object.isPerspectiveCamera){let e=t.length();r=te(e*d);let i=e-r;n.object.position.addScaledVector(w,i),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){let e=new q(T.x,T.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/d)),n.object.updateProjectionMatrix(),b=!0;let i=new q(T.x,T.y,0);i.unproject(n.object),n.object.position.sub(i).add(e),n.object.updateMatrixWorld(),r=t.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),n.zoomToCursor=!1;r!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(r).add(n.object.position):(My.origin.copy(n.object.position),My.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(My.direction))<Py?e.lookAt(n.target):(Ny.setFromNormalAndCoplanarPoint(n.object.up,n.target),My.intersectPlane(Ny,n.target))))}else n.object instanceof Nu&&n.object.isOrthographicCamera&&(b=d!==1,b&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/d)),n.object.updateProjectionMatrix()));return d=1,E=!1,b||m.distanceToSquared(n.object.position)>c||8*(1-h.dot(n.object.quaternion))>c?(n.dispatchEvent(r),m.copy(n.object.position),h.copy(n.object.quaternion),b=!1,!0):!1}})(),this.connect=e=>{n.domElement=e,n.domElement.style.touchAction=`none`,n.domElement.addEventListener(`contextmenu`,we),n.domElement.addEventListener(`pointerdown`,ge),n.domElement.addEventListener(`pointercancel`,ve),n.domElement.addEventListener(`wheel`,xe)},this.dispose=()=>{var e,t,r,i,a,o;n.domElement&&(n.domElement.style.touchAction=`auto`),(e=n.domElement)==null||e.removeEventListener(`contextmenu`,we),(t=n.domElement)==null||t.removeEventListener(`pointerdown`,ge),(r=n.domElement)==null||r.removeEventListener(`pointercancel`,ve),(i=n.domElement)==null||i.removeEventListener(`wheel`,xe),(a=n.domElement)==null||a.ownerDocument.removeEventListener(`pointermove`,_e),(o=n.domElement)==null||o.ownerDocument.removeEventListener(`pointerup`,ve),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener(`keydown`,Se)};let n=this,r={type:`change`},i={type:`start`},a={type:`end`},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},s=o.NONE,c=1e-6,l=new Zd,u=new Zd,d=1,f=new q,p=new K,m=new K,h=new K,g=new K,_=new K,v=new K,y=new K,S=new K,C=new K,w=new q,T=new K,E=!1,D=[],O={};function k(){return 2*Math.PI/60/60*n.autoRotateSpeed}function A(){return .95**n.zoomSpeed}function j(e){n.reverseOrbit||n.reverseHorizontalOrbit?u.theta+=e:u.theta-=e}function M(e){n.reverseOrbit||n.reverseVerticalOrbit?u.phi+=e:u.phi-=e}let N=(()=>{let e=new q;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),f.add(e)}})(),P=(()=>{let e=new q;return function(t,r){n.screenSpacePanning===!0?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),f.add(e)}})(),F=(()=>{let e=new q;return function(t,r){let i=n.domElement;if(i&&n.object instanceof Ou&&n.object.isPerspectiveCamera){let a=n.object.position;e.copy(a).sub(n.target);let o=e.length();o*=Math.tan(n.object.fov/2*Math.PI/180),N(2*t*o/i.clientHeight,n.object.matrix),P(2*r*o/i.clientHeight,n.object.matrix)}else i&&n.object instanceof Nu&&n.object.isOrthographicCamera?(N(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),P(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),n.enablePan=!1)}})();function I(e){n.object instanceof Ou&&n.object.isPerspectiveCamera||n.object instanceof Nu&&n.object.isOrthographicCamera?d=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function L(e){I(d/e)}function ee(e){I(d*e)}function R(e){if(!n.zoomToCursor||!n.domElement)return;E=!0;let t=n.domElement.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top,a=t.width,o=t.height;T.x=r/a*2-1,T.y=-(i/o)*2+1,w.set(T.x,T.y,1).unproject(n.object).sub(n.object.position).normalize()}function te(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function z(e){p.set(e.clientX,e.clientY)}function B(e){R(e),y.set(e.clientX,e.clientY)}function V(e){g.set(e.clientX,e.clientY)}function ne(e){m.set(e.clientX,e.clientY),h.subVectors(m,p).multiplyScalar(n.rotateSpeed);let t=n.domElement;t&&(j(2*Math.PI*h.x/t.clientHeight),M(2*Math.PI*h.y/t.clientHeight)),p.copy(m),n.update()}function re(e){S.set(e.clientX,e.clientY),C.subVectors(S,y),C.y>0?L(A()):C.y<0&&ee(A()),y.copy(S),n.update()}function ie(e){_.set(e.clientX,e.clientY),v.subVectors(_,g).multiplyScalar(n.panSpeed),F(v.x,v.y),g.copy(_),n.update()}function ae(e){R(e),e.deltaY<0?ee(A()):e.deltaY>0&&L(A()),n.update()}function oe(e){let t=!1;switch(e.code){case n.keys.UP:F(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:F(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:F(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:F(-n.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),n.update())}function se(){if(D.length==1)p.set(D[0].pageX,D[0].pageY);else{let e=.5*(D[0].pageX+D[1].pageX),t=.5*(D[0].pageY+D[1].pageY);p.set(e,t)}}function ce(){if(D.length==1)g.set(D[0].pageX,D[0].pageY);else{let e=.5*(D[0].pageX+D[1].pageX),t=.5*(D[0].pageY+D[1].pageY);g.set(e,t)}}function H(){let e=D[0].pageX-D[1].pageX,t=D[0].pageY-D[1].pageY,n=Math.sqrt(e*e+t*t);y.set(0,n)}function le(){n.enableZoom&&H(),n.enablePan&&ce()}function ue(){n.enableZoom&&H(),n.enableRotate&&se()}function de(e){if(D.length==1)m.set(e.pageX,e.pageY);else{let t=De(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);m.set(n,r)}h.subVectors(m,p).multiplyScalar(n.rotateSpeed);let t=n.domElement;t&&(j(2*Math.PI*h.x/t.clientHeight),M(2*Math.PI*h.y/t.clientHeight)),p.copy(m)}function fe(e){if(D.length==1)_.set(e.pageX,e.pageY);else{let t=De(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);_.set(n,r)}v.subVectors(_,g).multiplyScalar(n.panSpeed),F(v.x,v.y),g.copy(_)}function pe(e){let t=De(e),r=e.pageX-t.x,i=e.pageY-t.y,a=Math.sqrt(r*r+i*i);S.set(0,a),C.set(0,(S.y/y.y)**+n.zoomSpeed),L(C.y),y.copy(S)}function me(e){n.enableZoom&&pe(e),n.enablePan&&fe(e)}function he(e){n.enableZoom&&pe(e),n.enableRotate&&de(e)}function ge(e){var t,r;n.enabled!==!1&&(D.length===0&&((t=n.domElement)==null||t.ownerDocument.addEventListener(`pointermove`,_e),(r=n.domElement)==null||r.ownerDocument.addEventListener(`pointerup`,ve)),Te(e),e.pointerType===`touch`?U(e):ye(e))}function _e(e){n.enabled!==!1&&(e.pointerType===`touch`?Ce(e):be(e))}function ve(e){var t,r,i;W(e),D.length===0&&((t=n.domElement)==null||t.releasePointerCapture(e.pointerId),(r=n.domElement)==null||r.ownerDocument.removeEventListener(`pointermove`,_e),(i=n.domElement)==null||i.ownerDocument.removeEventListener(`pointerup`,ve)),n.dispatchEvent(a),s=o.NONE}function ye(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case b.DOLLY:if(n.enableZoom===!1)return;B(e),s=o.DOLLY;break;case b.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(n.enablePan===!1)return;V(e),s=o.PAN}else{if(n.enableRotate===!1)return;z(e),s=o.ROTATE}break;case b.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(n.enableRotate===!1)return;z(e),s=o.ROTATE}else{if(n.enablePan===!1)return;V(e),s=o.PAN}break;default:s=o.NONE}s!==o.NONE&&n.dispatchEvent(i)}function be(e){if(n.enabled!==!1)switch(s){case o.ROTATE:if(n.enableRotate===!1)return;ne(e);break;case o.DOLLY:if(n.enableZoom===!1)return;re(e);break;case o.PAN:if(n.enablePan===!1)return;ie(e);break}}function xe(e){n.enabled===!1||n.enableZoom===!1||s!==o.NONE&&s!==o.ROTATE||(e.preventDefault(),n.dispatchEvent(i),ae(e),n.dispatchEvent(a))}function Se(e){n.enabled===!1||n.enablePan===!1||oe(e)}function U(e){switch(Ee(e),D.length){case 1:switch(n.touches.ONE){case x.ROTATE:if(n.enableRotate===!1)return;se(),s=o.TOUCH_ROTATE;break;case x.PAN:if(n.enablePan===!1)return;ce(),s=o.TOUCH_PAN;break;default:s=o.NONE}break;case 2:switch(n.touches.TWO){case x.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;le(),s=o.TOUCH_DOLLY_PAN;break;case x.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ue(),s=o.TOUCH_DOLLY_ROTATE;break;default:s=o.NONE}break;default:s=o.NONE}s!==o.NONE&&n.dispatchEvent(i)}function Ce(e){switch(Ee(e),s){case o.TOUCH_ROTATE:if(n.enableRotate===!1)return;de(e),n.update();break;case o.TOUCH_PAN:if(n.enablePan===!1)return;fe(e),n.update();break;case o.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;me(e),n.update();break;case o.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;he(e),n.update();break;default:s=o.NONE}}function we(e){n.enabled!==!1&&e.preventDefault()}function Te(e){D.push(e)}function W(e){delete O[e.pointerId];for(let t=0;t<D.length;t++)if(D[t].pointerId==e.pointerId){D.splice(t,1);return}}function Ee(e){let t=O[e.pointerId];t===void 0&&(t=new K,O[e.pointerId]=t),t.set(e.pageX,e.pageY)}function De(e){return O[(e.pointerId===D[0].pointerId?D[1]:D[0]).pointerId]}this.dollyIn=(e=A())=>{ee(e),n.update()},this.dollyOut=(e=A())=>{L(e),n.update()},this.getScale=()=>d,this.setScale=e=>{I(e),n.update()},this.getZoomScale=()=>A(),t!==void 0&&this.connect(t),this.update()}},Ly=new ni,Ry=new q,zy=class extends Hu{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new Pi([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new Pi([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new Wd(t,6,1);return this.setAttribute(`instanceStart`,new Yi(n,3,0)),this.setAttribute(`instanceEnd`,new Yi(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e,t=3){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));let r=new Wd(n,t*2,1);return this.setAttribute(`instanceColorStart`,new Yi(r,t,0)),this.setAttribute(`instanceColorEnd`,new Yi(r,t,t)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new sl(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ni);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Ly.setFromBufferAttribute(t),this.boundingBox.union(Ly))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ri),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i<a;i++)Ry.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(Ry)),Ry.fromBufferAttribute(t,i),r=Math.max(r,n.distanceToSquared(Ry));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}applyMatrix(e){return console.warn(`THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().`),this.applyMatrix4(e)}},By=class extends zy{constructor(){super(),this.isLineGeometry=!0,this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e,t=3){let n=e.length-t,r=new Float32Array(2*n);if(t===3)for(let i=0;i<n;i+=t)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];else for(let i=0;i<n;i+=t)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5],r[2*i+6]=e[i+6],r[2*i+7]=e[i+7];return super.setColors(r,t),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},Vy=class extends yl{constructor(e){super({type:`LineMaterial`,uniforms:gl.clone(gl.merge([X.common,X.fog,{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new K(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}}])),vertexShader:`
|
||
#include <common>
|
||
#include <fog_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
|
||
uniform float linewidth;
|
||
uniform vec2 resolution;
|
||
|
||
attribute vec3 instanceStart;
|
||
attribute vec3 instanceEnd;
|
||
|
||
#ifdef USE_COLOR
|
||
#ifdef USE_LINE_COLOR_ALPHA
|
||
varying vec4 vLineColor;
|
||
attribute vec4 instanceColorStart;
|
||
attribute vec4 instanceColorEnd;
|
||
#else
|
||
varying vec3 vLineColor;
|
||
attribute vec3 instanceColorStart;
|
||
attribute vec3 instanceColorEnd;
|
||
#endif
|
||
#endif
|
||
|
||
#ifdef WORLD_UNITS
|
||
|
||
varying vec4 worldPos;
|
||
varying vec3 worldStart;
|
||
varying vec3 worldEnd;
|
||
|
||
#ifdef USE_DASH
|
||
|
||
varying vec2 vUv;
|
||
|
||
#endif
|
||
|
||
#else
|
||
|
||
varying vec2 vUv;
|
||
|
||
#endif
|
||
|
||
#ifdef USE_DASH
|
||
|
||
uniform float dashScale;
|
||
attribute float instanceDistanceStart;
|
||
attribute float instanceDistanceEnd;
|
||
varying float vLineDistance;
|
||
|
||
#endif
|
||
|
||
void trimSegment( const in vec4 start, inout vec4 end ) {
|
||
|
||
// trim end segment so it terminates between the camera plane and the near plane
|
||
|
||
// conservative estimate of the near plane
|
||
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
||
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
||
float nearEstimate = - 0.5 * b / a;
|
||
|
||
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
||
|
||
end.xyz = mix( start.xyz, end.xyz, alpha );
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
#ifdef USE_COLOR
|
||
|
||
vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
||
|
||
#endif
|
||
|
||
#ifdef USE_DASH
|
||
|
||
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
||
vUv = uv;
|
||
|
||
#endif
|
||
|
||
float aspect = resolution.x / resolution.y;
|
||
|
||
// camera space
|
||
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
||
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
||
|
||
#ifdef WORLD_UNITS
|
||
|
||
worldStart = start.xyz;
|
||
worldEnd = end.xyz;
|
||
|
||
#else
|
||
|
||
vUv = uv;
|
||
|
||
#endif
|
||
|
||
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
||
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
||
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
||
// perhaps there is a more elegant solution -- WestLangley
|
||
|
||
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
||
|
||
if ( perspective ) {
|
||
|
||
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
||
|
||
trimSegment( start, end );
|
||
|
||
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
||
|
||
trimSegment( end, start );
|
||
|
||
}
|
||
|
||
}
|
||
|
||
// clip space
|
||
vec4 clipStart = projectionMatrix * start;
|
||
vec4 clipEnd = projectionMatrix * end;
|
||
|
||
// ndc space
|
||
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
||
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
||
|
||
// direction
|
||
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
||
|
||
// account for clip-space aspect ratio
|
||
dir.x *= aspect;
|
||
dir = normalize( dir );
|
||
|
||
#ifdef WORLD_UNITS
|
||
|
||
// get the offset direction as perpendicular to the view vector
|
||
vec3 worldDir = normalize( end.xyz - start.xyz );
|
||
vec3 offset;
|
||
if ( position.y < 0.5 ) {
|
||
|
||
offset = normalize( cross( start.xyz, worldDir ) );
|
||
|
||
} else {
|
||
|
||
offset = normalize( cross( end.xyz, worldDir ) );
|
||
|
||
}
|
||
|
||
// sign flip
|
||
if ( position.x < 0.0 ) offset *= - 1.0;
|
||
|
||
float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
|
||
|
||
// don't extend the line if we're rendering dashes because we
|
||
// won't be rendering the endcaps
|
||
#ifndef USE_DASH
|
||
|
||
// extend the line bounds to encompass endcaps
|
||
start.xyz += - worldDir * linewidth * 0.5;
|
||
end.xyz += worldDir * linewidth * 0.5;
|
||
|
||
// shift the position of the quad so it hugs the forward edge of the line
|
||
offset.xy -= dir * forwardOffset;
|
||
offset.z += 0.5;
|
||
|
||
#endif
|
||
|
||
// endcaps
|
||
if ( position.y > 1.0 || position.y < 0.0 ) {
|
||
|
||
offset.xy += dir * 2.0 * forwardOffset;
|
||
|
||
}
|
||
|
||
// adjust for linewidth
|
||
offset *= linewidth * 0.5;
|
||
|
||
// set the world position
|
||
worldPos = ( position.y < 0.5 ) ? start : end;
|
||
worldPos.xyz += offset;
|
||
|
||
// project the worldpos
|
||
vec4 clip = projectionMatrix * worldPos;
|
||
|
||
// shift the depth of the projected points so the line
|
||
// segments overlap neatly
|
||
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
||
clip.z = clipPose.z * clip.w;
|
||
|
||
#else
|
||
|
||
vec2 offset = vec2( dir.y, - dir.x );
|
||
// undo aspect ratio adjustment
|
||
dir.x /= aspect;
|
||
offset.x /= aspect;
|
||
|
||
// sign flip
|
||
if ( position.x < 0.0 ) offset *= - 1.0;
|
||
|
||
// endcaps
|
||
if ( position.y < 0.0 ) {
|
||
|
||
offset += - dir;
|
||
|
||
} else if ( position.y > 1.0 ) {
|
||
|
||
offset += dir;
|
||
|
||
}
|
||
|
||
// adjust for linewidth
|
||
offset *= linewidth;
|
||
|
||
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
||
offset /= resolution.y;
|
||
|
||
// select end
|
||
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
||
|
||
// back to clip space
|
||
offset *= clip.w;
|
||
|
||
clip.xy += offset;
|
||
|
||
#endif
|
||
|
||
gl_Position = clip;
|
||
|
||
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
||
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <fog_vertex>
|
||
|
||
}
|
||
`,fragmentShader:`
|
||
uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
uniform float linewidth;
|
||
|
||
#ifdef USE_DASH
|
||
|
||
uniform float dashOffset;
|
||
uniform float dashSize;
|
||
uniform float gapSize;
|
||
|
||
#endif
|
||
|
||
varying float vLineDistance;
|
||
|
||
#ifdef WORLD_UNITS
|
||
|
||
varying vec4 worldPos;
|
||
varying vec3 worldStart;
|
||
varying vec3 worldEnd;
|
||
|
||
#ifdef USE_DASH
|
||
|
||
varying vec2 vUv;
|
||
|
||
#endif
|
||
|
||
#else
|
||
|
||
varying vec2 vUv;
|
||
|
||
#endif
|
||
|
||
#include <common>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
|
||
#ifdef USE_COLOR
|
||
#ifdef USE_LINE_COLOR_ALPHA
|
||
varying vec4 vLineColor;
|
||
#else
|
||
varying vec3 vLineColor;
|
||
#endif
|
||
#endif
|
||
|
||
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
||
|
||
float mua;
|
||
float mub;
|
||
|
||
vec3 p13 = p1 - p3;
|
||
vec3 p43 = p4 - p3;
|
||
|
||
vec3 p21 = p2 - p1;
|
||
|
||
float d1343 = dot( p13, p43 );
|
||
float d4321 = dot( p43, p21 );
|
||
float d1321 = dot( p13, p21 );
|
||
float d4343 = dot( p43, p43 );
|
||
float d2121 = dot( p21, p21 );
|
||
|
||
float denom = d2121 * d4343 - d4321 * d4321;
|
||
|
||
float numer = d1343 * d4321 - d1321 * d4343;
|
||
|
||
mua = numer / denom;
|
||
mua = clamp( mua, 0.0, 1.0 );
|
||
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
||
mub = clamp( mub, 0.0, 1.0 );
|
||
|
||
return vec2( mua, mub );
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
#include <clipping_planes_fragment>
|
||
|
||
#ifdef USE_DASH
|
||
|
||
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
||
|
||
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
||
|
||
#endif
|
||
|
||
float alpha = opacity;
|
||
|
||
#ifdef WORLD_UNITS
|
||
|
||
// Find the closest points on the view ray and the line segment
|
||
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
||
vec3 lineDir = worldEnd - worldStart;
|
||
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
||
|
||
vec3 p1 = worldStart + lineDir * params.x;
|
||
vec3 p2 = rayEnd * params.y;
|
||
vec3 delta = p1 - p2;
|
||
float len = length( delta );
|
||
float norm = len / linewidth;
|
||
|
||
#ifndef USE_DASH
|
||
|
||
#ifdef USE_ALPHA_TO_COVERAGE
|
||
|
||
float dnorm = fwidth( norm );
|
||
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
||
|
||
#else
|
||
|
||
if ( norm > 0.5 ) {
|
||
|
||
discard;
|
||
|
||
}
|
||
|
||
#endif
|
||
|
||
#endif
|
||
|
||
#else
|
||
|
||
#ifdef USE_ALPHA_TO_COVERAGE
|
||
|
||
// artifacts appear on some hardware if a derivative is taken within a conditional
|
||
float a = vUv.x;
|
||
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
||
float len2 = a * a + b * b;
|
||
float dlen = fwidth( len2 );
|
||
|
||
if ( abs( vUv.y ) > 1.0 ) {
|
||
|
||
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
||
|
||
}
|
||
|
||
#else
|
||
|
||
if ( abs( vUv.y ) > 1.0 ) {
|
||
|
||
float a = vUv.x;
|
||
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
||
float len2 = a * a + b * b;
|
||
|
||
if ( len2 > 1.0 ) discard;
|
||
|
||
}
|
||
|
||
#endif
|
||
|
||
#endif
|
||
|
||
vec4 diffuseColor = vec4( diffuse, alpha );
|
||
#ifdef USE_COLOR
|
||
#ifdef USE_LINE_COLOR_ALPHA
|
||
diffuseColor *= vLineColor;
|
||
#else
|
||
diffuseColor.rgb *= vLineColor;
|
||
#endif
|
||
#endif
|
||
|
||
#include <logdepthbuf_fragment>
|
||
|
||
gl_FragColor = diffuseColor;
|
||
|
||
#include <tonemapping_fragment>
|
||
#include <${Cy>=154?`colorspace_fragment`:`encodings_fragment`}>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
|
||
}
|
||
`,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA=`1`:delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return`WORLD_UNITS`in this.defines},set:function(e){e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return`USE_DASH`in this.defines},set(e){!!e!=`USE_DASH`in this.defines&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return`USE_ALPHA_TO_COVERAGE`in this.defines},set:function(e){!!e!=`USE_ALPHA_TO_COVERAGE`in this.defines&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE=``,this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}},Hy=new Zn,Uy=new q,Wy=new q,Gy=new Zn,Ky=new Zn,qy=new Zn,Jy=new q,Yy=new J,Xy=new uf,Zy=new q,Qy=new ni,$y=new Ri,eb=new Zn,tb,nb;function rb(e,t,n){return eb.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),eb.multiplyScalar(1/eb.w),eb.x=nb/n.width,eb.y=nb/n.height,eb.applyMatrix4(e.projectionMatrixInverse),eb.multiplyScalar(1/eb.w),Math.abs(Math.max(eb.x,eb.y))}function ib(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;r<s;r++){Xy.start.fromBufferAttribute(i,r),Xy.end.fromBufferAttribute(a,r),Xy.applyMatrix4(n);let o=new q,s=new q;tb.distanceSqToSegment(Xy.start,Xy.end,s,o),s.distanceTo(o)<nb*.5&&t.push({point:s,pointOnLine:o,distance:tb.origin.distanceTo(s),object:e,face:null,faceIndex:r,uv:null,[wy]:null})}}function ab(e,t,n){let r=t.projectionMatrix,i=e.material.resolution,a=e.matrixWorld,o=e.geometry,s=o.attributes.instanceStart,c=o.attributes.instanceEnd,l=Math.min(o.instanceCount,s.count),u=-t.near;tb.at(1,qy),qy.w=1,qy.applyMatrix4(t.matrixWorldInverse),qy.applyMatrix4(r),qy.multiplyScalar(1/qy.w),qy.x*=i.x/2,qy.y*=i.y/2,qy.z=0,Jy.copy(qy),Yy.multiplyMatrices(t.matrixWorldInverse,a);for(let t=0,o=l;t<o;t++){if(Gy.fromBufferAttribute(s,t),Ky.fromBufferAttribute(c,t),Gy.w=1,Ky.w=1,Gy.applyMatrix4(Yy),Ky.applyMatrix4(Yy),Gy.z>u&&Ky.z>u)continue;if(Gy.z>u){let e=Gy.z-Ky.z,t=(Gy.z-u)/e;Gy.lerp(Ky,t)}else if(Ky.z>u){let e=Ky.z-Gy.z,t=(Ky.z-u)/e;Ky.lerp(Gy,t)}Gy.applyMatrix4(r),Ky.applyMatrix4(r),Gy.multiplyScalar(1/Gy.w),Ky.multiplyScalar(1/Ky.w),Gy.x*=i.x/2,Gy.y*=i.y/2,Ky.x*=i.x/2,Ky.y*=i.y/2,Xy.start.copy(Gy),Xy.start.z=0,Xy.end.copy(Ky),Xy.end.z=0;let o=Xy.closestPointToPointParameter(Jy,!0);Xy.at(o,Zy);let l=jn.lerp(Gy.z,Ky.z,o),d=l>=-1&&l<=1,f=Jy.distanceTo(Zy)<nb*.5;if(d&&f){Xy.start.fromBufferAttribute(s,t),Xy.end.fromBufferAttribute(c,t),Xy.start.applyMatrix4(a),Xy.end.applyMatrix4(a);let r=new q,i=new q;tb.distanceSqToSegment(Xy.start,Xy.end,i,r),n.push({point:i,pointOnLine:r,distance:tb.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,[wy]:null})}}}var ob=class extends La{constructor(e=new zy,t=new Vy({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,a=t.count;e<a;e++,i+=2)Uy.fromBufferAttribute(t,e),Wy.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+Uy.distanceTo(Wy);let i=new Wd(r,2,1);return e.setAttribute(`instanceDistanceStart`,new Yi(i,1,0)),e.setAttribute(`instanceDistanceEnd`,new Yi(i,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`);let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;tb=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;nb=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),$y.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?nb*.5:rb(r,Math.max(r.near,$y.distanceToPoint(tb.origin)),s.resolution),$y.radius+=c,tb.intersectsSphere($y)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),Qy.copy(o.boundingBox).applyMatrix4(a);let l;l=n?nb*.5:rb(r,Math.max(r.near,Qy.distanceToPoint(tb.origin)),s.resolution),Qy.expandByScalar(l),tb.intersectsBox(Qy)!==!1&&(n?ib(this,t):ab(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Hy),this.material.uniforms.resolution.value.set(Hy.z,Hy.w))}},sb=class extends ob{constructor(e=new By,t=new Vy({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},cb=new q,lb=new q,ub=new q,db=(e,t,n)=>{let r=n.width/2,i=n.height/2;t.updateMatrixWorld(!1);let a=e.project(t);return a.x=a.x*r+r,a.y=-(a.y*i)+i,a},fb=(e,t,n,r=1)=>{let i=cb.set(e.x/n.width*2-1,-(e.y/n.height)*2+1,r);return i.unproject(t),i},pb=(e,t,n,r)=>{let i=db(ub.copy(e),n,r),a=0;for(let o=0;o<2;++o){let s=lb.copy(i).setComponent(o,i.getComponent(o)+t),c=fb(s,n,r,s.z);a=Math.max(a,e.distanceTo(c))}return a},mb=v.forwardRef(function({points:e,color:t=16777215,vertexColors:n,linewidth:r,lineWidth:i,segments:a,dashed:o,...s},c){var l;let u=A_(e=>e.size),d=v.useMemo(()=>a?new ob:new sb,[a]),[f]=v.useState(()=>new Vy),p=(n==null||(l=n[0])==null?void 0:l.length)===4?4:3,m=v.useMemo(()=>{let r=a?new zy:new By,i=e.map(e=>{let t=Array.isArray(e);return e instanceof q||e instanceof Zn?[e.x,e.y,e.z]:e instanceof K?[e.x,e.y,0]:t&&e.length===3?[e[0],e[1],e[2]]:t&&e.length===2?[e[0],e[1],0]:e});if(r.setPositions(i.flat()),n){t=16777215;let e=n.map(e=>e instanceof Y?e.toArray():e);r.setColors(e.flat(),p)}return r},[e,a,n,p]);return v.useLayoutEffect(()=>{d.computeLineDistances()},[e,d]),v.useLayoutEffect(()=>{o?f.defines.USE_DASH=``:delete f.defines.USE_DASH,f.needsUpdate=!0},[o,f]),v.useEffect(()=>()=>{m.dispose(),f.dispose()},[m]),v.createElement(`primitive`,ny({object:d,ref:c},s),v.createElement(`primitive`,{object:m,attach:`geometry`}),v.createElement(`primitive`,ny({object:f,attach:`material`,color:t,vertexColors:!!n,resolution:[u.width,u.height],linewidth:r??i??1,dashed:o,transparent:p===4},s)))});function hb(e,t,n,r){var i;return i=class extends yl{constructor(i){super({vertexShader:t,fragmentShader:n,...i});for(let t in e)this.uniforms[t]=new Vd(e[t]),Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(e){this.uniforms[t].value=e}});this.uniforms=gl.clone(this.uniforms),r?.(this)}},i.key=jn.generateUUID(),i}var gb=parseInt(`184`.replace(/\D+/g,``));function _b(e,t,n){let r=A_(e=>e.size),i=A_(e=>e.viewport),a=typeof e==`number`?e:r.width*i.dpr,o=typeof t==`number`?t:r.height*i.dpr,s=(typeof e==`number`?n:e)||{},{samples:c=0,depth:l,...u}=s,d=l??s.depthBuffer,f=v.useMemo(()=>{let e=new $n(a,o,{minFilter:M,magFilter:M,type:ne,...u});return d&&(e.depthTexture=new _s(a,o,V)),e.samples=c,e},[]);return v.useLayoutEffect(()=>{f.setSize(a,o),c&&(f.samples=c)},[c,f,a,o]),v.useEffect(()=>()=>f.dispose(),[]),f}var vb=e=>typeof e==`function`,yb=v.forwardRef(({envMap:e,resolution:t=256,frames:n=1/0,children:r,makeDefault:i,...a},o)=>{let s=A_(({set:e})=>e),c=A_(({camera:e})=>e),l=A_(({size:e})=>e),u=v.useRef(null);v.useImperativeHandle(o,()=>u.current,[]);let d=v.useRef(null),f=_b(t);v.useLayoutEffect(()=>{a.manual||u.current.updateProjectionMatrix()},[l,a]),v.useLayoutEffect(()=>{u.current.updateProjectionMatrix()}),v.useLayoutEffect(()=>{if(i){let e=c;return s(()=>({camera:u.current})),()=>s(()=>({camera:e}))}},[u,i,s]);let p=0,m=null,h=vb(r);return j_(t=>{h&&(n===1/0||p<n)&&(d.current.visible=!1,t.gl.setRenderTarget(f),m=t.scene.background,e&&(t.scene.background=e),t.gl.render(t.scene,u.current),t.scene.background=m,t.gl.setRenderTarget(null),d.current.visible=!0,p++)}),v.createElement(v.Fragment,null,v.createElement(`orthographicCamera`,ny({left:l.width/-2,right:l.width/2,top:l.height/2,bottom:l.height/-2,ref:u},a),!h&&r),v.createElement(`group`,{ref:d},h&&r(f.texture)))}),bb=e=>typeof e==`function`,xb=v.forwardRef(({envMap:e,resolution:t=256,frames:n=1/0,makeDefault:r,children:i,...a},o)=>{let s=A_(({set:e})=>e),c=A_(({camera:e})=>e),l=A_(({size:e})=>e),u=v.useRef(null);v.useImperativeHandle(o,()=>u.current,[]);let d=v.useRef(null),f=_b(t);v.useLayoutEffect(()=>{a.manual||(u.current.aspect=l.width/l.height)},[l,a]),v.useLayoutEffect(()=>{u.current.updateProjectionMatrix()});let p=0,m=null,h=bb(i);return j_(t=>{h&&(n===1/0||p<n)&&(d.current.visible=!1,t.gl.setRenderTarget(f),m=t.scene.background,e&&(t.scene.background=e),t.gl.render(t.scene,u.current),t.scene.background=m,t.gl.setRenderTarget(null),d.current.visible=!0,p++)}),v.useLayoutEffect(()=>{if(r){let e=c;return s(()=>({camera:u.current})),()=>s(()=>({camera:e}))}},[u,r,s]),v.createElement(v.Fragment,null,v.createElement(`perspectiveCamera`,ny({ref:u},a),!h&&i),v.createElement(`group`,{ref:d},h&&i(f.texture)))}),Sb=v.forwardRef(({makeDefault:e,camera:t,regress:n,domElement:r,enableDamping:i=!0,keyEvents:a=!1,onChange:o,onStart:s,onEnd:c,...l},u)=>{let d=A_(e=>e.invalidate),f=A_(e=>e.camera),p=A_(e=>e.gl),m=A_(e=>e.events),h=A_(e=>e.setEvents),g=A_(e=>e.set),_=A_(e=>e.get),y=A_(e=>e.performance),b=t||f,x=r||m.connected||p.domElement,S=v.useMemo(()=>new Iy(b),[b]);return j_(()=>{S.enabled&&S.update()},-1),v.useEffect(()=>(a&&S.connect(a===!0?x:a),S.connect(x),()=>void S.dispose()),[a,x,n,S,d]),v.useEffect(()=>{let e=e=>{d(),n&&y.regress(),o&&o(e)},t=e=>{s&&s(e)},r=e=>{c&&c(e)};return S.addEventListener(`change`,e),S.addEventListener(`start`,t),S.addEventListener(`end`,r),()=>{S.removeEventListener(`start`,t),S.removeEventListener(`end`,r),S.removeEventListener(`change`,e)}},[o,s,c,S,d,h]),v.useEffect(()=>{if(e){let e=_().controls;return g({controls:S}),()=>g({controls:e})}},[e,S]),v.createElement(`primitive`,ny({ref:u,object:S,enableDamping:i},l))});function Cb({defaultScene:e,defaultCamera:t,renderPriority:n=1}){let{gl:r,scene:i,camera:a}=A_(),o;return j_(()=>{o=r.autoClear,n===1&&(r.autoClear=!0,r.render(e,t)),r.autoClear=!1,r.clearDepth(),r.render(i,a),r.autoClear=o},n),v.createElement(`group`,{onPointerOver:()=>null})}function wb({children:e,renderPriority:t=1}){let{scene:n,camera:r}=A_(),[i]=v.useState(()=>new Vr);return v.createElement(v.Fragment,null,Dv(v.createElement(v.Fragment,null,e,v.createElement(Cb,{defaultScene:n,defaultCamera:r,renderPriority:t})),i,{events:{priority:t+1}}))}var Tb=v.createContext({}),Eb=()=>v.useContext(Tb),Db=2*Math.PI,Ob=new Ar,kb=new J,[Ab,jb]=[new Mn,new Mn],Mb=new q,Nb=new q,Pb=e=>`minPolarAngle`in e,Fb=e=>`getTarget`in e,Ib=({alignment:e=`bottom-right`,margin:t=[80,80],renderPriority:n=1,onUpdate:r,onTarget:i,children:a})=>{let o=A_(e=>e.size),s=A_(e=>e.camera),c=A_(e=>e.controls),l=A_(e=>e.invalidate),u=v.useRef(null),d=v.useRef(null),f=v.useRef(!1),p=v.useRef(0),m=v.useRef(new q(0,0,0)),h=v.useRef(new q(0,0,0));v.useEffect(()=>{h.current.copy(s.up),Ob.up.copy(s.up)},[s]);let g=v.useCallback(e=>{f.current=!0,(c||i)&&(m.current=i?.()||(Fb(c)?c.getTarget(m.current):c?.target)),p.current=s.position.distanceTo(Mb),Ab.copy(s.quaternion),Nb.copy(e).multiplyScalar(p.current).add(Mb),Ob.lookAt(Nb),jb.copy(Ob.quaternion),l()},[c,s,i,l]);j_((e,t)=>{if(d.current&&u.current){var n;if(f.current)if(Ab.angleTo(jb)<.01)f.current=!1,Pb(c)&&s.up.copy(h.current);else{let e=t*Db;Ab.rotateTowards(jb,e),s.position.set(0,0,1).applyQuaternion(Ab).multiplyScalar(p.current).add(m.current),s.up.set(0,1,0).applyQuaternion(Ab).normalize(),s.quaternion.copy(Ab),Fb(c)&&c.setPosition(s.position.x,s.position.y,s.position.z),r?r():c&&c.update(t),l()}kb.copy(s.matrix).invert(),(n=u.current)==null||n.quaternion.setFromRotationMatrix(kb)}});let _=v.useMemo(()=>({tweenCamera:g}),[g]),[y,b]=t,x=e.endsWith(`-center`)?0:e.endsWith(`-left`)?-o.width/2+y:o.width/2-y,S=e.startsWith(`center-`)?0:e.startsWith(`top-`)?o.height/2-b:-o.height/2+b;return v.createElement(wb,{renderPriority:n},v.createElement(Tb.Provider,{value:_},v.createElement(yb,{makeDefault:!0,ref:d,position:[0,0,200]}),v.createElement(`group`,{ref:u,position:[x,S,0]},a)))};function Lb({scale:e=[.8,.05,.05],color:t,rotation:n}){return v.createElement(`group`,{rotation:n},v.createElement(`mesh`,{position:[.4,0,0]},v.createElement(`boxGeometry`,{args:e}),v.createElement(`meshBasicMaterial`,{color:t,toneMapped:!1})))}function Rb({onClick:e,font:t,disabled:n,arcStyle:r,label:i,labelColor:a,axisHeadScale:o=1,...s}){let c=A_(e=>e.gl),l=v.useMemo(()=>{let e=document.createElement(`canvas`);e.width=64,e.height=64;let n=e.getContext(`2d`);return n.beginPath(),n.arc(32,32,16,0,2*Math.PI),n.closePath(),n.fillStyle=r,n.fill(),i&&(n.font=t,n.textAlign=`center`,n.fillStyle=a,n.fillText(i,32,41)),new hs(e)},[r,i,a,t]),[u,d]=v.useState(!1),f=(i?1:.75)*(u?1.2:1)*o;return v.createElement(`sprite`,ny({scale:f,onPointerOver:n?void 0:e=>{e.stopPropagation(),d(!0)},onPointerOut:n?void 0:e||(e=>{e.stopPropagation(),d(!1)})},s),v.createElement(`spriteMaterial`,{map:l,"map-anisotropy":c.capabilities.getMaxAnisotropy()||1,alphaTest:.3,opacity:i?1:.75,toneMapped:!1}))}var zb=({hideNegativeAxes:e,hideAxisHeads:t,disabled:n,font:r=`18px Inter var, Arial, sans-serif`,axisColors:i=[`#ff2060`,`#20df80`,`#2080ff`],axisHeadScale:a=1,axisScale:o,labels:s=[`X`,`Y`,`Z`],labelColor:c=`#000`,onClick:l,...u})=>{let[d,f,p]=i,{tweenCamera:m}=Eb(),h={font:r,disabled:n,labelColor:c,onClick:l,axisHeadScale:a,onPointerDown:n?void 0:e=>{m(e.object.position),e.stopPropagation()}};return v.createElement(`group`,ny({scale:40},u),v.createElement(Lb,{color:d,rotation:[0,0,0],scale:o}),v.createElement(Lb,{color:f,rotation:[0,0,Math.PI/2],scale:o}),v.createElement(Lb,{color:p,rotation:[0,-Math.PI/2,0],scale:o}),!t&&v.createElement(v.Fragment,null,v.createElement(Rb,ny({arcStyle:d,position:[1,0,0],label:s[0]},h)),v.createElement(Rb,ny({arcStyle:f,position:[0,1,0],label:s[1]},h)),v.createElement(Rb,ny({arcStyle:p,position:[0,0,1],label:s[2]},h)),!e&&v.createElement(v.Fragment,null,v.createElement(Rb,ny({arcStyle:d,position:[-1,0,0]},h)),v.createElement(Rb,ny({arcStyle:f,position:[0,-1,0]},h)),v.createElement(Rb,ny({arcStyle:p,position:[0,0,-1]},h)))))},Bb=hb({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:new Y,sectionColor:new Y,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new q,worldPlanePosition:new q},`
|
||
varying vec3 localPosition;
|
||
varying vec4 worldPosition;
|
||
|
||
uniform vec3 worldCamProjPosition;
|
||
uniform vec3 worldPlanePosition;
|
||
uniform float fadeDistance;
|
||
uniform bool infiniteGrid;
|
||
uniform bool followCamera;
|
||
|
||
void main() {
|
||
localPosition = position.xzy;
|
||
if (infiniteGrid) localPosition *= 1.0 + fadeDistance;
|
||
|
||
worldPosition = modelMatrix * vec4(localPosition, 1.0);
|
||
if (followCamera) {
|
||
worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);
|
||
localPosition = (inverse(modelMatrix) * worldPosition).xyz;
|
||
}
|
||
|
||
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
||
}
|
||
`,`
|
||
varying vec3 localPosition;
|
||
varying vec4 worldPosition;
|
||
|
||
uniform vec3 worldCamProjPosition;
|
||
uniform float cellSize;
|
||
uniform float sectionSize;
|
||
uniform vec3 cellColor;
|
||
uniform vec3 sectionColor;
|
||
uniform float fadeDistance;
|
||
uniform float fadeStrength;
|
||
uniform float fadeFrom;
|
||
uniform float cellThickness;
|
||
uniform float sectionThickness;
|
||
|
||
float getGrid(float size, float thickness) {
|
||
vec2 r = localPosition.xz / size;
|
||
vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
||
float line = min(grid.x, grid.y) + 1.0 - thickness;
|
||
return 1.0 - min(line, 1.0);
|
||
}
|
||
|
||
void main() {
|
||
float g1 = getGrid(cellSize, cellThickness);
|
||
float g2 = getGrid(sectionSize, sectionThickness);
|
||
|
||
vec3 from = worldCamProjPosition*vec3(fadeFrom);
|
||
float dist = distance(from, worldPosition.xyz);
|
||
float d = 1.0 - min(dist / fadeDistance, 1.0);
|
||
vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));
|
||
|
||
gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));
|
||
gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);
|
||
if (gl_FragColor.a <= 0.0) discard;
|
||
|
||
#include <tonemapping_fragment>
|
||
#include <${gb>=154?`colorspace_fragment`:`encodings_fragment`}>
|
||
}
|
||
`),Vb=v.forwardRef(({args:e,cellColor:t=`#000000`,sectionColor:n=`#2080ff`,cellSize:r=.5,sectionSize:i=1,followCamera:a=!1,infiniteGrid:o=!1,fadeDistance:s=100,fadeStrength:c=1,fadeFrom:l=1,cellThickness:u=.5,sectionThickness:d=1,side:f=1,...p},m)=>{nv({GridMaterial:Bb});let h=v.useRef(null);v.useImperativeHandle(m,()=>h.current,[]);let g=new mo,_=new q(0,1,0),y=new q(0,0,0);j_(e=>{g.setFromNormalAndCoplanarPoint(_,y).applyMatrix4(h.current.matrixWorld);let t=h.current.material,n=t.uniforms.worldCamProjPosition,r=t.uniforms.worldPlanePosition;g.projectPoint(e.camera.position,n.value),r.value.set(0,0,0).applyMatrix4(h.current.matrixWorld)});let b={cellSize:r,sectionSize:i,cellColor:t,sectionColor:n,cellThickness:u,sectionThickness:d},x={fadeDistance:s,fadeStrength:c,fadeFrom:l,infiniteGrid:o,followCamera:a};return v.createElement(`mesh`,ny({ref:h,frustumCulled:!1},p),v.createElement(`gridMaterial`,ny({transparent:!0,"extensions-derivatives":!0,side:f},b,x)),v.createElement(`planeGeometry`,{args:e}))}),Hb=`modulepreload`,Ub=function(e){return`/`+e},Wb={},Gb=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Ub(t,n),t in Wb)return;Wb[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Hb,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Kb=v.createContext(null),qb=new q,Jb=new q,Yb=(e,t,n,r)=>{let i=t.dot(t),a=t.dot(e)-t.dot(n),o=t.dot(r);return o===0?-a/i:(qb.copy(r).multiplyScalar(i/o).sub(t),Jb.copy(r).multiplyScalar(a/o).add(n).sub(e),-qb.dot(Jb)/qb.dot(qb))},Xb=new q(0,1,0),Zb=new J,Qb=({direction:e,axis:t})=>{let{translation:n,translationLimits:r,annotations:i,annotationsClass:a,depthTest:o,scale:s,lineWidth:c,fixed:l,axisColors:u,hoveredColor:d,opacity:f,renderOrder:p,onDragStart:m,onDrag:h,onDragEnd:g,userData:_}=v.useContext(Kb),y=A_(e=>e.controls),b=v.useRef(null),x=v.useRef(null),S=v.useRef(null),C=v.useRef(0),[w,T]=v.useState(!1),E=v.useCallback(r=>{i&&(b.current.innerText=`${n.current[t].toFixed(2)}`,b.current.style.display=`block`),r.stopPropagation();let a=new J().extractRotation(x.current.matrixWorld),o=r.point.clone(),s=new q().setFromMatrixPosition(x.current.matrixWorld),c=e.clone().applyMatrix4(a).normalize();S.current={clickPoint:o,dir:c},C.current=n.current[t],m({component:`Arrow`,axis:t,origin:s,directions:[c]}),y&&(y.enabled=!1),r.target.setPointerCapture(r.pointerId)},[i,e,y,m,n,t]),D=v.useCallback(e=>{if(e.stopPropagation(),w||T(!0),S.current){let{clickPoint:a,dir:o}=S.current,[s,c]=r?.[t]||[void 0,void 0],l=Yb(a,o,e.ray.origin,e.ray.direction);s!==void 0&&(l=Math.max(l,s-C.current)),c!==void 0&&(l=Math.min(l,c-C.current)),n.current[t]=C.current+l,i&&(b.current.innerText=`${n.current[t].toFixed(2)}`),Zb.makeTranslation(o.x*l,o.y*l,o.z*l),h(Zb)}},[i,h,w,n,r,t]),O=v.useCallback(e=>{i&&(b.current.style.display=`none`),e.stopPropagation(),S.current=null,g(),y&&(y.enabled=!0),e.target.releasePointerCapture(e.pointerId)},[i,y,g]),k=v.useCallback(e=>{e.stopPropagation(),T(!1)},[]),{cylinderLength:A,coneWidth:j,coneLength:M,matrixL:N}=v.useMemo(()=>{let t=l?c/s*1.6:s/20,n=l?.2:s/5,r=l?1-n:s-n,i=new Mn().setFromUnitVectors(Xb,e.clone().normalize());return{cylinderLength:r,coneWidth:t,coneLength:n,matrixL:new J().makeRotationFromQuaternion(i)}},[e,s,c,l]),P=w?d:u[t];return v.createElement(`group`,{ref:x},v.createElement(`group`,{matrix:N,matrixAutoUpdate:!1,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerOut:k},i&&v.createElement(_y,{position:[0,-M,0]},v.createElement(`div`,{style:{display:`none`,background:`#151520`,color:`white`,padding:`6px 8px`,borderRadius:7,whiteSpace:`nowrap`},className:a,ref:b})),v.createElement(`mesh`,{visible:!1,position:[0,(A+M)/2,0],userData:_},v.createElement(`cylinderGeometry`,{args:[j*1.4,j*1.4,A+M,8,1]})),v.createElement(mb,{transparent:!0,raycast:()=>null,depthTest:o,points:[0,0,0,0,A,0],lineWidth:c,side:2,color:P,opacity:f,polygonOffset:!0,renderOrder:p,polygonOffsetFactor:-10,fog:!1}),v.createElement(`mesh`,{raycast:()=>null,position:[0,A+M/2,0],renderOrder:p},v.createElement(`coneGeometry`,{args:[j,M,24,1]}),v.createElement(`meshBasicMaterial`,{transparent:!0,depthTest:o,color:P,opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))))},$b=new q,ex=new q,tx=e=>e*180/Math.PI,nx=e=>e*Math.PI/180,rx=(e,t,n,r,i)=>{$b.copy(e).sub(n),ex.copy(t).sub(n);let a=r.dot(r),o=i.dot(i),s=$b.dot(r)/a,c=$b.dot(i)/o,l=ex.dot(r)/a,u=ex.dot(i)/o;return Math.atan2(u,l)-Math.atan2(c,s)},ix=(e,t)=>{let n=Math.floor(e/t);return n=n<0?n+1:n,e-n*t},ax=e=>{let t=ix(e,2*Math.PI);return Math.abs(t)<1e-6?0:(t<0&&(t+=2*Math.PI),t)},ox=new J,sx=new q,cx=new wa,lx=new q,ux=({dir1:e,dir2:t,axis:n})=>{let{rotationLimits:r,annotations:i,annotationsClass:a,depthTest:o,scale:s,lineWidth:c,fixed:l,axisColors:u,hoveredColor:d,renderOrder:f,opacity:p,onDragStart:m,onDrag:h,onDragEnd:g,userData:_}=v.useContext(Kb),y=A_(e=>e.controls),b=v.useRef(null),x=v.useRef(null),S=v.useRef(0),C=v.useRef(0),w=v.useRef(null),[T,E]=v.useState(!1),D=v.useCallback(e=>{i&&(b.current.innerText=`${tx(C.current).toFixed(0)}º`,b.current.style.display=`block`),e.stopPropagation();let t=e.point.clone(),r=new q().setFromMatrixPosition(x.current.matrixWorld),a=new q().setFromMatrixColumn(x.current.matrixWorld,0).normalize(),o=new q().setFromMatrixColumn(x.current.matrixWorld,1).normalize(),s=new q().setFromMatrixColumn(x.current.matrixWorld,2).normalize();w.current={clickPoint:t,origin:r,e1:a,e2:o,normal:s,plane:new mo().setFromNormalAndCoplanarPoint(s,r)},m({component:`Rotator`,axis:n,origin:r,directions:[a,o,s]}),y&&(y.enabled=!1),e.target.setPointerCapture(e.pointerId)},[i,y,m,n]),O=v.useCallback(e=>{if(e.stopPropagation(),T||E(!0),w.current){let{clickPoint:t,origin:a,e1:o,e2:s,normal:c,plane:l}=w.current,[u,d]=r?.[n]||[void 0,void 0];cx.copy(e.ray),cx.intersectPlane(l,lx),cx.direction.negate(),cx.intersectPlane(l,lx);let f=rx(t,lx,a,o,s),p=tx(f);e.shiftKey&&(p=Math.round(p/10)*10,f=nx(p)),u!==void 0&&d!==void 0&&d-u<2*Math.PI?(f=ax(f),f=f>Math.PI?f-2*Math.PI:f,f=jn.clamp(f,u-S.current,d-S.current),C.current=S.current+f):(C.current=ax(S.current+f),C.current=C.current>Math.PI?C.current-2*Math.PI:C.current),i&&(p=tx(C.current),b.current.innerText=`${p.toFixed(0)}º`),ox.makeRotationAxis(c,f),sx.copy(a).applyMatrix4(ox).sub(a).negate(),ox.setPosition(sx),h(ox)}},[i,h,T,r,n]),k=v.useCallback(e=>{i&&(b.current.style.display=`none`),e.stopPropagation(),S.current=C.current,w.current=null,g(),y&&(y.enabled=!0),e.target.releasePointerCapture(e.pointerId)},[i,y,g]),A=v.useCallback(e=>{e.stopPropagation(),E(!1)},[]),j=v.useMemo(()=>{let n=e.clone().normalize(),r=t.clone().normalize();return new J().makeBasis(n,r,n.clone().cross(r))},[e,t]),M=l?.65:s*.65,N=v.useMemo(()=>{let e=[];for(let t=0;t<=32;t++){let n=Math.PI/2*t/32;e.push(new q(Math.cos(n)*M,Math.sin(n)*M,0))}return e},[M]);return v.createElement(`group`,{ref:x,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerOut:A,matrix:j,matrixAutoUpdate:!1},i&&v.createElement(_y,{position:[M,M,0]},v.createElement(`div`,{style:{display:`none`,background:`#151520`,color:`white`,padding:`6px 8px`,borderRadius:7,whiteSpace:`nowrap`},className:a,ref:b})),v.createElement(mb,{points:N,lineWidth:c*4,visible:!1,userData:_}),v.createElement(mb,{transparent:!0,raycast:()=>null,depthTest:o,points:N,lineWidth:c,side:2,color:T?d:u[n],opacity:p,polygonOffset:!0,polygonOffsetFactor:-10,renderOrder:f,fog:!1}))},dx=(e,t,n)=>{let r=Math.abs(e.x)>=Math.abs(e.y)&&Math.abs(e.x)>=Math.abs(e.z)?0:Math.abs(e.y)>=Math.abs(e.x)&&Math.abs(e.y)>=Math.abs(e.z)?1:2,i=[0,1,2].sort((e,n)=>Math.abs(t.getComponent(n))-Math.abs(t.getComponent(e))),a=r===i[0]?i[1]:i[0],o=e.getComponent(r),s=e.getComponent(a),c=t.getComponent(r),l=t.getComponent(a),u=n.getComponent(r),d=(n.getComponent(a)-s/o*u)/(l-s/o*c);return[(u-d*c)/o,d]},fx=new wa,px=new q,mx=new J,hx=({dir1:e,dir2:t,axis:n})=>{let{translation:r,translationLimits:i,annotations:a,annotationsClass:o,depthTest:s,scale:c,lineWidth:l,fixed:u,axisColors:d,hoveredColor:f,opacity:p,renderOrder:m,onDragStart:h,onDrag:g,onDragEnd:_,userData:y}=v.useContext(Kb),b=A_(e=>e.controls),x=v.useRef(null),S=v.useRef(null),C=v.useRef(null),w=v.useRef(0),T=v.useRef(0),[E,D]=v.useState(!1),O=v.useCallback(e=>{a&&(x.current.innerText=`${r.current[(n+1)%3].toFixed(2)}, ${r.current[(n+2)%3].toFixed(2)}`,x.current.style.display=`block`),e.stopPropagation();let t=e.point.clone(),i=new q().setFromMatrixPosition(S.current.matrixWorld),o=new q().setFromMatrixColumn(S.current.matrixWorld,0).normalize(),s=new q().setFromMatrixColumn(S.current.matrixWorld,1).normalize(),c=new q().setFromMatrixColumn(S.current.matrixWorld,2).normalize();C.current={clickPoint:t,e1:o,e2:s,plane:new mo().setFromNormalAndCoplanarPoint(c,i)},w.current=r.current[(n+1)%3],T.current=r.current[(n+2)%3],h({component:`Slider`,axis:n,origin:i,directions:[o,s,c]}),b&&(b.enabled=!1),e.target.setPointerCapture(e.pointerId)},[a,b,h,n]),k=v.useCallback(e=>{if(e.stopPropagation(),E||D(!0),C.current){let{clickPoint:t,e1:o,e2:s,plane:c}=C.current,[l,u]=i?.[(n+1)%3]||[void 0,void 0],[d,f]=i?.[(n+2)%3]||[void 0,void 0];fx.copy(e.ray),fx.intersectPlane(c,px),fx.direction.negate(),fx.intersectPlane(c,px),px.sub(t);let[p,m]=dx(o,s,px);l!==void 0&&(p=Math.max(p,l-w.current)),u!==void 0&&(p=Math.min(p,u-w.current)),d!==void 0&&(m=Math.max(m,d-T.current)),f!==void 0&&(m=Math.min(m,f-T.current)),r.current[(n+1)%3]=w.current+p,r.current[(n+2)%3]=T.current+m,a&&(x.current.innerText=`${r.current[(n+1)%3].toFixed(2)}, ${r.current[(n+2)%3].toFixed(2)}`),mx.makeTranslation(p*o.x+m*s.x,p*o.y+m*s.y,p*o.z+m*s.z),g(mx)}},[a,g,E,r,i,n]),A=v.useCallback(e=>{a&&(x.current.style.display=`none`),e.stopPropagation(),C.current=null,_(),b&&(b.enabled=!0),e.target.releasePointerCapture(e.pointerId)},[a,b,_]),j=v.useCallback(e=>{e.stopPropagation(),D(!1)},[]),M=v.useMemo(()=>{let n=e.clone().normalize(),r=t.clone().normalize();return new J().makeBasis(n,r,n.clone().cross(r))},[e,t]),N=u?1/7:c/7,P=u?.225:c*.225,F=E?f:d[n],I=v.useMemo(()=>[new q(0,0,0),new q(0,P,0),new q(P,P,0),new q(P,0,0),new q(0,0,0)],[P]);return v.createElement(`group`,{ref:S,matrix:M,matrixAutoUpdate:!1},a&&v.createElement(_y,{position:[0,0,0]},v.createElement(`div`,{style:{display:`none`,background:`#151520`,color:`white`,padding:`6px 8px`,borderRadius:7,whiteSpace:`nowrap`},className:o,ref:x})),v.createElement(`group`,{position:[N*1.7,N*1.7,0]},v.createElement(`mesh`,{visible:!0,onPointerDown:O,onPointerMove:k,onPointerUp:A,onPointerOut:j,scale:P,userData:y,renderOrder:m},v.createElement(`planeGeometry`,null),v.createElement(`meshBasicMaterial`,{transparent:!0,depthTest:s,color:F,polygonOffset:!0,polygonOffsetFactor:-10,side:2,fog:!1})),v.createElement(mb,{position:[-P/2,-P/2,0],transparent:!0,depthTest:s,points:I,lineWidth:l,color:F,opacity:p,polygonOffset:!0,polygonOffsetFactor:-10,userData:y,fog:!1,renderOrder:m})))},gx=new q,_x=new q,vx=(e,t,n,r)=>{let i=t.dot(t),a=t.dot(e)-t.dot(n),o=t.dot(r);return o===0?-a/i:(gx.copy(r).multiplyScalar(i/o).sub(t),_x.copy(r).multiplyScalar(a/o).add(n).sub(e),-gx.dot(_x)/gx.dot(gx))},yx=new q(0,1,0),bx=new q,xx=new J,Sx=({direction:e,axis:t})=>{let{scaleLimits:n,annotations:r,annotationsClass:i,depthTest:a,scale:o,lineWidth:s,fixed:c,axisColors:l,hoveredColor:u,opacity:d,renderOrder:f,onDragStart:p,onDrag:m,onDragEnd:h,userData:g}=v.useContext(Kb),_=A_(e=>e.size),y=A_(e=>e.controls),b=v.useRef(null),x=v.useRef(null),S=v.useRef(null),C=v.useRef(1),w=v.useRef(1),T=v.useRef(null),[E,D]=v.useState(!1),O=c?1.2:1.2*o,k=v.useCallback(n=>{r&&(b.current.innerText=`${w.current.toFixed(2)}`,b.current.style.display=`block`),n.stopPropagation();let i=new J().extractRotation(x.current.matrixWorld),a=n.point.clone(),s=new q().setFromMatrixPosition(x.current.matrixWorld),l=e.clone().applyMatrix4(i).normalize(),u=x.current.matrixWorld.clone();T.current={clickPoint:a,dir:l,mPLG:u,mPLGInv:u.clone().invert(),offsetMultiplier:c?1/pb(x.current.getWorldPosition(gx),o,n.camera,_):1},p({component:`Sphere`,axis:t,origin:s,directions:[l]}),y&&(y.enabled=!1),n.target.setPointerCapture(n.pointerId)},[r,y,e,p,t,c,o,_]),A=v.useCallback(e=>{if(e.stopPropagation(),E||D(!0),T.current){let{clickPoint:i,dir:a,mPLG:s,mPLGInv:l,offsetMultiplier:u}=T.current,[d,f]=n?.[t]||[1e-5,void 0],p=vx(i,a,e.ray.origin,e.ray.direction)*u,h=2**((c?p:p/o)*.2);e.shiftKey&&(h=Math.round(h*10)/10),h=Math.max(h,d/C.current),f!==void 0&&(h=Math.min(h,f/C.current)),w.current=C.current*h,S.current.position.set(0,O+p,0),r&&(b.current.innerText=`${w.current.toFixed(2)}`),bx.set(1,1,1),bx.setComponent(t,h),xx.makeScale(bx.x,bx.y,bx.z).premultiply(s).multiply(l),m(xx)}},[r,O,m,E,n,t]),j=v.useCallback(e=>{r&&(b.current.style.display=`none`),e.stopPropagation(),C.current=w.current,T.current=null,S.current.position.set(0,O,0),h(),y&&(y.enabled=!0),e.target.releasePointerCapture(e.pointerId)},[r,y,h,O]),M=v.useCallback(e=>{e.stopPropagation(),D(!1)},[]),{radius:N,matrixL:P}=v.useMemo(()=>{let t=c?s/o*1.8:o/22.5,n=new Mn().setFromUnitVectors(yx,e.clone().normalize());return{radius:t,matrixL:new J().makeRotationFromQuaternion(n)}},[e,o,s,c]),F=E?u:l[t];return v.createElement(`group`,{ref:x},v.createElement(`group`,{matrix:P,matrixAutoUpdate:!1,onPointerDown:k,onPointerMove:A,onPointerUp:j,onPointerOut:M},r&&v.createElement(_y,{position:[0,O/2,0]},v.createElement(`div`,{style:{display:`none`,background:`#151520`,color:`white`,padding:`6px 8px`,borderRadius:7,whiteSpace:`nowrap`},className:i,ref:b})),v.createElement(`mesh`,{ref:S,position:[0,O,0],renderOrder:f,userData:g},v.createElement(`sphereGeometry`,{args:[N,12,12]}),v.createElement(`meshBasicMaterial`,{transparent:!0,depthTest:a,color:F,opacity:d,polygonOffset:!0,polygonOffsetFactor:-10}))))},Cx=new J,wx=new J,Tx=new J,Ex=new J,Dx=new J,Ox=new J,kx=new J,Ax=new J,jx=new J,Mx=new ni,Nx=new ni,Px=new q,Fx=new q,Ix=new q,Lx=new q,Rx=new q,zx=new q(1,0,0),Bx=new q(0,1,0),Vx=new q(0,0,1),Hx=v.forwardRef(({enabled:e=!0,matrix:t,onDragStart:n,onDrag:r,onDragEnd:i,autoTransform:a=!0,anchor:o,disableAxes:s=!1,disableSliders:c=!1,disableRotations:l=!1,disableScaling:u=!1,activeAxes:d=[!0,!0,!0],offset:f=[0,0,0],rotation:p=[0,0,0],scale:m=1,lineWidth:h=4,fixed:g=!1,translationLimits:_,rotationLimits:y,scaleLimits:b,depthTest:x=!0,renderOrder:S=500,axisColors:C=[`#ff2060`,`#20df80`,`#2080ff`],hoveredColor:w=`#ffff40`,annotations:T=!1,annotationsClass:E,opacity:D=1,visible:O=!0,userData:k,children:A,...j},M)=>{let N=A_(e=>e.invalidate),P=v.useRef(null),F=v.useRef(null),I=v.useRef(null),L=v.useRef(null),ee=v.useRef([0,0,0]),R=v.useRef(new q(1,1,1)),te=v.useRef(new q(1,1,1));v.useLayoutEffect(()=>{o&&(L.current.updateWorldMatrix(!0,!0),Ex.copy(L.current.matrixWorld).invert(),Mx.makeEmpty(),L.current.traverse(e=>{e.geometry&&(e.geometry.boundingBox||e.geometry.computeBoundingBox(),Ox.copy(e.matrixWorld).premultiply(Ex),Nx.copy(e.geometry.boundingBox),Nx.applyMatrix4(Ox),Mx.union(Nx))}),Px.copy(Mx.max).add(Mx.min).multiplyScalar(.5),Fx.copy(Mx.max).sub(Mx.min).multiplyScalar(.5),Ix.copy(Fx).multiply(new q(...o)).add(Px),Lx.set(...f).add(Ix),I.current.position.copy(Lx),N())});let z=v.useMemo(()=>({onDragStart:e=>{Cx.copy(F.current.matrix),wx.copy(F.current.matrixWorld),n&&n(e),N()},onDrag:e=>{Tx.copy(P.current.matrixWorld),Ex.copy(Tx).invert(),Dx.copy(wx).premultiply(e),Ox.copy(Dx).premultiply(Ex),kx.copy(Cx).invert(),Ax.copy(Ox).multiply(kx),a&&F.current.matrix.copy(Ox),r&&r(Ox,Ax,Dx,e),N()},onDragEnd:()=>{i&&i(),N()},translation:ee,translationLimits:_,rotationLimits:y,axisColors:C,hoveredColor:w,opacity:D,scale:m,lineWidth:h,fixed:g,depthTest:x,renderOrder:S,userData:k,annotations:T,annotationsClass:E}),[n,r,i,ee,_,y,b,x,m,h,g,...C,w,D,k,a,T,E]),B=new q;return j_(e=>{if(g){let t=pb(I.current.getWorldPosition(B),m,e.camera,e.size);R.current.setScalar(t)}t&&t instanceof J&&(F.current.matrix=t),F.current.updateWorldMatrix(!0,!0),jx.makeRotationFromEuler(I.current.rotation).setPosition(I.current.position).premultiply(F.current.matrixWorld),te.current.setFromMatrixScale(jx),Rx.copy(R.current).divide(te.current),(Math.abs(I.current.scale.x-Rx.x)>1e-4||Math.abs(I.current.scale.y-Rx.y)>1e-4||Math.abs(I.current.scale.z-Rx.z)>1e-4)&&(I.current.scale.copy(Rx),e.invalidate())}),v.useImperativeHandle(M,()=>F.current,[]),v.createElement(Kb.Provider,{value:z},v.createElement(`group`,{ref:P},v.createElement(`group`,ny({ref:F,matrix:t,matrixAutoUpdate:!1},j),v.createElement(`group`,{visible:O,ref:I,position:f,rotation:p},e&&v.createElement(v.Fragment,null,!s&&d[0]&&v.createElement(Qb,{axis:0,direction:zx}),!s&&d[1]&&v.createElement(Qb,{axis:1,direction:Bx}),!s&&d[2]&&v.createElement(Qb,{axis:2,direction:Vx}),!c&&d[0]&&d[1]&&v.createElement(hx,{axis:2,dir1:zx,dir2:Bx}),!c&&d[0]&&d[2]&&v.createElement(hx,{axis:1,dir1:Vx,dir2:zx}),!c&&d[2]&&d[1]&&v.createElement(hx,{axis:0,dir1:Bx,dir2:Vx}),!l&&d[0]&&d[1]&&v.createElement(ux,{axis:2,dir1:zx,dir2:Bx}),!l&&d[0]&&d[2]&&v.createElement(ux,{axis:1,dir1:Vx,dir2:zx}),!l&&d[2]&&d[1]&&v.createElement(ux,{axis:0,dir1:Bx,dir2:Vx}),!u&&d[0]&&v.createElement(Sx,{axis:0,direction:zx}),!u&&d[1]&&v.createElement(Sx,{axis:1,direction:Bx}),!u&&d[2]&&v.createElement(Sx,{axis:2,direction:Vx}))),v.createElement(`group`,{ref:L},A))))}),Ux=.5,Wx=[.5,.75,1,1.25,1.5,2,3,4],Gx=e=>.05+e*.055,Kx=e=>e*Math.PI/180;function qx(e){let t=Ux,n=Kx(e.angle??90)-Math.PI/2;return[{id:`a`,pos:[0,0,0],dir:[-1,0,0]},{id:`b`,pos:[t*Math.cos(n),t*Math.sin(n)+t,0],dir:[-Math.sin(n),Math.cos(n),0]}]}function Jx(e){let t=Wx[0],n=Math.abs(e-t);for(let r of Wx){let i=Math.abs(e-r);i<n&&(t=r,n=i)}return t}var Yx={pipe:{type:`pipe`,label:`Pipe`,category:`Plumbing`,description:`Straight pipe segment`,color:`#b8bfc9`,defaults:{length:2,diameter:1},params:{length:{label:`Length`,min:.5,max:12,step:.5,unit:`ft`},diameter:{label:`Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:e=>[{id:`a`,pos:[-e.length/2,0,0],dir:[-1,0,0]},{id:`b`,pos:[e.length/2,0,0],dir:[1,0,0]}]},coupling:{type:`coupling`,label:`Coupling`,category:`Plumbing`,description:`Straight fitting for joining two pipe ends`,color:`#aeb7c2`,defaults:{diameter:1},params:{diameter:{label:`Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`a`,pos:[-.3,0,0],dir:[-1,0,0]},{id:`b`,pos:[.3,0,0],dir:[1,0,0]}]},reducer:{type:`reducer`,label:`Reducer`,category:`Plumbing`,description:`Inline reducer fitting between two pipe diameters`,color:`#a8b2bf`,defaults:{diameterA:1.5,diameterB:1},params:{diameterA:{label:`Diameter A`,min:.5,max:4,step:.25,unit:`in`},diameterB:{label:`Diameter B`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`a`,pos:[-.35,0,0],dir:[-1,0,0]},{id:`b`,pos:[.35,0,0],dir:[1,0,0]}]},cap:{type:`cap`,label:`Cap`,category:`Plumbing`,description:`End cap that terminates a pipe run`,color:`#9aa3b0`,defaults:{diameter:1},params:{diameter:{label:`Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`in`,pos:[-.22,0,0],dir:[-1,0,0]}]},elbow:{type:`elbow`,label:`Elbow`,category:`Plumbing`,description:`Bend fitting (15–180°)`,color:`#9aa3b0`,defaults:{angle:90,diameter:1},params:{angle:{label:`Bend angle`,min:15,max:180,step:15,unit:`°`},diameter:{label:`Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:qx},tee:{type:`tee`,label:`T-Joint`,category:`Plumbing`,description:`3-way splitter fitting`,color:`#9aa3b0`,defaults:{diameter:1},params:{diameter:{label:`Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`a`,pos:[-.6,0,0],dir:[-1,0,0]},{id:`b`,pos:[.6,0,0],dir:[1,0,0]},{id:`c`,pos:[0,0,.6],dir:[0,0,1]}]},valve:{type:`valve`,label:`Valve`,category:`Flow Control`,description:`Inline ball valve (0–100% open)`,color:`#e0564f`,defaults:{diameter:1,open:100},params:{open:{label:`Open`,min:0,max:100,step:5,unit:`%`},diameter:{label:`Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`a`,pos:[-.35,0,0],dir:[-1,0,0]},{id:`b`,pos:[.35,0,0],dir:[1,0,0]}]},pump:{type:`pump`,label:`Pump`,category:`Flow Control`,description:`Submersible/inline pump — pressure source`,color:`#3d7bfa`,defaults:{gph:400,maxHeadFt:8,on:1},params:{gph:{label:`Rated flow`,min:50,max:2e3,step:25,unit:`GPH`},maxHeadFt:{label:`Max head`,min:2,max:30,step:1,unit:`ft`}},getConnectors:()=>[{id:`in`,pos:[-.45,.25,0],dir:[-1,0,0]},{id:`out`,pos:[.45,.25,0],dir:[1,0,0]}]},reservoir:{type:`reservoir`,label:`Reservoir`,category:`Flow Control`,description:`Water tank — source & return sink`,color:`#2a3950`,defaults:{width:2,depth:1.4,height:1,level:70,ph:6,ec:1.2},params:{width:{label:`Width`,min:1,max:6,step:.5,unit:`ft`},depth:{label:`Depth`,min:1,max:6,step:.5,unit:`ft`},height:{label:`Height`,min:.5,max:4,step:.25,unit:`ft`},level:{label:`Fill level`,min:0,max:100,step:5,unit:`%`},ph:{label:`Water pH`,min:4,max:8.5,step:.1,unit:``},ec:{label:`Water EC`,min:0,max:3,step:.1,unit:`mS/cm`}},getConnectors:e=>[{id:`a`,pos:[-e.width/2,.25,0],dir:[-1,0,0]},{id:`b`,pos:[e.width/2,.25,0],dir:[1,0,0]},{id:`c`,pos:[0,.25,-e.depth/2],dir:[0,0,-1]},{id:`d`,pos:[0,.25,e.depth/2],dir:[0,0,1]}]},tower:{type:`tower`,label:`Grow Tower`,category:`Growing`,description:`Vertical NFT tower with plant sites`,color:`#e8eaed`,defaults:{height:4,sites:6},params:{height:{label:`Height`,min:2,max:10,step:.5,unit:`ft`},sites:{label:`Plant sites`,min:2,max:16,step:1}},getConnectors:e=>[{id:`in`,pos:[0,e.height,0],dir:[0,1,0]},{id:`out`,pos:[.45,.15,0],dir:[1,0,0]}]},tray:{type:`tray`,label:`Grow Tray`,category:`Growing`,description:`Flood/NFT channel tray`,color:`#d7dce2`,defaults:{length:3,width:1.2},params:{length:{label:`Length`,min:1,max:8,step:.5,unit:`ft`},width:{label:`Width`,min:.5,max:4,step:.25,unit:`ft`}},getConnectors:e=>[{id:`in`,pos:[-e.length/2,.15,0],dir:[-1,0,0]},{id:`out`,pos:[e.length/2,.15,0],dir:[1,0,0]}]},wallPanel:{type:`wallPanel`,label:`Wall Panel`,category:`Growing`,description:`Vertical grow wall with pockets`,color:`#3b7a57`,defaults:{width:3,height:4,rows:4,cols:5},params:{width:{label:`Width`,min:1,max:8,step:.5,unit:`ft`},height:{label:`Height`,min:1,max:8,step:.5,unit:`ft`},rows:{label:`Pocket rows`,min:1,max:8,step:1},cols:{label:`Pocket cols`,min:1,max:10,step:1}},getConnectors:e=>[{id:`in`,pos:[0,e.height,0],dir:[0,1,0]},{id:`out`,pos:[0,.05,0],dir:[0,-1,0]}]},lattice:{type:`lattice`,label:`Lattice`,category:`Structure`,description:`Structural lattice frame (no flow)`,color:`#8a7a5c`,defaults:{width:2.5,height:3},params:{width:{label:`Width`,min:1,max:8,step:.5,unit:`ft`},height:{label:`Height`,min:1,max:8,step:.5,unit:`ft`}},getConnectors:()=>[]},netPot:{type:`netPot`,label:`Net Pot`,category:`Growing`,description:`Plant cup with seedling (decorative)`,color:`#222a33`,defaults:{size:1},params:{size:{label:`Size`,min:.5,max:2,step:.25}},getConnectors:()=>[]},emitter:{type:`emitter`,label:`Emitter`,category:`Flow Control`,description:`Drip/spray outlet — terminates a line`,color:`#46c0e8`,defaults:{},params:{},getConnectors:()=>[{id:`in`,pos:[.2,0,0],dir:[1,0,0]}]},drain:{type:`drain`,label:`Drain`,category:`Flow Control`,description:`Floor drain — limited-capacity exit point`,color:`#64748b`,defaults:{capacityGph:250},params:{capacityGph:{label:`Capacity`,min:50,max:2e3,step:25,unit:`GPH`}},getConnectors:()=>[{id:`in`,pos:[-.35,.25,0],dir:[-1,0,0]}]},growTent:{type:`growTent`,label:`Grow Tent`,category:`Environment`,description:`Room/tent enclosure for planning air exchange and equipment`,color:`#475569`,defaults:{width:7,depth:5,height:4,sealed:0},params:{width:{label:`Width`,min:2,max:20,step:.5,unit:`ft`},depth:{label:`Depth`,min:2,max:20,step:.5,unit:`ft`},height:{label:`Height`,min:2,max:12,step:.5,unit:`ft`},sealed:{label:`Sealed room`,min:0,max:1,step:1}},getConnectors:()=>[]},inlineFan:{type:`inlineFan`,label:`Inline Fan`,category:`Environment`,description:`Duct fan for room exhaust/intake calculations`,color:`#0f766e`,defaults:{cfm:600,diameter:6,exhaust:1},params:{cfm:{label:`Airflow`,min:50,max:4e3,step:25,unit:`CFM`},diameter:{label:`Duct size`,min:4,max:14,step:2,unit:`in`},exhaust:{label:`Exhaust mode`,min:0,max:1,step:1}},getConnectors:()=>[]},circulationFan:{type:`circulationFan`,label:`Circulation Fan`,category:`Environment`,description:`Internal airflow fan for canopy mixing`,color:`#2563eb`,defaults:{cfm:250,sweep:90},params:{cfm:{label:`Airflow`,min:50,max:1500,step:25,unit:`CFM`},sweep:{label:`Sweep`,min:0,max:180,step:15,unit:`°`}},getConnectors:()=>[]},growLight:{type:`growLight`,label:`Grow Light`,category:`Environment`,description:`Overhead grow fixture for room planning`,color:`#fbbf24`,defaults:{width:2,depth:2,watts:650,hangingHeight:1.5,photoperiod:18},params:{width:{label:`Width`,min:.5,max:6,step:.25,unit:`ft`},depth:{label:`Depth`,min:.5,max:6,step:.25,unit:`ft`},watts:{label:`Power`,min:50,max:1500,step:25,unit:`W`},hangingHeight:{label:`Hang height`,min:.25,max:6,step:.25,unit:`ft`},photoperiod:{label:`Hours On`,min:0,max:24,step:1,unit:`h`}},getConnectors:()=>[]},co2Tank:{type:`co2Tank`,label:`CO₂ Tank`,category:`Environment`,description:`CO₂ cylinder for sealed-room enrichment planning`,color:`#22c55e`,defaults:{pounds:20,regulatorCfh:20},params:{pounds:{label:`Tank size`,min:5,max:100,step:5,unit:`lb`},regulatorCfh:{label:`Release rate`,min:1,max:100,step:1,unit:`CFH`}},getConnectors:()=>[]},airCompressor:{type:`airCompressor`,label:`Air Compressor`,category:`Flow Control`,description:`Aerate reservoir water with an attached airstone`,color:`#0ea5e9`,defaults:{gph:120,frequency:5,on:1},params:{gph:{label:`Air Flow`,min:20,max:400,step:10,unit:`GPH`},frequency:{label:`Bubble Freq`,min:1,max:10,step:1,unit:`Hz`}},getConnectors:()=>[]},reducingTee:{type:`reducingTee`,label:`Reducing Tee`,category:`Plumbing`,description:`Tee branch with a reduced secondary outlet size`,color:`#8b9bb4`,defaults:{diameterA:1.5,diameterB:1},params:{diameterA:{label:`Main Run Diameter`,min:.5,max:4,step:.25,unit:`in`},diameterB:{label:`Branch Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`a`,pos:[-.6,0,0],dir:[-1,0,0]},{id:`b`,pos:[.6,0,0],dir:[1,0,0]},{id:`c`,pos:[0,0,.6],dir:[0,0,1]}]},reducingElbow:{type:`reducingElbow`,label:`Reducing Elbow`,category:`Plumbing`,description:`90-degree elbow transitioning between two diameters`,color:`#9aa3b0`,defaults:{diameterA:1.5,diameterB:1},params:{diameterA:{label:`Diameter A`,min:.5,max:4,step:.25,unit:`in`},diameterB:{label:`Diameter B`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`a`,pos:[0,0,0],dir:[-1,0,0]},{id:`b`,pos:[.18,.18,0],dir:[0,1,0]}]},bulkhead:{type:`bulkhead`,label:`Bulkhead Fitting`,category:`Plumbing`,description:`Tank wall pass-through connector`,color:`#27272a`,defaults:{diameter:1},params:{diameter:{label:`Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`a`,pos:[-.2,0,0],dir:[-1,0,0]},{id:`b`,pos:[.2,0,0],dir:[1,0,0]}]},waterChiller:{type:`waterChiller`,label:`Water Chiller`,category:`Flow Control`,description:`Thermoelectric water chiller to keep reservoirs cool`,color:`#0891b2`,defaults:{targetTemp:68,on:1,diameter:1},params:{targetTemp:{label:`Target Temp`,min:45,max:80,step:1,unit:`°F`},diameter:{label:`Port Size`,min:.5,max:2,step:.25,unit:`in`}},getConnectors:()=>[{id:`in`,pos:[-.2,1.05,0],dir:[0,1,0]},{id:`out`,pos:[.2,1.05,0],dir:[0,1,0]}]},reverseOsmosis:{type:`reverseOsmosis`,label:`RO Filter`,category:`Plumbing`,description:`Reverse osmosis filter to purify source water`,color:`#3b82f6`,defaults:{diameter:1},params:{diameter:{label:`Diameter`,min:.5,max:4,step:.25,unit:`in`}},getConnectors:()=>[{id:`a`,pos:[-.3,0,0],dir:[-1,0,0]},{id:`b`,pos:[.3,0,0],dir:[1,0,0]}]}},Xx=[{name:`Plumbing`,types:[`pipe`,`coupling`,`reducer`,`cap`,`elbow`,`tee`,`reducingTee`,`reducingElbow`,`bulkhead`,`reverseOsmosis`]},{name:`Flow Control`,types:[`pump`,`reservoir`,`valve`,`emitter`,`drain`,`airCompressor`,`waterChiller`]},{name:`Growing`,types:[`tower`,`tray`,`wallPanel`,`netPot`]},{name:`Structure`,types:[`lattice`]},{name:`Environment`,types:[`growTent`,`inlineFan`,`circulationFan`,`growLight`,`co2Tank`]}],Zx=new Set([`pipe`,`coupling`,`reducer`,`cap`,`elbow`,`tee`,`valve`,`pump`,`reservoir`,`tower`,`tray`,`wallPanel`,`emitter`,`drain`,`reducingTee`,`reducingElbow`,`bulkhead`,`waterChiller`,`reverseOsmosis`]),Qx=new Set([`pipe`,`coupling`,`reducer`,`elbow`,`tee`,`valve`,`pump`,`reducingTee`,`reducingElbow`,`bulkhead`,`waterChiller`,`reverseOsmosis`]),$x=.8,eS=new pr,tS=new q;function nS(e){let t=Yx[e.type];return eS.set(e.rotation[0],e.rotation[1],e.rotation[2],`XYZ`),t.getConnectors(e.params).map(t=>{let n=tS.set(...t.pos).applyEuler(eS).toArray();n[0]+=e.position[0],n[1]+=e.position[1],n[2]+=e.position[2];let r=new q(...t.dir).applyEuler(eS).toArray();return{key:`${e.id}:${t.id}`,partId:e.id,connectorId:t.id,partType:e.type,pos:n,dir:r}})}var rS=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]);function iS(e,t){let n=nS(e);if(!n.length)return null;let r=null;for(let i of t)if(i.id!==e.id)for(let e of nS(i))for(let t of n){let n=rS(t.pos,e.pos);n<.8&&(!r||n<r.d)&&(r={d:n,delta:[e.pos[0]-t.pos[0],e.pos[1]-t.pos[1],e.pos[2]-t.pos[2]]})}return r&&r.d<1e-4?null:r?r.delta:null}function aS(e,t,n,r=$x){let i=[];for(let e of t)n.has(e.id)||i.push(...nS(e));let a=new Set;for(let e=0;e<i.length;e++)for(let t=e+1;t<i.length;t++)i[e].partId!==i[t].partId&&rS(i[e].pos,i[t].pos)<.35&&(a.add(i[e].key),a.add(i[t].key));let o=null;for(let t of i){if(a.has(t.key))continue;let n=rS(e,t.pos);n<r&&(!o||n<o.d)&&(o={...t,d:n})}return o}function oS(e,t,n=$x){let r=null;for(let i of t){if(i.type!==`pipe`)continue;let t=nS(i),a=t.find(e=>e.connectorId===`a`),o=t.find(e=>e.connectorId===`b`);if(!a||!o)continue;let s=a.pos[0],c=a.pos[2],l=o.pos[0],u=o.pos[2],d=l-s,f=u-c,p=d*d+f*f;if(p<1e-6)continue;let m=e[0]-s,h=e[2]-c,g=(m*d+h*f)/p;if(g<=.15||g>=.85)continue;let _=s+d*g,v=c+f*g,y=Math.hypot(e[0]-_,e[2]-v);if(y>n)continue;let b=i.rotation[1],x=e[0]-_,S=e[2]-v,C=Math.atan2(-S,x)-b,w=b+Math.round(C/(Math.PI/2))*(Math.PI/2)+Math.PI/2;w=Math.atan2(Math.sin(w),Math.cos(w));let T=nS({id:`__tap__`,type:`tee`,position:[_,i.position[1],v],rotation:[0,w,0],params:{...Yx.tee.defaults,diameter:i.params.diameter??1}}).find(e=>e.connectorId===`c`);if(!T)continue;let E={partId:i.id,pos:[_,i.position[1],v],branchPos:T.pos,rotationY:w,diameter:i.params.diameter??1,d:y};(!r||y<r.d)&&(r=E)}return r}var sS=new Set([`reservoir`,`emitter`,`drain`,`tower`,`tray`,`wallPanel`]);function cS(e){if(!Yx[e.type])return[];try{return nS(e)}catch{return[]}}function lS(e){return e?e.label??Yx[e.type]?.label??e.type:`Unknown part`}function uS(e){return e?.params?.on===0||e?.params?.enabled===0}function dS(e){return e?sS.has(e.type)?!0:Yx[e.type]?.category===`Growing`&&cS(e).length>0:!1}function fS(e,t){let[n,r,i]=e.position,a=e.params??{},o=.2,s=[e.position,...t.map(e=>e.pos)],c=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];for(let e of s)for(let t=0;t<3;t++)c[t]=Math.min(c[t],e[t]-o),l[t]=Math.max(l[t],e[t]+o);let u=(a.width??0)/2;u>0&&(c[0]=Math.min(c[0],n-u),l[0]=Math.max(l[0],n+u));let d=(a.length??0)/2;d>0&&(c[0]=Math.min(c[0],n-d),l[0]=Math.max(l[0],n+d));let f=(a.depth??a.width??0)/2;return f>0&&(c[2]=Math.min(c[2],i-f),l[2]=Math.max(l[2],i+f)),(a.height??0)>0&&(c[1]=Math.min(c[1],r),l[1]=Math.max(l[1],r+a.height)),{min:c,max:l}}var pS=class{parent=new Map;find(e){let t=this.parent.get(e)??e;return t!==e&&(t=this.find(t),this.parent.set(e,t)),t}union(e,t){let n=this.find(e),r=this.find(t);n!==r&&this.parent.set(n,r)}};function mS(e){let t=new Map,n=[];for(let r of e){let e=cS(r);t.set(r.id,e),n.push(...e)}let r=[],i=new Set,a=new pS;for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){let o=n[e],s=n[t];o.partId!==s.partId&&rS(o.pos,s.pos)<.35&&(r.push({a:o,b:s}),i.add(o.key),i.add(s.key),a.union(o.key,s.key))}let o=new Map,s=(e,t)=>{let n=o.get(e);n||o.set(e,n=new Set),n.add(t)};for(let{a:e,b:t}of r)s(e.partId,t.partId),s(t.partId,e.partId);let c=[],l=new Map;for(let n of e){if(!t.get(n.id)?.length||l.has(n.id))continue;let e=new Set,r=[n.id];for(l.set(n.id,c.length);r.length;){let t=r.pop();e.add(t);for(let e of o.get(t)??[])l.has(e)||(l.set(e,c.length),r.push(e))}c.push(e)}let u=new Map,d=new Map,f=(e,t)=>{let n=u.get(e);return n||(n={id:e,pos:t,edges:[]},u.set(e,n)),n};for(let n of e){let e=t.get(n.id)??[];if(!e.length)continue;let r=f(`P:${n.id}`,n.position);for(let t of e){let e=`N:${a.find(t.key)}`;d.set(t.key,e),f(e,t.pos).edges.push({to:r.id,partId:n.id}),r.edges.push({to:e,partId:n.id})}}return{connectorsByPart:t,joints:r,joinedKeys:i,neighbors:o,componentOf:l,components:c,nodes:u,nodeOfConnector:d}}var hS=()=>Math.random().toString(36).substring(2,10);function gS(e){if(e.type!==`growTent`&&e.type!==`reservoir`&&e.type!==`tray`&&e.type!==`wallPanel`&&e.type!==`tower`)return null;let t=1,n=1,r=1;e.type===`tray`?(t=e.params.length??3,n=e.params.width??1.2,r=.25):e.type===`wallPanel`?(t=e.params.width??3,n=.5,r=e.params.height??4):e.type===`tower`?(t=1,n=1,r=e.params.height??4):(t=e.params.width??2,n=e.params.depth??1.4,r=e.params.height??1);let i=new ni(new q(-t/2,0,-n/2),new q(t/2,r,n/2)),a=new q(...e.position),o=new pr(...e.rotation,`XYZ`),s=new J().compose(a,new Mn().setFromEuler(o),new q(1,1,1));return i.applyMatrix4(s),i}function _S(e,t,n){let r=e instanceof q?e.clone():new q(...e),i=t instanceof q?t.clone():new q(...t),a=Math.round(r.x*2),o=Math.round(r.y*2),s=Math.round(r.z*2),c=Math.round(i.x*2),l=Math.round(i.y*2),u=Math.round(i.z*2),d=`${a},${o},${s}`,f=`${c},${l},${u}`,p=Math.min(a,c)-12,m=Math.max(a,c)+12,h=Math.min(o,l)-12,g=Math.max(o,l)+12,_=Math.min(s,u)-12,v=Math.max(s,u)+12;h=Math.max(h,-4);for(let e of n)p=Math.min(p,Math.round((e.min.x-2)*2)),m=Math.max(m,Math.round((e.max.x+2)*2)),h=Math.min(h,Math.round((e.min.y-2)*2)),g=Math.max(g,Math.round((e.max.y+2)*2)),_=Math.min(_,Math.round((e.min.z-2)*2)),v=Math.max(v,Math.round((e.max.z+2)*2));let y=new Set([d]),b=new Map,x=new Map,S=new Map;x.set(d,0);let C=(e,t,n,r,i,a)=>Math.abs(e-r)+Math.abs(t-i)+Math.abs(n-a);S.set(d,C(a,o,s,c,l,u));let w=0;for(;y.size>0&&(w++,!(w>3e4));){let e=``,t=1/0;for(let n of y){let r=S.get(n)??1/0;r<t&&(t=r,e=n)}if(!e)break;let[a,o,s]=e.split(`,`).map(Number);if(e===f){let t=[],n=e;for(;n;){let[e,r,i]=n.split(`,`).map(Number);t.push(new q(e/2,r/2,i/2)),n=b.get(n)}t.reverse();let a=[r.clone()];for(let e of t)a[a.length-1].distanceTo(e)>.05&&a.push(e);return a[a.length-1].distanceTo(i)>.05&&a.push(i.clone()),a}y.delete(e);let w=[[a+1,o,s],[a-1,o,s],[a,o+1,s],[a,o-1,s],[a,o,s+1],[a,o,s-1]];for(let[t,r,i]of w){if(t<p||t>m||r<h||r>g||i<_||i>v)continue;let w=`${t},${r},${i}`,T=new q(t/2,r/2,i/2);if(w!==f&&w!==d){let e=!1;for(let t of n)if(t.clone().expandByScalar(.08).containsPoint(T)){e=!0;break}if(e)continue}let E=x.get(e)??1/0,D=t-a,O=r-o,k=i-s,A=!1,j=b.get(e);if(j){let[e,t,n]=j.split(`,`).map(Number),r=a-e,i=o-t,c=s-n;(r!==D||i!==O||c!==k)&&(A=!0)}let M=E+(.5+(A?5:0));M<(x.get(w)??1/0)&&(b.set(w,e),x.set(w,M),S.set(w,M+C(t,r,i,c,l,u)),y.add(w))}}return null}function vS(e,t,n){if(e.length<2)return[];let r=[e[0]];for(let t=1;t<e.length-1;t++){let n=r[r.length-1],i=e[t],a=e[t+1],o=i.clone().sub(n).normalize(),s=a.clone().sub(i).normalize();o.dot(s)<.999&&r.push(i)}r.push(e[e.length-1]);let i=[],a=Array(r.length).fill(!1);for(let e=1;e<r.length-1;e++)a[e]=!0;for(let e=0;e<r.length-1;e++){let o=r[e],s=r[e+1],c=s.clone().sub(o).normalize(),l=o.clone().addScaledVector(c,a[e]?.5:0),u=s.clone().addScaledVector(c,a[e+1]?-.5:0),d=l.distanceTo(u);if(d>.05){let e=l.clone().add(u).multiplyScalar(.5),r=new Mn().setFromUnitVectors(new q(1,0,0),c),a=new pr().setFromQuaternion(r,`XYZ`);i.push({id:`pipe-${hS()}`,type:`pipe`,position:[e.x,e.y,e.z],rotation:[a.x,a.y,a.z],params:{length:d,diameter:t},roomId:n})}if(a[e+1]){let a=s,o=r[e+2],l=c,u=o.clone().sub(a).normalize(),d=a.clone().addScaledVector(l,-.5),f=new J().makeBasis(l,u,new q().crossVectors(l,u).normalize()),p=new pr().setFromRotationMatrix(f,`XYZ`);i.push({id:`elbow-${hS()}`,type:`elbow`,position:[d.x,d.y,d.z],rotation:[p.x,p.y,p.z],params:{angle:90,diameter:t},roomId:n})}}return i}var yS=Sy((e,t)=>({toasts:[],addToast:(n,r)=>{let i=typeof crypto.randomUUID==`function`?crypto.randomUUID().slice(0,8):Math.random().toString(36).substring(2,10);e({toasts:[...t().toasts,{id:i,message:n,type:r}]}),setTimeout(()=>t().dismissToast(i),3e3)},dismissToast:n=>{e({toasts:t().toasts.map(e=>e.id===n?{...e,exiting:!0}:e)}),setTimeout(()=>e({toasts:t().toasts.filter(e=>e.id!==n)}),300)}})),bS=yS.getState().addToast,xS={success:`border-l-emerald-500`,error:`border-l-rose-500`,info:`border-l-sky-500`};function SS(){let e=yS(e=>e.toasts),t=yS(e=>e.dismissToast);return e.length===0?null:(0,Z.jsx)(`div`,{className:`pointer-events-none fixed bottom-4 right-4 z-[200] flex flex-col-reverse gap-2`,children:e.map(e=>(0,Z.jsx)(CS,{toast:e,onDismiss:t},e.id))})}function CS({toast:e,onDismiss:t}){return(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex items-start gap-2 rounded-lg border-l-4 bg-zinc-900 px-4 py-3 shadow-2xl ${xS[e.type]} ${e.exiting?`animate-toast-out`:`animate-toast-in`}`,children:[(0,Z.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.message}),(0,Z.jsx)(`button`,{onClick:()=>t(e.id),className:`ml-2 shrink-0 text-zinc-500 hover:text-zinc-200 transition cursor-pointer text-xs leading-none mt-0.5`,children:`✕`})]})}var wS=()=>crypto.randomUUID().slice(0,8),TS=new Mn,ES=new pr,DS=new q,OS=new q,kS=1,AS=.18,jS=new Set([`inlineFan`,`circulationFan`,`growLight`,`co2Tank`]),MS={tag:``,time:0},NS=(e,t)=>Math.round(e/t)*t;function PS(e,t,n){return t===`diameter`||t===`diameterA`||t===`diameterB`?Jx(n):n}function FS(e,t,n){return Math.max(t,Math.min(n,e))}function IS(e,t,n){if(!jS.has(e.type))return null;let r=null;for(let i of Object.values(n)){if(i.id===e.id||i.type!==`growTent`||i.roomId!==e.roomId)continue;let n=i.params.width??0,a=i.params.depth??0,o=i.params.height??0,s=Math.max(0,Math.abs(t[0]-i.position[0])-n/2),c=Math.max(0,Math.abs(t[2]-i.position[2])-a/2),l=t[1]<i.position[1]?i.position[1]-t[1]:t[1]>i.position[1]+o?t[1]-(i.position[1]+o):0,u=s+c+l,d=s<=kS&&c<=kS&&l<=Math.max(kS,o);(t[0]>=i.position[0]-n/2&&t[0]<=i.position[0]+n/2&&t[2]>=i.position[2]-a/2&&t[2]<=i.position[2]+a/2&&t[1]>=i.position[1]&&t[1]<=i.position[1]+o||d)&&(!r||u<r.score)&&(r={room:i,score:u})}return r?.room??null}function LS(e,t,n,r){let i=IS(e,t,r);if(!i)return null;let a=i.params.width??0,o=i.params.depth??0,s=i.params.height??0,c=i.position[0]-a/2+AS,l=i.position[0]+a/2-AS,u=i.position[2]-o/2+AS,d=i.position[2]+o/2-AS,f=i.position[1],p=i.position[1]+s;if(e.type===`growLight`)return{position:[FS(t[0],c+.4,l-.4),Math.max(f+1,p-.3),FS(t[2],u+.4,d-.4)],rotation:[0,n[1],0]};if(e.type===`co2Tank`){let e=[[c+.16,f,u+.16],[c+.16,f,d-.16],[l-.16,f,u+.16],[l-.16,f,d-.16]],r=e[0],i=1/0;for(let n of e){let e=Math.hypot(t[0]-n[0],t[2]-n[2]);e<i&&(r=n,i=e)}return{position:r,rotation:[0,n[1],0]}}let m=Math.abs(t[0]-c),h=Math.abs(t[0]-l),g=Math.abs(t[2]-u),_=Math.abs(t[2]-d),v=[{kind:`left`,d:m},{kind:`right`,d:h},{kind:`front`,d:g},{kind:`back`,d:_}].sort((e,t)=>e.d-t.d)[0]?.kind;return e.type===`inlineFan`?v===`left`?{position:[c,Math.max(f+.5,p-.45),FS(t[2],u+.25,d-.25)],rotation:[0,0,0]}:v===`right`?{position:[l,Math.max(f+.5,p-.45),FS(t[2],u+.25,d-.25)],rotation:[0,Math.PI,0]}:v===`front`?{position:[FS(t[0],c+.25,l-.25),Math.max(f+.5,p-.45),u],rotation:[0,-Math.PI/2,0]}:{position:[FS(t[0],c+.25,l-.25),Math.max(f+.5,p-.45),d],rotation:[0,Math.PI/2,0]}:e.type===`circulationFan`?v===`left`?{position:[c,f+s*.6,FS(t[2],u+.35,d-.35)],rotation:[0,0,0]}:v===`right`?{position:[l,f+s*.6,FS(t[2],u+.35,d-.35)],rotation:[0,Math.PI,0]}:v===`front`?{position:[FS(t[0],c+.35,l-.35),f+s*.6,u],rotation:[0,-Math.PI/2,0]}:{position:[FS(t[0],c+.35,l-.35),f+s*.6,d],rotation:[0,Math.PI/2,0]}:null}function RS(e,t,n){let r=t.type===`reducer`?e.connectorId===`a`?t.params.diameterA:t.params.diameterB:t.params.diameter??Yx.cap.defaults.diameter??1,i=new q(-e.dir[0],-e.dir[1],-e.dir[2]).normalize();return TS.setFromUnitVectors(new q(-1,0,0),i),ES.setFromQuaternion(TS,`XYZ`),DS.set(-.22,0,0).applyQuaternion(TS),OS.set(e.pos[0],e.pos[1],e.pos[2]).sub(DS),{id:wS(),type:`cap`,position:[OS.x,OS.y,OS.z],rotation:[ES.x,ES.y,ES.z],params:{...Yx.cap.defaults,diameter:r},roomId:n??t.roomId}}function zS(e,t,n){let r=new q(-e.dir[0],-e.dir[1],-e.dir[2]).normalize();return TS.setFromUnitVectors(new q(1,0,0),r),ES.setFromQuaternion(TS,`XYZ`),DS.set(.2,0,0).applyQuaternion(TS),OS.set(e.pos[0],e.pos[1],e.pos[2]).sub(DS),{id:wS(),type:`emitter`,position:[OS.x,OS.y,OS.z],rotation:[ES.x,ES.y,ES.z],params:{...Yx.emitter.defaults},label:`${t.label??Yx[t.type].label} outlet`,roomId:n??t.roomId}}var Q=Sy((e,t)=>({parts:{},selectedIds:[],placingType:null,draggingId:null,gizmoDragging:!1,snapTargetKey:null,colorPopover:null,tool:`select`,viewMode:`orbit`,renderMode:`builder`,showFlow:!0,heatmapMode:!1,simRunning:!0,snapToGrid:!0,gridSize:.25,measurePoints:[],pipeRunPoints:[],projectName:`Untitled system`,growthStage:`vegetative`,focusTarget:null,scene:null,rooms:[{id:`room-1`,name:`Room 1`}],activeRoomId:`room-1`,past:[],future:[],pushHistory:(t=``)=>{let n=Date.now();if(t&&t===MS.tag&&n-MS.time<400){MS.time=n;return}MS={tag:t,time:n},e(e=>({past:[...e.past.slice(-99),e.parts],future:[]}))},undo:()=>e(e=>{if(!e.past.length)return e;let t=e.past[e.past.length-1];return{parts:t,past:e.past.slice(0,-1),future:[e.parts,...e.future],selectedIds:e.selectedIds.filter(e=>t[e])}}),redo:()=>e(e=>{if(!e.future.length)return e;let t=e.future[0];return{parts:t,past:[...e.past,e.parts],future:e.future.slice(1),selectedIds:e.selectedIds.filter(e=>t[e])}}),addRoom:t=>{let n=wS();e(e=>({rooms:[...e.rooms,{id:n,name:t}],activeRoomId:n}))},removeRoom:n=>{let r=t();if(r.rooms.length<=1)return;r.pushHistory(`remove-room`);let i=r.rooms.filter(e=>e.id!==n),a=r.activeRoomId===n?i[0].id:r.activeRoomId,o=Object.fromEntries(Object.entries(r.parts).filter(([e,t])=>t.roomId!==n));e({rooms:i,activeRoomId:a,parts:o,selectedIds:r.selectedIds.filter(e=>o[e])})},setActiveRoomId:t=>e({activeRoomId:t}),syncParts:t=>e({parts:t}),addPart:(n,r,i)=>{t().pushHistory();let a=wS(),o={id:a,type:n,position:r,rotation:[0,0,0],params:{...Yx[n].defaults},roomId:t().activeRoomId},s=LS(o,o.position,o.rotation,t().parts);return s&&(o={...o,...s}),e(e=>({parts:{...e.parts,[a]:o},selectedIds:[a]})),i?.snap!==!1&&t().snapPartToConnectors(a),a},spawnPipeAtConnector:n=>{let r=t(),[i,a]=n.split(`:`),o=r.parts[i];if(!o)return;let s=nS(o).find(e=>e.connectorId===a);if(!s)return;r.pushHistory(`spawn-pipe`);let c=wS(),l=o.params.diameter??1,u=new Mn().setFromUnitVectors(new q(1,0,0),new q(...s.dir).normalize()),d=new pr().setFromQuaternion(u,`XYZ`),f={id:c,type:`pipe`,position:[s.pos[0]+s.dir[0]*(2/2),s.pos[1]+s.dir[1]*(2/2),s.pos[2]+s.dir[2]*(2/2)],rotation:[d.x,d.y,d.z],params:{length:2,diameter:l},roomId:r.activeRoomId};e(e=>({parts:{...e.parts,[c]:f},selectedIds:[c]}))},extendPipeRun:(n,r)=>{let i=t(),a=i.pipeRunPoints,o={},s=new Set,c=(e,t,n,r)=>{let i=t[0]-e[0],a=t[2]-e[2],o=Math.hypot(i,a);return o<.1?null:{...r,id:wS(),position:[(e[0]+t[0])/2,r.position[1],(e[2]+t[2])/2],rotation:[0,Math.atan2(-a,i),0],params:{...r.params,length:o,diameter:n}}},l=e=>{if(!e.tapPipeId||e.tapRotationY===void 0)return e;let t=i.parts[e.tapPipeId];if(!t||t.type!==`pipe`)return e;let n=wS(),r={id:n,type:`tee`,position:e.pos,rotation:[0,e.tapRotationY,0],params:{...Yx.tee.defaults,diameter:e.tapDiameter??Yx.tee.defaults.diameter??1},roomId:i.activeRoomId};o[n]=r;let a=nS(r),l=a.find(e=>e.connectorId===`c`),u=a.find(e=>e.connectorId===`a`),d=a.find(e=>e.connectorId===`b`),f=nS(t),p=f.find(e=>e.connectorId===`a`),m=f.find(e=>e.connectorId===`b`);if(u&&d&&p&&m){s.add(t.id);let e=c(p.pos,u.pos,r.params.diameter??1,t),n=c(d.pos,m.pos,r.params.diameter??1,t);e&&(o[e.id]=e),n&&(o[n.id]=n)}return{pos:l?l.pos:e.pos,connectorKey:l?.key??`${n}:c`}};if(a.length===0){let t=l(n);Object.keys(o).length>0?(i.pushHistory(`pipe-run-start`),e(e=>({parts:{...Object.fromEntries(Object.entries(e.parts).filter(([e])=>!s.has(e))),...o},pipeRunPoints:[t],selectedIds:Object.keys(o)}))):e({pipeRunPoints:[t]});return}let u=a[a.length-1],d=l(n),f=d.pos[0]-u.pos[0],p=d.pos[2]-u.pos[2],m=Math.hypot(f,p);if(m<1e-6)return;i.pushHistory(`pipe-run`);let h=Yx.pipe.params.length,g=Math.min(h.max,Math.max(h.min,m)),_=Math.atan2(-p,f),v=e=>{if(!e)return;let[t,n]=e.split(`:`),r=i.parts[t];if(r)return r.type===`reducer`?n===`a`?r.params.diameterA:r.params.diameterB:r.params.diameter},y=v(u.connectorKey),b=v(d.connectorKey),x=y??b??Yx.pipe.defaults.diameter??1,S=wS();if(o[S]={id:S,type:`pipe`,position:[(u.pos[0]+d.pos[0])/2,.25,(u.pos[2]+d.pos[2])/2],rotation:[0,_,0],params:{...Yx.pipe.defaults,length:g,diameter:x},roomId:i.activeRoomId},a.length>=2){let e=a[a.length-2],t=u.pos[0]-e.pos[0],n=u.pos[2]-e.pos[2],r=Math.hypot(t,n);if((r>1e-6?(t*f+n*p)/(r*m):1)<.96){let e=wS();o[e]={id:e,type:`elbow`,position:[u.pos[0],.25,u.pos[2]],rotation:[Math.PI/2,Math.atan2(-n,t)+Math.PI,0],params:{...Yx.elbow.defaults,angle:90,diameter:x},roomId:i.activeRoomId}}}if(b!==void 0&&Math.abs(b-x)>1e-6){let e=wS(),t=Math.cos(_),n=-Math.sin(_);o[e]={id:e,type:`reducer`,position:[d.pos[0]-t*.35,.25,d.pos[2]-n*.35],rotation:[0,_,0],params:{...Yx.reducer.defaults,diameterA:x,diameterB:b},roomId:i.activeRoomId}}e(e=>({parts:{...Object.fromEntries(Object.entries(e.parts).filter(([e])=>!s.has(e))),...o},selectedIds:[S],pipeRunPoints:r?[...a,d]:[]}))},updatePart:(t,n)=>e(e=>{let r=e.parts[t];if(!r)return e;let i={...r,...n};if(n.position&&jS.has(r.type)){let t=LS(i,n.position,n.rotation??i.rotation,e.parts);t&&(i={...i,...t})}return{parts:{...e.parts,[t]:i}}}),setParam:(n,r,i)=>{t().pushHistory(`param:${n}:${r}`),e(e=>{let t=e.parts[n];if(!t)return e;let a=PS(t,r,i);return{parts:{...e.parts,[n]:{...t,params:{...t.params,[r]:a}}}}})},removeParts:n=>{n.length&&(t().pushHistory(),e(e=>{let t=new Set(n);return{parts:Object.fromEntries(Object.entries(e.parts).filter(([e])=>!t.has(e))),selectedIds:e.selectedIds.filter(e=>!t.has(e))}}))},duplicateParts:(n,r)=>{let i=t(),a=n.map(e=>i.parts[e]).filter(Boolean);if(!a.length)return[];i.pushHistory();let o=r?.offset??[1,0,1],s=a.map(e=>({...e,id:wS(),position:[e.position[0]+o[0],e.position[1]+o[1],e.position[2]+o[2]],rotation:[...e.rotation],params:{...e.params},roomId:i.activeRoomId}));return e(e=>({parts:{...e.parts,...Object.fromEntries(s.map(e=>[e.id,e]))},selectedIds:s.map(e=>e.id)})),s.map(e=>e.id)},rotateParts:(n,r,i)=>{n.length&&(t().pushHistory(`rotate:${n.join(`+`)}`),e(e=>{let t={...e.parts};for(let e of n){let n=t[e];if(!n)continue;let a=[...n.rotation];a[r]+=i,t[e]={...n,rotation:a}}return{parts:t}}))},translateParts:(n,r,i)=>{if(!n.length)return;let a=t();i&&a.pushHistory(i);let o=1/0;for(let e of n){let t=a.parts[e];t&&(o=Math.min(o,t.position[1]))}let s=Number.isFinite(o)?Math.max(r[1],-o):r[1];e(e=>{let t={...e.parts};for(let e of n){let n=t[e];if(!n)continue;let i={...n,position:[n.position[0]+r[0],n.position[1]+s,n.position[2]+r[2]]},a=LS(i,i.position,i.rotation,t);a&&(i={...i,...a}),t[e]=i}return{parts:t}})},setPositions:t=>e(e=>{let n={...e.parts};for(let[e,r]of Object.entries(t)){let t=n[e];if(!t)continue;let i={...t,position:r},a=LS(i,r,i.rotation,n);a&&(i={...i,...a}),n[e]=i}return{parts:n}}),setPipeStretch:(t,n,r)=>e(e=>{let i=e.parts[t];return!i||i.type!==`pipe`?e:{parts:{...e.parts,[t]:{...i,position:n,params:{...i.params,length:r}}}}}),applyColor:(n,r)=>{n.length&&(t().pushHistory(`color:${n.join(`+`)}`),e(e=>{let t={...e.parts};for(let e of n){let n=t[e];if(!n)continue;let i={...n};r===void 0?delete i.color:i.color=r,t[e]=i}return{parts:t}}))},snapPartToConnectors:e=>{let n=t(),r=n.parts[e];if(!r)return;let i=iS(r,Object.values(n.parts));i&&n.updatePart(e,{position:[r.position[0]+i[0],r.position[1]+i[1],r.position[2]+i[2]]})},snapGroupToConnectors:(e,n)=>{let r=t(),i=r.parts[n];if(!i)return;let a=new Set(e),o=iS(i,Object.values(r.parts).filter(e=>!a.has(e.id)));o&&r.translateParts(e,o)},selectConnectedRun:n=>{let r=t(),i=Object.values(r.parts);if(!r.parts[n])return;let a=mS(i),o=a.componentOf.get(n);if(o===void 0){e({selectedIds:[n]});return}let s=a.components[o],c=i.filter(e=>s.has(e.id)&&(a.connectorsByPart.get(e.id)?.length??0)>0).map(e=>e.id);e({selectedIds:c.length?c:[n]})},autoCapOpenEnds:()=>{let n=t(),r=Object.values(n.parts),i=mS(r),a=[];for(let e of r){if(!Qx.has(e.type)||e.type===`pump`)continue;let t=i.connectorsByPart.get(e.id)??[];for(let n of t)i.joinedKeys.has(n.key)||a.push(RS(n,e))}return a.length?(n.pushHistory(`auto-cap`),e(e=>({parts:{...e.parts,...Object.fromEntries(a.map(e=>[e.id,e]))},selectedIds:a.map(e=>e.id)})),a.length):0},fixDeadLeg:n=>{let r=t(),i=mS(Object.values(r.parts)),a=new Set(n),o=[...n];for(;o.length;){let e=o.shift();for(let t of i.neighbors.get(e)??[]){let e=r.parts[t];!e||a.has(t)||e.type===`pump`||e.type===`reservoir`||e.type===`drain`||(a.add(t),o.push(t))}}let s=null,c=[...a];for(let e=0;e<c.length;e++){let t=c[e],n=r.parts[t];if(!n)continue;let a=i.connectorsByPart.get(t)??[],o=a.filter(e=>i.joinedKeys.has(e.key)).length;for(let t of a)i.joinedKeys.has(t.key)||(!s||o<s.joinedCount||o===s.joinedCount&&e>s.idx)&&(s={part:n,conn:t,joinedCount:o,idx:e})}if(s){let t=zS(s.conn,s.part);return r.pushHistory(`fix-dead-leg`),e(e=>({parts:{...e.parts,[t.id]:t},selectedIds:[t.id]})),t.id}return null},fixDiameterMismatch:n=>{let r=t(),i=n.map(e=>r.parts[e]).filter(e=>e?typeof e.params.diameter==`number`:!1);if(i.length<2)return null;let a=Math.max(...i.map(e=>e.params.diameter??0)),o=0;return r.pushHistory(`fix-diameter`),e(e=>{let t={...e.parts};for(let e of i)(e.params.diameter??0)!==a&&(t[e.id]={...e,params:{...e.params,diameter:a}},o++);return{parts:t,selectedIds:i.map(e=>e.id)}}),o},fixPumpDeadEnd:n=>{let r=t(),i=r.parts[n];if(!i||i.type!==`pump`)return null;let a=mS(Object.values(r.parts)),o=a.connectorsByPart.get(n)??[],s=o.find(e=>e.connectorId===`out`)??o[o.length-1];if(!s)return null;let c=new Set([n]),l=[];for(let{a:e,b:t}of a.joints)e.key===s.key&&l.push(t.partId),t.key===s.key&&l.push(e.partId);for(;l.length;){let e=l.shift();if(!c.has(e)){c.add(e);for(let t of a.neighbors.get(e)??[])!c.has(t)&&r.parts[t]?.type!==`reservoir`&&l.push(t)}}let u=null;for(let e of c){if(e===n)continue;let t=r.parts[e];if(!t)continue;let i=a.connectorsByPart.get(e)??[],o=i.filter(e=>a.joinedKeys.has(e.key)).length;for(let e of i){let n=!a.joinedKeys.has(e.key),r=t.type===`cap`&&a.joinedKeys.has(e.key);if(!n&&!r)continue;let i=(r?10:0)+(t.type===`cap`?5:0)-o;(!u||i>u.score)&&(u={part:t,conn:e,replace:r,score:i})}}if(!u)return null;let d=zS(u.conn,u.part,r.activeRoomId);return r.pushHistory(`fix-pump-dead-end`),e(e=>{let t={...e.parts};return u?.replace&&delete t[u.part.id],t[d.id]=d,{parts:t,selectedIds:[d.id]}}),d.id},selectAll:()=>e({selectedIds:Object.keys(t().parts)}),pasteParts:n=>{let r=t();if(!n.length)return[];r.pushHistory(`paste`);let i=[1,0,1],a=n.map(e=>({...e,id:wS(),position:[e.position[0]+i[0],e.position[1]+i[1],e.position[2]+i[2]],rotation:[...e.rotation],params:{...e.params},roomId:r.activeRoomId}));return e(e=>({parts:{...e.parts,...Object.fromEntries(a.map(e=>[e.id,e]))},selectedIds:a.map(e=>e.id)})),a.map(e=>e.id)},setSelected:t=>e({selectedIds:t?[t]:[]}),toggleSelected:t=>e(e=>({selectedIds:e.selectedIds.includes(t)?e.selectedIds.filter(e=>e!==t):[...e.selectedIds,t]})),setPlacingType:t=>e(e=>({placingType:t,selectedIds:t?[]:e.selectedIds})),setDraggingId:t=>e({draggingId:t}),setGizmoDragging:t=>e({gizmoDragging:t}),setSnapTargetKey:t=>e(e=>e.snapTargetKey===t?e:{snapTargetKey:t}),openColorPopover:(t,n)=>e({colorPopover:{x:t,y:n}}),closeColorPopover:()=>e({colorPopover:null}),setTool:t=>e({tool:t,placingType:null,measurePoints:[],pipeRunPoints:[]}),setViewMode:t=>e({viewMode:t}),setRenderMode:t=>e({renderMode:t}),toggleFlow:()=>e(e=>({showFlow:!e.showFlow})),toggleHeatmapMode:()=>e(e=>({heatmapMode:!e.heatmapMode})),toggleSimRunning:()=>e(e=>({simRunning:!e.simRunning})),toggleSnap:()=>e(e=>({snapToGrid:!e.snapToGrid})),addMeasurePoint:t=>e(e=>({measurePoints:e.measurePoints.length>=2?[t]:[...e.measurePoints,t]})),clearMeasure:()=>e({measurePoints:[]}),setFocusTarget:t=>e({focusTarget:t}),loadParts:(t,n)=>{let r=Array.from(new Set(t.map(e=>e.roomId).filter(Boolean)));r.length===0&&(r=[`room-1`]);let i=r.map((e,t)=>({id:e,name:e===`room-1`?`Room 1`:`Room ${t+1}`})),a=t.map(e=>({...e,roomId:e.roomId||`room-1`}));e({parts:Object.fromEntries(a.map(e=>[e.id,e])),selectedIds:[],placingType:null,colorPopover:null,pipeRunPoints:[],past:[],future:[],rooms:i,activeRoomId:r[0],...n?{projectName:n}:{}})},clearAll:()=>{t().pushHistory(),e({parts:{},selectedIds:[],colorPopover:null,pipeRunPoints:[],rooms:[{id:`room-1`,name:`Room 1`}],activeRoomId:`room-1`})},setProjectName:t=>e({projectName:t}),setGrowthStage:t=>e({growthStage:t}),setScene:t=>e({scene:t}),autoRoute:(n,r)=>{let i=t(),[a,o]=n.split(`:`),[s,c]=r.split(`:`),l=i.parts[a],u=i.parts[s];if(!l||!u)return;let d=nS(l),f=nS(u),p=d.find(e=>e.connectorId===o),m=f.find(e=>e.connectorId===c);if(!p||!m){bS(`Auto-route: connector not found.`,`error`);return}let h=[];for(let e of Object.values(i.parts)){if(e.id===a||e.id===s||e.roomId!==i.activeRoomId)continue;let t=gS(e);t&&h.push(t)}let g=_S(p.pos,m.pos,h);if(!g){bS(`No valid path found avoiding obstacles.`,`error`);return}let _=vS(g,l.params.diameter??l.params.diameterA??l.params.diameterB??1,i.activeRoomId);_.length>0?(i.pushHistory(`auto-route`),e(e=>{let t={...e.parts};for(let e of _)t[e.id]=e;return{parts:t,selectedIds:_.map(e=>e.id)}}),bS(`Path successfully routed with ${_.length} parts.`,`success`)):bS(`Path could not be converted to parts.`,`error`)}})),BS=.4,VS=new Set([`reservoir`,`emitter`,`drain`,`tower`,`tray`,`wallPanel`]),HS=class{parent=new Map;find(e){let t=this.parent.get(e)??e;return t!==e&&(t=this.find(t),this.parent.set(e,t)),t}union(e,t){let n=this.find(e),r=this.find(t);n!==r&&this.parent.set(n,r)}};function US(e){let t=e.params,n=Math.max(.25,t.diameter??1);switch(e.type){case`pipe`:return(t.length??2)/n**4;case`coupling`:return .15/n**2;case`reducer`:{let e=Math.max(.25,t.diameterA??1.5),n=Math.max(.25,t.diameterB??1),r=Math.min(e,n);return(.35+Math.abs(e-n)/Math.max(e,n))/r**2}case`cap`:return .25/n**2;case`elbow`:return 1.2*((t.angle??90)/90)/n**2;case`tee`:return .8/n**2;case`valve`:{let e=t.open??100;return e<=0?null:.3+(100-e)/e*8}case`tower`:return .5;case`tray`:return .3;case`wallPanel`:return .6;case`emitter`:return 1.5;case`drain`:return .6;default:return .1}}function WS(e){let t=e.params;switch(e.type){case`pipe`:return t.length??2;case`coupling`:return .6;case`reducer`:return .7;case`cap`:return .25;case`elbow`:return Ux*((t.angle??90)*Math.PI/180);case`tee`:return .9;case`valve`:return .7;case`pump`:return .9;case`reservoir`:return Math.max(t.width??2,t.depth??1.4)*.5;case`tower`:return t.height??4;case`tray`:return t.length??3;case`wallPanel`:return t.height??4;case`emitter`:return .4;case`drain`:return .4;default:return .5}}function GS(e){switch(e.type){case`pipe`:case`coupling`:case`reducer`:case`cap`:case`elbow`:case`tee`:case`valve`:return e.position[1]+Gx(e.params.diameter??e.params.diameterA??1);case`tray`:return e.position[1]+.24;case`tower`:return e.position[1]+.45;default:return e.position[1]+.25}}function KS(e,t,n){let r=e[0]-t[0],i=e[2]-t[2],a=n[0]-t[0],o=n[2]-t[2],s=a*a+o*o;if(s<=1e-6)return Math.hypot(r,i);let c=Math.max(0,Math.min(1,(r*a+i*o)/s)),l=t[0]+a*c,u=t[2]+o*c;return Math.hypot(e[0]-l,e[2]-u)}function qS(e,t){let n=nS(e);if(n.length>=2){if(e.type===`tee`)return Math.min(...n.map(n=>KS(t,e.position,n.pos)));let r=1/0;for(let e=0;e<n.length;e++)for(let i=e+1;i<n.length;i++)r=Math.min(r,KS(t,n[e].pos,n[i].pos));if(Number.isFinite(r))return r}return Math.hypot(t[0]-e.position[0],t[2]-e.position[2])}function JS(e){let t=Object.values(e),n=[],r={},i=new Set,a=t.filter(e=>Zx.has(e.type)),o=a.flatMap(nS),s=new HS,c=0;for(let e=0;e<o.length;e++)for(let t=e+1;t<o.length;t++)o[e].partId!==o[t].partId&&rS(o[e].pos,o[t].pos)<.35&&(s.find(o[e].key)!==s.find(o[t].key)&&c++,s.union(o[e].key,o[t].key),i.add(o[e].key),i.add(o[t].key));let l=new Map,u=(e,t)=>{let n=l.get(e);return n||(n={pos:t,edges:[],members:[]},l.set(e,n)),n};for(let e of a){let t=`P:${e.id}`;u(t,e.position);for(let n of nS(e)){let r=s.find(n.key),i=u(r,n.pos);i.members.push(n),i.edges.push({to:t,partId:e.id}),l.get(t).edges.push({to:r,partId:e.id})}}let d=(t,n,r)=>{let i=new Set([n,r]),a=[n];for(;a.length;){let n=a.shift();if(n.startsWith(`P:`)){let t=n.slice(2);if(e[t]?.type===`reservoir`)return t}for(let e of t.get(n)?.edges??[])i.has(e.to)||(i.add(e.to),a.push(e.to))}},f=[],p=new Map,m=e=>{f.push(e),p.has(e.u)||p.set(e.u,[]),p.has(e.v)||p.set(e.v,[]),p.get(e.u).push(e),p.get(e.v).push(e)},h=a.filter(e=>e.type===`pump`);a.filter(e=>e.type===`reservoir`);for(let e of a){let t=`P:${e.id}`,n=nS(e);if(e.type===`pump`){let n=(e.params.on??e.params.enabled??1)===0,r=s.find(`${e.id}:in`),i=s.find(`${e.id}:out`),a=e.params.gph??400,o=e.params.maxHeadFt??8;n?(m({u:r,v:t,partId:e.id,r:1e10,baseR:1e10,isPump:!1,pumpBoost:0,pumpMaxGph:0}),m({u:t,v:i,partId:e.id,r:1e10,baseR:1e10,isPump:!1,pumpBoost:0,pumpMaxGph:0})):(m({u:r,v:t,partId:e.id,r:.01,baseR:.01,isPump:!1,pumpBoost:0,pumpMaxGph:0}),m({u:t,v:i,partId:e.id,r:.01+o/a,baseR:.01+o/a,isPump:!0,pumpBoost:o,pumpMaxGph:a}))}else if(e.type===`reservoir`)for(let r of n)m({u:s.find(r.key),v:t,partId:e.id,r:.01,baseR:.01,isPump:!1,pumpBoost:0,pumpMaxGph:0});else{let r=US(e),i=r===null?1e10:Math.max(1e-4,r);for(let r of n)m({u:s.find(r.key),v:t,partId:e.id,r:i/2,baseR:i/2,isPump:!1,pumpBoost:0,pumpMaxGph:0})}}let g=new Set,_=new Map;for(let[t,n]of l.entries())if(t.startsWith(`P:`)){let n=e[t.slice(2)];n&&VS.has(n.type)&&(g.add(t),_.set(t,n.position[1]))}else n.members.length===1&&Qx.has(n.members[0].partType)&&(g.add(t),_.set(t,n.pos[1]));let v={};for(let[e,t]of l.entries())g.has(e)?v[e]=_.get(e):v[e]=t.pos[1];let y=a.filter(e=>e.type===`drain`),b=new Map;for(let e of y){let t=US(e)??.6;b.set(e.id,t)}let x=!1,S=new Map;for(let e=0;e<4;e++){for(let e=0;e<200;e++){let e=0;for(let[t,n]of l.entries()){if(g.has(t))continue;let n=v[t]??0,r=0,i=0,a=p.get(t)||[];for(let e of a){let n=v[e.u===t?e.v:e.u]??0,a=e.r,o=n;if(e.isPump){let n=e.pumpBoost,r=e.r,i=e.u,s=e.v,c=l.get(i).pos[1],u=l.get(s).pos[1],d=v[i]??0,f=v[s]??0;t===i?d+u-c+n-f>0?(a=r,o=f-u+c-n):(a=1e10,o=f):d+u-c+n-f>0?(a=r,o=d+u-c+n):(a=1e10,o=d)}r+=o/a,i+=1/a}if(i>0){let a=r/i;e=Math.max(e,Math.abs(a-n)),v[t]=a}}if(e<1e-5)break}for(let e of a)r[e.id]=0;for(let[e,t]of p.entries()){if(!e.startsWith(`P:`))continue;let n=e.slice(2),i=0;for(let e of t){let t=0,n=e.u,r=e.v,a=v[n]??0,o=v[r]??0;if(e.isPump){let i=e.pumpBoost,s=e.r,c=l.get(n).pos[1],u=l.get(r).pos[1];t=Math.max(0,(a+u-c+i-o)/s)}else{let n=e.r;t=Math.abs(a-o)/n}i+=t}r[n]=i/2}x=!1;for(let t of y){let n=r[t.id]??0;e===0&&S.set(t.id,n);let i=t.params.capacityGph??250;if(n>i*1.001){x=!0;let e=(n/i)**2,r=p.get(`P:`+t.id)||[];for(let n of r)n.r=(b.get(t.id)??.6)*e/2}}if(!x)break}let C=new Set,w=[];for(let e of y){let t=r[e.id]??0,i=S.get(e.id)??t,a=e.params.capacityGph??250,o=i>a*1.001;if(w.push({partId:e.id,inflowGph:o?i:t,capacityGph:a,overflowing:o}),o){n.push({level:`error`,partId:e.id,message:`${e.label??`Drain`} undersized: receiving ${Math.round(i)} GPH, capacity ${Math.round(a)} GPH — line is backing up.`});let t=new Set,r=[`P:`+e.id];for(t.add(`P:`+e.id);r.length>0;){let e=r.shift();e.startsWith(`P:`)&&C.add(e.slice(2));let n=p.get(e)||[];for(let i of n){let n=i.u===e?i.v:i.u;if(t.has(n))continue;let a=i.u,o=i.v,s=v[a]??0,c=v[o]??0,u=!1;if(i.isPump){let t=i.pumpBoost,n=i.r,r=l.get(a).pos[1],d=l.get(o).pos[1],f=Math.max(0,(s+d-r+t-c)/n);e===o&&f>.05&&(u=!0)}else e===o&&(s-c)/i.r>.05&&(u=!0),e===a&&(c-s)/i.r>.05&&(u=!0);u&&(t.add(n),r.push(n))}}}}let T=new Set;for(let t of h){if((r[t.id]??0)<=0)continue;let n=s.find(`${t.id}:out`),i=[n],a=new Set([`P:${t.id}`,n]);for(;i.length>0;){let t=i.shift(),n=l.get(t);if(n)for(let t of n.edges){let n=e[t.partId];if(n&&US(n)!==null&&(a.has(t.to)||(a.add(t.to),i.push(t.to)),t.to.startsWith(`P:`))){let e=t.to.slice(2);(r[e]??0)<.05&&n.type!==`pump`&&n.type!==`reservoir`&&T.add(e)}}}}if(T.size>0){n.push({level:`warning`,message:`${T.size} part${T.size>1?`s`:``} on a dead-end branch — water is trapped and backing up.`});for(let e of T)C.add(e)}let E=[];for(let t of h){let r=t.label??`Pump`,a=t.params.gph??400,o=t.params.maxHeadFt??8,c=`P:${t.id}`;if((t.params.on??t.params.enabled??1)===0){n.push({level:`info`,partId:t.id,message:`${r} is switched off.`}),E.push({pumpId:t.id,ratedGph:a,gph:0,headFt:0,maxHeadFt:o,resistance:0,running:!1,opPoint:{gph:0,headFt:0},phase:`continuous`});continue}let u=s.find(`${t.id}:in`),f=s.find(`${t.id}:out`),m=d(l,u,c),h=m!==void 0,g=(p.get(c)||[]).find(e=>e.isPump&&e.v===f),_=0,y=0;if(g&&h){let e=g.u,t=g.v,n=v[e]??0,r=v[t]??0,i=l.get(e).pos[1],a=l.get(t).pos[1];_=Math.max(0,(n+a-i+o-r)/g.r),y=Math.max(0,r-a-(n-i))}let b=new Set([c]),x=new Set,S=[f];b.add(f);let C=0,w=t.position[1],T=!1,D=!1,O=0,k=!1,A=nS(t).find(e=>e.connectorId===`out`);for(A&&!i.has(A.key)&&O++;S.length;){let n=S.shift(),r=l.get(n);if(r){w=Math.max(w,r.pos[1]),!n.startsWith(`P:`)&&r.members.length===1&&Qx.has(r.members[0].partType)&&r.members[0].partId!==t.id&&O++;for(let t of r.edges){if(t.to===c)continue;if(b.has(t.to)){!x.has(t.partId)&&t.to!==n&&(T=!0);continue}let r=e[t.partId];if(!x.has(t.partId)&&r){let e=US(r);if(e===null){D=!0;continue}C+=e,x.add(t.partId),VS.has(r.type)&&(k=!0)}b.add(t.to),S.push(t.to)}}}let j=x.size>0;if(h||n.push({level:`error`,partId:t.id,message:`${r}: inlet is not connected to a reservoir — no water source.`}),j||n.push({level:`error`,partId:t.id,message:`${r}: outlet is not connected to anything.`}),h&&j){let e=Math.max(0,w-t.position[1]);e>o?(_=0,n.push({level:`error`,partId:t.id,message:`${r} is too weak: system rises ${e.toFixed(1)} ft but max head is ${o} ft.`})):e>.65*o&&n.push({level:`warning`,partId:t.id,message:`${r}: high head (${e.toFixed(1)} / ${o} ft) — flow significantly reduced.`}),_>0&&_<.2*a&&n.push({level:`warning`,partId:t.id,message:`${r}: bottleneck — long/narrow pipes & fittings are choking flow (R=${C.toFixed(1)}).`}),O>0&&n.push({level:`warning`,partId:t.id,message:`${O} open pipe end${O>1?`s`:``} downstream — water will leak out.`}),!k&&O===0&&_>0&&n.push({level:`warning`,partId:t.id,message:`${r}: dead end — water has nowhere to go (no reservoir, emitter, drain or tray downstream).`}),D&&n.push({level:`info`,message:`A closed valve is blocking part of the network.`}),T&&n.push({level:`info`,message:`Loop detected — flow split is approximated.`})}E.push({pumpId:t.id,ratedGph:a,gph:_,headFt:y,maxHeadFt:o,resistance:C,running:_>.05,opPoint:{gph:_,headFt:y},phase:`continuous`,sourceReservoirId:m})}let D=[],O=new Set;for(let[t,n]of p.entries()){if(!t.startsWith(`P:`))continue;let i=t.slice(2),a=e[i];if(!a)continue;let o=r[i]??0;if(!(o<=.05))for(let e of n){let t=e.u,n=e.v,r=v[t]??0,s=v[n]??0,c=!0;if(e.isPump){let i=e.pumpBoost,a=e.r,o=l.get(t).pos[1];c=(r+l.get(n).pos[1]-o+i-s)/a>0}else c=r>s;let u=c?l.get(t).pos:l.get(n).pos,d=c?l.get(n).pos:l.get(t).pos,f=`${i}:${u.join(`,`)}:${d.join(`,`)}`;O.has(f)||(O.add(f),D.push({partId:i,from:u,to:d,gph:o,diameter:a.params.diameter??1}))}}let k={},A={},j={},M={},N={},P={},F={},I=0;for(let e of a)A[e.id]=WS(e);let L=new Set,ee=[];for(let e of h){if((r[e.id]??0)<=0)continue;let t=s.find(`${e.id}:out`),n=s.find(`${e.id}:in`);k[e.id]=0,j[e.id]=`in`,I=Math.max(I,A[e.id]),ee.push({nodeId:t,dist:A[e.id],fromPartId:e.id}),L.add(`P:${e.id}`),L.add(t),L.add(n)}for(;ee.length>0;){let{nodeId:t,dist:n,fromPartId:i}=ee.shift(),a=l.get(t);if(a){for(let t of a.edges)if(t.to.startsWith(`P:`)){let o=t.to.slice(2);if(!e[o]||(r[o]??0)<=.05)continue;if(!L.has(t.to)){L.add(t.to),k[o]=n,i&&(M[o]=i);let e=a.members.find(e=>e.partId===o);e&&(j[o]=e.connectorId),I=Math.max(I,n+A[o]),ee.push({nodeId:t.to,dist:n,fromPartId:o})}}else if(!L.has(t.to)){L.add(t.to);let e=n+(i?A[i]:0);ee.push({nodeId:t.to,dist:e,fromPartId:i})}}}for(let e of a){let t=r[e.id]??0;if(t<=0)continue;let n=Math.max(.25,e.params.diameter??1),i=Math.PI*(n/24)**2,a=t/7.48/3600;N[e.id]=a/i;let o=v[`P:${e.id}`]??e.position[1];if(P[e.id]=Math.max(0,(o-e.position[1])*.433),VS.has(e.type)){let n=F[e.id]??{inGph:0,exits:[],unlimited:!1};n.inGph+=t,n.unlimited=e.type===`reservoir`||e.type===`emitter`,F[e.id]=n}}for(let t of w){let n=e[t.partId];if(!n)continue;let r=M[t.partId];if(!r)continue;let i=F[r]??{inGph:0,exits:[],unlimited:!1};i.exits.push({partId:t.partId,type:n.type,capacityGph:t.capacityGph}),F[r]=i}let R=new Set([`pipe`,`coupling`,`reducer`,`cap`,`elbow`,`tee`,`valve`,`tray`,`tower`]),te=[];for(let e of t){if(e.type!==`netPot`)continue;let t=e.params.size??1,n=e.position[1]+.22*t,i=.24*t,o;for(let t of a){if(!R.has(t.type))continue;let a=r[t.id]??0;if(a<=.1||!C.has(t.id))continue;let s=qS(t,e.position);if(s>i)continue;let c=GS(t)+(P[t.id]??0)/.433;n-c>BS||(!o||s<o.d||a>o.inflow)&&(o={part:t,inflow:a,waterHeight:c,d:s})}o&&te.push({partId:e.id,sourcePartId:o.part.id,inflowGph:o.inflow,rimHeightFt:n,waterHeightFt:o.waterHeight,overflowing:o.waterHeight>=n-.02})}for(let e of te)e.overflowing&&n.push({level:`warning`,partId:e.partId,message:`Net pot is sitting over a backed-up line and will spill from the rim (${Math.round(e.inflowGph)} GPH below).`});return{flows:r,pumps:E,segments:D.filter(e=>e.gph>.05),warnings:n,connectedKeys:i,connectionCount:c,totalGph:E.reduce((e,t)=>e+t.gph,0),fillDistance:k,fillLength:A,totalPathLength:I,entryConnector:j,backedUp:C,drains:w,netPots:te,velocities:N,pressures:P,upstream:M,vesselIO:F,reservoirRuntime:{}}}function YS(){let e=Q(e=>e.parts),t=Q(e=>e.simRunning),[n,r]=(0,v.useState)(0),i=(0,v.useMemo)(()=>JS(e),[e]);return(0,v.useEffect)(()=>{if(!t)return;let e=window.setInterval(()=>r(e=>e+1),250);return()=>window.clearInterval(e)},[t]),(0,v.useMemo)(()=>tC(i,e,t,n),[i,e,t,n])}var XS=new Map,ZS=``;function QS(e){let t=e.params.width??2,n=e.params.depth??1.4,r=e.params.height??1;return Math.max(.1,t*n*r*7.48)}function $S(e){return QS(e)*((e.params.level??70)/100)}function eC(e){return Object.values(e).filter(e=>e.type===`reservoir`).map(e=>`${e.id}:${e.params.width}:${e.params.depth}:${e.params.height}:${e.params.level}`).sort().join(`|`)}function tC(e,t,n,r){let i=eC(t),a=Date.now();if(i!==ZS){ZS=i,XS.clear();for(let e of Object.values(t)){if(e.type!==`reservoir`)continue;let t=$S(e);XS.set(e.id,{current:t,initial:t,capacity:QS(e),lastTs:a})}}let o={},s={};for(let t of e.pumps)!t.sourceReservoirId||t.gph<=0||(s[t.sourceReservoirId]=(s[t.sourceReservoirId]??0)+t.gph);for(let i of Object.values(t)){if(i.type!==`reservoir`)continue;let t=$S(i),c=QS(i),l=XS.get(i.id)??{current:t,initial:t,capacity:c,lastTs:a};(Math.abs(l.initial-t)>1e-6||Math.abs(l.capacity-c)>1e-6)&&(l.initial=t,l.capacity=c,l.current=Math.min(c,t),l.lastTs=a);let u=e.vesselIO[i.id]?.inGph??0,d=s[i.id]??0,f=Math.max(0,d-u);if(n&&r>=0){let e=Math.max(0,a-l.lastTs)/36e5;e>0&&f>0&&(l.current=Math.max(0,l.current-f*e)),l.lastTs=a}else l.lastTs=a;XS.set(i.id,l);let p=l.current<=.01&&f>0;o[i.id]={partId:i.id,gallonsInitial:l.initial,gallonsCurrent:l.current,gallonsCapacity:l.capacity,netOutflowGph:f,minutesRemaining:f>0?l.current/f*60:null,empty:p}}let c=new Set(Object.values(o).filter(e=>e.empty).map(e=>e.partId));if(!c.size)return{...e,reservoirRuntime:o};let l=e.pumps.map(e=>!e.sourceReservoirId||!c.has(e.sourceReservoirId)?e:{...e,gph:0,running:!1,opPoint:{gph:0,headFt:e.headFt}}),u=new Set;for(let e of l)e.running||u.add(e.pumpId);let d=new Set;for(let[t]of Object.entries(e.flows)){let n=t,r=0;for(;n&&r++<200;){if(u.has(n)){d.add(t);break}n=e.upstream[n]}}for(let e of u)d.add(e);let f={...e.flows};for(let e of d)f[e]=0;let p=e.segments.map(e=>d.has(e.partId)?{...e,gph:0}:e).filter(e=>e.gph>0),m=[...e.warnings];for(let e of c){let n=t[e];m.push({level:`warning`,partId:e,message:`${n?.label??`Reservoir`} has run dry under load.`})}return{...e,totalGph:l.reduce((e,t)=>e+t.gph,0),pumps:l,flows:f,segments:p,warnings:m,reservoirRuntime:o}}function nC(e,t){let n=Object.values(t),r=e.params.width??2,i=e.params.depth??1.4,a=e.params.height??1,o=e.params.level??70,s=Math.max(1,r*i*a*(o/100)*7.48),c=0;for(let t of n)if(t.type===`airCompressor`&&(t.params.on??1)>0){let r=null,i=1/0;for(let e of n)if(e.type===`reservoir`){let n=Math.hypot(e.position[0]-t.position[0],e.position[1]-t.position[1],e.position[2]-t.position[2]);n<i&&(i=n,r=e)}r&&r.id===e.id&&(c+=t.params.gph??120)}let l=5.5;if(c>0&&s>0){let e=c/s;l=5.5+3.7*(1-Math.exp(-e*2))}let u=0,d=0,f=[];for(let e of n)e.type===`pump`&&(e.params.on??1)>0?u++:e.type===`airCompressor`&&(e.params.on??1)>0?d++:e.type===`waterChiller`&&(e.params.on??1)>0&&f.push(e);let p=75+(u*.5+d*.2),m=p;f.length>0&&(m=p-(p-Math.min(...f.map(e=>e.params.targetTemp??68)))*.85);let h=!1,g=new Map,_=n.flatMap(e=>nS(e).map(t=>({...t,partId:e.id})));for(let e=0;e<_.length;e++)for(let t=e+1;t<_.length;t++){let n=_[e],r=_[t];n.partId!==r.partId&&rS(n.pos,r.pos)<.35&&(g.has(n.partId)||g.set(n.partId,[]),g.has(r.partId)||g.set(r.partId,[]),g.get(n.partId).push(r.partId),g.get(r.partId).push(n.partId))}let v=new Set([e.id]),y=[e.id];for(;y.length>0;){let e=y.shift();if(t[e]?.type===`reverseOsmosis`){h=!0;break}let n=g.get(e);if(n)for(let e of n)v.has(e)||(v.add(e),y.push(e))}let b=h?0:e.params.ec??1.2;return{id:e.id,label:e.label||`Reservoir #${e.id}`,volGal:s,activeAerationGph:c,tdo:l,tempF:m,ph:e.params.ph??6,ec:b}}var rC={grabOffset:[0,0,0],pushed:!1,mode:`body`,groupIds:[],startPositions:{},connectorKey:null,pipeStretch:null,planeKey:``,planeAnchor:[0,0,0]};function iC(e){let t=Q.getState(),n=t.parts[e.partId];if(!n)return;let r=t.selectedIds.includes(e.partId)?[...t.selectedIds]:[e.partId];rC.mode=e.mode,rC.connectorKey=e.connectorKey??null,rC.pipeStretch=null,rC.grabOffset=[e.grabPoint[0]-n.position[0],e.grabPoint[1]-n.position[1],e.grabPoint[2]-n.position[2]],rC.groupIds=r,rC.startPositions={};for(let e of r){let n=t.parts[e];n&&(rC.startPositions[e]=[...n.position])}if(e.mode===`handle`&&n.type===`pipe`&&e.connectorKey){let t=e.connectorKey.split(`:`)[1],r=t===`a`?`b`:t===`b`?`a`:null;if(r){let i=nS(n),a=i.find(e=>e.connectorId===t),o=i.find(e=>e.connectorId===r);if(a&&o){let t=a.pos[0]-o.pos[0],i=a.pos[1]-o.pos[1],s=a.pos[2]-o.pos[2],c=Math.hypot(t,i,s)||(n.params.length??2);rC.pipeStretch={anchorConnectorId:r,anchorPos:[...o.pos],axis:[t/c,i/c,s/c],startLength:n.params.length??c},rC.groupIds=[e.partId]}}}rC.pushed=!1,rC.planeKey=``,rC.planeAnchor=[...e.grabPoint],t.setDraggingId(e.partId)}var aC=new Map;function oC(e){return aC.get(e)}var sC=0,cC=0;function lC(e){cC=e,sC+=e}function uC(){cC=0}var dC=()=>sC,fC=()=>cC;function pC(e){let t=aC.get(e);return t||(t={fill:0,flow:0,backedUp:!1,overflow:!1,spill:!1,state:`empty`},aC.set(e,t)),t}var mC=Math.PI/2,hC=new Y(`#38bdf8`),gC=new Y(`#0c4a6e`),_C=new Y(`#f59e0b`),vC=new Y(`#ef4444`),yC=new Y(`#556b2f`),bC=new Y(`#1e2e0a`);function xC(e,t,n,r=!1,i=0,a=0){if(Q.getState().heatmapMode)if(a<5)e.color.copy(yC),e.emissive.copy(bC),e.emissiveIntensity=.12;else if(i>3)e.color.copy(vC),e.emissive.copy(vC).multiplyScalar(.5),e.emissiveIntensity=.5;else{let t=new Y(`#22c55e`),n=new Y(`#eab308`);if(i>=1){let r=Math.min(1,Math.max(0,(i-1)/2));e.color.copy(t).lerp(n,r)}else{let n=Math.min(1,Math.max(0,i));e.color.copy(yC).lerp(t,n)}e.emissive.copy(e.color).multiplyScalar(.4),e.emissiveIntensity=.3}else if(t?.backedUp){let t=.5+.5*Math.sin(n*5);e.color.copy(_C).lerp(vC,t),e.emissive.copy(_C),e.emissiveIntensity=.3+.35*t}else r?(e.color.copy(yC),e.emissive.copy(bC),e.emissiveIntensity=.12):(e.color.copy(hC),e.emissive.copy(gC),e.emissiveIntensity=.25)}var SC=e=>.4+Math.min(3,e/120),CC=null;function wC(){if(!CC){let e=document.createElement(`canvas`);e.width=64,e.height=256;let t=e.getContext(`2d`);t.fillStyle=`#0284c7`,t.fillRect(0,0,64,256);let n=(e,n,r)=>{t.strokeStyle=r,t.lineWidth=n,t.beginPath(),t.moveTo(e,0);for(let n=0;n<=256;n+=20){let r=e+Math.sin(n*.05)*6;t.lineTo(r,n)}t.stroke()};n(12,3,`#0369a1`),n(32,5,`#0ea5e9`),n(48,2,`#38bdf8`),n(22,4,`#7dd3fc`);let r=(e,n,r)=>{t.fillStyle=`rgba(255, 255, 255, 0.35)`,t.beginPath(),t.arc(e,n,r,0,Math.PI*2),t.fill(),t.strokeStyle=`rgba(255, 255, 255, 0.7)`,t.lineWidth=.8,t.stroke()};for(let e=0;e<24;e++){let e=Math.random()*64,n=Math.random()*256,i=1.2+Math.random()*2.2;r(e,n,i),t.fillStyle=`rgba(255, 255, 255, 0.15)`,t.fillRect(e-i/2,n-i*2,i,i*3)}CC=new hs(e),CC.wrapS=CC.wrapT=w}return CC}function TC(e){let t=(0,v.useMemo)(()=>{let t=wC().clone();return t.needsUpdate=!0,t.repeat.set(1,Math.max(1,Math.round(e))),t},[e]);return(0,v.useEffect)(()=>()=>t.dispose(),[t]),t}var EC=null;function DC(){if(!EC){let e=document.createElement(`canvas`);e.width=256,e.height=256;let t=e.getContext(`2d`);t.fillStyle=`#0284c7`,t.fillRect(0,0,256,256),t.strokeStyle=`#0369a1`,t.lineWidth=4;for(let e=20;e<240;e+=30)t.beginPath(),t.arc(128,128,e,0,Math.PI*2),t.stroke();t.strokeStyle=`#0ea5e9`,t.lineWidth=3;for(let e=35;e<240;e+=45)t.beginPath(),t.arc(128,128,e,0,Math.PI*1.5),t.stroke();t.strokeStyle=`#38bdf8`,t.lineWidth=2;for(let e=50;e<240;e+=60)t.beginPath(),t.arc(128,128,e,Math.PI*.5,Math.PI*1.8),t.stroke();let n=(e,n,r)=>{t.fillStyle=`rgba(255, 255, 255, 0.35)`,t.beginPath(),t.arc(e,n,r,0,Math.PI*2),t.fill(),t.strokeStyle=`rgba(255, 255, 255, 0.65)`,t.lineWidth=.5,t.stroke()};for(let e=0;e<50;e++){let e=Math.random()*256,r=Math.random()*256,i=1+Math.random()*3.5;n(e,r,i),t.fillStyle=`rgba(255, 255, 255, 0.12)`,t.fillRect(e-i,r-i*1.5,i*2,i*3)}EC=new hs(e),EC.wrapS=EC.wrapT=w}return EC}function OC(){let e=(0,v.useMemo)(()=>{let e=DC().clone();return e.needsUpdate=!0,e.repeat.set(2,2),e.center.set(.5,.5),e},[]);return(0,v.useEffect)(()=>()=>e.dispose(),[e]),e}function kC({partId:e,length:t,radius:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=TC(t*2),o=YS();return j_(()=>{let t=r.current,n=i.current;if(!t||!n)return;let s=oC(e),c=s?.fill??0;if(c<=.002){t.visible=!1;return}t.visible=!0,s?.entry,t.scale.y=Math.max(.002,c);let l=o.velocities[e]??0,u=s?.flow??0;if(u>0){let e=l>0?l/2.5:1;a.offset.y-=fC()*SC(u)*e*c,a.offset.x=Math.sin(dC()*6)*.08}else a.offset.x=0;xC(n,s,dC(),!1,l,u)}),(0,Z.jsxs)(`mesh`,{ref:r,rotation:[0,0,mC],visible:!1,renderOrder:1,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[n,n,t,12]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:i,map:a,color:`#38bdf8`,transparent:!0,opacity:.88,roughness:.03,metalness:.18,emissive:`#0369a1`,emissiveIntensity:.5,depthWrite:!1})]})}function AC(){return(0,Z.jsx)(`meshStandardMaterial`,{color:`#38bdf8`,transparent:!0,opacity:0,roughness:.15,depthWrite:!1,emissive:`#0c4a6e`,emissiveIntensity:.25})}function jC({partId:e,maxOpacity:t=.85,children:n}){let r=(0,v.useRef)(null),i=YS();return j_(()=>{let n=r.current;if(!n)return;let a=oC(e),o=a?.fill??0;if(n.visible=o>.02,!n.visible)return;let s=dC(),c=a?.flow??0,l=i.pumps.some(e=>e.running)&&c<5,u=i.velocities[e]??0;n.traverse(e=>{let n=e.material;n?.isMeshStandardMaterial&&(n.opacity=t*o,xC(n,a,s,l,u,c))})}),(0,Z.jsx)(`group`,{ref:r,visible:!1,children:n})}function MC({partId:e,radius:t,arc:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(-1),o=YS();return j_(()=>{let s=r.current,c=i.current;if(!s||!c)return;let l=oC(e),u=l?.fill??0;if(u<=.02){s.visible=!1;return}s.visible=!0;let d=l?.entry!==`b`,f=Math.max(.05,n*u);Math.abs(a.current-f)>.04&&(s.geometry.dispose(),s.geometry=new il(Ux,t,10,20,f),a.current=f),s.rotation.z=d?-mC:-mC+n*(1-u);let p=l?.flow??0,m=o.pumps.some(e=>e.running)&&p<5,h=o.velocities[e]??0;xC(c,l,dC(),m,h,p),c.opacity=.88}),(0,Z.jsxs)(`mesh`,{ref:r,position:[0,Ux,0],rotation:[0,0,-mC],visible:!1,renderOrder:1,children:[(0,Z.jsx)(`torusGeometry`,{args:[Ux,t,10,20,n]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:i,color:`#38bdf8`,transparent:!0,opacity:0,roughness:.15,depthWrite:!1,emissive:`#0c4a6e`,emissiveIntensity:.25})]})}function NC({partId:e,radius:t}){let n=(0,v.useRef)(null),r=YS();return j_(()=>{let t=n.current;if(!t)return;let i=oC(e),a=i?.fill??0;if(t.visible=a>.02,!t.visible)return;let o=dC(),s=i?.entry??`a`,c=s===`a`||s===`b`||s===`c`?s:`a`,l=i?.flow??0,u=Math.min(1,a/.34),d=a<=.34?0:Math.min(1,(a-.34)/.66),f=Math.min(1,.55+l/900),p=i?.flow??0,m=r.pumps.some(e=>e.running)&&p<5,h=r.velocities[e]??0;t.children.forEach(e=>{let t=e,n=t.userData.role,r=t.material;if(!n||!r)return;if(xC(r,i,o,m,h,p),n===`core`){t.visible=u>.02,t.scale.setScalar(Math.max(.001,u)),r.opacity=.5+.3*u;return}let a=n===c,s=a?Math.max(u,d*.8):d*f;if(t.visible=s>.02,t.visible){if(n===`a`||n===`b`){t.scale.set(1,Math.max(.001,s),1);let e=n===`a`?-1:1;t.position.x=e*(.29+.29*s),t.position.z=0}else t.scale.set(1,Math.max(.001,s),1),t.position.x=0,t.position.z=.15+.15*s;r.opacity=a?.88:.72}})}),(0,Z.jsxs)(`group`,{ref:n,visible:!1,children:[(0,Z.jsxs)(`mesh`,{userData:{role:`a`},position:[-.58,0,0],rotation:[0,0,mC],renderOrder:1,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t,t,.58,12]}),(0,Z.jsx)(AC,{})]}),(0,Z.jsxs)(`mesh`,{userData:{role:`b`},position:[.58,0,0],rotation:[0,0,mC],renderOrder:1,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t,t,.58,12]}),(0,Z.jsx)(AC,{})]}),(0,Z.jsxs)(`mesh`,{userData:{role:`c`},position:[0,0,.3],rotation:[mC,0,0],renderOrder:1,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t,t,.3,12]}),(0,Z.jsx)(AC,{})]}),(0,Z.jsxs)(`mesh`,{userData:{role:`core`},renderOrder:1,children:[(0,Z.jsx)(`sphereGeometry`,{args:[t*1.28,12,12]}),(0,Z.jsx)(AC,{})]})]})}function PC({partId:e,radius:t}){return(0,Z.jsx)(jC,{partId:e,children:(0,Z.jsxs)(`mesh`,{rotation:[0,0,mC],renderOrder:1,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t,t,.66,12]}),(0,Z.jsx)(AC,{})]})})}var FC=e=>new Mn().setFromUnitVectors(new q(0,1,0),new q(...e).normalize());function IC({partId:e,dir:t,radius:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useMemo)(()=>FC(t),[t[0],t[1],t[2]]),c=YS();return j_(()=>{let t=r.current;if(!t)return;let s=oC(e),l=s?.fill??0,u=s?.flow??0,d=u>.1&&l>.35;if(t.visible=d,!d)return;let f=dC(),p=fC(),m=Math.min(1,u/600),h=.35+m*.55,g=c.pumps.some(e=>e.running)&&u<5,_=c.velocities[e]??0;i.current&&a.current&&(i.current.position.y=h/2,i.current.scale.set(1+m*.4,h,1+m*.4),a.current.opacity=.45+.25*Math.sin(f*10)*m,xC(a.current,s,f,g,_,u));let v=o.current;v&&v.children.forEach((e,t)=>{let r=(f*(1.5+m*2.5)+t*.23)%1;e.position.set(Math.sin(t*3.1+f*4)*n*.9*r,.12+r*(h+.35),Math.cos(t*2.7+f*3)*n*.9*r),e.scale.setScalar(.45+r*.65),e.rotation.x+=p*2})}),(0,Z.jsxs)(`group`,{ref:r,quaternion:s,visible:!1,children:[(0,Z.jsxs)(`mesh`,{ref:i,position:[0,.25,0],renderOrder:3,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[n*.28,n*.55,1,8,1,!0]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:a,color:`#7dd3fc`,transparent:!0,opacity:.5,roughness:.05,depthWrite:!1,side:2})]}),(0,Z.jsx)(`group`,{ref:o,children:Array.from({length:5},(e,t)=>(0,Z.jsxs)(`mesh`,{renderOrder:3,children:[(0,Z.jsx)(`sphereGeometry`,{args:[Math.max(.018,n*.22),6,6]}),(0,Z.jsx)(`meshStandardMaterial`,{color:`#bae6fd`,transparent:!0,opacity:.85,roughness:.05,depthWrite:!1})]},t))})]})}function LC({partId:e}){let t=(0,v.useRef)(null),n=(0,v.useRef)(null),r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=YS();return j_(()=>{let c=t.current;if(!c)return;let l=oC(e),u=l?.fill??0,d=l?.flow??0;if(c.visible=u>.05,!c.visible)return;let f=dC(),p=s.pumps.some(e=>e.running)&&d<5,m=s.velocities[e]??0;if(n.current&&(n.current.opacity=.75*u,xC(n.current,l,f,p,m,d)),r.current&&i.current&&(r.current.rotation.z+=fC()*(2.5+d/30),i.current.opacity=(d>0?.7:.25)*u),a.current&&o.current){let e=l?.overflow??!1;if(a.current.visible=e,e){let e=.5+.5*Math.sin(f*4.5);a.current.scale.setScalar(1+.18*e),o.current.opacity=.3+.3*e}}}),(0,Z.jsxs)(`group`,{ref:t,visible:!1,children:[(0,Z.jsxs)(`mesh`,{position:[0,.315,0],renderOrder:1,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.26,.2,.05,18]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:n,color:`#38bdf8`,transparent:!0,opacity:0,roughness:.1,depthWrite:!1})]}),(0,Z.jsxs)(`mesh`,{ref:r,position:[0,.35,0],rotation:[mC+.13,0,0],renderOrder:2,children:[(0,Z.jsx)(`torusGeometry`,{args:[.15,.025,6,24]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:i,color:`#bae6fd`,transparent:!0,opacity:0,roughness:.08,depthWrite:!1})]}),(0,Z.jsxs)(`mesh`,{ref:a,position:[0,.3,0],visible:!1,renderOrder:2,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.42,.47,.035,22]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:o,color:`#f59e0b`,transparent:!0,opacity:0,roughness:.25,depthWrite:!1,emissive:`#b45309`,emissiveIntensity:.5})]})]})}function RC({partId:e,length:t}){let n=(0,v.useRef)(null),r=(0,v.useRef)(null),i=(0,v.useRef)(null);return j_(()=>{let a=n.current;if(!a)return;let o=oC(e),s=o?.flow??0,c=s>0&&(o?.fill??0)>.4&&t>.1;if(a.visible=c,!c)return;let l=dC();r.current&&(r.current.opacity=.4+.12*Math.sin(l*9));let u=i.current;if(u){let e=1.2+s/150;u.children.forEach((n,r)=>{let i=(l*e+r*.37)%1;n.position.set(.06*Math.sin(r*2.4+l*2)*i,-.2-i*t,.06*Math.cos(r*1.7+l*2)*i),n.scale.setScalar(.6+.5*i)})}}),(0,Z.jsxs)(`group`,{ref:n,visible:!1,children:[(0,Z.jsxs)(`mesh`,{position:[0,-.2-t/2,0],renderOrder:1,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.025,.075,t,8,1,!0]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:r,color:`#7dd3fc`,transparent:!0,opacity:.45,roughness:.05,depthWrite:!1,side:2})]}),(0,Z.jsx)(`group`,{ref:i,children:Array.from({length:6},(e,t)=>(0,Z.jsxs)(`mesh`,{renderOrder:1,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.03,6,6]}),(0,Z.jsx)(`meshStandardMaterial`,{color:`#bae6fd`,transparent:!0,opacity:.85,roughness:.05,depthWrite:!1})]},t))})]})}function zC({partId:e,length:t,width:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=YS();return j_(()=>{let t=r.current,n=i.current;if(!t||!n)return;let o=oC(e),s=o?.fill??0;if(t.visible=s>.02,!t.visible)return;let c=dC();n.opacity=.55*s;let l=o?.flow??0;xC(n,o,c,a.pumps.some(e=>e.running)&&l<5,a.velocities[e]??0,l),t.position.y=.21+(l>0?.006*Math.sin(c*3):0)}),(0,Z.jsxs)(`mesh`,{ref:r,position:[0,.21,0],visible:!1,renderOrder:1,children:[(0,Z.jsx)(`boxGeometry`,{args:[t-.15,.1,n-.15]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:i,color:`#38bdf8`,transparent:!0,opacity:0,roughness:.15,depthWrite:!1})]})}function BC({partId:e,width:t,depth:n,surfaceY:r}){let i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=OC(),c=Q(e=>e.parts),l=YS();return j_((t,n)=>{let u=i.current,d=o.current;if(!u||!a.current)return;let f=oC(e),p=l.reservoirRuntime[e],m=p?Math.max(0,Math.min(1,p.gallonsCurrent/Math.max(.1,p.gallonsCapacity))):.7,h=Math.max(.03,(r-.1)*m)+.03,g=+((f?.flow??0)>0),_=0,v=[u.position.x,h,u.position.z];for(let e of Object.values(c))e.type===`airCompressor`&&(e.params.on??1)>0&&Math.hypot(e.position[0]-v[0],e.position[1]-v[1],e.position[2]-v[2])<10&&(_+=e.params.gph??120);let y=+(_>0),b=g||y,x=dC(),S=.012*Math.sin(x*2.6)*g+.004*Math.sin(x*12)*y;if(u.position.y=h+S,g>0){let e=Math.min(.1,n);s.offset.x+=e*.16,s.offset.y+=e*.12,s.rotation=x*.05}else if(y>0){let e=Math.min(.1,n);s.offset.x+=e*.06,s.offset.y+=e*.08,s.rotation=x*.025}if(d&&b>0){let e=d.attributes.position;for(let t=0;t<e.count;t++){let n=e.getX(t),r=e.getY(t),i=.012*Math.sin(n*5+x*4)*Math.cos(r*5+x*3.5)*g+.005*Math.sin(n*12-x*6)*g;if(y>0){let e=Math.hypot(n,r),t=.008*Math.sin(e*22-x*16)*Math.exp(-e*1.8)*y;i+=t}e.setZ(t,i)}e.needsUpdate=!0,d.computeVertexNormals()}else if(d){let e=d.attributes.position;for(let t=0;t<e.count;t++)e.setZ(t,0);e.needsUpdate=!0,d.computeVertexNormals()}let C=!g&&!y,w=f?.flow??0;xC(a.current,f,x,C,0,w),a.current.opacity=.75+.15*Math.sin(x*4)*b}),(0,Z.jsxs)(`mesh`,{ref:i,position:[0,r,0],rotation:[-mC,0,0],renderOrder:2,children:[(0,Z.jsx)(`planeGeometry`,{ref:o,args:[t,n,16,16]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:a,map:s,color:`#38bdf8`,transparent:!0,opacity:.75,roughness:.02,metalness:.15,emissive:`#0284c7`,emissiveIntensity:.5,depthWrite:!1,side:2})]})}function VC({partId:e,size:t}){let n=(0,v.useRef)(null),r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=YS();return j_(()=>{let o=oC(e),s=o?.spill??!1;if(n.current&&(n.current.visible=s),i.current&&(i.current.visible=s),!s)return;let c=dC(),l=fC(),u=o?.flow??0,d=a.pumps.some(e=>e.running)&&u<5,f=a.velocities[e]??0;r.current&&(r.current.opacity=.45+.18*(.5+.5*Math.sin(c*6)),xC(r.current,o,c,d,f,u)),i.current&&i.current.children.forEach((e,n)=>{let r=(c*(1.8+(o?.flow??0)/260)+n*.29)%1,a=e,s=n/Math.max(1,i.current.children.length)*Math.PI*2;a.position.set(Math.cos(s)*.12*t,.26*t-r*.38*t,Math.sin(s)*.12*t),a.scale.setScalar(.55+.5*(1-r)),a.rotation.x+=l*2})}),(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{ref:n,position:[0,.225*t,0],visible:!1,renderOrder:2,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.16*t,.1*t,.035*t,16]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:r,color:`#38bdf8`,transparent:!0,opacity:0,roughness:.08,depthWrite:!1,emissive:`#0c4a6e`,emissiveIntensity:.25})]}),(0,Z.jsx)(`group`,{ref:i,visible:!1,children:Array.from({length:6},(e,n)=>(0,Z.jsxs)(`mesh`,{renderOrder:2,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.024*t,6,6]}),(0,Z.jsx)(`meshStandardMaterial`,{color:`#7dd3fc`,transparent:!0,opacity:.85,roughness:.05,depthWrite:!1})]},n))})]})}function HC({startPos:e,maxY:t,index:n,count:r,active:i,frequency:a}){let o=(0,v.useRef)(null);return j_(()=>{let s=o.current;if(!s)return;if(!i){s.visible=!1;return}s.visible=!0;let c=dC(),l=(c*(1+a/10*.6)*.4+n/r)%1;s.position.y=e.y+l*(t-e.y);let u=c*7+n*1.5;s.position.x=e.x+Math.sin(u)*.05,s.position.z=e.z+Math.cos(u*.8)*.05,s.scale.setScalar(.45+.9*l)}),(0,Z.jsxs)(`mesh`,{ref:o,renderOrder:3,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.015,6,6]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#e0f2fe`,transparent:!0,opacity:.65})]})}function UC(){let e=Q(e=>e.parts);return(0,Z.jsx)(Z.Fragment,{children:Object.values(e).filter(e=>e.type===`airCompressor`).map(e=>(0,Z.jsx)(WC,{comp:e},e.id))})}function WC({comp:e}){let t=Q(e=>e.parts),n=(e.params.on??1)>0,r=e.params.frequency??5,i=(0,v.useMemo)(()=>{let n=null,r=1/0,i=e.position;for(let e of Object.values(t))if(e.type===`reservoir`){let t=Math.hypot(e.position[0]-i[0],e.position[1]-i[1],e.position[2]-i[2]);t<r&&(r=t,n=e)}return n},[t,e.position]);if(!i)return null;let a=i.params.width??2,o=i.params.depth??1.4,s=i.params.height??1,c=new q(.28,.22,0).applyEuler(new pr(e.rotation[0],e.rotation[1],e.rotation[2],`XYZ`)).add(new q(...e.position)),l=new q(i.position[0],i.position[1]+.05,i.position[2]),u=c.x-i.position[0],d=c.z-i.position[2],f=u>0?1:-1,p=d>0?1:-1,m=i.position[0]+f*(a/2+.04),h=i.position[2]+p*(o/2+.04),g=[[c.x,c.y,c.z],[c.x,.02,c.z],[m,.02,c.z],[m,.02,h],[m,i.position[1]+s+.03,h],[i.position[0]+f*(a/2-.08),i.position[1]+s+.03,i.position[2]+p*(o/2-.08)],[l.x,l.y,l.z]],_=Math.max(.02,(s-.1)*((i.params.level??70)/100)),y=i.position[1]+_+.02;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsx)(mb,{points:g,color:`#1e293b`,lineWidth:3}),(0,Z.jsxs)(`mesh`,{position:l,rotation:[0,0,mC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.04,.04,.12,10]}),(0,Z.jsx)(`meshStandardMaterial`,{color:`#64748b`,roughness:.8})]}),Array.from({length:12},(e,t)=>(0,Z.jsx)(HC,{startPos:l,maxY:y,index:t,count:12,active:n,frequency:r},t))]})}function GC({partId:e,width:t,depth:n,height:r}){let i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=Q(e=>e.parts),s=YS();return j_(()=>{if(!i.current||!a.current)return;let t=oC(e),n=s.reservoirRuntime[e],c=n?Math.max(0,Math.min(1,n.gallonsCurrent/Math.max(.1,n.gallonsCapacity))):.7,l=Math.max(.02,(r-.1)*c);i.current.scale.y=l,i.current.position.y=l/2+.02;let u=+((t?.flow??0)>0),d=0,f=[i.current.position.x,l,i.current.position.z];for(let e of Object.values(o))e.type===`airCompressor`&&(e.params.on??1)>0&&Math.hypot(e.position[0]-f[0],e.position[1]-f[1],e.position[2]-f[2])<10&&(d+=e.params.gph??120);let p=!u&&!+(d>0);xC(a.current,t,dC(),p,0,t?.flow??0)}),(0,Z.jsxs)(`mesh`,{ref:i,position:[0,r/2+.02,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[t,1,n]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:a,color:`#1d4ed8`,transparent:!0,opacity:.6,roughness:.1,depthWrite:!1})]})}var KC=Math.PI/2,qC=(0,v.createContext)({ghost:!1,selected:!1});function $({color:e,metalness:t=.25,roughness:n=.55,opacity:r,transparent:i,physical:a=!1,transmission:o=.9,thickness:s=.4}){let{ghost:c,selected:l}=(0,v.useContext)(qC),u=Q(e=>e.renderMode),d=u===`water`?.06:u===`xray`?Math.min(r??1,.2):r,f=c||i||d!==void 0||u!==`builder`||a;return a&&u===`builder`?(0,Z.jsx)(`meshPhysicalMaterial`,{color:e,metalness:.05,roughness:.08,transmission:o,thickness:s,ior:1.45,transparent:!0,opacity:c?.45:1,depthWrite:!1,emissive:l?`#0ea5e9`:`#000000`,emissiveIntensity:l?.4:0}):(0,Z.jsx)(`meshStandardMaterial`,{color:e,metalness:t,roughness:n,transparent:f,opacity:c?.4:d??1,depthWrite:!f,emissive:l?`#0ea5e9`:`#000000`,emissiveIntensity:l?.4:0})}function JC(e,t){if(t<=0)return e;let n=new Y(e);return n.lerp(new Y(`#3b82f6`),Math.min(.55,.25+t/800)),`#${n.getHexString()}`}var YC=new Y(`#34d399`),XC=new Y(`#f59e0b`),ZC=new Y(`#22d3ee`),QC=new Y(`#67e8f9`);function $C({partId:e,pos:t,joined:n,seed:r}){let i=(0,v.useRef)(null),a=(0,v.useRef)(null);return j_(()=>{let t=i.current,o=a.current;if(!t)return;if(!n){t.color.copy(XC),t.emissive.copy(XC),t.emissiveIntensity=.45,o&&(o.visible=!1);return}let s=oC(e);if((s?.flow??0)>0&&(s?.fill??0)>.05){let e=.5+.5*Math.sin(dC()*3.2+r);if(t.color.copy(ZC),t.emissive.copy(ZC),t.emissiveIntensity=1.1+1*e,o){o.visible=!0,o.scale.setScalar(1+.35*e);let t=o.material;t.color.copy(QC),t.opacity=.2+.25*e}}else t.color.copy(YC),t.emissive.copy(YC),t.emissiveIntensity=.7,o&&(o.visible=!1)}),(0,Z.jsxs)(`group`,{position:t,children:[(0,Z.jsxs)(`mesh`,{children:[(0,Z.jsx)(`sphereGeometry`,{args:[.06,10,10]}),(0,Z.jsx)(`meshStandardMaterial`,{ref:i,color:`#f59e0b`,emissive:`#f59e0b`,emissiveIntensity:.45,toneMapped:!1})]}),(0,Z.jsxs)(`mesh`,{ref:a,visible:!1,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.11,10,10]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#67e8f9`,transparent:!0,opacity:.25,blending:2,depthWrite:!1,toneMapped:!1})]})]})}function ew({part:e,connectedKeys:t,radius:n}){return(0,Z.jsx)(Z.Fragment,{children:Yx[e.type].getConnectors(e.params).map(r=>t?.has(`${e.id}:${r.id}`)?null:(0,Z.jsx)(`group`,{position:r.pos,children:(0,Z.jsx)(IC,{partId:e.id,dir:r.dir,radius:n})},r.id))})}function tw({part:e,connectedKeys:t}){return(0,Z.jsx)(Z.Fragment,{children:Yx[e.type].getConnectors(e.params).map((n,r)=>(0,Z.jsx)($C,{partId:e.id,pos:n.pos,joined:t?.has(`${e.id}:${n.id}`)??!1,seed:r*1.7},n.id))})}function nw({width:e,depth:t,height:n,on:r}){let i=(0,v.useRef)(null);return j_(()=>{if(i.current){if(!r){i.current.opacity=0;return}let e=dC();i.current.opacity=.03+.015*Math.sin(e*1.5)*Math.cos(e*.7)}}),r?(0,Z.jsxs)(`mesh`,{position:[0,-n/2-.08,0],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[e*.45,e*1.25,n,16,1,!0]}),(0,Z.jsx)(`meshBasicMaterial`,{ref:i,color:`#fef08a`,transparent:!0,opacity:.03,depthWrite:!1,side:2})]}):null}function rw({w:e,d:t,floorY:n,watts:r,selected:i}){let a=.5*Math.abs(n),o=Math.max(e,t)*.4+a*.3,s=Math.max(e,t)*.8+a*.6,c=Math.max(e,t)*1.3+a*1,l=(0,v.useMemo)(()=>{let e=[];for(let t=0;t<=64;t++){let n=t/64*Math.PI*2;e.push([Math.cos(n)*o,0,Math.sin(n)*o])}return e},[o]),u=(0,v.useMemo)(()=>{let e=[];for(let t=0;t<=64;t++){let n=t/64*Math.PI*2;e.push([Math.cos(n)*s,0,Math.sin(n)*s])}return e},[s]),d=(0,v.useMemo)(()=>{let e=[];for(let t=0;t<=64;t++){let n=t/64*Math.PI*2;e.push([Math.cos(n)*c,0,Math.sin(n)*c])}return e},[c]),f=[[e/2,-.06,t/2],[-e/2,-.06,t/2],[-e/2,-.06,-t/2],[e/2,-.06,-t/2]],p=[[c*.707,n+.01,c*.707],[-c*.707,n+.01,c*.707],[-c*.707,n+.01,-c*.707],[c*.707,n+.01,-c*.707]],m=i?1:.45;return(0,Z.jsxs)(`group`,{children:[f.map((e,t)=>(0,Z.jsx)(mb,{points:[e,p[t]],color:`#fde68a`,lineWidth:i?1.2:.6,dashed:!0,dashScale:2,transparent:!0,opacity:.2*m},t)),(0,Z.jsxs)(`group`,{position:[0,n+.01,0],children:[(0,Z.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],children:[(0,Z.jsx)(`circleGeometry`,{args:[o,32]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#fbbf24`,transparent:!0,opacity:.16*m,depthWrite:!1})]}),(0,Z.jsx)(mb,{points:l,color:`#fbbf24`,lineWidth:i?2:1,transparent:!0,opacity:.3*m}),(0,Z.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],children:[(0,Z.jsx)(`ringGeometry`,{args:[o,s,32]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#f59e0b`,transparent:!0,opacity:.09*m,depthWrite:!1})]}),(0,Z.jsx)(mb,{points:u,color:`#f59e0b`,lineWidth:i?1.5:.8,transparent:!0,opacity:.2*m}),(0,Z.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],children:[(0,Z.jsx)(`ringGeometry`,{args:[s,c,32]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#eab308`,transparent:!0,opacity:.04*m,depthWrite:!1})]}),(0,Z.jsx)(mb,{points:d,color:`#eab308`,lineWidth:i?1:.5,transparent:!0,opacity:.1*m})]})]})}function iw({baseColor:e,on:t}){let n=(0,v.useRef)(null);return j_(()=>{if(n.current&&t){let e=dC();n.current.position.y=Math.sin(e*60)*.0025,n.current.position.x=Math.cos(e*50)*.0018}else n.current&&n.current.position.set(0,0,0)}),(0,Z.jsxs)(`group`,{ref:n,children:[(0,Z.jsxs)(`mesh`,{position:[0,.2,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.6,.35,.4]}),(0,Z.jsx)($,{color:e,metalness:.4,roughness:.3})]}),(0,Z.jsxs)(`mesh`,{position:[-.2,.02,-.12],children:[(0,Z.jsx)(`sphereGeometry`,{args:[.04,8,8]}),(0,Z.jsx)($,{color:`#0f172a`})]}),(0,Z.jsxs)(`mesh`,{position:[.2,.02,-.12],children:[(0,Z.jsx)(`sphereGeometry`,{args:[.04,8,8]}),(0,Z.jsx)($,{color:`#0f172a`})]}),(0,Z.jsxs)(`mesh`,{position:[-.2,.02,.12],children:[(0,Z.jsx)(`sphereGeometry`,{args:[.04,8,8]}),(0,Z.jsx)($,{color:`#0f172a`})]}),(0,Z.jsxs)(`mesh`,{position:[.2,.02,.12],children:[(0,Z.jsx)(`sphereGeometry`,{args:[.04,8,8]}),(0,Z.jsx)($,{color:`#0f172a`})]}),(0,Z.jsxs)(`mesh`,{position:[.28,.22,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.02,.02,.08,10]}),(0,Z.jsx)($,{color:`#d97706`,metalness:.8,roughness:.2})]})]})}function aw({part:e,flow:t,connectedKeys:n}){let r=e.params,i=Yx[e.type],a=e.color||i.color,o=Q(e=>e.renderMode),s=o===`water`?.15:o===`xray`?.42:.8;switch(e.type){case`pipe`:{let i=Gx(r.diameter??1),o=r.length??2;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,receiveShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[i,i,o,16]}),(0,Z.jsx)($,{color:JC(a,t),opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsx)(kC,{partId:e.id,length:o,radius:i*.78}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:i})]})}case`coupling`:{let i=Gx(r.diameter??1);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,receiveShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[i*1.18,i*1.18,.6,16]}),(0,Z.jsx)($,{color:JC(a,t),opacity:.65,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[-.22,0,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`torusGeometry`,{args:[i*1.18,.018,8,18]}),(0,Z.jsx)($,{color:`#7c8794`})]}),(0,Z.jsxs)(`mesh`,{position:[.22,0,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`torusGeometry`,{args:[i*1.18,.018,8,18]}),(0,Z.jsx)($,{color:`#7c8794`})]}),(0,Z.jsx)(kC,{partId:e.id,length:.6,radius:i*.72}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:i})]})}case`reducer`:{let i=Gx(r.diameterA??1.5),o=Gx(r.diameterB??1),s=Math.min(i,o),c=JC(a,t);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,receiveShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[o*1.15,i*1.15,.7,20]}),(0,Z.jsx)($,{color:c,opacity:.65,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[-.28,0,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`torusGeometry`,{args:[i*1.15,.018,8,18]}),(0,Z.jsx)($,{color:`#7c8794`})]}),(0,Z.jsxs)(`mesh`,{position:[.28,0,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`torusGeometry`,{args:[o*1.15,.018,8,18]}),(0,Z.jsx)($,{color:`#7c8794`})]}),(0,Z.jsx)(kC,{partId:e.id,length:.7,radius:s*.72}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:Math.max(i,o)})]})}case`cap`:{let e=Gx(r.diameter??1);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[.05,0,0],rotation:[0,0,KC],castShadow:!0,receiveShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[e*1.2,e*1.2,.45,16]}),(0,Z.jsx)($,{color:JC(a,t),opacity:.75,roughness:.38})]}),(0,Z.jsxs)(`mesh`,{position:[.28,0,0],rotation:[0,KC,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[e*1.2,e*1.2,.04,16]}),(0,Z.jsx)($,{color:`#6b7280`,roughness:.35})]}),(0,Z.jsxs)(`mesh`,{position:[-.12,0,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`torusGeometry`,{args:[e*1.2,.018,8,18]}),(0,Z.jsx)($,{color:`#7c8794`})]})]})}case`elbow`:{let i=Gx(r.diameter??1),o=Ux,s=(r.angle??90)*Math.PI/180;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,o,0],rotation:[0,0,-KC],castShadow:!0,children:[(0,Z.jsx)(`torusGeometry`,{args:[o,i,12,24,s]}),(0,Z.jsx)($,{color:JC(a,t),opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsx)(MC,{partId:e.id,radius:i*.78,arc:s}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:i})]})}case`tee`:{let i=Gx(r.diameter??1),o=JC(a,t);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[i,i,1.2,16]}),(0,Z.jsx)($,{color:o,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[0,0,.3],rotation:[KC,0,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[i,i,.6,16]}),(0,Z.jsx)($,{color:o,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsx)(NC,{partId:e.id,radius:i*.75}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:i})]})}case`valve`:{let i=Gx(r.diameter??1)*1.25,o=(r.open??100)>0;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[i,i,.7,16]}),(0,Z.jsx)($,{color:JC(`#8b939e`,t),metalness:.5,roughness:.35,opacity:.75,physical:!0,transmission:.9,thickness:.4})]}),(0,Z.jsx)(PC,{partId:e.id,radius:Gx(r.diameter??1)*.78}),(0,Z.jsxs)(`mesh`,{position:[0,.22,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[.07,.28,.07]}),(0,Z.jsx)($,{color:`#6b7280`})]}),(0,Z.jsxs)(`mesh`,{position:[0,.4,0],rotation:[KC,0,0],children:[(0,Z.jsx)(`torusGeometry`,{args:[.16,.04,8,20]}),(0,Z.jsx)($,{color:o?a:`#991b1b`})]}),o&&(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:Gx(r.diameter??1)})]})}case`pump`:return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,.25,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.8,.5,.6]}),(0,Z.jsx)($,{color:a,metalness:.4,roughness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[0,.56,0],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.14,.14,.14,16]}),(0,Z.jsx)($,{color:`#1e3a8a`})]}),(0,Z.jsxs)(`mesh`,{position:[-.43,.25,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.1,.1,.2,12]}),(0,Z.jsx)($,{color:`#64748b`})]}),(0,Z.jsxs)(`mesh`,{position:[.43,.25,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.1,.1,.2,12]}),(0,Z.jsx)($,{color:`#64748b`})]})]});case`reservoir`:{let t=r.width??2,n=r.depth??1.4,i=r.height??1;return Math.max(.02,(i-.1)*((r.level??70)/100)),(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,i/2,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[t,i,n]}),(0,Z.jsx)($,{color:`#44607e`,opacity:.3,roughness:.3})]}),(0,Z.jsx)(GC,{partId:e.id,width:t-.12,depth:n-.12,height:i}),(0,Z.jsx)(BC,{partId:e.id,width:t-.12,depth:n-.12,surfaceY:i}),(0,Z.jsxs)(`mesh`,{position:[0,i,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[t+.06,.06,n+.06]}),(0,Z.jsx)($,{color:a})]})]})}case`tower`:{let e=r.height??4,t=Math.max(1,Math.round(r.sites??6)),n=[];for(let r=0;r<t;r++){let i=.8+(e-1.4)*r/Math.max(1,t-1),a=r%2==0?1:-1;n.push((0,Z.jsxs)(`group`,{position:[a*.33,i,0],rotation:[0,0,a*-.5],children:[(0,Z.jsxs)(`mesh`,{castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.13,.09,.22,12]}),(0,Z.jsx)($,{color:`#1f2937`})]}),(0,Z.jsxs)(`mesh`,{position:[0,.16,0],children:[(0,Z.jsx)(`sphereGeometry`,{args:[.13,10,10]}),(0,Z.jsx)($,{color:`#3fae51`,roughness:.8})]})]},r))}return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,e/2,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.33,.36,e,20]}),(0,Z.jsx)($,{color:a,roughness:.7})]}),(0,Z.jsxs)(`mesh`,{position:[.4,.15,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.1,.1,.25,12]}),(0,Z.jsx)($,{color:`#9aa3b0`})]}),n]})}case`tray`:{let t=r.length??3,n=r.width??1.2;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,.125,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[t,.25,n]}),(0,Z.jsx)($,{color:a,roughness:.7})]}),(0,Z.jsx)(zC,{partId:e.id,length:t,width:n})]})}case`wallPanel`:{let e=r.width??3,t=r.height??4,n=Math.max(1,Math.round(r.rows??4)),i=Math.max(1,Math.round(r.cols??5)),o=[];for(let r=0;r<n;r++)for(let a=0;a<i;a++){let s=-e/2+.4+a*(e-.8)/Math.max(1,i-1),c=.4+r*(t-.8)/Math.max(1,n-1);o.push((0,Z.jsxs)(`group`,{position:[s,c,.12],children:[(0,Z.jsxs)(`mesh`,{rotation:[KC,0,0],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.11,.08,.14,10]}),(0,Z.jsx)($,{color:`#1f2937`})]}),(0,Z.jsxs)(`mesh`,{position:[0,.05,.08],children:[(0,Z.jsx)(`sphereGeometry`,{args:[.1,8,8]}),(0,Z.jsx)($,{color:`#4cae51`,roughness:.85})]})]},`${r}-${a}`))}return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,t/2,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[e,t,.18]}),(0,Z.jsx)($,{color:a,roughness:.75})]}),o]})}case`lattice`:{let e=r.width??2.5,t=r.height??3,n=[],i=.5;for(let r=-e/2;r<=e/2+1e-6;r+=i)n.push((0,Z.jsxs)(`mesh`,{position:[r,t/2,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.06,t,.06]}),(0,Z.jsx)($,{color:a,roughness:.8})]},`v${r.toFixed(2)}`));for(let r=0;r<=t+1e-6;r+=i)n.push((0,Z.jsxs)(`mesh`,{position:[0,r,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[e,.06,.06]}),(0,Z.jsx)($,{color:a,roughness:.8})]},`h${r.toFixed(2)}`));return(0,Z.jsx)(`group`,{children:n})}case`netPot`:return(0,Z.jsxs)(`group`,{scale:r.size??1,children:[(0,Z.jsxs)(`mesh`,{position:[0,.11,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.18,.12,.22,14]}),(0,Z.jsx)($,{color:a,roughness:.6})]}),(0,Z.jsx)(VC,{partId:e.id,size:1}),(0,Z.jsxs)(`mesh`,{position:[0,.3,0],children:[(0,Z.jsx)(`sphereGeometry`,{args:[.15,10,10]}),(0,Z.jsx)($,{color:`#3fae51`,roughness:.85})]})]});case`emitter`:{let t=Math.max(0,e.position[1]-.2);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.3,.18,.18]}),(0,Z.jsx)($,{color:a,metalness:.3})]}),(0,Z.jsxs)(`mesh`,{position:[0,-.15,0],rotation:[Math.PI,0,0],children:[(0,Z.jsx)(`coneGeometry`,{args:[.08,.14,10]}),(0,Z.jsx)($,{color:`#155e75`})]}),(0,Z.jsx)(RC,{partId:e.id,length:t})]})}case`drain`:return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,.15,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.3,.13,.3,18]}),(0,Z.jsx)($,{color:a,metalness:.45,roughness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[0,.3,0],rotation:[KC,0,0],children:[(0,Z.jsx)(`torusGeometry`,{args:[.3,.035,8,24]}),(0,Z.jsx)($,{color:`#475569`,metalness:.5,roughness:.35})]}),[-.18,-.06,.06,.18].map(e=>(0,Z.jsxs)(`mesh`,{position:[0,.295,e],children:[(0,Z.jsx)(`boxGeometry`,{args:[2*Math.sqrt(Math.max(.012,.0784-e*e)),.03,.045]}),(0,Z.jsx)($,{color:`#334155`,metalness:.5,roughness:.45})]},e)),(0,Z.jsxs)(`mesh`,{position:[-.26,.25,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.1,.1,.2,12]}),(0,Z.jsx)($,{color:`#8b939e`})]}),(0,Z.jsx)(LC,{partId:e.id})]});case`growTent`:{let e=r.width??7,t=r.depth??5,n=r.height??4,i=(r.sealed??0)>0;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,n/2,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[e,n,t]}),(0,Z.jsx)($,{color:i?`#164e63`:`#334155`,opacity:.08,roughness:.9})]}),(0,Z.jsxs)(`lineSegments`,{position:[0,n/2,0],children:[(0,Z.jsx)(`edgesGeometry`,{args:[new bs(e,n,t)]}),(0,Z.jsx)(`lineBasicMaterial`,{color:i?`#22d3ee`:`#94a3b8`,transparent:!0,opacity:s})]}),(0,Z.jsxs)(`mesh`,{position:[0,n/2,t/2+.01],children:[(0,Z.jsx)(`planeGeometry`,{args:[e*.22,n*.8]}),(0,Z.jsx)($,{color:`#0f172a`,opacity:.22})]})]})}case`inlineFan`:return(0,Z.jsx)(ow,{baseColor:a,cfm:r.cfm??600});case`circulationFan`:return(0,Z.jsx)(sw,{baseColor:a,cfm:r.cfm??250,sweep:r.sweep??90});case`growLight`:{let t=r.width??2,n=r.depth??2,i=r.watts??650,{selected:o}=(0,v.useContext)(qC);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[t,.12,n]}),(0,Z.jsx)($,{color:a,metalness:.35,roughness:.35})]}),(0,Z.jsxs)(`mesh`,{position:[0,-.07,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[t*.88,.03,n*.88]}),(0,Z.jsx)($,{color:`#fde68a`,opacity:.55})]}),(0,Z.jsx)(`pointLight`,{position:[0,-.15,0],intensity:i/100,distance:16,decay:1.8,castShadow:!0,"shadow-mapSize":[512,512]}),(0,Z.jsx)(nw,{width:t,depth:n,height:6,on:i>0}),i>0&&(0,Z.jsx)(rw,{w:t,d:n,floorY:-e.position[1],watts:i,selected:o})]})}case`co2Tank`:return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,.7,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.18,.2,1.4,20]}),(0,Z.jsx)($,{color:a,metalness:.35,roughness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[0,1.48,0],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.07,.07,.12,12]}),(0,Z.jsx)($,{color:`#e2e8f0`})]}),(0,Z.jsxs)(`mesh`,{position:[.14,1.5,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.03,.03,.18,12]}),(0,Z.jsx)($,{color:`#cbd5e1`})]})]});case`airCompressor`:return(0,Z.jsx)(`group`,{children:(0,Z.jsx)(iw,{baseColor:a,on:(r.on??1)>0})});case`reducingTee`:{let i=Gx(r.diameterA??1.5),o=Gx(r.diameterB??1),s=JC(a,t);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[i,i,1.2,16]}),(0,Z.jsx)($,{color:s,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[0,0,.15],rotation:[KC,0,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[o,i,.3,16]}),(0,Z.jsx)($,{color:s,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[0,0,.4],rotation:[KC,0,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[o,o,.2,16]}),(0,Z.jsx)($,{color:s,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsx)(NC,{partId:e.id,radius:i*.75}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:i})]})}case`reducingElbow`:{let i=Gx(r.diameterA??1.5),o=Gx(r.diameterB??1),s=JC(a,t);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,-.15,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[i,i,.3,16]}),(0,Z.jsx)($,{color:s,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[0,.05,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[o,i,.1,16]}),(0,Z.jsx)($,{color:s,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[-.1,.1,0],rotation:[0,0,-KC],castShadow:!0,children:[(0,Z.jsx)(`torusGeometry`,{args:[.1,o,12,16,KC]}),(0,Z.jsx)($,{color:s,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsxs)(`mesh`,{position:[-.25,.2,0],rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[o,o,.3,16]}),(0,Z.jsx)($,{color:s,opacity:.55,roughness:.35,physical:!0,transmission:.92,thickness:.4})]}),(0,Z.jsx)(MC,{partId:e.id,radius:o*.78,arc:KC}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:i})]})}case`bulkhead`:{let t=Gx(r.diameter??1),i=t*1.5;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t,t,.4,16]}),(0,Z.jsx)($,{color:`#27272a`,metalness:.2,roughness:.8})]}),(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[i,i,.08,16]}),(0,Z.jsx)($,{color:`#18181b`,metalness:.1,roughness:.9})]}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:t})]})}case`waterChiller`:{let e=(r.on??1)>0;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,.5,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.8,1,.8]}),(0,Z.jsx)($,{color:`#3f3f46`,metalness:.6,roughness:.25})]}),(0,Z.jsxs)(`mesh`,{position:[0,.5,.41],children:[(0,Z.jsx)(`boxGeometry`,{args:[.6,.4,.01]}),(0,Z.jsx)($,{color:`#18181b`,roughness:.9})]}),(0,Z.jsxs)(`mesh`,{position:[0,.85,.41],children:[(0,Z.jsx)(`boxGeometry`,{args:[.3,.15,.01]}),(0,Z.jsx)($,{color:`#09090b`,roughness:.9})]}),e&&(0,Z.jsxs)(`mesh`,{position:[0,.85,.415],children:[(0,Z.jsx)(`planeGeometry`,{args:[.26,.11]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#22c55e`})]}),(0,Z.jsxs)(`mesh`,{position:[-.2,1.05,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.08,.08,.15,12]}),(0,Z.jsx)($,{color:`#71717a`,metalness:.8,roughness:.2})]}),(0,Z.jsxs)(`mesh`,{position:[.2,1.05,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.08,.08,.15,12]}),(0,Z.jsx)($,{color:`#71717a`,metalness:.8,roughness:.2})]}),(0,Z.jsx)(`group`,{position:[0,.5,-.41],rotation:[KC,0,0],children:(0,Z.jsx)(cw,{active:e})})]})}case`reverseOsmosis`:{let t=Gx(r.diameter??1);return(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,receiveShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t,t,.6,16]}),(0,Z.jsx)($,{color:`#e2e8f0`,roughness:.4})]}),(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,receiveShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t*2.2,t*2.2,.38,20]}),(0,Z.jsx)($,{color:`#ffffff`,roughness:.3})]}),(0,Z.jsxs)(`mesh`,{position:[-.19,0,0],rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t*2.3,t*2.3,.04,20]}),(0,Z.jsx)($,{color:`#cbd5e1`,metalness:.8,roughness:.2})]}),(0,Z.jsxs)(`mesh`,{position:[.19,0,0],rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[t*2.3,t*2.3,.04,20]}),(0,Z.jsx)($,{color:`#cbd5e1`,metalness:.8,roughness:.2})]}),(0,Z.jsx)(ew,{part:e,connectedKeys:n,radius:t})]})}default:return(0,Z.jsxs)(`mesh`,{castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,Z.jsx)($,{color:`#888888`})]})}}function ow({baseColor:e,cfm:t}){let n=(0,v.useRef)(null);return j_(e=>{if(n.current){let r=15+t/400*20;n.current.rotation.y=e.clock.getElapsedTime()*r}}),(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.25,.25,.7,16,1,!0]}),(0,Z.jsx)($,{color:e,metalness:.5,roughness:.3})]}),(0,Z.jsxs)(`mesh`,{position:[-.34,0,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`torusGeometry`,{args:[.25,.02,8,16]}),(0,Z.jsx)($,{color:`#64748b`})]}),(0,Z.jsxs)(`mesh`,{position:[.34,0,0],rotation:[0,0,KC],children:[(0,Z.jsx)(`torusGeometry`,{args:[.25,.02,8,16]}),(0,Z.jsx)($,{color:`#64748b`})]}),(0,Z.jsxs)(`mesh`,{position:[0,.22,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.16,.08,.16]}),(0,Z.jsx)($,{color:`#334155`})]}),(0,Z.jsxs)(`mesh`,{rotation:[0,0,KC],children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.08,.08,.25,12]}),(0,Z.jsx)($,{color:`#475569`,metalness:.4})]}),(0,Z.jsx)(`group`,{ref:n,children:(0,Z.jsxs)(`group`,{rotation:[0,0,KC],children:[(0,Z.jsxs)(`mesh`,{rotation:[.3,0,0],position:[0,.14,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[.04,.12,.005]}),(0,Z.jsx)($,{color:`#f1f5f9`})]}),(0,Z.jsxs)(`mesh`,{rotation:[.3,0,Math.PI/2],position:[-.14,0,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[.04,.12,.005]}),(0,Z.jsx)($,{color:`#f1f5f9`})]}),(0,Z.jsxs)(`mesh`,{rotation:[.3,0,Math.PI],position:[0,-.14,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[.04,.12,.005]}),(0,Z.jsx)($,{color:`#f1f5f9`})]}),(0,Z.jsxs)(`mesh`,{rotation:[.3,0,-Math.PI/2],position:[.14,0,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[.04,.12,.005]}),(0,Z.jsx)($,{color:`#f1f5f9`})]})]})})]})}function sw({baseColor:e,cfm:t,sweep:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null);return j_(e=>{if(i.current){let n=10+t/200*15;i.current.rotation.z=e.clock.getElapsedTime()*n}if(r.current&&n>0){let t=n*Math.PI/180;r.current.rotation.y=Math.sin(e.clock.getElapsedTime()*1.5)*(t/2)}}),(0,Z.jsxs)(`group`,{children:[(0,Z.jsxs)(`mesh`,{position:[0,.02,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.2,.22,.04,16]}),(0,Z.jsx)($,{color:`#1e293b`,metalness:.1,roughness:.8})]}),(0,Z.jsxs)(`mesh`,{position:[0,.3,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.02,.02,.55,12]}),(0,Z.jsx)($,{color:`#94a3b8`,metalness:.6,roughness:.2})]}),(0,Z.jsxs)(`group`,{ref:r,position:[0,.6,0],children:[(0,Z.jsxs)(`mesh`,{position:[0,-.05,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[.06,.08,.06]}),(0,Z.jsx)($,{color:`#475569`})]}),(0,Z.jsxs)(`mesh`,{position:[0,0,-.08],rotation:[KC,0,0],castShadow:!0,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.07,.07,.16,16]}),(0,Z.jsx)($,{color:e,metalness:.2,roughness:.5})]}),(0,Z.jsxs)(`mesh`,{position:[0,0,.05],children:[(0,Z.jsx)(`sphereGeometry`,{args:[.26,16,12]}),(0,Z.jsx)(`meshBasicMaterial`,{wireframe:!0,color:`#64748b`,transparent:!0,opacity:.25})]}),(0,Z.jsxs)(`mesh`,{position:[0,0,.05],rotation:[KC,0,0],children:[(0,Z.jsx)(`torusGeometry`,{args:[.26,.012,8,24]}),(0,Z.jsx)($,{color:`#64748b`})]}),(0,Z.jsxs)(`group`,{ref:i,position:[0,0,.05],children:[(0,Z.jsxs)(`mesh`,{castShadow:!0,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.04,12,12]}),(0,Z.jsx)($,{color:`#f1f5f9`})]}),(0,Z.jsxs)(`mesh`,{rotation:[.25,0,0],position:[0,.12,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.06,.22,.008]}),(0,Z.jsx)($,{color:`#f1f5f9`})]}),(0,Z.jsxs)(`mesh`,{rotation:[.25,0,Math.PI*2/3],position:[-.104,-.06,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.06,.22,.008]}),(0,Z.jsx)($,{color:`#f1f5f9`})]}),(0,Z.jsxs)(`mesh`,{rotation:[.25,0,-Math.PI*2/3],position:[.104,-.06,0],castShadow:!0,children:[(0,Z.jsx)(`boxGeometry`,{args:[.06,.22,.008]}),(0,Z.jsx)($,{color:`#f1f5f9`})]})]})]})]})}function cw({active:e}){let t=(0,v.useRef)(null);return j_(n=>{t.current&&e&&(t.current.rotation.z=n.clock.getElapsedTime()*15)}),(0,Z.jsxs)(`group`,{ref:t,children:[(0,Z.jsxs)(`mesh`,{castShadow:!0,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.03,10,10]}),(0,Z.jsx)($,{color:`#18181b`})]}),Array.from({length:4}).map((e,t)=>(0,Z.jsx)(`group`,{rotation:[0,0,t*Math.PI/2],children:(0,Z.jsxs)(`mesh`,{position:[0,.1,0],rotation:[.2,0,0],children:[(0,Z.jsx)(`boxGeometry`,{args:[.03,.12,.004]}),(0,Z.jsx)($,{color:`#27272a`})]})},t))]})}function lw(e){let t=new ni;e.updateWorldMatrix(!0,!0);let n=new J().copy(e.matrixWorld).invert(),r=new J,i=new ni,a=a=>{e.traverse(e=>{let o=e;!o.isMesh||a&&!o.castShadow||(o.geometry.boundingBox||o.geometry.computeBoundingBox(),o.geometry.boundingBox&&(i.copy(o.geometry.boundingBox),r.multiplyMatrices(n,o.matrixWorld),i.applyMatrix4(r),t.union(i)))})};return a(!0),t.isEmpty()&&a(!1),t}var uw=e=>Math.max(e+.22,.5),dw=(0,v.memo)(function({part:e,flow:t=0,selected:n=!1,ghost:r=!1,connectedKeys:i}){let a=(0,v.useRef)(null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null);vy(o&&!r);let u=JSON.stringify(e.params);(0,v.useEffect)(()=>{if(r)return;let e=requestAnimationFrame(()=>{let e=a.current;if(!e)return;let t=lw(e);if(t.isEmpty()){l({center:[0,.25,0],size:[.5,.5,.5]});return}let n=t.getCenter(new q),r=t.getSize(new q);l({center:[n.x,n.y,n.z],size:[r.x,r.y,r.z]})});return()=>cancelAnimationFrame(e)},[e.type,u,r]);let d=(0,v.useMemo)(()=>{if(!c||r)return null;let e=new bs(c.size[0]+.1,c.size[1]+.1,c.size[2]+.1),t=new js(e);return e.dispose(),t},[c,r]);return(0,v.useEffect)(()=>()=>d?.dispose(),[d]),(0,Z.jsx)(qC.Provider,{value:{ghost:r,selected:n},children:(0,Z.jsxs)(`group`,{position:e.position,rotation:e.rotation,onPointerDown:t=>{if(r)return;let n=Q.getState();if(n.placingType||n.tool===`measure`)return;let i=t.intersections.find(e=>e.object.userData?.connectorHandle);if(i&&i.distance<=t.distance+.5)return;t.stopPropagation();let a=t.nativeEvent;if(a.metaKey||a.ctrlKey){n.selectedIds.includes(e.id)||n.setSelected(e.id),n.openColorPopover(a.clientX,a.clientY);return}if(a.shiftKey){n.toggleSelected(e.id);return}if(n.selectedIds.includes(e.id)||n.setSelected(e.id),t.button===0){if(a.altKey){let r=n.selectedIds.includes(e.id)?[...n.selectedIds]:[e.id],i=n.duplicateParts(r,{offset:[0,0,0]}),a=i[r.indexOf(e.id)]??i[0];if(!a)return;iC({partId:a,grabPoint:[t.point.x,t.point.y,t.point.z],mode:`body`});return}iC({partId:e.id,grabPoint:[t.point.x,t.point.y,t.point.z],mode:`body`})}},onDoubleClick:t=>{if(r)return;t.stopPropagation();let n=Q.getState();n.placingType||n.tool===`measure`||(Zx.has(e.type)?n.selectConnectedRun(e.id):n.setSelected(e.id),e.type===`pump`&&window.dispatchEvent(new CustomEvent(`hydro:flash-pump`,{detail:e.id})))},onPointerOver:e=>{if(r)return;let t=Q.getState();t.placingType||t.tool===`measure`||t.draggingId||e.intersections[0]?.eventObject===e.eventObject&&s(!0)},onPointerOut:()=>s(!1),children:[(0,Z.jsxs)(`group`,{ref:a,children:[(0,Z.jsx)(`group`,{name:`part-body-mesh`,userData:{partId:e.id},children:(0,Z.jsx)(aw,{part:e,flow:t,connectedKeys:i})}),!r&&(0,Z.jsx)(tw,{part:e,connectedKeys:i})]}),!r&&c&&(0,Z.jsxs)(`mesh`,{position:c.center,children:[(0,Z.jsx)(`boxGeometry`,{args:[uw(c.size[0]),uw(c.size[1]),uw(c.size[2])]}),(0,Z.jsx)(`meshBasicMaterial`,{visible:!1})]}),!r&&o&&!n&&c&&d&&(0,Z.jsx)(`lineSegments`,{geometry:d,position:c.center,children:(0,Z.jsx)(`lineBasicMaterial`,{color:`#38bdf8`,transparent:!0,opacity:.55,depthWrite:!1})})]})})});function fw(){let e=Q(e=>e.showFlow),t=Q(e=>e.parts),n=YS();return(0,Z.jsxs)(`group`,{children:[(0,Z.jsx)(vw,{sim:n,parts:t}),e&&n.segments.map((e,t)=>(0,Z.jsx)(bw,{seg:e},`${e.partId}-${t}`))]})}var pw=0,mw=e=>e<0?0:e>1?1:e,hw=(e,t,n)=>e<t?t:e>n?n:e,gw=7.48;function _w(e,t){let n=e.params,r=Math.max(.25,n.diameter??1);switch(e.type){case`pipe`:case`elbow`:case`tee`:case`valve`:return Math.PI*(r/24)**2*t*gw;case`pump`:return .06;case`tower`:return .1*(n.height??4);case`tray`:return .08*(n.length??3)*(n.width??1.2);case`wallPanel`:return .25;case`emitter`:return .02;case`drain`:return .05;case`reservoir`:return 2;default:return .1}}function vw({sim:e,parts:t}){let n=(0,v.useRef)(e);n.current=e;let r=(0,v.useMemo)(()=>{let n=Object.keys(e.fillLength),r=[];for(let i of n){let n=e.fillDistance[i],a=e.flows[i]??0,o=t[i];if(n===void 0||a<=0||!o)continue;let s=Math.max(.2,e.fillLength[i]),c=Math.max(.004,_w(o,s));r.push({dist:n,len:s,speed:hw(a/3600*s/c,.5,5)})}return{partIds:n,spans:r}},[e,t]),i=(0,v.useRef)(r);return i.current=r,j_((e,t)=>{if(!Q.getState().simRunning){uC();return}let r=n.current,a=Math.min(t,.1);if(lC(a),r.totalGph>.5){let e=1/0;for(let t of i.current.spans)pw>=t.dist&&pw<t.dist+t.len&&(e=Math.min(e,t.speed));Number.isFinite(e)||(e=2),pw=Math.min(pw+e*a,r.totalPathLength+1)}else pw=Math.max(pw-5*a,0);for(let e of i.current.partIds)pC(e);for(let[e,t]of aC){if(!(e in r.fillLength)){t.fill=Math.max(0,t.fill-a*1.5),t.fill<=0&&aC.delete(e);continue}let n=r.flows[e]??0,i=r.backedUp.has(e),o=r.fillDistance[e],s=Math.max(.2,r.fillLength[e]);n>0&&o!==void 0?t.fill=mw((pw-o)/s):i?t.fill=Math.min(1,t.fill+a*.6):t.fill=Math.max(0,t.fill-a*.9),t.flow=n,t.backedUp=i,t.overflow=!1,t.spill=!1,t.entry=r.entryConnector[e],t.state=i?`backedUp`:t.fill<=.002?`empty`:t.fill>=.998?`full`:`filling`}for(let e of r.drains){if(!e.overflowing)continue;let t=aC.get(e.partId);t&&(t.overflow=!0)}for(let e of r.netPots){if(!e.overflowing)continue;let t=pC(e.partId);t.fill=1,t.flow=e.inflowGph,t.backedUp=!0,t.overflow=!1,t.spill=!0,t.state=`backedUp`}}),null}var yw=new q(0,1,0);function bw({seg:e}){let t=(0,v.useRef)(null),{from:n,dir:r,len:i,quat:a,count:o,speed:s}=(0,v.useMemo)(()=>{let t=new q(...e.from),n=new q(...e.to).clone().sub(t),r=n.length();n.normalize();let i=Math.max(.5,e.diameter??1);return{from:t,dir:n,len:r,quat:new Mn().setFromUnitVectors(yw,n),count:Math.max(1,Math.round(r/.55)),speed:.35+Math.min(2.5,e.gph/(i*i)/220)}},[e]);return j_(()=>{let a=t.current;if(!a)return;let c=dC()*s,l=oC(e.partId)?.fill??1;a.children.forEach((e,t)=>{let a=((t+c)%o+o)%o/o;e.position.copy(n).addScaledVector(r,a*i);let s=e.material;s.opacity=.85*l*Math.min(1,Math.min(a,1-a)*4+.15)})}),i<.2?null:(0,Z.jsx)(`group`,{ref:t,children:Array.from({length:o},(e,t)=>(0,Z.jsxs)(`mesh`,{quaternion:a,children:[(0,Z.jsx)(`coneGeometry`,{args:[.05,.14,8]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#38bdf8`,toneMapped:!1,transparent:!0,opacity:.85})]},t))})}function xw(){let e=Q(e=>e.selectedIds),t=Q(e=>e.parts),n=Q(e=>e.placingType),r=Q(e=>e.tool);if(n||r===`measure`||!e.length)return null;let i=[];for(let n of e){let e=t[n];e&&i.push(...nS(e))}return(0,Z.jsxs)(Z.Fragment,{children:[e.filter(e=>t[e]?.type===`pipe`).map(e=>(0,Z.jsx)(ww,{partId:e},`pipe-stretch-${e}`)),i.map(e=>(0,Z.jsx)(Cw,{conn:e,dimmed:t[e.partId]?.type===`pipe`},e.key)),(0,Z.jsx)(Ew,{})]})}var Sw=e=>new Mn().setFromUnitVectors(new q(0,0,1),new q(...e).normalize());function Cw({conn:e,dimmed:t=!1}){let n=Q(e=>e.draggingId),[r,i]=(0,v.useState)(!1);vy(r,`grab`);let a=(0,v.useMemo)(()=>Sw(e.dir),[e.dir[0],e.dir[1],e.dir[2]]),o=n!==null&&rC.connectorKey===e.key,s=r||o;return(0,Z.jsxs)(`group`,{position:e.pos,children:[(0,Z.jsxs)(`mesh`,{userData:{connectorHandle:!0},onPointerDown:t=>{if(t.button!==0)return;let n=Q.getState();if(n.placingType||n.tool===`measure`)return;t.stopPropagation();let r=t.clientX,i=t.clientY,a=t=>{window.removeEventListener(`pointerup`,a);let o=t.clientX-r,s=t.clientY-i;Math.hypot(o,s)<4&&n.spawnPipeAtConnector(e.key)};window.addEventListener(`pointerup`,a),iC({partId:e.partId,grabPoint:e.pos,mode:`handle`,connectorKey:e.key})},onPointerOver:e=>{if(Q.getState().draggingId)return;let t=e.intersections.find(e=>e.object.userData?.connectorHandle);t?.object!==e.object||t.distance>(e.intersections[0]?.distance??1/0)+.5||i(!0)},onPointerOut:()=>i(!1),children:[(0,Z.jsx)(`sphereGeometry`,{args:[.22,10,10]}),(0,Z.jsx)(`meshBasicMaterial`,{visible:!1})]}),(0,Z.jsxs)(`mesh`,{scale:s?1.4:1,renderOrder:998,children:[(0,Z.jsx)(`sphereGeometry`,{args:[t?.05:.075,14,14]}),(0,Z.jsx)(`meshBasicMaterial`,{color:s?`#bae6fd`:`#38bdf8`,toneMapped:!1,depthTest:!1,transparent:!0,opacity:t?s?.85:.45:.95})]}),(0,Z.jsxs)(`mesh`,{quaternion:a,scale:s?1.25:1,renderOrder:998,children:[(0,Z.jsx)(`torusGeometry`,{args:[t?.11:.15,t?.014:.018,8,24]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#38bdf8`,toneMapped:!1,depthTest:!1,transparent:!0,opacity:t?s?.8:.35:s?.95:.55})]})]})}function ww({partId:e}){let t=Q(t=>t.parts[e]),n=Q(e=>e.draggingId);if(!t||t.type!==`pipe`)return null;let r=nS(t),i=r.find(e=>e.connectorId===`a`),a=r.find(e=>e.connectorId===`b`);if(!i||!a)return null;let o=t.params.length??0,s=[(i.pos[0]+a.pos[0])/2,(i.pos[1]+a.pos[1])/2+.28,(i.pos[2]+a.pos[2])/2],c=n===e&&!!rC.pipeStretch;return(0,Z.jsxs)(`group`,{children:[(0,Z.jsx)(mb,{points:[i.pos,a.pos],color:c?`#7dd3fc`:`#38bdf8`,lineWidth:2,transparent:!0,opacity:c?.95:.55}),(0,Z.jsx)(Tw,{conn:i}),(0,Z.jsx)(Tw,{conn:a}),(0,Z.jsx)(_y,{position:s,center:!0,distanceFactor:12,children:(0,Z.jsxs)(`div`,{className:`rounded-full border px-2 py-1 text-[10px] font-semibold whitespace-nowrap shadow-lg backdrop-blur ${c?`border-sky-400 bg-sky-300/95 text-sky-950`:`border-zinc-700 bg-zinc-950/90 text-zinc-200`}`,children:[o.toFixed(2),` ft`,(0,Z.jsx)(`span`,{className:`ml-1 text-zinc-400`,children:c?`stretching`:`drag ends to stretch`})]})})]})}function Tw({conn:e}){let t=Q(e=>e.draggingId),[n,r]=(0,v.useState)(!1);vy(n,`grab`);let i=(0,v.useMemo)(()=>Sw(e.dir),[e.dir[0],e.dir[1],e.dir[2]]),a=n||t!==null&&rC.connectorKey===e.key;return(0,Z.jsxs)(`group`,{position:e.pos,children:[(0,Z.jsxs)(`mesh`,{userData:{connectorHandle:!0},onPointerDown:t=>{if(t.button!==0)return;let n=Q.getState();n.placingType||n.tool===`measure`||(t.stopPropagation(),iC({partId:e.partId,grabPoint:e.pos,mode:`handle`,connectorKey:e.key}))},onPointerOver:e=>{if(Q.getState().draggingId)return;let t=e.intersections.find(e=>e.object.userData?.connectorHandle);t?.object!==e.object||t.distance>(e.intersections[0]?.distance??1/0)+.5||r(!0)},onPointerOut:()=>r(!1),children:[(0,Z.jsx)(`sphereGeometry`,{args:[.28,12,12]}),(0,Z.jsx)(`meshBasicMaterial`,{visible:!1})]}),(0,Z.jsxs)(`mesh`,{quaternion:i,scale:a?1.12:1,renderOrder:998,children:[(0,Z.jsx)(`cylinderGeometry`,{args:[.05,.1,.18,12]}),(0,Z.jsx)(`meshBasicMaterial`,{color:a?`#e0f2fe`:`#7dd3fc`,toneMapped:!1,depthTest:!1,transparent:!0,opacity:.98})]}),(0,Z.jsxs)(`mesh`,{quaternion:i,position:[0,0,.11],scale:a?1.18:1,renderOrder:998,children:[(0,Z.jsx)(`coneGeometry`,{args:[.08,.16,12]}),(0,Z.jsx)(`meshBasicMaterial`,{color:a?`#38bdf8`:`#0ea5e9`,toneMapped:!1,depthTest:!1,transparent:!0,opacity:.95})]})]})}function Ew(){let e=Q(e=>e.snapTargetKey),t=Q(e=>e.parts),n=(0,v.useRef)(null);if(j_(({clock:e})=>{if(n.current){let t=1+.18*Math.sin(e.elapsedTime*7);n.current.scale.setScalar(t)}}),!e)return null;let r=t[e.split(`:`)[0]];if(!r)return null;let i=nS(r).find(t=>t.key===e);return i?(0,Z.jsx)(`group`,{position:i.pos,children:(0,Z.jsxs)(`group`,{ref:n,children:[(0,Z.jsxs)(`mesh`,{quaternion:Sw(i.dir),renderOrder:999,children:[(0,Z.jsx)(`torusGeometry`,{args:[.24,.035,10,28]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#34d399`,toneMapped:!1,depthTest:!1,transparent:!0,opacity:.95})]}),(0,Z.jsxs)(`mesh`,{renderOrder:999,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.1,12,12]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#6ee7b7`,toneMapped:!1,depthTest:!1,transparent:!0,opacity:.9})]})]})}):null}function Dw(){let e=Q(e=>e.selectedIds),t=Q(e=>e.parts),n=Q(e=>e.draggingId),r=Q(e=>e.placingType),i=Q(e=>e.tool),a=(0,v.useMemo)(()=>new J,[]),o=(0,v.useRef)(!1),s=(0,v.useRef)(null),c=e.map(e=>t[e]).filter(Boolean),l=[0,0,0];for(let e of c)l[0]+=e.position[0]/c.length,l[1]+=e.position[1]/c.length,l[2]+=e.position[2]/c.length;return(0,v.useLayoutEffect)(()=>{o.current||a.setPosition(l[0],l[1],l[2])}),!c.length||n||r||i===`measure`?null:(0,Z.jsx)(Hx,{matrix:a,autoTransform:!1,fixed:!0,scale:72,lineWidth:3,depthTest:!1,disableRotations:!0,disableScaling:!0,axisColors:[`#f87171`,`#4ade80`,`#60a5fa`],hoveredColor:`#fbbf24`,onDragStart:()=>{o.current=!0;let e=Q.getState();e.pushHistory(),e.setGizmoDragging(!0);let t={};for(let n of e.selectedIds){let r=e.parts[n];r&&(t[n]=[...r.position])}s.current={centroid:[...l],positions:t}},onDrag:e=>{let t=s.current;if(!t)return;let n=Q.getState();a.copy(e);let r=new q().setFromMatrixPosition(e),i=e=>n.snapToGrid?NS(e,n.gridSize):e,o=[i(r.x-t.centroid[0]),i(r.y-t.centroid[1]),i(r.z-t.centroid[2])],c=1/0;for(let e of Object.values(t.positions))c=Math.min(c,e[1]);Number.isFinite(c)&&(o[1]=Math.max(o[1],-c));let l={};for(let[e,n]of Object.entries(t.positions))l[e]=[n[0]+o[0],n[1]+o[1],n[2]+o[2]];n.setPositions(l)},onDragEnd:()=>{o.current=!1,s.current=null,Q.getState().setGizmoDragging(!1)}})}var Ow=Math.PI/2;function kw(e){switch(e){case`pipe`:case`elbow`:case`tee`:case`valve`:case`emitter`:return .25;default:return 0}}var Aw={camera:null,el:null};function jw(e,t){let{camera:n,el:r}=Aw;if(!n||!r)return null;let i=r.getBoundingClientRect(),a=new K((e-i.left)/i.width*2-1,-((t-i.top)/i.height)*2+1),o=new qd;o.setFromCamera(a,n);let s=new q;return o.ray.intersectPlane(new mo(new q(0,1,0),0),s)?[s.x,s.y,s.z]:null}function Mw(){let e=A_(e=>e.camera),t=A_(e=>e.gl.domElement),n=A_(e=>e.scene),r=Q(e=>e.setScene);return(0,v.useEffect)(()=>{Aw.camera=e,Aw.el=t},[e,t]),(0,v.useEffect)(()=>(r(n),()=>r(null)),[n,r]),null}var Nw={orbit:{pos:[9,7,11],up:[0,1,0],target:[0,1,0]},top:{pos:[0,60,0],up:[0,0,-1],target:[0,0,0]},front:{pos:[0,2,60],up:[0,1,0],target:[0,2,0]},side:{pos:[60,2,0],up:[0,1,0],target:[0,2,0]}};function Pw(e){switch(e){case`xray`:return{background:`#071019`,fogFar:180,ambient:.72,hemi:.82,dir:1.15,gridCell:`#15384a`,gridSection:`#1f536d`};case`water`:return{background:`#04131c`,fogFar:210,ambient:.3,hemi:.42,dir:.9,gridCell:`#0c2a3b`,gridSection:`#134764`};default:return{background:`#0a0e13`,fogFar:140,ambient:.45,hemi:.5,dir:1.4,gridCell:`#1b2531`,gridSection:`#2c3d52`}}}function Fw(){let e=Q(e=>e.viewMode),t=A_(e=>e.camera),n=A_(e=>e.controls);return(0,v.useEffect)(()=>{let r=Nw[e];t.position.set(...r.pos),t.up.set(...r.up),t.lookAt(...r.target),n&&(n.target.set(...r.target),n.update())},[e,t,n]),null}function Iw(){let e=Q(e=>e.placingType),t=Q(e=>e.tool),n=Q(e=>e.snapToGrid),r=Q(e=>e.gridSize),i=Q(e=>e.measurePoints),a=Q(e=>e.pipeRunPoints),o=Q(e=>e.parts),s=Q(e=>e.activeRoomId),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),f=(0,v.useMemo)(()=>Object.values(o).filter(e=>e.roomId===s),[o,s]),p=e=>n?NS(e,r):e,m=t=>[p(t.point.x),e?kw(e):0,p(t.point.z)],h=n=>{if(e&&l(m(n)),t===`pipeRun`){let e=m(n),t=aS(e,f,new Set,Bw);if(t)Q.getState().setSnapTargetKey(t.key),d(t.pos);else{let t=oS(e,f,Bw);Q.getState().setSnapTargetKey(null),d(t?t.branchPos:e)}}else Q.getState().snapTargetKey&&Q.getState().setSnapTargetKey(null)},g=n=>{if(n.delta>6)return;let r=Q.getState();if(e){r.addPart(e,m(n)),n.nativeEvent.shiftKey||r.setPlacingType(null);return}if(t===`measure`){r.addMeasurePoint([n.point.x,Math.max(0,n.point.y),n.point.z]);return}if(t===`pipeRun`){let e=m(n),t=aS(e,f,new Set,Bw);if(t)r.setSnapTargetKey(t.key),r.extendPipeRun({pos:t.pos,connectorKey:t.key},n.nativeEvent.shiftKey);else{let t=oS(e,f,Bw);r.setSnapTargetKey(null),r.extendPipeRun(t?{pos:t.pos,tapPipeId:t.partId,tapRotationY:t.rotationY,tapDiameter:t.diameter}:{pos:e},n.nativeEvent.shiftKey)}n.nativeEvent.shiftKey||r.setSnapTargetKey(null);return}n.intersections[0]?.eventObject===n.eventObject&&(n.nativeEvent.shiftKey||r.setSelected(null))},_=(0,v.useMemo)(()=>!e||!c?null:{id:`__ghost__`,type:e,position:c,rotation:[0,0,0],params:{...Yx[e].defaults}},[e,c]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`mesh`,{rotation:[-Ow,0,0],position:[0,-.02,0],onPointerMove:h,onClick:g,children:[(0,Z.jsx)(`planeGeometry`,{args:[600,600]}),(0,Z.jsx)(`meshBasicMaterial`,{visible:!1,side:2})]}),(0,Z.jsxs)(`mesh`,{rotation:[-Ow,0,0],position:[0,-.01,0],receiveShadow:!0,children:[(0,Z.jsx)(`planeGeometry`,{args:[300,300]}),(0,Z.jsx)(`shadowMaterial`,{opacity:.35})]}),_&&(0,Z.jsx)(dw,{part:_,ghost:!0}),i.length>0&&(0,Z.jsx)(Rw,{points:i}),t===`pipeRun`&&a.length>0&&u&&(0,Z.jsx)(Lw,{points:a,hover:u})]})}function Lw({points:e,hover:t}){let n=e[e.length-1].pos,r=t,i=[n[0],.28,n[2]],a=[r[0],.28,r[2]],o=[(i[0]+a[0])/2,.55,(i[2]+a[2])/2],s=Uw(Math.hypot(r[0]-n[0],r[2]-n[2]));return(0,Z.jsxs)(`group`,{children:[e.length>1&&(0,Z.jsx)(mb,{points:e.map(e=>[e.pos[0],.26,e.pos[2]]),color:`#0ea5e9`,lineWidth:2,dashed:!0,dashScale:3}),(0,Z.jsx)(mb,{points:[i,a],color:`#38bdf8`,lineWidth:2,dashed:!0,dashScale:4}),(0,Z.jsx)(_y,{position:o,center:!0,distanceFactor:12,children:(0,Z.jsxs)(`div`,{className:`rounded bg-sky-400 px-1.5 py-0.5 font-mono text-[11px] font-bold text-sky-950 whitespace-nowrap`,children:[s.toFixed(2),` ft · Shift-click continues`]})})]})}function Rw({points:e}){let[t,n]=e,r=n?[(t[0]+n[0])/2,(t[1]+n[1])/2+.3,(t[2]+n[2])/2]:null,i=n?Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]):0;return(0,Z.jsxs)(`group`,{children:[e.map((e,t)=>(0,Z.jsxs)(`mesh`,{position:e,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.09,12,12]}),(0,Z.jsx)(`meshBasicMaterial`,{color:`#fbbf24`,toneMapped:!1})]},t)),n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(mb,{points:[t,n],color:`#fbbf24`,lineWidth:2,dashed:!0,dashScale:3}),(0,Z.jsx)(_y,{position:r,center:!0,distanceFactor:12,children:(0,Z.jsxs)(`div`,{className:`rounded bg-amber-400 px-1.5 py-0.5 font-mono text-[11px] font-bold text-black whitespace-nowrap`,children:[i.toFixed(2),` ft`]})})]})]})}var zw=.45,Bw=.9,Vw=Yx.pipe.params.length.min,Hw=Yx.pipe.params.length.max;function Uw(e){return Math.min(Hw,Math.max(Vw,e))}function Ww(e){let t=rC.pipeStretch;if(!t)return null;let n=[e[0]-t.anchorPos[0],e[1]-t.anchorPos[1],e[2]-t.anchorPos[2]],r=Uw(n[0]*t.axis[0]+n[1]*t.axis[1]+n[2]*t.axis[2]),i=[t.anchorPos[0]+t.axis[0]*r,t.anchorPos[1]+t.axis[1]*r,t.anchorPos[2]+t.axis[2]*r];return{end:i,position:[(t.anchorPos[0]+i[0])/2,(t.anchorPos[1]+i[1])/2,(t.anchorPos[2]+i[2])/2],length:r}}function Gw(){let e=Q(e=>e.draggingId),t=Q(e=>e.viewMode),n=Q(e=>e.draggingId?e.parts[e.draggingId]:void 0),r=A_(e=>e.camera),[i,a]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{let e=e=>e.key===`Shift`&&a(!0),t=e=>e.key===`Shift`&&a(!1);return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]),(0,v.useEffect)(()=>{if(!e)return;let t=()=>Kw(e);return window.addEventListener(`pointerup`,t),()=>window.removeEventListener(`pointerup`,t)},[e]),!e||!n)return null;let o=t===`orbit`&&i,s=`${t}:${o?`free`:`flat`}`,c=rC.groupIds.length?rC.groupIds:[e],l=n=>{let r=Q.getState(),i=r.parts[e];if(!i)return;rC.pushed||=(r.pushHistory(`drag:${e}`),!0),rC.planeKey&&rC.planeKey!==s&&(rC.grabOffset=[n.point.x-i.position[0],n.point.y-i.position[1],n.point.z-i.position[2]],rC.planeAnchor=[n.point.x,n.point.y,n.point.z]),rC.planeKey=s;let a=e=>r.snapToGrid?NS(e,r.gridSize):e;if(rC.pipeStretch&&rC.connectorKey){let i;i=o?[a(n.point.x),a(n.point.y),a(n.point.z)]:t===`front`?[a(n.point.x),a(n.point.y),rC.planeAnchor[2]]:t===`side`?[rC.planeAnchor[0],a(n.point.y),a(n.point.z)]:[a(n.point.x),rC.planeAnchor[1],a(n.point.z)];let s=Ww(i);if(!s)return;let c=aS(s.end,Object.values(r.parts).filter(e=>e.roomId===r.activeRoomId),new Set([e]));r.setSnapTargetKey(c?c.key:null),c&&c.d<zw&&(s=Ww(c.pos)??s),r.setPipeStretch(e,s.position,s.length);return}let[l,u,d]=rC.grabOffset,f=rC.startPositions[e]??i.position,p;p=o?[a(n.point.x-l),a(n.point.y-u),a(n.point.z-d)]:t===`front`?[a(n.point.x-l),a(n.point.y-u),f[2]]:t===`side`?[f[0],a(n.point.y-u),a(n.point.z-d)]:[a(n.point.x-l),f[1],a(n.point.z-d)];let m=[p[0]-f[0],p[1]-f[1],p[2]-f[2]];if(rC.mode===`handle`&&rC.connectorKey){let e=rC.connectorKey.split(`:`)[1],t=nS({...i,position:[f[0]+m[0],f[1]+m[1],f[2]+m[2]]}).find(t=>t.connectorId===e);if(t){let e=aS(t.pos,Object.values(r.parts).filter(e=>e.roomId===r.activeRoomId),new Set(c));r.setSnapTargetKey(e?e.key:null),e&&e.d<zw&&(m=[m[0]+e.pos[0]-t.pos[0],m[1]+e.pos[1]-t.pos[1],m[2]+e.pos[2]-t.pos[2]])}}let h=1/0;for(let e of c){let t=rC.startPositions[e];t&&(h=Math.min(h,t[1]))}Number.isFinite(h)&&(m[1]=Math.max(m[1],-h));let g={};for(let e of c){let t=rC.startPositions[e];t&&(g[e]=[t[0]+m[0],t[1]+m[1],t[2]+m[2]])}r.setPositions(g)},u=rC.planeAnchor,d={onPointerMove:l,onPointerUp:()=>Kw(e)},f=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`planeGeometry`,{args:[600,600]}),(0,Z.jsx)(`meshBasicMaterial`,{visible:!1,side:2})]});if(o)return(0,Z.jsx)(`mesh`,{position:u,quaternion:r.quaternion,...d,children:f});let p=t===`front`||t===`side`;return(0,Z.jsx)(`mesh`,{position:p?t===`front`?[0,0,u[2]]:[u[0],0,0]:[0,u[1],0],rotation:p?t===`side`?[0,Ow,0]:[0,0,0]:[-Ow,0,0],...d,children:f})}function Kw(e){let t=Q.getState();if(t.draggingId!==e)return;let n=rC.groupIds.length?rC.groupIds:[e],r=rC.startPositions[e],i=t.parts[e],a=!r||!i?!1:Math.hypot(i.position[0]-r[0],i.position[1]-r[1],i.position[2]-r[2])>1e-6;if(rC.mode===`body`&&!a&&n.length>1){t.setSelected(e),t.setSnapTargetKey(null),t.setDraggingId(null);return}if(rC.mode===`handle`&&rC.connectorKey&&t.snapTargetKey){let r=t.parts[e],i=t.parts[t.snapTargetKey.split(`:`)[0]];if(r&&i){let a=rC.connectorKey.split(`:`)[1],o=nS(r).find(e=>e.connectorId===a),s=nS(i).find(e=>e.key===t.snapTargetKey);if(o&&s)if(rC.pipeStretch){let n=Ww(s.pos);n&&t.setPipeStretch(e,n.position,n.length)}else t.translateParts(n,[s.pos[0]-o.pos[0],s.pos[1]-o.pos[1],s.pos[2]-o.pos[2]])}}else rC.mode===`body`&&t.snapGroupToConnectors(n,e);t.setSnapTargetKey(null),t.setDraggingId(null)}function qw(){let e=Q(e=>e.parts),t=Q(e=>e.activeRoomId),n=Q(e=>e.selectedIds),r=YS();return(0,Z.jsx)(Z.Fragment,{children:(0,v.useMemo)(()=>Object.values(e).filter(e=>e.roomId===t),[e,t]).map(e=>(0,Z.jsx)(dw,{part:e,flow:r.flows[e.id]??0,selected:n.includes(e.id),connectedKeys:r.connectedKeys},e.id))})}var Jw=.05,Yw=20,Xw=.03;function Zw(){let e=Q(e=>e.draggingId),t=Q(e=>e.parts),n=Q(e=>e.activeRoomId),r=(0,v.useMemo)(()=>{if(!e)return[];let r=t[e];if(!r)return[];let[i,,a]=r.position,o=Object.values(t).filter(t=>t.id!==e&&t.roomId===n).map(e=>({p:e,d:Math.hypot(e.position[0]-i,e.position[2]-a)})).sort((e,t)=>e.d-t.d).slice(0,Yw).map(e=>e.p),s=[];for(let e of o){let[t,,n]=e.position;if(Math.abs(t-i)<Jw){let r=Math.min(a,n),i=Math.max(a,n);s.push({points:[[t,Xw,r],[t,Xw,i]],key:`x:${e.id}`})}if(Math.abs(n-a)<Jw){let r=Math.min(i,t),a=Math.max(i,t);s.push({points:[[r,Xw,n],[a,Xw,n]],key:`z:${e.id}`})}}return s},[e,t]);return r.length===0?null:(0,Z.jsx)(`group`,{children:r.map(e=>(0,Z.jsx)(mb,{points:e.points,color:`#22d3ee`,lineWidth:1.5,dashed:!0,dashScale:6},e.key))})}function Qw(){let e=Q(e=>e.focusTarget),t=A_(e=>e.controls),n=A_(e=>e.camera),r=(0,v.useRef)(0),i=(0,v.useRef)(new q),a=(0,v.useRef)(new q),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{!e||!t||(i.current.copy(t.target),a.current.copy(n.position),o.current=e,r.current=0)},[e,t,n]),j_((e,s)=>{let c=o.current;if(!c||!t)return;r.current=Math.min(1,r.current+s/.5);let l=r.current,u=l*l*(3-2*l);t.target.lerpVectors(i.current,new q(...c),u);let d=n.position.clone().sub(a.current),f=new q(...c).sub(i.current).multiplyScalar(u);n.position.copy(a.current).add(d).add(f),t.update(),l>=1&&(o.current=null,Q.getState().setFocusTarget(null))}),null}function $w(){let e=A_(e=>e.camera),t=A_(e=>e.controls),n=(0,v.useRef)({});return(0,v.useEffect)(()=>{let e=e=>{let t=e.target;t&&/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)||[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.key)&&(e.preventDefault(),n.current[e.key]=!0)},t=e=>{[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.key)&&(n.current[e.key]=!1)};return window.addEventListener(`keydown`,e,{passive:!1}),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]),j_((r,i)=>{let a=Math.min(.1,i),o=new q(1,0,0).applyQuaternion(e.quaternion),s=new q(0,1,0).applyQuaternion(e.quaternion),c=new q;n.current.ArrowUp&&c.add(s),n.current.ArrowDown&&c.add(s.clone().negate()),n.current.ArrowLeft&&c.add(o.clone().negate()),n.current.ArrowRight&&c.add(o),c.lengthSq()>0&&(c.normalize(),c.multiplyScalar(15*a),e.position.add(c),t&&t.target.add(c)),e.position.x=Math.max(-120,Math.min(120,e.position.x)),e.position.y=Math.max(-120,Math.min(120,e.position.y)),e.position.z=Math.max(-120,Math.min(120,e.position.z)),t&&(t.target.x=Math.max(-120,Math.min(120,t.target.x)),t.target.y=Math.max(-120,Math.min(120,t.target.y)),t.target.z=Math.max(-120,Math.min(120,t.target.z)),t.update())}),null}function eT({remoteCursors:e}){let t=Q(e=>e.activeRoomId);return(0,Z.jsx)(Z.Fragment,{children:Object.entries(e).map(([e,n])=>n.activeRoomId===t?(0,Z.jsxs)(`mesh`,{position:n.position,children:[(0,Z.jsx)(`sphereGeometry`,{args:[.15,16,16]}),(0,Z.jsx)(`meshBasicMaterial`,{color:n.color,toneMapped:!1}),(0,Z.jsx)(_y,{distanceFactor:15,center:!0,position:[0,.4,0],children:(0,Z.jsx)(`div`,{className:`px-1.5 py-0.5 rounded text-[10px] font-bold text-white whitespace-nowrap shadow-lg select-none pointer-events-none`,style:{backgroundColor:n.color},children:n.userName.split(`@`)[0]})})]},e):null)})}function tT(){let{raycaster:e}=A_();return j_(()=>{let t=new mo(new q(0,1,0),-.25),n=new q;e.ray.intersectPlane(t,n)&&window.dispatchEvent(new CustomEvent(`collab:cursor`,{detail:{x:n.x,y:n.y,z:n.z}}))}),null}function nT({remoteCursors:e={}}){let t=Q(e=>e.viewMode),n=Q(e=>e.renderMode),r=Q(e=>e.draggingId),i=Q(e=>e.gizmoDragging),a=(0,v.useRef)(null),o=Pw(n);return(0,Z.jsxs)(ty,{shadows:!0,dpr:[1,2],className:`touch-none`,children:[(0,Z.jsx)(`color`,{attach:`background`,args:[o.background]}),(0,Z.jsx)(`fog`,{attach:`fog`,args:[o.background,50,o.fogFar]}),t===`orbit`?(0,Z.jsx)(xb,{makeDefault:!0,fov:50,position:Nw.orbit.pos,near:.1,far:400}):(0,Z.jsx)(yb,{makeDefault:!0,zoom:48,position:Nw[t].pos,near:.1,far:400}),(0,Z.jsx)(Sb,{ref:a,makeDefault:!0,enabled:!r&&!i,enableRotate:t===`orbit`,enableDamping:!0,dampingFactor:.12,maxPolarAngle:Math.PI/2-.02,minDistance:2,maxDistance:120}),(0,Z.jsx)(Fw,{}),(0,Z.jsx)(Mw,{}),(0,Z.jsx)($w,{}),(0,Z.jsx)(`ambientLight`,{intensity:o.ambient}),(0,Z.jsx)(`hemisphereLight`,{args:[`#bcd6ff`,`#1a2230`,o.hemi]}),(0,Z.jsx)(`directionalLight`,{position:[12,18,8],intensity:o.dir,castShadow:!0,"shadow-mapSize":[2048,2048],"shadow-camera-left":-25,"shadow-camera-right":25,"shadow-camera-top":25,"shadow-camera-bottom":-25}),(0,Z.jsx)(Vb,{position:[0,0,0],args:[200,200],cellSize:.5,cellColor:o.gridCell,sectionSize:2.5,sectionColor:o.gridSection,fadeDistance:90,fadeStrength:1.5,infiniteGrid:!0}),(0,Z.jsx)(Iw,{}),(0,Z.jsx)(Gw,{}),(0,Z.jsx)(qw,{}),(0,Z.jsx)(xw,{}),(0,Z.jsx)(Dw,{}),(0,Z.jsx)(fw,{}),(0,Z.jsx)(UC,{}),(0,Z.jsx)(Zw,{}),(0,Z.jsx)(Qw,{}),(0,Z.jsx)(eT,{remoteCursors:e}),(0,Z.jsx)(tT,{}),(0,Z.jsx)(Ib,{alignment:`top-right`,margin:[80,80],children:(0,Z.jsx)(zb,{axisColors:[`#ef4444`,`#22c55e`,`#3b82f6`],labelColor:`white`})})]})}var rT=[`pipe`,`elbow`,`tee`,`valve`,`pump`,`reservoir`,`tower`,`tray`,`emitter`];function iT(e){let t=Number(e)-1;return Number.isInteger(t)&&t>=0&&t<rT.length?rT[t]:null}var aT=[{id:`nftLoop`,label:`NFT loop`,description:`Reservoir, pump, NFT tray, return drain, and plant cups`},{id:`dripManifold`,label:`Drip manifold`,description:`Pump-fed header with tee branches, valves, and emitters`},{id:`dwcSystem`,label:`DWC bucket system`,description:`Deep Water Culture bucket with aerator, airstone, net pots, and water chiller`},{id:`finiteDrainTest`,label:`Finite drain test`,description:`Tiny reservoir feeding a drain so the source visibly runs out`}],oT=(e,t)=>`quick-${e}-${t}-${crypto.randomUUID().slice(0,8)}`,sT=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],cT=(e,t,n,r)=>({...n,id:oT(e,t),position:sT(n.position,r),rotation:[...n.rotation],params:{...n.params}});function lT(e){if(!e.length)return[0,0,0];let t=Math.max(...e.map(e=>e.position[0]));return[Math.ceil(t/2)*2+4,0,0]}function uT(e,t=[0,0,0]){let n=Math.PI/2;return e===`dwcSystem`?[cT(e,`dwc-res`,{type:`reservoir`,position:[0,0,0],rotation:[0,0,0],params:{width:1.6,depth:1.6,height:1.5,level:75,ph:6,ec:1.2},label:`DWC Bucket`},t),cT(e,`dwc-pot-a`,{type:`netPot`,position:[-.3,1.5,0],rotation:[0,0,0],params:{size:1}},t),cT(e,`dwc-pot-b`,{type:`netPot`,position:[.3,1.5,0],rotation:[0,0,0],params:{size:1}},t),cT(e,`dwc-comp`,{type:`airCompressor`,position:[-1.6,0,0],rotation:[0,0,0],params:{gph:60,frequency:5,on:1},label:`DWC Aerator`},t),cT(e,`dwc-chiller`,{type:`waterChiller`,position:[0,0,-1.6],rotation:[0,0,0],params:{targetTemp:68,on:1,diameter:1},label:`Water Chiller`},t)]:e===`finiteDrainTest`?[cT(e,`res`,{type:`reservoir`,position:[-2,0,0],rotation:[0,0,0],params:{width:1,depth:1,height:1,level:10,ph:6,ec:1.2},label:`Finite test reservoir`},t),cT(e,`pump`,{type:`pump`,position:[-1.05,0,0],rotation:[0,0,0],params:{gph:400,maxHeadFt:8,on:1},label:`Drain test pump`},t),cT(e,`pipe`,{type:`pipe`,position:[.4,.25,0],rotation:[0,0,0],params:{length:2,diameter:1}},t),cT(e,`drain`,{type:`drain`,position:[1.75,0,0],rotation:[0,0,0],params:{capacityGph:1e3},label:`Open drain`},t)]:e===`dripManifold`?[cT(e,`res`,{type:`reservoir`,position:[-2,0,0],rotation:[0,0,0],params:{width:2,depth:1.4,height:1,level:70},label:`Drip reservoir`},t),cT(e,`pump`,{type:`pump`,position:[-.55,0,0],rotation:[0,0,0],params:{gph:240,maxHeadFt:8,on:1},label:`Drip pump`},t),cT(e,`pipe-feed`,{type:`pipe`,position:[.4,.25,0],rotation:[0,0,0],params:{length:1,diameter:.75}},t),cT(e,`tee-a`,{type:`tee`,position:[1.5,.25,0],rotation:[0,0,0],params:{diameter:.75},label:`Manifold split`},t),cT(e,`header`,{type:`pipe`,position:[2.35,.25,0],rotation:[0,0,0],params:{length:.5,diameter:.75}},t),cT(e,`tee-b`,{type:`tee`,position:[3.2,.25,0],rotation:[0,0,0],params:{diameter:.75}},t),cT(e,`valve-a`,{type:`valve`,position:[1.5,.25,.95],rotation:[0,-n,0],params:{diameter:.5,open:75}},t),cT(e,`branch-a`,{type:`pipe`,position:[1.5,.25,1.65],rotation:[0,-n,0],params:{length:.7,diameter:.5}},t),cT(e,`emit-a`,{type:`emitter`,position:[1.5,.25,2.2],rotation:[0,n,0],params:{},label:`Dripper A`},t),cT(e,`valve-b`,{type:`valve`,position:[3.2,.25,.95],rotation:[0,-n,0],params:{diameter:.5,open:75}},t),cT(e,`branch-b`,{type:`pipe`,position:[3.2,.25,1.65],rotation:[0,-n,0],params:{length:.7,diameter:.5}},t),cT(e,`emit-b`,{type:`emitter`,position:[3.2,.25,2.2],rotation:[0,n,0],params:{},label:`Dripper B`},t)]:[cT(e,`res`,{type:`reservoir`,position:[-2.5,0,0],rotation:[0,0,0],params:{width:2,depth:1.4,height:1,level:70},label:`NFT reservoir`},t),cT(e,`pump`,{type:`pump`,position:[-1.05,0,0],rotation:[0,0,0],params:{gph:300,maxHeadFt:8,on:1},label:`NFT pump`},t),cT(e,`feed`,{type:`pipe`,position:[.2,.25,0],rotation:[0,0,0],params:{length:1.6,diameter:1}},t),cT(e,`tray`,{type:`tray`,position:[2.5,0,0],rotation:[0,0,0],params:{length:3,width:1.2},label:`NFT channel`},t),cT(e,`return`,{type:`pipe`,position:[4.35,.15,0],rotation:[0,0,0],params:{length:.7,diameter:1}},t),cT(e,`drain`,{type:`drain`,position:[5.05,-.1,0],rotation:[0,0,0],params:{capacityGph:350},label:`NFT return drain`},t),cT(e,`pot-a`,{type:`netPot`,position:[1.8,.25,-.2],rotation:[0,0,0],params:{size:.8}},t),cT(e,`pot-b`,{type:`netPot`,position:[2.5,.25,-.2],rotation:[0,0,0],params:{size:.8}},t),cT(e,`pot-c`,{type:`netPot`,position:[3.2,.25,-.2],rotation:[0,0,0],params:{size:.8}},t)]}function dT(){let e=Math.PI/2;return[{id:`demo-res`,type:`reservoir`,position:[-4,0,0],rotation:[0,0,0],params:{width:2,depth:1.4,height:1,level:70},label:`Main reservoir`},{id:`demo-pump`,type:`pump`,position:[-2.55,0,0],rotation:[0,0,0],params:{gph:550,maxHeadFt:8,on:1},label:`Main pump`},{id:`demo-tee`,type:`tee`,position:[-1.5,.25,0],rotation:[0,0,0],params:{diameter:1}},{id:`demo-pipe1`,type:`pipe`,position:[-.4,.25,0],rotation:[0,0,0],params:{length:1,diameter:1}},{id:`demo-elbow1`,type:`elbow`,position:[.1,.25,0],rotation:[0,0,0],params:{angle:90,diameter:1}},{id:`demo-pipe2`,type:`pipe`,position:[.6,1.75,0],rotation:[0,0,e],params:{length:2,diameter:1}},{id:`demo-elbow2`,type:`elbow`,position:[.6,2.75,0],rotation:[0,0,e],params:{angle:90,diameter:1}},{id:`demo-pipe3`,type:`pipe`,position:[-1.4,3.25,0],rotation:[0,0,0],params:{length:3,diameter:1}},{id:`demo-emitter`,type:`emitter`,position:[-3.1,3.25,0],rotation:[0,0,0],params:{},label:`Return emitter`},{id:`demo-pipe4`,type:`pipe`,position:[-1.5,.25,1.1],rotation:[0,-e,0],params:{length:1,diameter:.5}},{id:`demo-drain`,type:`drain`,position:[-1.5,0,1.95],rotation:[0,-e,0],params:{capacityGph:100},label:`Floor drain`},{id:`demo-res2`,type:`reservoir`,position:[7.5,0,1.5],rotation:[0,0,0],params:{width:2,depth:1.4,height:1,level:60},label:`Tower reservoir`},{id:`demo-pump2`,type:`pump`,position:[6.05,0,1.5],rotation:[0,Math.PI,0],params:{gph:240,maxHeadFt:8,on:1},label:`Tower pump`},{id:`demo-elbow-t1`,type:`elbow`,position:[5.6,.25,1.5],rotation:[0,Math.PI,0],params:{angle:90,diameter:1}},{id:`demo-riser2`,type:`pipe`,position:[5.1,2.375,1.5],rotation:[0,0,e],params:{length:3.25,diameter:1}},{id:`demo-elbow-t2`,type:`elbow`,position:[5.1,4,1.5],rotation:[0,0,e],params:{angle:90,diameter:1}},{id:`demo-pipe-t1`,type:`pipe`,position:[4.05,4.5,1.5],rotation:[0,0,0],params:{length:1.1,diameter:1}},{id:`demo-elbow-t3`,type:`elbow`,position:[3.5,4.5,1.5],rotation:[0,0,Math.PI],params:{angle:90,diameter:1}},{id:`demo-elbow-t4`,type:`elbow`,position:[3.45,.15,1.5],rotation:[e,0,0],params:{angle:90,diameter:1}},{id:`demo-pipe-t2`,type:`pipe`,position:[3.95,.15,2.75],rotation:[0,e,0],params:{length:1.5,diameter:1}},{id:`demo-drain2`,type:`drain`,position:[3.95,-.1,3.85],rotation:[0,-e,0],params:{capacityGph:100},label:`Tower drain`},{id:`demo-tower`,type:`tower`,position:[3,0,1.5],rotation:[0,0,0],params:{height:4,sites:6},label:`Tower A`},{id:`demo-tray`,type:`tray`,position:[3,0,-1.5],rotation:[0,0,0],params:{length:3,width:1.2}},{id:`demo-pot1`,type:`netPot`,position:[2.4,.25,-1.5],rotation:[0,0,0],params:{size:1}},{id:`demo-pot2`,type:`netPot`,position:[3.4,.25,-1.5],rotation:[0,0,0],params:{size:1}},{id:`demo-lattice`,type:`lattice`,position:[5.5,0,0],rotation:[0,-e,0],params:{width:2.5,height:3}}]}var fT=`#cbd5e1`,pT=`#4ade80`;function mT({children:e,className:t}){return(0,Z.jsx)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,stroke:fT,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,"aria-hidden":`true`,children:e})}function hT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`8`,y:`15`,width:`24`,height:`10`,rx:`2`,fill:e,fillOpacity:.35}),(0,Z.jsx)(`rect`,{x:`4`,y:`12.5`,width:`5`,height:`15`,rx:`1.5`,fill:e,fillOpacity:.55}),(0,Z.jsx)(`rect`,{x:`31`,y:`12.5`,width:`5`,height:`15`,rx:`1.5`,fill:e,fillOpacity:.55}),(0,Z.jsx)(`path`,{d:`M12 18.5 H28`,strokeOpacity:.45,strokeWidth:1.5})]})}function gT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M5 10 H22 A8 8 0 0 1 30 18 V35 H20 V20 H5 Z`,fill:e,fillOpacity:.35}),(0,Z.jsx)(`rect`,{x:`3`,y:`8`,width:`4`,height:`14`,rx:`1.5`,fill:e,fillOpacity:.55}),(0,Z.jsx)(`rect`,{x:`18`,y:`33`,width:`14`,height:`4`,rx:`1.5`,fill:e,fillOpacity:.55})]})}function _T({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M5 13 H35 V23 H25 V35 H15 V23 H5 Z`,fill:e,fillOpacity:.35}),(0,Z.jsx)(`rect`,{x:`3`,y:`11`,width:`4`,height:`14`,rx:`1.5`,fill:e,fillOpacity:.55}),(0,Z.jsx)(`rect`,{x:`33`,y:`11`,width:`4`,height:`14`,rx:`1.5`,fill:e,fillOpacity:.55}),(0,Z.jsx)(`rect`,{x:`13`,y:`33`,width:`14`,height:`4`,rx:`1.5`,fill:e,fillOpacity:.55})]})}function vT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M6 15 L20 21.5 L6 28 Z`,fill:e,fillOpacity:.35}),(0,Z.jsx)(`path`,{d:`M34 15 L20 21.5 L34 28 Z`,fill:e,fillOpacity:.35}),(0,Z.jsx)(`path`,{d:`M20 21.5 V11`}),(0,Z.jsx)(`ellipse`,{cx:`20`,cy:`9`,rx:`8`,ry:`3`,stroke:e,fill:e,fillOpacity:.3})]})}function yT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`23`,y:`11`,width:`13`,height:`7`,rx:`1.5`,fill:e,fillOpacity:.45}),(0,Z.jsx)(`circle`,{cx:`18`,cy:`23`,r:`10`,fill:e,fillOpacity:.25}),(0,Z.jsx)(`path`,{d:`M18 23 L18 16`,strokeWidth:1.8}),(0,Z.jsx)(`path`,{d:`M18 23 L12 26.5`,strokeWidth:1.8}),(0,Z.jsx)(`path`,{d:`M18 23 L24 26.5`,strokeWidth:1.8}),(0,Z.jsx)(`circle`,{cx:`18`,cy:`23`,r:`1.8`,fill:fT,stroke:`none`}),(0,Z.jsx)(`path`,{d:`M10 36 H26`})]})}function bT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`7`,y:`9`,width:`26`,height:`25`,rx:`3`}),(0,Z.jsx)(`path`,{d:`M8.5 21 Q12 18.5 15.5 21 T22.5 21 T29.5 21 L31.5 21 V29.5 Q31.5 32.5 28.5 32.5 H11.5 Q8.5 32.5 8.5 29.5 Z`,fill:e,fillOpacity:.6,stroke:`none`}),(0,Z.jsx)(`path`,{d:`M8.5 21 Q12 18.5 15.5 21 T22.5 21 T29.5 21 L31.5 21`,stroke:e,strokeWidth:1.8})]})}function xT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`16`,y:`5`,width:`8`,height:`28`,rx:`2`,fill:e,fillOpacity:.25}),(0,Z.jsx)(`path`,{d:`M16 12 L10 9.5 V15 L16 16 Z`,fill:e,fillOpacity:.4}),(0,Z.jsx)(`path`,{d:`M24 19 L30 16.5 V22 L24 23 Z`,fill:e,fillOpacity:.4}),(0,Z.jsx)(`path`,{d:`M16 26 L10 23.5 V29 L16 30 Z`,fill:e,fillOpacity:.4}),(0,Z.jsx)(`path`,{d:`M10 9.5 Q7 7 7.5 4.5 Q11 5 11.5 8.5`,fill:pT,stroke:pT,strokeWidth:1.2}),(0,Z.jsx)(`path`,{d:`M30 16.5 Q33 14 32.5 11.5 Q29 12 28.5 15.5`,fill:pT,stroke:pT,strokeWidth:1.2}),(0,Z.jsx)(`path`,{d:`M10 23.5 Q7 21 7.5 18.5 Q11 19 11.5 22.5`,fill:pT,stroke:pT,strokeWidth:1.2}),(0,Z.jsx)(`rect`,{x:`12`,y:`33`,width:`16`,height:`3.5`,rx:`1.5`,fill:e,fillOpacity:.4})]})}function ST({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M6 21 L14 14 H34 L26 21 Z`,fill:e,fillOpacity:.25}),(0,Z.jsx)(`path`,{d:`M6 21 H26 V28 H6 Z`,fill:e,fillOpacity:.45}),(0,Z.jsx)(`path`,{d:`M26 21 L34 14 V21 L26 28 Z`,fill:e,fillOpacity:.35}),(0,Z.jsx)(`path`,{d:`M12 18.5 Q14 17 16 18.5`,strokeWidth:1.4,strokeOpacity:.8}),(0,Z.jsx)(`path`,{d:`M20 17.5 Q22 16 24 17.5`,strokeWidth:1.4,strokeOpacity:.8})]})}function CT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`8`,y:`6`,width:`24`,height:`28`,rx:`2`,fill:e,fillOpacity:.2}),[12.5,20.5,28.5].map(t=>[13,23].map(n=>(0,Z.jsx)(`path`,{d:`M${n} ${t} q2 2.5 4 0`,stroke:e,strokeWidth:1.8,fill:`none`},`${n}-${t}`))),(0,Z.jsx)(`path`,{d:`M14 11 q1 -2.5 3 -3`,stroke:pT,strokeWidth:1.4}),(0,Z.jsx)(`path`,{d:`M24 19 q1 -2.5 3 -3`,stroke:pT,strokeWidth:1.4}),(0,Z.jsx)(`path`,{d:`M14 27 q1 -2.5 3 -3`,stroke:pT,strokeWidth:1.4})]})}function wT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`7`,y:`7`,width:`26`,height:`26`,rx:`2`}),(0,Z.jsxs)(`g`,{stroke:e,strokeWidth:1.6,children:[(0,Z.jsx)(`path`,{d:`M7 21 L21 7`}),(0,Z.jsx)(`path`,{d:`M7 33 L33 7`}),(0,Z.jsx)(`path`,{d:`M19 33 L33 19`}),(0,Z.jsx)(`path`,{d:`M19 7 L33 21`}),(0,Z.jsx)(`path`,{d:`M7 7 L33 33`}),(0,Z.jsx)(`path`,{d:`M7 19 L21 33`})]})]})}function TT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M11 19 H29 L25.5 33 H14.5 Z`,fill:e,fillOpacity:.35}),(0,Z.jsx)(`path`,{d:`M14 22 L17 30 M19 22 L20 30 M24 22 L22 30`,strokeWidth:1.3,strokeOpacity:.7}),(0,Z.jsx)(`rect`,{x:`8.5`,y:`15.5`,width:`23`,height:`4`,rx:`1.5`,fill:e,fillOpacity:.55}),(0,Z.jsx)(`path`,{d:`M20 15 V8`,stroke:pT}),(0,Z.jsx)(`path`,{d:`M20 10 C16.5 10 14.5 7.5 14.5 4.5 C18 4.5 20 7 20 10 Z`,fill:pT,stroke:pT,strokeWidth:1}),(0,Z.jsx)(`path`,{d:`M20 10 C23.5 10 25.5 7.5 25.5 4.5 C22 4.5 20 7 20 10 Z`,fill:pT,stroke:pT,strokeWidth:1})]})}function ET({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M20 17 V10`,stroke:e,strokeWidth:1.8}),(0,Z.jsx)(`path`,{d:`M15.5 18.5 L10.5 12.5`,stroke:e,strokeWidth:1.8}),(0,Z.jsx)(`path`,{d:`M24.5 18.5 L29.5 12.5`,stroke:e,strokeWidth:1.8}),(0,Z.jsx)(`circle`,{cx:`20`,cy:`7.5`,r:`1.6`,fill:e,stroke:`none`}),(0,Z.jsx)(`circle`,{cx:`9`,cy:`10.5`,r:`1.6`,fill:e,stroke:`none`}),(0,Z.jsx)(`circle`,{cx:`31`,cy:`10.5`,r:`1.6`,fill:e,stroke:`none`}),(0,Z.jsx)(`rect`,{x:`17.5`,y:`20`,width:`5`,height:`5`,rx:`1`,fill:e,fillOpacity:.5}),(0,Z.jsx)(`path`,{d:`M14 25 H26 L24 32 H16 Z`,fill:e,fillOpacity:.3}),(0,Z.jsx)(`path`,{d:`M12 35 H28`})]})}function DT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M7 9 H33 L24 21 V29 L16 26 V21 Z`,fill:e,fillOpacity:.3}),(0,Z.jsx)(`path`,{d:`M14 12.5 V16`,strokeWidth:1.5,strokeOpacity:.8}),(0,Z.jsx)(`path`,{d:`M20 12.5 V19.5`,strokeWidth:1.5,strokeOpacity:.8}),(0,Z.jsx)(`path`,{d:`M26 12.5 V16`,strokeWidth:1.5,strokeOpacity:.8}),(0,Z.jsx)(`path`,{d:`M20 31.5 C18 34.5 18.4 36.8 20 36.8 C21.6 36.8 22 34.5 20 31.5 Z`,fill:e,stroke:`none`})]})}function OT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M7 33 V10 L12 6 H28 L33 10 V33`,fill:e,fillOpacity:.18}),(0,Z.jsx)(`path`,{d:`M12 6 V33 M28 6 V33 M7 15 H33`,stroke:e,strokeWidth:1.6}),(0,Z.jsx)(`path`,{d:`M20 15 V33`,strokeWidth:1.4,strokeOpacity:.7})]})}function kT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`circle`,{cx:`20`,cy:`20`,r:`11`,fill:e,fillOpacity:.25}),(0,Z.jsx)(`circle`,{cx:`20`,cy:`20`,r:`4`,fill:e,fillOpacity:.6}),(0,Z.jsx)(`path`,{d:`M20 9 C25 11 27 15 25 20`,stroke:e}),(0,Z.jsx)(`path`,{d:`M31 20 C29 25 25 27 20 25`,stroke:e}),(0,Z.jsx)(`path`,{d:`M20 31 C15 29 13 25 15 20`,stroke:e}),(0,Z.jsx)(`path`,{d:`M9 20 C11 15 15 13 20 15`,stroke:e})]})}function AT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`circle`,{cx:`20`,cy:`15`,r:`8`,fill:e,fillOpacity:.18}),(0,Z.jsx)(`path`,{d:`M20 10 C23 11 24.5 13 23.5 16`,stroke:e}),(0,Z.jsx)(`path`,{d:`M25 15 C24 18 22 19.5 19 18.5`,stroke:e}),(0,Z.jsx)(`path`,{d:`M20 20 C17 19 15.5 17 16.5 14`,stroke:e}),(0,Z.jsx)(`path`,{d:`M20 23 V34`,stroke:e}),(0,Z.jsx)(`path`,{d:`M14 34 H26`,stroke:e})]})}function jT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`8`,y:`9`,width:`24`,height:`8`,rx:`2`,fill:e,fillOpacity:.4}),(0,Z.jsx)(`path`,{d:`M12 9 L15 5 M28 9 L25 5`}),(0,Z.jsx)(`path`,{d:`M12 21 L10 27 M18 21 L18 29 M24 21 L26 27 M30 21 L32 27`,stroke:e})]})}function MT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`14`,y:`8`,width:`12`,height:`24`,rx:`4`,fill:e,fillOpacity:.25}),(0,Z.jsx)(`rect`,{x:`17`,y:`5`,width:`6`,height:`4`,rx:`1.5`,fill:e,fillOpacity:.5}),(0,Z.jsx)(`path`,{d:`M23 7 H28`}),(0,Z.jsx)(`text`,{x:`20`,y:`23`,textAnchor:`middle`,fontSize:`7`,fill:fT,stroke:`none`,children:`CO2`})]})}function NT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`9`,y:`9`,width:`22`,height:`22`,rx:`5`,fill:e,fillOpacity:.4}),(0,Z.jsx)(`circle`,{cx:`20`,cy:`20`,r:`3`,fill:e,stroke:`none`})]})}function PT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`8`,y:`14`,width:`24`,height:`16`,rx:`3`,fill:e,fillOpacity:.25}),(0,Z.jsx)(`circle`,{cx:`12`,cy:`32`,r:`2`,fill:e,fillOpacity:.6}),(0,Z.jsx)(`circle`,{cx:`28`,cy:`32`,r:`2`,fill:e,fillOpacity:.6}),(0,Z.jsx)(`rect`,{x:`30`,y:`19`,width:`4`,height:`4`,fill:fT}),(0,Z.jsx)(`circle`,{cx:`16`,cy:`22`,r:`3`,fill:e,fillOpacity:.4}),(0,Z.jsx)(`line`,{x1:`16`,y1:`22`,x2:`18`,y2:`20`,stroke:fT,strokeWidth:1.5})]})}var FT={pipe:hT,elbow:gT,tee:_T,valve:vT,pump:yT,reservoir:bT,tower:xT,tray:ST,wallPanel:CT,lattice:wT,netPot:TT,emitter:ET,drain:DT,growTent:OT,inlineFan:kT,circulationFan:AT,growLight:jT,co2Tank:MT,airCompressor:PT,reducingTee:IT,reducingElbow:LT,bulkhead:RT,waterChiller:zT,reverseOsmosis:BT};function IT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M 6,18 L 34,18`,stroke:e,strokeWidth:8,strokeLinecap:`round`}),(0,Z.jsx)(`path`,{d:`M 6,18 L 34,18`,stroke:fT,strokeWidth:1.5}),(0,Z.jsx)(`path`,{d:`M 20,18 L 20,30`,stroke:e,strokeWidth:4.5,strokeLinecap:`round`}),(0,Z.jsx)(`path`,{d:`M 20,18 L 20,30`,stroke:fT,strokeWidth:1.2})]})}function LT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`path`,{d:`M 8,28 A 12,12 0 0,1 28,8`,fill:`none`,stroke:e,strokeWidth:7,strokeLinecap:`round`}),(0,Z.jsx)(`path`,{d:`M 8,28 A 12,12 0 0,1 28,8`,fill:`none`,stroke:fT,strokeWidth:1.5}),(0,Z.jsx)(`line`,{x1:`8`,y1:`28`,x2:`12`,y2:`28`,stroke:fT,strokeWidth:1.5}),(0,Z.jsx)(`line`,{x1:`28`,y1:`8`,x2:`28`,y2:`12`,stroke:fT,strokeWidth:1.5})]})}function RT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`18`,y:`6`,width:`4`,height:`28`,fill:e,fillOpacity:.4,stroke:e,strokeWidth:1.2}),(0,Z.jsx)(`rect`,{x:`10`,y:`14`,width:`20`,height:`12`,fill:e,fillOpacity:.25,rx:`1`}),(0,Z.jsx)(`rect`,{x:`12`,y:`16`,width:`16`,height:`8`,fill:`none`,stroke:fT,strokeWidth:1.5})]})}function zT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`8`,y:`12`,width:`24`,height:`22`,rx:`2`,fill:e,fillOpacity:.25}),(0,Z.jsx)(`rect`,{x:`12`,y:`7`,width:`3`,height:`5`,fill:e}),(0,Z.jsx)(`rect`,{x:`25`,y:`7`,width:`3`,height:`5`,fill:e}),(0,Z.jsx)(`rect`,{x:`14`,y:`17`,width:`12`,height:`6`,fill:`#09090b`,rx:`1`}),(0,Z.jsx)(`circle`,{cx:`20`,cy:`20`,r:`1.5`,fill:`#22c55e`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`27`,x2:`28`,y2:`27`,stroke:fT,strokeWidth:1.2}),(0,Z.jsx)(`line`,{x1:`12`,y1:`30`,x2:`28`,y2:`30`,stroke:fT,strokeWidth:1.2})]})}function BT({color:e,className:t}){return(0,Z.jsxs)(mT,{className:t,children:[(0,Z.jsx)(`rect`,{x:`4`,y:`18`,width:`32`,height:`4`,rx:`1`,fill:e,fillOpacity:.4}),(0,Z.jsx)(`rect`,{x:`11`,y:`10`,width:`18`,height:`20`,rx:`3`,fill:e,fillOpacity:.25}),(0,Z.jsx)(`line`,{x1:`11`,y1:`15`,x2:`29`,y2:`15`,stroke:fT,strokeWidth:1.5}),(0,Z.jsx)(`line`,{x1:`11`,y1:`20`,x2:`29`,y2:`20`,stroke:fT,strokeWidth:1.5}),(0,Z.jsx)(`line`,{x1:`11`,y1:`25`,x2:`29`,y2:`25`,stroke:fT,strokeWidth:1.5})]})}function VT({type:e,color:t,className:n}){return(0,Z.jsx)(FT[e]??NT,{color:t??Yx[e]?.color??`#71717a`,className:n})}function HT(){let e=Q(e=>e.parts),t=Q(e=>e.placingType),n=Q(e=>e.setPlacingType),r=Q(e=>e.addPart),i=Q(e=>e.updatePart),a=Q(e=>e.setSelected),o=Q(e=>e.toggleSelected),[s,c]=(0,v.useState)(``),l=s.toLowerCase(),u=e=>Yx[e].label.toLowerCase().includes(l),d=l?rT.filter(u):rT,f=l?aT.filter(e=>e.label.toLowerCase().includes(l)):aT,p=Xx.map(e=>({...e,types:l?e.types.filter(u):e.types})).filter(e=>e.types.length>0),m=t=>{n(null);let s=uT(t,lT(Object.values(e))).map(e=>{let t=r(e.type,e.position,{snap:!1});return i(t,{rotation:e.rotation,params:e.params,label:e.label,color:e.color}),t});a(s[0]??null),s.slice(1).forEach(o)};return(0,Z.jsxs)(`aside`,{className:`flex w-56 shrink-0 flex-col border-r border-zinc-800 bg-zinc-950/80 backdrop-blur`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-zinc-800 px-4 py-3`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-semibold tracking-widest text-zinc-400 uppercase`,children:`Parts Library`}),(0,Z.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-zinc-600`,children:`Click then place in scene, or drag onto the canvas. Shift-click to stamp copies.`})]}),(0,Z.jsx)(`div`,{className:`px-3 pt-2`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`Search parts…`,className:`w-full rounded-md border border-zinc-800 bg-zinc-900 px-2.5 py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 outline-none focus:border-zinc-600 focus:ring-1 focus:ring-zinc-700`}),s&&(0,Z.jsx)(`button`,{onClick:()=>c(``),className:`absolute right-1.5 top-1/2 -translate-y-1/2 rounded px-1 text-xs text-zinc-500 hover:text-zinc-300`,children:`×`})]})}),(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:[d.length>0&&(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsx)(`h3`,{className:`px-1 py-1.5 text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Tool Belt`}),(0,Z.jsx)(`div`,{className:`grid grid-cols-3 gap-1.5`,children:d.map((e,r)=>(0,Z.jsx)(WT,{type:e,active:t===e,badge:l?void 0:`${r+1}`,compact:!0,onClick:()=>n(t===e?null:e)},`hotbar-${e}`))})]}),f.length>0&&(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsx)(`h3`,{className:`px-1 py-1.5 text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Quick Builds`}),(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:f.map(e=>(0,Z.jsx)(UT,{label:e.label,description:e.description,onClick:()=>m(e.id)},e.id))})]}),p.map(e=>(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`h3`,{className:`px-1 py-1.5 text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:e.name}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:e.types.map(e=>(0,Z.jsx)(WT,{type:e,active:t===e,onClick:()=>n(t===e?null:e)},e))})]},e.name))]})]})}function UT({label:e,description:t,onClick:n}){return(0,Z.jsxs)(`button`,{onClick:n,title:t,className:`flex items-center justify-between gap-2 rounded-lg border border-zinc-800 bg-zinc-900/60 px-3 py-2 text-left text-zinc-200 transition hover:border-emerald-500/60 hover:bg-emerald-500/10 hover:text-emerald-100`,children:[(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block text-[12px] leading-tight font-semibold`,children:e}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-[10px] leading-snug text-zinc-500`,children:t})]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-sm text-emerald-400`,children:`+`})]})}function WT({type:e,active:t,badge:n,compact:r,onClick:i}){let a=Yx[e];return(0,Z.jsxs)(`button`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(`application/x-hydro-part`,e),t.dataTransfer.effectAllowed=`copy`},onClick:i,title:t?`${a.description} — click again to cancel${n?` (${n})`:``}`:`${a.description}${n?` (${n})`:``}`,className:`group relative flex flex-col items-center gap-1 rounded-lg border px-1.5 text-center transition
|
||
${t?`border-sky-400 bg-sky-500/15 text-sky-300 shadow-[0_0_10px_-2px_rgba(56,189,248,0.6)] ring-1 ring-sky-400/40`:`border-zinc-800 bg-zinc-900/60 text-zinc-300 hover:border-zinc-600 hover:bg-zinc-800/80`} ${r?`py-1.5`:`py-2`}`,children:[n&&(0,Z.jsx)(`span`,{className:`absolute top-1 left-1 rounded bg-zinc-950/90 px-1 py-0.5 text-[9px] font-bold leading-none text-zinc-400 ring-1 ring-zinc-800`,children:n}),(0,Z.jsx)(VT,{type:e,className:`${r?`h-7 w-7`:`h-9 w-9`} transition-transform duration-150 group-hover:scale-110 ${t?`scale-110 drop-shadow-[0_0_4px_rgba(56,189,248,0.5)]`:``}`}),(0,Z.jsx)(`span`,{className:`w-full font-medium break-words ${r?`text-[10px]`:`text-[11px] leading-tight`}`,children:a.label}),t&&(0,Z.jsx)(`span`,{className:`text-[9px] font-semibold tracking-wider text-sky-400 uppercase`,children:`Placing…`})]})}function GT(e,t){let n=e.params.width??0,r=e.params.depth??0,i=e.params.height??0,[a,o,s]=e.position,[c,l,u]=t.position;return c>=a-n/2&&c<=a+n/2&&u>=s-r/2&&u<=s+r/2&&l>=o&&l<=o+i}function KT(e){let t=Object.values(e);return t.filter(e=>e.type===`growTent`).map(e=>{let n=t.filter(t=>t.id!==e.id&>(e,t)),r=n.filter(e=>e.type===`inlineFan`&&(e.params.exhaust??1)>0).reduce((e,t)=>e+(t.params.cfm??0),0),i=n.filter(e=>e.type===`circulationFan`).reduce((e,t)=>e+(t.params.cfm??0),0),a=n.filter(e=>e.type===`growLight`).reduce((e,t)=>e+(t.params.watts??0),0),o=n.filter(e=>e.type===`co2Tank`),s=o.reduce((e,t)=>e+(t.params.regulatorCfh??0),0),c=(e.params.width??0)*(e.params.depth??0)*(e.params.height??0),l=c>0?r/c:0,u=(e.params.width??0)*(e.params.depth??0),d=u>0?a*2/u:0,f=n.filter(e=>e.type===`growLight`),p=u>0&&f.length>0?f.reduce((e,t)=>{let n=t.params.watts??0,r=t.params.photoperiod??18;return e+n*2/u*r*.0036},0):0,m=f.reduce((e,t)=>{let n=t.params.photoperiod??18,r=t.params.watts??0;return e+(n>0?r:0)},0),h=75+.01*m,g=e.params.humidity??60,_=(h-32)*5/9,v=.61078*Math.exp(17.27*_/(_+237.3)),y=v*(1-g/100),b=(e.params.sealed??0)>0,x=m>0,S=400;b&&x?S=o.length===0?150:1200:o.length>0&&(S=1200);let C=m*3.412,w=Math.max(.1,Math.min(1,y/1.2)),T=m*.032*w,E=T/24*1060,D=.01352*(g/100*v)/(_+273.15),O=.01352*(.61078*Math.exp(215/9*17.27/261.1888888888889)*.5)/297.0388888888889,k=0;!b&&r>0&&(k=Math.max(0,r*1381*(D-O)));let A=Math.max(0,T-k),j=0;!b&&r>0&&(j=r*1.08*(h-75));let M=A/24*1200,N=C-E-j+M,P=Math.max(0,N*1.15);return{roomId:e.id,label:e.label??`Grow room`,sealed:b,volumeFt3:c,exhaustCfm:r,circulationCfm:i,lightWatts:a,co2TankCount:o.length,co2Cfh:s,airChangesPerMinute:l,airChangesPerHour:l*60,roomPPFD:d,roomDLI:p,roomTempF:h,roomRH:g,roomVPD:y,roomCo2:S,sensibleHeatGainsBtuHr:C,latentCoolingBtuHr:E,acSizingBtuHr:P,dehumidifierPintsDay:A}})}var qT=[`#b8bfc9`,`#64748b`,`#38bdf8`,`#3d7bfa`,`#34d399`,`#3b7a57`,`#fbbf24`,`#f97316`,`#e0564f`,`#a78bfa`];function JT({ids:e}){let t=Q(e=>e.applyColor),n=Q(t=>{let n=e.length?t.parts[e[0]]:void 0;return n?n.color??Yx[n.type].color:`#888888`});return(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:qT.map(r=>(0,Z.jsx)(`button`,{title:r,onClick:()=>t(e,r),className:`h-6 w-full rounded-md ring-1 transition hover:scale-110 ${n.toLowerCase()===r?`ring-2 ring-white`:`ring-black/40`}`,style:{backgroundColor:r}},r))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsxs)(`label`,{className:`relative flex h-6 flex-1 cursor-pointer items-center justify-center gap-1 overflow-hidden rounded-md border border-zinc-700 bg-zinc-800 text-[10px] font-medium text-zinc-300 hover:bg-zinc-700`,title:`Pick a custom color`,children:[(0,Z.jsx)(`span`,{className:`h-3 w-3 rounded-sm ring-1 ring-black/40`,style:{backgroundColor:n}}),`Custom`,(0,Z.jsx)(`input`,{type:`color`,value:n,onChange:n=>t(e,n.target.value),className:`absolute inset-0 cursor-pointer opacity-0`})]}),(0,Z.jsx)(`button`,{onClick:()=>t(e,void 0),title:`Reset to the catalog color`,className:`h-6 rounded-md border border-zinc-700 bg-zinc-800 px-2 text-[10px] font-medium text-zinc-300 hover:bg-zinc-700`,children:`Reset`})]})]})}function YT(){let e=Q(e=>e.colorPopover),t=Q(e=>e.selectedIds),n=Q(e=>e.closeColorPopover),r=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!e)return;let t=e=>{r.current&&!r.current.contains(e.target)&&n()};return window.addEventListener(`pointerdown`,t,!0),()=>window.removeEventListener(`pointerdown`,t,!0)},[e,n]),!e||!t.length?null:(0,Z.jsxs)(`div`,{ref:r,className:`fixed z-50 w-[188px] rounded-xl border border-zinc-700 bg-zinc-900/95 p-2.5 shadow-2xl backdrop-blur`,style:{left:Math.max(8,Math.min(e.x,window.innerWidth-196)),top:Math.max(8,Math.min(e.y+10,window.innerHeight-150))},children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:[`Color · `,t.length,` part`,t.length>1?`s`:``]}),(0,Z.jsx)(JT,{ids:t})]})}var XT=e=>Math.round(e*180/Math.PI),ZT=e=>e*Math.PI/180;function QT(){let e=Q(e=>e.selectedIds);return(0,Z.jsxs)(`aside`,{className:`flex w-64 shrink-0 flex-col border-l border-zinc-800 bg-zinc-950/80 backdrop-blur`,children:[(0,Z.jsx)(`div`,{className:`border-b border-zinc-800 px-4 py-3`,children:(0,Z.jsxs)(`h2`,{className:`text-xs font-semibold tracking-widest text-zinc-400 uppercase`,children:[`Inspector`,e.length>1&&(0,Z.jsxs)(`span`,{className:`ml-2 rounded-full bg-sky-500/15 px-2 py-0.5 text-[10px] font-bold text-sky-300`,children:[e.length,` selected`]})]})}),e.length===0?(0,Z.jsx)($T,{}):e.length===1?(0,Z.jsx)(uE,{partId:e[0]}):(0,Z.jsx)(tE,{ids:e})]})}function $T(){let e=Q(e=>e.growthStage),t=Q(e=>e.setGrowthStage);return(0,Z.jsxs)(`div`,{className:`px-4 py-6 text-xs leading-relaxed text-zinc-600 space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-zinc-800 bg-zinc-900/30 p-3`,children:[(0,Z.jsx)(`h3`,{className:`mb-1.5 text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Crop Growth Stage`}),(0,Z.jsxs)(`select`,{value:e,onChange:e=>t(e.target.value),className:`w-full rounded-md border border-zinc-800 bg-zinc-900 px-2 py-1.5 text-xs text-zinc-200 outline-none focus:border-sky-600 cursor-pointer`,children:[(0,Z.jsx)(`option`,{value:`seedling`,children:`Seedling`}),(0,Z.jsx)(`option`,{value:`vegetative`,children:`Vegetative`}),(0,Z.jsx)(`option`,{value:`flowering`,children:`Flowering`})]})]}),(0,Z.jsxs)(`div`,{children:[`Select a part to edit its properties.`,(0,Z.jsxs)(`ul`,{className:`mt-4 space-y-1.5 text-[11px] text-zinc-700`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`Click`}),` select · drag to move`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`⇧Click`}),` add/remove from selection`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`⌘Click`}),` change color`]}),(0,Z.jsxs)(`li`,{children:[`Drag `,(0,Z.jsx)(`span`,{className:`text-sky-600`,children:`connector dots`}),` to snap pipes`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`⇧Drag`}),` move vertically (3D view)`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`⌥Drag`}),` clone while dragging`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`Space`}),` play / pause water`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`R`}),` rotate 90° \xA0 `,(0,Z.jsx)(eE,{children:`Q`}),`/`,(0,Z.jsx)(eE,{children:`E`}),` lower / raise`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`D`}),` duplicate \xA0 `,(0,Z.jsx)(eE,{children:`⌫`}),` delete`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`⌘Z`}),` undo \xA0 `,(0,Z.jsx)(eE,{children:`⇧⌘Z`}),` redo`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(eE,{children:`Esc`}),` deselect / cancel`]})]})]})]})}function eE({children:e}){return(0,Z.jsx)(`kbd`,{className:`rounded border border-zinc-700 bg-zinc-800 px-1.5 py-0.5 font-mono text-[10px] text-zinc-300`,children:e})}function tE({ids:e}){let t=Q(e=>e.parts),n=Q(e=>e.removeParts),r=Q(e=>e.duplicateParts),i=new Map;for(let n of e){let e=t[n];if(!e)continue;let r=Yx[e.type].label;i.set(r,(i.get(r)??0)+1)}return(0,Z.jsxs)(`div`,{className:`flex-1 space-y-4 overflow-y-auto px-4 py-3`,children:[(0,Z.jsxs)(dE,{title:`Selection`,children:[(0,Z.jsx)(`ul`,{className:`space-y-1`,children:[...i.entries()].map(([e,t])=>(0,Z.jsxs)(`li`,{className:`flex justify-between text-xs text-zinc-300`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsxs)(`span`,{className:`font-mono text-zinc-500`,children:[`× `,t]})]},e))}),(0,Z.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-zinc-600`,children:`Drag any selected part (or the gizmo) to move the whole group.`})]}),(0,Z.jsx)(dE,{title:`Color`,children:(0,Z.jsx)(JT,{ids:e})}),(0,Z.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,Z.jsx)(`button`,{onClick:()=>r(e),title:`Duplicate the whole selection (D)`,className:`flex-1 rounded-md border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-xs font-medium text-zinc-200 hover:bg-zinc-700`,children:`Duplicate`}),(0,Z.jsx)(`button`,{onClick:()=>n(e),title:`Delete every selected part (⌫)`,className:`flex-1 rounded-md border border-rose-900 bg-rose-950 px-2 py-1.5 text-xs font-medium text-rose-300 hover:bg-rose-900`,children:`Delete`})]})]})}var nE=new Set([`gph`,`maxHeadFt`]),rE=new Set([`gph`,`frequency`]),iE=new Set([`ph`,`ec`]);function aE({part:e}){let t=Q(e=>e.setParam),n=YS(),r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=t=>{t.detail===e.id&&(r.current?.scrollIntoView({behavior:`smooth`,block:`nearest`}),a(!0),setTimeout(()=>a(!1),1e3))};return window.addEventListener(`hydro:flash-pump`,t),()=>window.removeEventListener(`hydro:flash-pump`,t)},[e.id]);let o=Yx.pump,s=(e.params.on??1)>0,c=n.pumps.find(t=>t.pumpId===e.id),l=e.params.gph??o.defaults.gph,u=e.params.maxHeadFt??o.defaults.maxHeadFt;return(0,Z.jsxs)(`div`,{ref:r,className:`rounded-lg border p-3 transition-all duration-300 ${i?`border-sky-400 bg-sky-950/60 ring-2 ring-sky-400/60`:`border-sky-900/70 bg-sky-950/30`}`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-bold tracking-wider text-sky-400 uppercase`,children:`Pump`}),(0,Z.jsx)(`button`,{onClick:()=>t(e.id,`on`,+!s),title:s?`Turn pump off`:`Turn pump on`,className:`relative h-6 w-12 rounded-full transition-colors ${s?`bg-emerald-500`:`bg-zinc-700`}`,children:(0,Z.jsx)(`span`,{className:`absolute top-0.5 grid h-5 w-5 place-items-center rounded-full bg-white text-[8px] font-black text-zinc-700 shadow transition-all ${s?`left-6`:`left-0.5`}`,children:s?`I`:`O`})})]}),(0,Z.jsxs)(`div`,{className:`mb-2 rounded-md bg-zinc-900/70 px-2.5 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`text-lg font-bold tabular-nums text-sky-300`,children:[c&&s?c.gph.toFixed(0):`0`,(0,Z.jsx)(`span`,{className:`ml-1 text-[10px] font-medium text-zinc-500`,children:`GPH delivered`})]}),(0,Z.jsx)(`div`,{className:`text-[10px] text-zinc-500 tabular-nums`,children:c?`head ${c.headFt.toFixed(1)} / ${c.maxHeadFt} ft`:`not connected to a reservoir`})]}),(0,Z.jsx)(lE,{label:`Rated flow`,unit:`GPH`,value:l,meta:o.params.gph,onChange:n=>t(e.id,`gph`,n)}),(0,Z.jsx)(lE,{label:`Max head`,unit:`ft`,value:u,meta:o.params.maxHeadFt,onChange:n=>t(e.id,`maxHeadFt`,n)})]})}function oE({part:e}){let t=Q(e=>e.setParam),n=Q(e=>e.parts),r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=t=>{t.detail===e.id&&(r.current?.scrollIntoView({behavior:`smooth`,block:`nearest`}),a(!0),setTimeout(()=>a(!1),1e3))};return window.addEventListener(`hydro:flash-airCompressor`,t),()=>window.removeEventListener(`hydro:flash-airCompressor`,t)},[e.id]);let o=Yx.airCompressor,s=(e.params.on??1)>0,c=e.params.gph??o.defaults.gph,l=e.params.frequency??o.defaults.frequency,u=(0,v.useMemo)(()=>{let t=null,r=1/0,i=e.position;for(let e of Object.values(n))if(e.type===`reservoir`){let n=Math.hypot(e.position[0]-i[0],e.position[1]-i[1],e.position[2]-i[2]);n<r&&(r=n,t=e)}return t},[n,e.position]),d=(0,v.useMemo)(()=>{if(!u)return null;let e=0;for(let t of Object.values(n))if(t.type===`airCompressor`&&(t.params.on??1)>0){let r=null,i=1/0;for(let e of Object.values(n))if(e.type===`reservoir`){let n=Math.hypot(e.position[0]-t.position[0],e.position[1]-t.position[1],e.position[2]-t.position[2]);n<i&&(i=n,r=e)}r&&r.id===u.id&&(e+=t.params.gph??120)}let t=u.params.width??2,r=u.params.depth??1.4,i=u.params.height??1,a=u.params.level??70,o=t*r*i*(a/100)*7.48,s=5.5;if(e>0&&o>0){let t=e/o;s=5.5+3.7*(1-Math.exp(-t*2))}return{volGal:o,totalAerationGph:e,tdo:s}},[n,u]);return(0,Z.jsxs)(`div`,{ref:r,className:`rounded-lg border p-3 transition-all duration-300 ${i?`border-sky-400 bg-sky-950/60 ring-2 ring-sky-400/60`:`border-sky-900/70 bg-sky-950/30`}`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-bold tracking-wider text-sky-400 uppercase`,children:`Air Compressor`}),(0,Z.jsx)(`button`,{onClick:()=>t(e.id,`on`,+!s),title:s?`Turn compressor off`:`Turn compressor on`,className:`relative h-6 w-12 rounded-full transition-colors ${s?`bg-emerald-500`:`bg-zinc-700`}`,children:(0,Z.jsx)(`span`,{className:`absolute top-0.5 grid h-5 w-5 place-items-center rounded-full bg-white text-[8px] font-black text-zinc-700 shadow transition-all ${s?`left-6`:`left-0.5`}`,children:s?`I`:`O`})})]}),(0,Z.jsxs)(`div`,{className:`mb-3 rounded-md bg-zinc-900/70 px-2.5 py-1.5 space-y-1`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] font-semibold text-zinc-400`,children:`Target Reservoir:`}),u?(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center text-xs text-zinc-200`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:u.label||`Reservoir #${u.id}`}),(0,Z.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500`,children:[Math.hypot(u.position[0]-e.position[0],u.position[2]-e.position[2]).toFixed(1),` ft away`]})]}),d&&(0,Z.jsxs)(`div`,{className:`mt-1.5 pt-1.5 border-t border-zinc-800/60 space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`Dissolved O₂:`}),(0,Z.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-bold ${d.tdo>=8?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:d.tdo>=7?`bg-sky-500/10 text-sky-400 border border-sky-500/20`:`bg-amber-500/10 text-amber-400 border border-amber-500/20`}`,children:[d.tdo.toFixed(1),` mg/L`]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-zinc-500`,children:[(0,Z.jsx)(`span`,{children:`Tank Volume:`}),(0,Z.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[d.volGal.toFixed(1),` Gal`]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-zinc-500`,children:[(0,Z.jsx)(`span`,{children:`Total Aeration:`}),(0,Z.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[d.totalAerationGph,` GPH`]})]})]})]}):(0,Z.jsx)(`div`,{className:`text-xs text-amber-400/80 font-medium`,children:`No reservoir in scene!`})]}),(0,Z.jsx)(lE,{label:`Air Flow`,unit:`GPH`,value:c,meta:o.params.gph,onChange:n=>t(e.id,`gph`,n)}),(0,Z.jsx)(lE,{label:`Bubble Frequency`,unit:`Hz`,value:l,meta:o.params.frequency,onChange:n=>t(e.id,`frequency`,n)})]})}function sE({part:e}){let t=Q(e=>e.parts),n=(0,v.useMemo)(()=>KT(t).find(t=>t.roomId===e.id),[t,e.id]);return n?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-sky-900/50 bg-sky-950/20 p-3 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-bold tracking-wider text-sky-400 uppercase`,children:`Room Simulation`}),(0,Z.jsxs)(`span`,{className:`font-mono text-xs text-sky-300`,children:[n.volumeFt3.toFixed(0),` ft³`]})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-md bg-zinc-900/80 p-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-zinc-500 font-bold uppercase`,children:`VPD`}),(0,Z.jsxs)(`div`,{className:`mt-0.5 text-xs font-bold text-emerald-400`,children:[n.roomVPD.toFixed(2),(0,Z.jsx)(`span`,{className:`text-[8px] font-normal text-zinc-500 ml-0.5`,children:`kPa`})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-md bg-zinc-900/80 p-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-zinc-500 font-bold uppercase`,children:`DLI`}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs font-bold text-amber-400`,children:n.roomDLI.toFixed(1)})]}),(0,Z.jsxs)(`div`,{className:`rounded-md bg-zinc-900/80 p-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-zinc-500 font-bold uppercase`,children:`CO₂`}),(0,Z.jsxs)(`div`,{className:`mt-0.5 text-xs font-bold text-sky-400`,children:[n.roomCo2,(0,Z.jsx)(`span`,{className:`text-[8px] font-normal text-zinc-500 ml-0.5`,children:`PPM`})]})]})]}),(0,Z.jsxs)(`div`,{className:`text-[10px] text-zinc-400 space-y-1 pt-1.5 border-t border-zinc-800/60 font-mono`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Est. Temp:`}),(0,Z.jsxs)(`span`,{className:`text-zinc-200`,children:[n.roomTempF.toFixed(1),`°F`]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Est. RH:`}),(0,Z.jsxs)(`span`,{className:`text-zinc-200`,children:[n.roomRH,`%`]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Room PPFD:`}),(0,Z.jsxs)(`span`,{className:`text-zinc-200`,children:[n.roomPPFD.toFixed(0),` μmol/m²/s`]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`AC Sizing:`}),(0,Z.jsxs)(`span`,{className:`text-zinc-300 font-semibold`,children:[Math.round(n.acSizingBtuHr),` BTU/hr`]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Dehumidifier:`}),(0,Z.jsxs)(`span`,{className:`text-zinc-300 font-semibold`,children:[n.dehumidifierPintsDay.toFixed(1),` Pints/day`]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Sensible Heat:`}),(0,Z.jsxs)(`span`,{className:`text-zinc-500`,children:[Math.round(n.sensibleHeatGainsBtuHr),` BTU/hr`]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Latent Cooling:`}),(0,Z.jsxs)(`span`,{className:`text-emerald-500/80`,children:[Math.round(n.latentCoolingBtuHr),` BTU/hr`]})]})]})]}):null}function cE({part:e}){let t=Q(e=>e.setParam),n=Q(e=>e.parts),r=Q(e=>e.growthStage),i=YS(),a=(0,v.useMemo)(()=>nC(e,n),[e,n]),o=i.reservoirRuntime[e.id],{ecLow:s,ecHigh:c}=(0,v.useMemo)(()=>r===`seedling`?{ecLow:.4,ecHigh:.8}:r===`flowering`?{ecLow:1.5,ecHigh:2.2}:{ecLow:1,ecHigh:1.6},[r]),l=a.ec<s||a.ec>c;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-sky-900/50 bg-sky-950/20 p-3 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-bold tracking-wider text-sky-400 uppercase`,children:`Reservoir Health`}),(0,Z.jsxs)(`span`,{className:`font-mono text-xs ${o?.empty?`text-rose-300`:`text-sky-300`}`,children:[(o?.gallonsCurrent??a.volGal).toFixed(1),` Gal`]})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-md bg-zinc-900/80 p-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-zinc-500 font-bold uppercase`,children:`Runtime`}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs font-bold ${o?.empty?`text-rose-400`:o?.minutesRemaining===null?`text-emerald-400`:`text-amber-400`}`,children:o?o.minutesRemaining===null?`Stable`:o.empty?`Dry`:`${o.minutesRemaining.toFixed(1)} min`:`Stable`}),(0,Z.jsx)(`div`,{className:`text-[8px] text-zinc-600`,children:o?.minutesRemaining===null?`No net draw`:o?.empty?`Source exhausted`:`${o.netOutflowGph.toFixed(1)} GPH net draw`})]}),(0,Z.jsxs)(`div`,{className:`rounded-md bg-zinc-900/80 p-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-zinc-500 font-bold uppercase`,children:`Volume`}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs font-bold text-sky-300`,children:o?`${o.gallonsCurrent.toFixed(1)} / ${o.gallonsCapacity.toFixed(1)}`:`${a.volGal.toFixed(1)} / ${a.volGal.toFixed(1)}`}),(0,Z.jsx)(`div`,{className:`text-[8px] text-zinc-600`,children:`Gallons`})]})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-md bg-zinc-900/80 p-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-zinc-500 font-bold uppercase`,children:`Temp`}),(0,Z.jsxs)(`div`,{className:`mt-0.5 text-xs font-bold ${a.tempF>73?`text-amber-400`:`text-emerald-400`}`,children:[a.tempF.toFixed(1),`°F`]}),(0,Z.jsx)(`div`,{className:`text-[8px] text-zinc-600`,children:a.tempF>73?`Too Warm`:`Optimal`})]}),(0,Z.jsxs)(`div`,{className:`rounded-md bg-zinc-900/80 p-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-zinc-500 font-bold uppercase`,children:`pH`}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs font-bold ${a.ph<5.5||a.ph>6.5?`text-amber-400`:`text-emerald-400`}`,children:a.ph.toFixed(1)}),(0,Z.jsx)(`div`,{className:`text-[8px] text-zinc-600`,children:a.ph<5.5||a.ph>6.5?`Lockout`:`Optimal`})]}),(0,Z.jsxs)(`div`,{className:`rounded-md bg-zinc-900/80 p-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-zinc-500 font-bold uppercase`,children:`EC`}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs font-bold ${l?`text-amber-400`:`text-emerald-400`}`,children:a.ec.toFixed(1)}),(0,Z.jsx)(`div`,{className:`text-[8px] text-zinc-600`,children:l?`Alert`:`Optimal`})]})]}),(0,Z.jsx)(lE,{label:`Adjust pH`,unit:``,value:e.params.ph??6,meta:Yx.reservoir.params.ph,onChange:n=>t(e.id,`ph`,n)}),(0,Z.jsx)(lE,{label:`Adjust EC`,unit:`mS/cm`,value:e.params.ec??1.2,meta:Yx.reservoir.params.ec,onChange:n=>t(e.id,`ec`,n)})]})}function lE({label:e,unit:t,value:n,meta:r,onChange:i}){return(0,Z.jsxs)(`div`,{className:`mt-1.5`,children:[(0,Z.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`text-zinc-400`,children:e}),(0,Z.jsxs)(`span`,{className:`font-mono text-sky-400`,children:[n,` `,t]})]}),(0,Z.jsx)(`input`,{type:`range`,min:r.min,max:r.max,step:r.step,value:n,onChange:e=>i(parseFloat(e.target.value)),className:`w-full accent-sky-500`})]})}function uE({partId:e}){let t=Q(t=>t.parts[e]),n=Q(e=>e.parts),r=Q(e=>e.updatePart),i=Q(e=>e.setParam),a=Q(e=>e.removeParts),o=Q(e=>e.duplicateParts),s=Q(e=>e.rotateParts),c=Q(e=>e.pushHistory),l=YS();if(!t)return null;let u=Yx[t.type],d=t.type===`netPot`?l.netPots.find(t=>t.partId===e):void 0,f=d?n[d.sourcePartId]:void 0,p=(n,i)=>{c(`pos:${e}:${n}`);let a=[...t.position];a[n]=n===1?Math.max(0,i):i,r(e,{position:a})},m=(n,i)=>{c(`rot:${e}:${n}`);let a=[...t.rotation];a[n]=ZT(i),r(e,{rotation:a})},h=Object.entries(u.params).filter(([e])=>(t.type!==`pump`||!nE.has(e))&&(t.type!==`airCompressor`||!rE.has(e))&&(t.type!==`reservoir`||!iE.has(e)));return(0,Z.jsxs)(`div`,{className:`flex-1 space-y-4 overflow-y-auto px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`h-3 w-3 rounded`,style:{backgroundColor:t.color??u.color}}),(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-zinc-200`,children:u.label}),(0,Z.jsxs)(`span`,{className:`ml-auto font-mono text-[10px] text-zinc-600`,children:[`#`,t.id]})]}),(0,Z.jsx)(`input`,{value:t.label??``,placeholder:`Name this part…`,onChange:t=>r(e,{label:t.target.value}),className:`w-full rounded-md border border-zinc-800 bg-zinc-900 px-2 py-1.5 text-xs text-zinc-200 placeholder-zinc-600 outline-none focus:border-sky-600`})]}),t.type===`pump`&&(0,Z.jsx)(aE,{part:t}),t.type===`airCompressor`&&(0,Z.jsx)(oE,{part:t}),t.type===`reservoir`&&(0,Z.jsx)(cE,{part:t}),t.type===`growTent`&&(0,Z.jsx)(sE,{part:t}),t.type===`netPot`&&d&&(0,Z.jsx)(dE,{title:`Hydraulics`,children:(0,Z.jsxs)(`div`,{className:`rounded-lg border px-3 py-2.5 ${d.overflowing?`border-rose-900/70 bg-rose-950/40`:`border-amber-900/60 bg-amber-950/30`}`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold ${d.overflowing?`text-rose-300`:`text-amber-300`}`,children:d.overflowing?`Pot overflow active`:`Pot near overflow`}),(0,Z.jsxs)(`p`,{className:`mt-1 text-[11px] leading-snug text-zinc-400`,children:[`Water under this pot is coming from `,f?Yx[f.type].label:`the flooded line`,` at`,` `,d.inflowGph.toFixed(0),` GPH. Water height is `,d.waterHeightFt.toFixed(2),` ft and the rim is `,d.rimHeightFt.toFixed(2),` ft.`]}),(0,Z.jsxs)(`p`,{className:`mt-1.5 rounded-md bg-zinc-900/80 px-2 py-1 text-[11px] leading-snug text-zinc-300`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-sky-400`,children:`Fix: `}),`Add drainage or move the pot off the backed-up run.`]})]})}),(0,Z.jsx)(dE,{title:`Position (ft)`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-3 gap-1.5`,children:[`X`,`Y`,`Z`].map((e,n)=>(0,Z.jsx)(fE,{label:e,value:t.position[n],step:.25,onChange:e=>p(n,e)},e))})}),(0,Z.jsxs)(dE,{title:`Rotation (°)`,children:[(0,Z.jsx)(`div`,{className:`grid grid-cols-3 gap-1.5`,children:[`X`,`Y`,`Z`].map((e,n)=>(0,Z.jsx)(fE,{label:e,value:XT(t.rotation[n]),step:15,onChange:e=>m(n,e)},e))}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex gap-1.5`,children:[(0,Z.jsx)(pE,{onClick:()=>s([e],1,Math.PI/2),children:`⟳ 90° Y`}),(0,Z.jsx)(pE,{onClick:()=>s([e],2,Math.PI/2),children:`⟳ 90° Z`}),(0,Z.jsx)(pE,{onClick:()=>r(e,{rotation:[0,0,0]}),children:`Reset`})]})]}),h.length>0&&(0,Z.jsx)(dE,{title:`Parameters`,children:(0,Z.jsx)(`div`,{className:`space-y-2.5`,children:h.map(([n,r])=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`text-zinc-400`,children:r.label}),(0,Z.jsxs)(`span`,{className:`font-mono text-sky-400`,children:[t.params[n]??u.defaults[n],r.unit?` ${r.unit}`:``]})]}),n===`diameter`||n===`diameterA`||n===`diameterB`?(0,Z.jsx)(`select`,{value:String(Jx(t.params[n]??u.defaults[n])),onChange:t=>i(e,n,parseFloat(t.target.value)),className:`w-full rounded-md border border-zinc-800 bg-zinc-900 px-2 py-1.5 text-[11px] text-zinc-200 outline-none focus:border-sky-600`,children:Wx.map(e=>(0,Z.jsxs)(`option`,{value:e,children:[e,` in`]},e))}):(0,Z.jsx)(`input`,{type:`range`,min:r.min,max:r.max,step:r.step,value:t.params[n]??u.defaults[n],onChange:t=>i(e,n,parseFloat(t.target.value)),className:`w-full accent-sky-500`})]},n))})}),(0,Z.jsx)(dE,{title:`Color`,children:(0,Z.jsx)(JT,{ids:[e]})}),(0,Z.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,Z.jsx)(`button`,{onClick:()=>o([e]),title:`Duplicate this part (D)`,className:`flex-1 rounded-md border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-xs font-medium text-zinc-200 hover:bg-zinc-700`,children:`Duplicate`}),(0,Z.jsx)(`button`,{onClick:()=>a([e]),title:`Delete this part (⌫)`,className:`flex-1 rounded-md border border-rose-900 bg-rose-950 px-2 py-1.5 text-xs font-medium text-rose-300 hover:bg-rose-900`,children:`Delete`})]})]})}function dE({title:e,children:t}){return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`mb-1.5 text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:e}),t]})}function fE({label:e,value:t,step:n,onChange:r}){return(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 rounded-md border border-zinc-800 bg-zinc-900 px-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-bold text-zinc-600`,children:e}),(0,Z.jsx)(`input`,{type:`number`,value:Number(t.toFixed(2)),step:n,onChange:e=>{let t=parseFloat(e.target.value);Number.isNaN(t)||r(t)},className:`w-full bg-transparent py-1.5 text-right font-mono text-[11px] text-zinc-200 outline-none`})]})}function pE({children:e,onClick:t}){return(0,Z.jsx)(`button`,{onClick:t,className:`flex-1 rounded border border-zinc-800 bg-zinc-900 px-1.5 py-1 text-[10px] text-zinc-300 hover:bg-zinc-800`,children:e})}var mE=`hydro-builder:autosave`;function hE(e,t){return{app:`hydro-builder`,version:1,name:e,savedAt:new Date().toISOString(),parts:t}}function gE(e){let t=e;if(!t||t.app!==`hydro-builder`||!Array.isArray(t.parts))throw Error(`Not a valid Hydro Builder project file.`);let n=new Set([`Plumbing`,`Flow Control`,`Growing`,`Structure`,`Environment`]);for(let e of t.parts){if(!e||typeof e!=`object`)throw Error(`Project contains invalid or null part data.`);if(typeof e.id!=`string`||!e.id)throw Error(`Part is missing a valid ID.`);if(typeof e.type!=`string`||!(e.type in Yx))throw Error(`Part ${e.id} has an invalid or unrecognized type: ${e.type}.`);let t=Yx[e.type].category;if(!n.has(t))throw Error(`Part ${e.id} has an invalid category: ${t}.`);if(!Array.isArray(e.position)||e.position.length!==3||!e.position.every(e=>typeof e==`number`&&Number.isFinite(e)))throw Error(`Part ${e.id} must have a position with an array of 3 numbers.`);if(!Array.isArray(e.rotation)||e.rotation.length!==3||!e.rotation.every(e=>typeof e==`number`&&Number.isFinite(e)))throw Error(`Part ${e.id} must have a rotation with an array of 3 numbers.`)}let r=t.parts;return _E(t.name??`Imported project`,r,t.savedAt)}function _E(e,t,n){return{app:`hydro-builder`,version:1,name:e,savedAt:n??new Date().toISOString(),parts:t}}function vE(e,t,n){try{let r=n?`hydro-builder:autosave:${n}`:mE;localStorage.setItem(r,JSON.stringify(hE(e,t)))}catch{}}function yE(e){try{let t=e?`hydro-builder:autosave:${e}`:mE,n=localStorage.getItem(t);return n?gE(JSON.parse(n)):null}catch{return null}}function bE(e,t){let n=new Blob([JSON.stringify(hE(e,t),null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.replace(/[^a-z0-9-_ ]/gi,``).trim()||`hydro-system`}.json`,i.click(),URL.revokeObjectURL(r)}async function xE(e){let t=await e.text();return gE(JSON.parse(t))}var SE=(0,v.createContext)(void 0),CE=({children:e})=>{let[t,n]=(0,v.useState)(localStorage.getItem(`hydro-token`)),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(null),l=async e=>{try{let t=await fetch(`/api/auth/me`,{headers:{Authorization:`Bearer ${e}`}});t.ok?i((await t.json()).user):f()}catch(e){console.error(`Error fetching user info:`,e)}finally{o(!1)}};(0,v.useEffect)(()=>{t?l(t):(i(null),o(!1));let e=new URLSearchParams(window.location.search);if(e.get(`checkout_success`)===`true`){let e=new URL(window.location.href);e.searchParams.delete(`checkout_success`),window.history.replaceState({},document.title,e.pathname),bS(`Payment successful! Your Premium Upgrade has been unlocked.`,`success`),t&&l(t)}else if(e.get(`checkout_cancel`)===`true`){let e=new URL(window.location.href);e.searchParams.delete(`checkout_cancel`),window.history.replaceState({},document.title,e.pathname),bS(`Payment cancelled.`,`info`)}},[t]);let u=async(e,t)=>{c(null);try{let r=await fetch(`/api/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,password:t})}),a=await r.json();if(!r.ok)throw Error(a.error||`Login failed`);localStorage.setItem(`hydro-token`,a.token),n(a.token),i(a.user)}catch(e){throw c(e instanceof Error?e.message:`Unknown login error`),e}},d=async(e,t)=>{c(null);try{let r=await fetch(`/api/auth/signup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,password:t})}),a=await r.json();if(!r.ok)throw Error(a.error||`Signup failed`);localStorage.setItem(`hydro-token`,a.token),n(a.token),i(a.user)}catch(e){throw c(e instanceof Error?e.message:`Unknown signup error`),e}},f=()=>{localStorage.removeItem(`hydro-token`),n(null),i(null)};return(0,Z.jsx)(SE.Provider,{value:{token:t,user:r,loading:a,error:s,login:u,signup:d,logout:f,refreshProfile:async()=>{t&&await l(t)},clearError:()=>{c(null)}},children:e})},wE=()=>{let e=(0,v.useContext)(SE);if(e===void 0)throw Error(`useAuth must be used within an AuthProvider`);return e},TE=({onClose:e})=>{let{token:t,user:n}=wE(),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(null);return(0,Z.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center bg-zinc-950/80 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-md overflow-hidden rounded-2xl border border-zinc-850 bg-zinc-900 shadow-2xl`,children:[(0,Z.jsx)(`div`,{className:`h-2 bg-gradient-to-r from-sky-400 via-blue-500 to-indigo-600`}),(0,Z.jsxs)(`div`,{className:`p-8`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,Z.jsx)(`div`,{className:`mb-4 grid h-14 w-14 place-items-center rounded-full bg-sky-500/10 text-2xl text-sky-400`,children:`💎`}),(0,Z.jsx)(`h3`,{className:`text-xl font-bold text-zinc-100`,children:`Unlock Premium Features`}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 leading-relaxed px-2`,children:`Free profiles do not have auto-saves or cloud build spaces. Upgrade to Premium permanently to enable browser auto-saves and unlock 10 cloud project slots.`})]}),(0,Z.jsxs)(`div`,{className:`my-6 rounded-xl border border-zinc-800 bg-zinc-950/50 p-5 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-semibold text-sky-400 uppercase tracking-wider`,children:`Premium Lifetime Upgrade`}),(0,Z.jsxs)(`div`,{className:`mt-2 flex items-baseline justify-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-3xl font-black text-zinc-100`,children:`$5`}),(0,Z.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`one-time purchase`})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-1.5 text-left text-xs text-zinc-400 border-t border-zinc-850 pt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Slots Owned:`}),(0,Z.jsx)(`span`,{className:`font-semibold text-zinc-200`,children:n&&n.purchased_slots>0?10:0})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Active Projects:`}),(0,Z.jsx)(`span`,{className:`font-semibold text-zinc-200`,children:n?.project_count??0})]})]})]}),a&&(0,Z.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/15 bg-red-500/5 p-3 text-xs text-red-400`,children:a}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,Z.jsx)(`div`,{className:`w-full flex justify-center py-1`,children:(0,Z.jsx)(`stripe-buy-button`,{"buy-button-id":`buy_btn_1ThubIDPQ7Y9c4bKgoRwZuIm`,"publishable-key":`pk_live_51ThuN5DPQ7Y9c4bKvvcy6bl6FuoQufKFWNYdkaXwINzWiEqyPlrU2WwO2mlCpKtuGXkBfKfozBVfT0aTBTU0TdLm00LIvAP3si`,"client-reference-id":String(n.id)})}),(0,Z.jsx)(`button`,{onClick:e,className:`w-full rounded-lg bg-zinc-800/60 py-2.5 text-xs font-medium text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200 transition cursor-pointer`,children:`Cancel`})]})]})]})})},EE=Sy(e=>({status:`saved`,setStatus:t=>e({status:t})}));function DE(){let e=EE(e=>e.status);return e===`saved`?(0,Z.jsx)(`span`,{title:`All changes saved to browser`,className:`h-2 w-2 rounded-full bg-emerald-500 transition-colors duration-300 shrink-0`}):e===`saving`?(0,Z.jsx)(`span`,{title:`Saving changes...`,className:`h-2 w-2 rounded-full bg-amber-500 animate-pulse shrink-0`}):(0,Z.jsx)(`span`,{title:`Unsaved changes`,className:`h-2 w-2 rounded-full bg-amber-500 shrink-0`})}function OE({onOpenBom:e,onCheckBuild:t}){let{token:n,user:r,logout:i,refreshProfile:a}=wE(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(!1),f=Q(e=>e.projectName),p=Q(e=>e.setProjectName),m=Q(e=>e.growthStage),h=Q(e=>e.setGrowthStage),g=Q(e=>e.viewMode),_=Q(e=>e.setViewMode),y=Q(e=>e.renderMode),b=Q(e=>e.setRenderMode),x=Q(e=>e.tool),S=Q(e=>e.setTool),C=Q(e=>e.showFlow),w=Q(e=>e.toggleFlow),T=Q(e=>e.simRunning),E=Q(e=>e.toggleSimRunning),D=Q(e=>e.snapToGrid),O=Q(e=>e.toggleSnap),k=Q(e=>e.undo),A=Q(e=>e.redo),j=Q(e=>e.past.length>0),M=Q(e=>e.future.length>0),N=Q(e=>e.autoCapOpenEnds),P=Q(e=>e.rooms),F=Q(e=>e.activeRoomId),I=Q(e=>e.addRoom),L=Q(e=>e.removeRoom),ee=Q(e=>e.setActiveRoomId),R=(0,v.useRef)(null),[te,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(!1),ne=async()=>{if(n){d(!0);try{let e=await fetch(`/api/projects`,{headers:{Authorization:`Bearer ${n}`}});e.ok&&l(await e.json())}catch(e){console.error(`Failed to fetch projects`,e)}finally{d(!1)}}};(0,v.useEffect)(()=>{te&&ne()},[te]);let re=async()=>{if(!n)return;let e=Q.getState(),t=Object.values(e.parts);try{let r=await fetch(`/api/projects`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${n}`},body:JSON.stringify({name:e.projectName,parts:t})}),i=await r.json();if(!r.ok){r.status===402?s(!0):bS(i.error||`Failed to save project`,`error`);return}await a(),bS(`Project saved successfully!`,`success`)}catch(e){bS(`Save failed: `+e,`error`)}},ie=e=>{let t=c.find(t=>t.name===e);t&&Q.getState().loadParts(t.parts,t.name),z(!1)},ae=async(e,t)=>{if(e.stopPropagation(),!(!n||!confirm(`Delete project "${t}" permanently?`)))try{let e=await fetch(`/api/projects/${encodeURIComponent(t)}`,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`}});e.ok?(await ne(),await a(),bS(`Project deleted successfully`,`success`)):bS((await e.json()).error||`Failed to delete project`,`error`)}catch(e){bS(`Delete failed: `+e,`error`)}},oe=()=>{let e=Q.getState();bE(e.projectName,Object.values(e.parts))},se=async e=>{try{let t=await xE(e);Q.getState().loadParts(t.parts,t.name),bS(`Project imported successfully`,`success`)}catch(e){bS(e instanceof Error?e.message:`Import failed`,`error`)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-zinc-800 bg-zinc-950 px-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pr-2`,children:[(0,Z.jsx)(`span`,{className:`grid h-7 w-7 place-items-center rounded-lg bg-gradient-to-br from-sky-500 to-blue-700 text-sm font-black text-white`,children:`H`}),(0,Z.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),className:`w-44 rounded-md border border-transparent bg-transparent px-1.5 py-1 text-sm font-semibold text-zinc-100 outline-none hover:border-zinc-800 focus:border-sky-700 focus:bg-zinc-900`}),(0,Z.jsx)(DE,{})]}),(0,Z.jsx)(kE,{}),(0,Z.jsx)(AE,{onClick:()=>{confirm(`Start a new empty project? Unsaved changes are kept in undo history.`)&&(Q.getState().clearAll(),p(`Untitled system`))},title:`New empty project`,children:`New`}),(0,Z.jsx)(AE,{onClick:re,title:`Save to cloud storage`,children:`Save`}),(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(AE,{onClick:()=>z(e=>!e),title:`Load a saved project`,children:`Load ▾`}),te&&(0,Z.jsxs)(`div`,{className:`absolute top-9 left-0 z-50 max-h-72 w-64 overflow-y-auto rounded-lg border border-zinc-700 bg-zinc-900 p-1 shadow-2xl`,children:[u&&(0,Z.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Loading...`}),!u&&c.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`No saved projects yet.`}),!u&&c.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-md px-3 py-1.5 hover:bg-zinc-800 group`,children:[(0,Z.jsxs)(`button`,{onClick:()=>ie(e.name),className:`flex-1 text-left text-xs text-zinc-200 outline-none`,children:[e.name,(0,Z.jsx)(`span`,{className:`block text-[10px] text-zinc-500`,children:new Date(e.savedAt).toLocaleString()})]}),(0,Z.jsx)(`button`,{onClick:t=>ae(t,e.name),className:`hidden group-hover:block text-[10px] text-red-400 hover:text-red-300 px-2 py-0.5 rounded bg-zinc-950/40`,title:`Delete project`,children:`✕`})]},e.name))]})]}),(0,Z.jsx)(AE,{onClick:oe,title:`Download design as JSON`,children:`Export`}),(0,Z.jsx)(AE,{onClick:()=>R.current?.click(),title:`Import a design JSON`,children:`Import`}),(0,Z.jsx)(AE,{onClick:()=>V(!0),title:`Show Keyboard Shortcuts`,children:`⌨️ Shortcuts`}),(0,Z.jsx)(`input`,{ref:R,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&se(t),e.target.value=``}}),(0,Z.jsx)(kE,{}),(0,Z.jsx)(AE,{onClick:e,title:`Open bill of materials`,children:`BOM`}),(0,Z.jsx)(AE,{onClick:t,title:`Run design validation`,children:`Check Build`}),(0,Z.jsx)(AE,{onClick:()=>N(),title:`Add caps to every loose plumbing end`,children:`Auto Cap`}),(0,Z.jsx)(kE,{}),(0,Z.jsx)(AE,{onClick:k,disabled:!j,title:`Undo (⌘Z)`,children:`↶`}),(0,Z.jsx)(AE,{onClick:A,disabled:!M,title:`Redo (⇧⌘Z)`,children:`↷`}),(0,Z.jsx)(kE,{}),(0,Z.jsx)(AE,{active:x===`measure`,onClick:()=>S(x===`measure`?`select`:`measure`),title:`Measure: click two points in the scene`,children:`📏 Measure`}),(0,Z.jsx)(AE,{active:x===`pipeRun`,onClick:()=>S(x===`pipeRun`?`select`:`pipeRun`),title:`Pipe Run: click two ground points`,children:`Pipe Run`}),(0,Z.jsx)(AE,{active:D,onClick:O,title:`Snap to grid (0.25 ft)`,children:`⌗ Snap`}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Z.jsx)(`button`,{onClick:E,title:T?`Pause water simulation (Space)`:`Run water simulation (Space)`,className:`grid h-8 w-8 shrink-0 place-items-center rounded-full text-white shadow-lg transition-all hover:scale-110 active:scale-95 ${T?`bg-emerald-500 shadow-emerald-500/40 hover:bg-emerald-400`:`bg-sky-600 shadow-sky-600/40 hover:bg-sky-500`}`,children:T?(0,Z.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:`h-3.5 w-3.5`,fill:`currentColor`,children:[(0,Z.jsx)(`rect`,{x:`3`,y:`2.5`,width:`3.4`,height:`11`,rx:`1`}),(0,Z.jsx)(`rect`,{x:`9.6`,y:`2.5`,width:`3.4`,height:`11`,rx:`1`})]}):(0,Z.jsx)(`svg`,{viewBox:`0 0 16 16`,className:`ml-0.5 h-3.5 w-3.5`,fill:`currentColor`,children:(0,Z.jsx)(`path`,{d:`M4 2.8a1 1 0 0 1 1.52-.86l8.2 5.2a1 1 0 0 1 0 1.7l-8.2 5.2A1 1 0 0 1 4 13.2V2.8Z`})})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 bg-zinc-900 border border-zinc-800 rounded-lg px-2.5 py-1`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] uppercase font-bold text-zinc-400`,children:`Stage`}),(0,Z.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),className:`bg-transparent text-xs text-zinc-200 outline-none border-none cursor-pointer pr-1`,children:[(0,Z.jsx)(`option`,{value:`seedling`,className:`bg-zinc-900 text-zinc-200`,children:`Seedling`}),(0,Z.jsx)(`option`,{value:`vegetative`,className:`bg-zinc-900 text-zinc-200`,children:`Vegetative`}),(0,Z.jsx)(`option`,{value:`flowering`,className:`bg-zinc-900 text-zinc-200`,children:`Flowering`})]})]}),(0,Z.jsx)(AE,{active:C,onClick:w,title:`Toggle water flow animation`,children:`💧 Flow`}),(0,Z.jsx)(`div`,{className:`flex overflow-hidden rounded-lg border border-zinc-800`,children:[{id:`builder`,label:`Builder`,title:`Standard building mode`},{id:`xray`,label:`X-Ray`,title:`Transparent shell with internal water visibility`},{id:`water`,label:`Water`,title:`Water-first view with solids faded back`}].map(e=>(0,Z.jsx)(`button`,{onClick:()=>b(e.id),title:e.title,className:`px-3 py-1.5 text-xs font-medium transition ${y===e.id?`bg-cyan-600 text-white`:`bg-zinc-900 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200`}`,children:e.label},e.id))}),(0,Z.jsx)(`div`,{className:`flex overflow-hidden rounded-lg border border-zinc-800`,children:[{id:`orbit`,label:`3D`,title:`Free 3D orbit view`},{id:`top`,label:`Top`,title:`Top-down plan view`},{id:`front`,label:`Front`,title:`Front elevation view`},{id:`side`,label:`Side`,title:`Side elevation view`}].map(e=>(0,Z.jsx)(`button`,{onClick:()=>_(e.id),title:e.title,className:`px-3 py-1.5 text-xs font-medium transition ${g===e.id?`bg-sky-600 text-white`:`bg-zinc-900 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200`}`,children:e.label},e.id))}),r&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kE,{}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-end`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-semibold text-zinc-300 max-w-24 truncate`,children:r.email}),(0,Z.jsxs)(`span`,{className:`text-[9px] font-bold uppercase ${r.total_slots===0||r.project_count>=r.total_slots?`text-amber-400`:`text-emerald-400`}`,children:[r.project_count,` / `,r.total_slots,` Slots`]})]}),r.total_slots===0?(0,Z.jsx)(`button`,{onClick:()=>s(!0),className:`rounded bg-gradient-to-r from-sky-500/20 to-blue-500/20 hover:from-sky-500/30 hover:to-blue-500/30 text-sky-300 border border-sky-700 px-2 py-1 text-[10px] font-bold transition cursor-pointer flex items-center gap-1 shadow-lg`,children:`💎 Upgrade`}):r.project_count>=r.total_slots&&(0,Z.jsx)(`button`,{onClick:()=>s(!0),className:`rounded bg-amber-500/20 hover:bg-amber-500/30 text-amber-300 border border-amber-600/30 px-2 py-1 text-[10px] font-semibold transition cursor-pointer`,children:`+ Add Slot`}),(0,Z.jsx)(`button`,{onClick:i,className:`rounded border border-zinc-800 bg-zinc-900 px-2 py-1 text-[10px] font-medium text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200 transition cursor-pointer`,children:`Logout`})]})]})]}),o&&(0,Z.jsx)(TE,{onClose:()=>s(!1)}),B&&(0,Z.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center bg-zinc-950/80 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-800 bg-zinc-900 p-6 shadow-2xl text-left`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-bold text-zinc-100 mb-4 flex items-center gap-1.5 border-b border-zinc-800 pb-2`,children:`⌨️ Keyboard Shortcuts`}),(0,Z.jsxs)(`div`,{className:`space-y-2.5 text-xs text-zinc-400`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between border-b border-zinc-800/40 pb-1.5`,children:[(0,Z.jsx)(`span`,{children:`Undo / Redo`}),(0,Z.jsx)(`span`,{className:`font-mono bg-zinc-950 px-1.5 py-0.5 rounded text-zinc-300`,children:`⌘Z / ⌘Y`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between border-b border-zinc-800/40 pb-1.5`,children:[(0,Z.jsx)(`span`,{children:`Rotate Selected`}),(0,Z.jsx)(`span`,{className:`font-mono bg-zinc-950 px-1.5 py-0.5 rounded text-zinc-300`,children:`R`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between border-b border-zinc-800/40 pb-1.5`,children:[(0,Z.jsx)(`span`,{children:`Duplicate Selected`}),(0,Z.jsx)(`span`,{className:`font-mono bg-zinc-950 px-1.5 py-0.5 rounded text-zinc-300`,children:`D`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between border-b border-zinc-800/40 pb-1.5`,children:[(0,Z.jsx)(`span`,{children:`Delete Selected`}),(0,Z.jsx)(`span`,{className:`font-mono bg-zinc-950 px-1.5 py-0.5 rounded text-zinc-300`,children:`⌫ / Del`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between border-b border-zinc-800/40 pb-1.5`,children:[(0,Z.jsx)(`span`,{children:`Run / Pause Sim`}),(0,Z.jsx)(`span`,{className:`font-mono bg-zinc-950 px-1.5 py-0.5 rounded text-zinc-300`,children:`Spacebar`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between border-b border-zinc-800/40 pb-1.5`,children:[(0,Z.jsx)(`span`,{children:`Pan Camera View`}),(0,Z.jsx)(`span`,{className:`font-mono bg-zinc-950 px-1.5 py-0.5 rounded text-zinc-300`,children:`Arrow Keys`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between border-b border-zinc-800/40 pb-1.5`,children:[(0,Z.jsx)(`span`,{children:`Clear Selection & Tool`}),(0,Z.jsx)(`span`,{className:`font-mono bg-zinc-950 px-1.5 py-0.5 rounded text-zinc-300`,children:`Esc`})]})]}),(0,Z.jsx)(`button`,{onClick:()=>V(!1),className:`mt-6 w-full rounded bg-zinc-800 py-2 text-xs font-semibold text-zinc-200 hover:bg-zinc-700 transition cursor-pointer`,children:`Close`})]})})]}),(0,Z.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between border-b border-zinc-850 bg-zinc-900/60 px-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto`,children:P.map(e=>(0,Z.jsxs)(`div`,{className:`group flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-semibold transition cursor-pointer select-none ${e.id===F?`bg-sky-500/15 text-sky-400 border border-sky-500/30`:`text-zinc-400 hover:text-zinc-200 border border-transparent`}`,onClick:()=>ee(e.id),children:[(0,Z.jsx)(`span`,{children:e.name}),P.length>1&&(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),confirm(`Delete room "${e.name}" and all its parts permanently?`)&&L(e.id)},className:`opacity-0 group-hover:opacity-100 hover:text-red-400 text-[10px] ml-1 transition`,children:`✕`})]},e.id))}),(0,Z.jsx)(`button`,{onClick:()=>{let e=prompt(`Enter room name:`,`Room ${P.length+1}`);e&&I(e.trim())},className:`rounded border border-zinc-700 bg-zinc-850 hover:bg-zinc-800 text-zinc-300 px-2.5 py-1 text-[11px] font-semibold transition flex items-center gap-1 cursor-pointer`,children:`+ Add Room`})]})]})}function kE(){return(0,Z.jsx)(`div`,{className:`mx-1 h-6 w-px bg-zinc-800`})}function AE({children:e,onClick:t,title:n,active:r,disabled:i}){return(0,Z.jsx)(`button`,{onClick:t,title:n,disabled:i,className:`rounded-md px-2.5 py-1.5 text-xs font-medium transition disabled:cursor-default disabled:opacity-30
|
||
${r?`bg-sky-500/15 text-sky-300 ring-1 ring-sky-700`:`text-zinc-300 hover:bg-zinc-800`}`,children:e})}var jE={error:`border-rose-900/60 bg-rose-950/60 text-rose-300`,warning:`border-amber-900/60 bg-amber-950/50 text-amber-300`,info:`border-sky-900/60 bg-sky-950/50 text-sky-300`},ME={error:`⛔`,warning:`⚠️`,info:`ℹ️`};function NE(){let e=YS(),t=Q(e=>Object.keys(e.parts).length),n=Q(e=>e.parts),r=Q(e=>e.setSelected),i=Q(e=>e.simRunning),a=Q(e=>e.toggleSimRunning),o=Q(e=>e.heatmapMode),s=Q(e=>e.toggleHeatmapMode),c=(0,v.useMemo)(()=>KT(n),[n]),l=(0,v.useMemo)(()=>Object.values(n).filter(e=>e.type===`reservoir`),[n]),u=(0,v.useMemo)(()=>l.map(e=>nC(e,n)),[l,n]),d=e.totalGph*3.785,f=e.pumps.some(e=>e.running),p=Math.max(0,...Object.values(e.velocities)),m=Math.max(0,...Object.values(e.pressures));return(0,Z.jsxs)(`footer`,{className:`flex h-36 shrink-0 border-t border-zinc-800 bg-zinc-950/90 backdrop-blur`,children:[(0,Z.jsxs)(`div`,{className:`flex w-56 shrink-0 flex-col justify-center gap-1 border-r border-zinc-800 px-4`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Simulation`}),(0,Z.jsxs)(`div`,{className:`text-2xl font-bold text-sky-400 tabular-nums`,children:[e.totalGph.toFixed(0),(0,Z.jsx)(`span`,{className:`ml-1 text-xs font-medium text-zinc-500`,children:`GPH`})]}),(0,Z.jsxs)(`div`,{className:`text-[11px] text-zinc-500 tabular-nums`,children:[`≈ `,d.toFixed(0),` L/h · `,t,` parts · `,e.connectionCount,` connections`]}),(0,Z.jsxs)(`div`,{className:`text-[10px] text-zinc-600 tabular-nums`,children:[`peak `,p.toFixed(1),` ft/s · `,m.toFixed(1),` psi`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,Z.jsxs)(`button`,{onClick:a,title:i?`Pause simulation (Space)`:`Resume simulation (Space)`,className:`inline-flex w-fit cursor-pointer items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-semibold transition hover:brightness-125 ${i?f?`bg-emerald-950 text-emerald-400 ring-1 ring-emerald-800`:`bg-zinc-900 text-zinc-500 ring-1 ring-zinc-800`:`bg-amber-950 text-amber-400 ring-1 ring-amber-800`}`,children:[(0,Z.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5`,children:[i&&f&&(0,Z.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,Z.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-current`})]}),i?f?`Water flowing`:`System idle`:`⏸ Paused`]}),(0,Z.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-[10px] font-semibold text-zinc-400 hover:text-zinc-200`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:o,onChange:s,className:`accent-sky-500 cursor-pointer h-3 w-3 rounded border-zinc-700 bg-zinc-850`}),(0,Z.jsx)(`span`,{children:`Heatmap`})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex w-72 shrink-0 flex-col gap-1.5 overflow-y-auto border-r border-zinc-800 px-4 py-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Pumps`}),e.pumps.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-zinc-600`,children:`No pumps in the system.`}),e.pumps.map(e=>(0,Z.jsxs)(`button`,{onClick:()=>r(e.pumpId),className:`rounded-md border border-zinc-800 bg-zinc-900/70 px-2.5 py-1.5 text-left hover:border-zinc-600`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Z.jsxs)(`span`,{className:`text-xs font-semibold text-zinc-200`,children:[e.gph>0?`${e.gph.toFixed(0)} GPH`:`No flow`,(0,Z.jsxs)(`span`,{className:`ml-1 text-[10px] font-normal text-zinc-500`,children:[`/ `,e.ratedGph,` rated`]})]}),(0,Z.jsxs)(`span`,{className:`font-mono text-[10px] text-zinc-500`,children:[`head `,e.headFt.toFixed(1),`/`,e.maxHeadFt,` ft`]})]}),(0,Z.jsx)(`div`,{className:`mt-1 h-1 overflow-hidden rounded-full bg-zinc-800`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full ${e.gph/e.ratedGph>.5?`bg-emerald-500`:e.gph>0?`bg-amber-500`:`bg-rose-600`}`,style:{width:`${Math.max(2,e.gph/e.ratedGph*100)}%`}})})]},e.pumpId))]}),(0,Z.jsxs)(`div`,{className:`flex w-80 shrink-0 flex-col gap-1 overflow-y-auto border-r border-zinc-800 px-4 py-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Environment`}),c.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-zinc-600`,children:`Add a grow tent/room to track air exchange.`}):c.map(e=>(0,Z.jsxs)(`button`,{onClick:()=>r(e.roomId),className:`rounded-md border border-zinc-800 bg-zinc-900/70 px-2.5 py-1.5 text-left hover:border-zinc-600`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-semibold text-zinc-200`,children:e.label}),(0,Z.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${e.sealed?`bg-emerald-950 text-emerald-300 ring-1 ring-emerald-800`:`bg-sky-950 text-sky-300 ring-1 ring-sky-800`}`,children:e.sealed?`Sealed`:`Open air`})]}),(0,Z.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-400 tabular-nums`,children:[e.volumeFt3.toFixed(0),` ft3 · `,e.exhaustCfm.toFixed(0),` exhaust CFM`]}),(0,Z.jsxs)(`div`,{className:`text-[10px] text-zinc-500 tabular-nums`,children:[e.airChangesPerMinute.toFixed(2),` exchanges/min · `,e.airChangesPerHour.toFixed(1),` ACH`]}),(0,Z.jsxs)(`div`,{className:`mt-1 text-[10px] text-zinc-600 tabular-nums`,children:[`circ `,e.circulationCfm.toFixed(0),` CFM · light `,e.lightWatts.toFixed(0),` W · CO2 `,e.co2TankCount,` tank`,e.co2TankCount===1?``:`s`]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-1.5 text-[9px] font-mono`,children:[(0,Z.jsxs)(`span`,{className:`rounded bg-zinc-900 px-1 py-0.5 text-emerald-400 border border-zinc-800`,children:[`VPD `,e.roomVPD.toFixed(2),` kPa`]}),(0,Z.jsxs)(`span`,{className:`rounded bg-zinc-900 px-1 py-0.5 text-amber-400 border border-zinc-800`,children:[`DLI `,e.roomDLI.toFixed(1)]}),(0,Z.jsxs)(`span`,{className:`rounded bg-zinc-900 px-1 py-0.5 text-sky-400 border border-zinc-800`,children:[`CO₂ `,e.roomCo2,` ppm`]})]})]},e.roomId))]}),(0,Z.jsxs)(`div`,{className:`flex w-56 shrink-0 flex-col justify-center gap-1.5 border-r border-zinc-800 px-4 py-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Room Readout`}),c.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-zinc-600`,children:`No room placed`}):(()=>{let e=c[0];return(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 text-[10px] font-mono tabular-nums`,children:[(0,Z.jsxs)(`span`,{className:`rounded bg-zinc-900 px-1.5 py-0.5 border border-zinc-800 text-rose-400`,children:[`🌡️ `,e.roomTempF.toFixed(0),`°F`]}),(0,Z.jsxs)(`span`,{className:`rounded bg-zinc-900 px-1.5 py-0.5 border border-zinc-800 text-sky-400`,children:[`💧 `,e.roomRH.toFixed(0),`%`]}),(0,Z.jsxs)(`span`,{className:`rounded bg-zinc-900 px-1.5 py-0.5 border border-zinc-800 text-emerald-400`,children:[`VPD `,e.roomVPD.toFixed(2)]}),(0,Z.jsxs)(`span`,{className:`rounded bg-zinc-900 px-1.5 py-0.5 border border-zinc-800 text-sky-400`,children:[`CO₂ `,e.roomCo2]}),(0,Z.jsxs)(`span`,{className:`rounded bg-zinc-900 px-1.5 py-0.5 border border-zinc-800 text-amber-400`,children:[`☀️ `,e.roomPPFD.toFixed(0)]})]})})()]}),(0,Z.jsxs)(`div`,{className:`flex w-72 shrink-0 flex-col gap-1.5 overflow-y-auto border-r border-zinc-800 px-4 py-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Aeration & Water`}),u.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-zinc-600`,children:`No reservoirs in the system.`}),u.map(t=>(0,Z.jsxs)(`button`,{onClick:()=>r(t.id),className:`rounded-md border border-zinc-800 bg-zinc-900/70 px-2.5 py-1.5 text-left hover:border-zinc-600`,children:[(()=>{let n=e.reservoirRuntime[t.id];return n?(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-[9px] font-mono`,children:[(0,Z.jsxs)(`span`,{className:`${n.empty?`text-rose-400`:`text-sky-400`}`,children:[n.gallonsCurrent.toFixed(1),` / `,n.gallonsCapacity.toFixed(1),` gal`]}),(0,Z.jsx)(`span`,{className:`text-zinc-500`,children:n.minutesRemaining===null?`steady`:`${n.minutesRemaining.toFixed(1)} min left`})]}):null})(),(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-semibold text-zinc-200`,children:t.label}),(0,Z.jsxs)(`span`,{className:`font-mono text-[10px] text-zinc-500`,children:[t.volGal.toFixed(1),` Gal`]})]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-[10px] text-zinc-400`,children:[(0,Z.jsxs)(`span`,{children:[`Aeration: `,t.activeAerationGph,` GPH`]}),(0,Z.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] font-bold ${t.tdo>=8?`bg-emerald-950 text-emerald-400 border border-emerald-800/30`:t.tdo>=7?`bg-sky-950 text-sky-300 border border-sky-800/30`:`bg-amber-950 text-amber-400 border border-amber-800/30 animate-pulse`}`,children:[t.tdo.toFixed(1),` mg/L`]})]}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex justify-between text-[9px] text-zinc-500 font-mono`,children:[(0,Z.jsxs)(`span`,{className:t.tempF>73?`text-amber-400 font-semibold`:`text-zinc-500`,children:[`Temp: `,t.tempF.toFixed(1),`°F`]}),(0,Z.jsxs)(`span`,{className:t.ph<5.5||t.ph>6.5?`text-amber-400 font-semibold`:`text-zinc-500`,children:[`pH: `,t.ph.toFixed(1)]}),(0,Z.jsxs)(`span`,{className:t.ec<.8||t.ec>2?`text-amber-400 font-semibold`:`text-zinc-500`,children:[`EC: `,t.ec.toFixed(1)]})]})]},t.id))]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 overflow-y-auto px-4 py-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Diagnostics`}),e.warnings.length===0?(0,Z.jsx)(`p`,{className:`flex items-center gap-1.5 text-xs text-emerald-400`,children:`✓ System healthy — no issues detected.`}):e.warnings.map((e,t)=>(0,Z.jsxs)(`button`,{onClick:()=>e.partId&&r(e.partId),className:`rounded-md border px-2.5 py-1 text-left text-[11px] leading-snug ${jE[e.level]} ${e.partId?`cursor-pointer hover:brightness-125`:`cursor-default`}`,children:[ME[e.level],` `,e.message]},t))]})]})}var PE=[[.5,.45],[.75,.55],[1,.75],[1.25,.95],[1.5,1.1],[2,1.55],[3,2.9],[4,3.8]];function FE(e){for(let[t,n]of PE)if(e<=t)return n;return 3.8+(e-4)*1}function IE(e){return UE(FE(e)*(120/12))}var LE={elbow:[.6,1.4,3.6],tee:[.85,1.9,4.6],cross:[1.6,3.2,7.5],yJoint:[1.4,2.8,6.5],wye:[1.4,2.8,6.5],reducer:[.9,1.8,4.2],coupling:[.45,.95,2.4],valve:[6,11,24],emitter:[1.25,1.25,1.25],reverseOsmosis:[15,30,65],generic:[1,2,5]};function RE(e,t){let n=LE[e];return n?n[t<=1?0:t<=2?1:2]:null}function zE(e){return e<=200?18:e<=400?28:e<=800?45:e<=1200?70:110}function BE(e){return e<=10?15:e<=20?25:e<=40?45:e<=75?80:130}var VE=e=>e*7.48052;function HE(e,t){switch(e){case`pump`:return zE(t.gph??400);case`reservoir`:return BE(VE((t.width??2)*(t.depth??1.4)*(t.height??1)));case`tower`:return UE(18+(t.height??4)*5+(t.sites??6)*1);case`tray`:return UE(12+(t.length??3)*(t.width??1.2)*6);case`wallPanel`:return UE(20+(t.rows??4)*(t.cols??5)*3);case`lattice`:return UE(10+(t.width??2.5)*(t.height??3)*4);case`netPot`:return UE(.75*(t.size??1));case`drain`:return(t.capacityGph??250)<=250?8:14;case`growTent`:case`tent`:return UE(90+(t.width??4)*(t.depth??4)*(t.height??6.5)*1.2);case`light`:case`growLight`:return UE(40+(t.watts??100)*.6);default:return null}}var UE=e=>Math.round(e*100)/100;function WE(e){let t=[],n=new Map,r=new Map;for(let t of e)t.type===`pipe`?lD(n,t.params.diameter??1,t):lD(r,KE(t),t);let i=[];for(let[e,r]of[...n.entries()].sort((e,t)=>e[0]-t[0])){let n=XE(e,r);i.push(n);let a=IE(e);if(t.push({key:`pipe:${e}`,partType:`pipe`,category:eD(`pipe`),description:`${iD(e)} PVC Pipe — 10 ft stick`,spec:`${aD(n.totalCutIn)} total run, ${n.cuts.length} cuts across ${r.length} pipe${r.length===1?``:`s`}`,qty:n.sticksToBuy,unit:`stick`,unitCost:a,totalCost:UE(a*n.sticksToBuy),estimated:!1,partIds:r.map(e=>e.id)}),n.spliceCount>0){let r=RE(`coupling`,e)??1;t.push({key:`coupling:${e}`,partType:`coupling`,category:eD(`pipe`),description:`${iD(e)} PVC Coupling`,spec:`splices for runs longer than 10 ft`,qty:n.spliceCount,unit:`each`,unitCost:r,totalCost:UE(r*n.spliceCount),estimated:!1,partIds:[]})}}for(let e of r.values())t.push(JE(e));tD(t);let a=new Map;for(let e of t)a.set(e.category,(a.get(e.category)??0)+e.totalCost);return{lines:t,cutLists:i,categories:[...a.entries()].map(([e,t])=>({name:e,subtotal:UE(t)})).sort((e,t)=>$E(e.name)-$E(t.name)),totalCost:UE(t.reduce((e,t)=>e+t.totalCost,0)),partCount:e.length}}var GE={pump:e=>`${e.gph??400} GPH, ${e.maxHeadFt??8} ft max head`,reservoir:e=>{let t=e.width??2,n=e.depth??1.4,r=e.height??1;return`${t} × ${n} × ${r} ft, ${VE(t*n*r).toFixed(1)} gal`},tower:e=>`${e.height??4} ft tall, ${e.sites??6} plant sites`,tray:e=>`${e.length??3} × ${e.width??1.2} ft`,wallPanel:e=>`${e.width??3} × ${e.height??4} ft, ${(e.rows??4)*(e.cols??5)} pockets`,lattice:e=>`${e.width??2.5} × ${e.height??3} ft`,netPot:e=>`size ${e.size??1}`,drain:e=>`${e.capacityGph??250} GPH capacity`};function KE(e){let t=e.params;if(e.type===`reducer`)return`${e.type}:${t.diameterA??1.5}:${t.diameterB??1}`;if(cD(t,`diameter`)&&qE(e.type)){let n=cD(t,`angle`)?`:${t.angle}`:``;return`${e.type}:${t.diameter}${n}`}let n=Object.keys(t).filter(e=>e!==`level`&&e!==`open`).sort().map(e=>`${e}=${t[e]}`).join(`,`);return`${e.type}:${n}`}function qE(e){return e in GE?!1:RE(e,1)!==null||!(e in Yx)}function JE(e){let t=e[0],{type:n,params:r}=t,i=Yx[n]?.label??nD(n),a=eD(n),o=e.length,s,c=!1,l=i,u,d=HE(n,r),f=RE(n,YE(n,r));return d===null?f!==null&&n in Yx?(s=f,cD(r,`diameter`)&&(l=`${iD(r.diameter)} ${i}`),n===`reducer`&&(l=`${iD(r.diameterA??1.5)} × ${iD(r.diameterB??1)} ${i}`),cD(r,`angle`)&&r.angle!==90&&(l+=` (${r.angle}°)`)):n in Yx&&cD(r,`diameter`)?(s=RE(`generic`,r.diameter)??5,c=!0,l=`${iD(r.diameter)} ${i}`):(s=5,c=!0,u=Object.entries(r).map(([e,t])=>`${e} ${t}`).join(`, `)||void 0):(s=d,u=GE[n]?.(r)),{key:KE(t),partType:n,category:a,description:l,spec:u,qty:o,unit:`each`,unitCost:UE(s),totalCost:UE(s*o),estimated:c,partIds:e.map(e=>e.id)}}function YE(e,t){return e===`reducer`?Math.max(t.diameterA??1.5,t.diameterB??1):t.diameter??1}function XE(e,t){let n=[],r=0;for(let e of t){let t=UE((e.params.length??2)*12);if(t<=0)continue;let i=[];for(;t>120;)i.push(120),t=UE(t-120);t>0&&i.push(t),r+=i.length-1,n.push(...i)}let i=ZE(n,120),a=UE(n.reduce((e,t)=>e+t,0));return{diameterIn:e,stickLengthIn:120,cuts:[...n].sort((e,t)=>t-e),sticks:i,sticksToBuy:i.length,totalCutIn:a,totalLeftoverIn:UE(i.reduce((e,t)=>e+t.leftoverIn,0)),spliceCount:r}}function ZE(e,t){let n=[...e].sort((e,t)=>t-e),r=[];for(let e of n){let n=!1;for(let i of r)if(i.usedIn+e<=t+1e-9){i.cuts.push(e),i.usedIn=UE(i.usedIn+e),n=!0;break}n||r.push({index:r.length+1,cuts:[e],usedIn:e,leftoverIn:0})}for(let e of r)e.leftoverIn=UE(t-e.usedIn);return r}var QE=[`Plumbing`,`Flow Control`,`Growing`,`Structure`,`Other`];function $E(e){let t=QE.indexOf(e);return t===-1?QE.length:t}function eD(e){return Yx[e]?.category??`Other`}function tD(e){e.sort((e,t)=>$E(e.category)-$E(t.category)||e.description.localeCompare(t.description))}function nD(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}var rD={"0.25":`1/4`,"0.5":`1/2`,"0.75":`3/4`,"1.25":`1-1/4`,"1.5":`1-1/2`,"1.75":`1-3/4`,"2.5":`2-1/2`,"3.5":`3-1/2`};function iD(e){return Number.isInteger(e)?`${e} in`:`${rD[String(e)]??String(e)} in`}function aD(e){let t=Math.floor(e/12),n=UE(e-t*12);return t===0?`${sD(n)}"`:n===0?`${t}'`:`${t}' ${sD(n)}"`}function oD(e){return`$${e.toFixed(2)}`}var sD=e=>String(UE(e));function cD(e,t){return typeof e[t]==`number`}function lD(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function uD(e){let t=String(e);return/[",\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}var dD=(...e)=>e.map(uD).join(`,`);function fD(e){let t=[];t.push(dD(`LINE ITEMS`)),t.push(dD(`Category`,`Item`,`Spec`,`Qty`,`Unit`,`Unit Cost`,`Total`,`Pricing`));for(let n of e.lines)t.push(dD(n.category,n.description,n.spec??``,n.qty,n.unit,n.unitCost.toFixed(2),n.totalCost.toFixed(2),n.estimated?`est.`:`listed`));if(e.cutLists.length>0){t.push(``),t.push(dD(`CUT LIST`)),t.push(dD(`Diameter`,`Stick`,`Cuts (in)`,`Used (in)`,`Leftover (in)`));for(let n of e.cutLists)for(let e of n.sticks)t.push(dD(iD(n.diameterIn),`Stick ${e.index}`,e.cuts.join(` | `),e.usedIn,e.leftoverIn))}t.push(``),t.push(dD(`TOTALS`));for(let n of e.categories)t.push(dD(n.name,n.subtotal.toFixed(2)));return t.push(dD(`Grand total`,e.totalCost.toFixed(2))),t.push(dD(`Part count`,e.partCount)),t.join(`
|
||
`)}function pD(e){let t=[],n=`─`.repeat(58);t.push(`HYDRO BUILDER — SHOPPING LIST`),t.push(`${e.partCount} parts · estimated total ${oD(e.totalCost)}`),t.push(n);let r=``;for(let n of e.lines){n.category!==r&&(r=n.category,t.push(``),t.push(`${r.toUpperCase()}`));let e=n.qty>1||n.unit===`stick`?`${n.description} ×${n.qty}`:n.description,i=`${oD(n.totalCost)}${n.estimated?` est.`:``}`;t.push(` ${e.padEnd(44)} ${i}`),n.spec&&t.push(` ${n.spec}`)}if(e.cutLists.length>0){t.push(``),t.push(n),t.push(`CUT LIST (10 ft sticks)`);for(let n of e.cutLists){t.push(``),t.push(`${iD(n.diameterIn)} PVC — buy ${n.sticksToBuy} stick${n.sticksToBuy===1?``:`s`}, ${aD(n.totalCutIn)} of cuts, ${aD(n.totalLeftoverIn)} scrap`);for(let e of n.sticks){let n=e.cuts.map(e=>aD(e)).join(`, `);t.push(` Stick ${e.index}: ${n} — ${aD(e.leftoverIn)} left`)}n.spliceCount>0&&t.push(` (${n.spliceCount} coupling${n.spliceCount===1?``:`s`} needed for runs over 10 ft)`)}}t.push(``),t.push(n);for(let n of e.categories)t.push(`${n.name.padEnd(46)} ${oD(n.subtotal)}`);return t.push(`${`TOTAL (estimated)`.padEnd(46)} ${oD(e.totalCost)}`),t.join(`
|
||
`)}function mD(e,t){let n=new Blob([fD(e)],{type:`text/csv;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.replace(/[^a-z0-9-_ ]/gi,``).trim()||`hydro-system`}-bom.csv`,i.click(),URL.revokeObjectURL(r)}function hD(e){"@babel/helpers - typeof";return hD=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},hD(e)}var gD=Uint8Array,_D=Uint16Array,vD=Int32Array,yD=new gD([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]),bD=new gD([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]),xD=new gD([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),SD=function(e,t){for(var n=new _D(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new vD(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},CD=SD(yD,2),wD=CD.b,TD=CD.r;wD[28]=258,TD[258]=28;var ED=SD(bD,0);ED.b;for(var DD=ED.r,OD=new _D(32768),kD=0;kD<32768;++kD){var AD=(kD&43690)>>1|(kD&21845)<<1;AD=(AD&52428)>>2|(AD&13107)<<2,AD=(AD&61680)>>4|(AD&3855)<<4,OD[kD]=((AD&65280)>>8|(AD&255)<<8)>>1}for(var jD=(function(e,t,n){for(var r=e.length,i=0,a=new _D(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new _D(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new _D(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[OD[d]>>c]=l}else for(s=new _D(r),i=0;i<r;++i)e[i]&&(s[i]=OD[o[e[i]-1]++]>>15-e[i]);return s}),MD=new gD(288),kD=0;kD<144;++kD)MD[kD]=8;for(var kD=144;kD<256;++kD)MD[kD]=9;for(var kD=256;kD<280;++kD)MD[kD]=7;for(var kD=280;kD<288;++kD)MD[kD]=8;for(var ND=new gD(32),kD=0;kD<32;++kD)ND[kD]=5;var PD=jD(MD,9,0),FD=jD(ND,5,0),ID=function(e){return(e+7)/8|0},LD=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new gD(e.subarray(t,n))},RD=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},zD=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},BD=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:qD,l:0};if(i==1){var o=new gD(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new _D(f+1),m=VD(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new gD(p),l:m}},VD=function(e,t,n){return e.s==-1?Math.max(VD(e.l,t,n+1),VD(e.r,t,n+1)):t[e.s]=n},HD=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new _D(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},UD=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},WD=function(e,t,n){var r=n.length,i=ID(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},GD=function(e,t,n,r,i,a,o,s,c,l,u){RD(t,u++,n),++i[256];for(var d=BD(i,15),f=d.t,p=d.l,m=BD(a,15),h=m.t,g=m.l,_=HD(f),v=_.c,y=_.n,b=HD(h),x=b.c,S=b.n,C=new _D(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=BD(C,7),E=T.t,D=T.l,O=19;O>4&&!E[xD[O-1]];--O);var k=l+5<<3,A=UD(i,MD)+UD(a,ND)+o,j=UD(i,f)+UD(a,h)+o+14+3*O+UD(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&k<=A&&k<=j)return WD(t,u,e.subarray(c,c+l));var M,N,P,F;if(RD(t,u,1+(j<A)),u+=2,j<A){M=jD(f,p,0),N=f,P=jD(h,g,0),F=h;var I=jD(E,D,0);RD(t,u,y-257),RD(t,u+5,S-1),RD(t,u+10,O-4),u+=14;for(var w=0;w<O;++w)RD(t,u+3*w,E[xD[w]]);u+=3*O;for(var L=[v,x],ee=0;ee<2;++ee)for(var R=L[ee],w=0;w<R.length;++w){var te=R[w]&31;RD(t,u,I[te]),u+=E[te],te>15&&(RD(t,u,R[w]>>5&127),u+=R[w]>>12)}}else M=PD,N=MD,P=FD,F=ND;for(var w=0;w<s;++w){var z=r[w];if(z>255){var te=z>>18&31;zD(t,u,M[te+257]),u+=N[te+257],te>7&&(RD(t,u,z>>23&31),u+=yD[te]);var B=z&31;zD(t,u,P[B]),u+=F[B],B>3&&(zD(t,u,z>>5&8191),u+=bD[B])}else zD(t,u,M[z]),u+=N[z]}return zD(t,u,M[256]),u+N[256]},KD=new vD([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),qD=new gD(0),JD=function(e,t,n,r,i,a){var o=a.z||e.length,s=new gD(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=KD[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new _D(32768),g=a.h||new _D(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new vD(25e3),x=new _D(288),S=new _D(32),C=0,w=0,T=a.i||0,E=0,D=a.w||0,O=0;T+2<o;++T){var k=y(T),A=T&32767,j=g[k];if(h[A]=j,g[k]=A,D<=T){var M=o-T;if((C>7e3||E>24576)&&(M>423||!l)){u=GD(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var N=0;N<286;++N)x[N]=0;for(var N=0;N<30;++N)S[N]=0}var P=2,F=0,I=p,L=A-j&32767;if(M>2&&k==y(T-L))for(var ee=Math.min(f,M)-1,R=Math.min(32767,T),te=Math.min(258,M);L<=R&&--I&&A!=j;){if(e[T+P]==e[T+P-L]){for(var z=0;z<te&&e[T+z]==e[T+z-L];++z);if(z>P){if(P=z,F=L,z>ee)break;for(var B=Math.min(L,z-2),V=0,N=0;N<B;++N){var ne=T-L+N&32767,re=ne-h[ne]&32767;re>V&&(V=re,j=ne)}}}A=j,j=h[A],L+=A-j&32767}if(F){b[E++]=268435456|TD[P]<<18|DD[F];var ie=TD[P]&31,ae=DD[F]&31;w+=yD[ie]+bD[ae],++x[257+ie],++S[ae],D=T+P,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T<o;++T)b[E++]=e[T],++x[e[T]];u=GD(e,c,l,b,x,S,w,E,O,T-O,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=D)}else{for(var T=a.w||0;T<o+l;T+=65535){var oe=T+65535;oe>=o&&(c[u/8|0]=l,oe=o),u=WD(c,u+1,e.subarray(T,oe))}a.i=o}return LD(s,0,r+ID(u)+i)},YD=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=n.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=r+=n[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}e=r,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},XD=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new gD(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return JD(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},ZD=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},QD=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=YD();i.p(t.dictionary),ZD(e,2,i.d())}};function $D(e,t){t||={};var n=YD();n.p(e);var r=XD(e,t,t.dictionary?6:2,4);return QD(r,t),ZD(r,r.length-4,n.d()),r}var eO=typeof TextDecoder<`u`&&new TextDecoder;try{eO.decode(qD,{stream:!0})}catch{}function tO(e){if(Array.isArray(e))return e}function nO(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function rO(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function iO(e,t){if(e){if(typeof e==`string`)return rO(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?rO(e,t):void 0}}function aO(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function oO(e,t){return tO(e)||nO(e,t)||iO(e,t)||aO()}function sO(e,t=`utf8`){return new TextDecoder(t).decode(e)}var cO=new TextEncoder;function lO(e){return cO.encode(e)}var uO=1024*8,dO=(()=>{let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),fO={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},pO=class e{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=uO,n={}){let r=!1;typeof t==`number`?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let i=n.offset?n.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof e)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),r?this.lastWrittenByte=a:this.lastWrittenByte=0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw Error(`Mark stack empty`);return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let t=(this.offset+e)*2,n=new Uint8Array(t);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=t,this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,`uint8`)}readArray(e,t){let n=fO[t].BYTES_PER_ELEMENT*e,r=this.byteOffset+this.offset,i=this.buffer.slice(r,r+n);if(this.littleEndian===dO&&t!==`uint8`&&t!==`int8`){let e=new Uint8Array(this.buffer.slice(r,r+n));e.reverse();let i=new fO[t](e.buffer);return this.offset+=n,i.reverse(),i}let a=new fO[t](i);return this.offset+=n,a}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t=``;for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return sO(this.readBytes(e))}decodeText(e=1,t=`utf8`){return sO(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(lO(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}},mO=4,hO=0,gO=1,_O=2;function vO(e){let t=e.length;for(;--t>=0;)e[t]=0}var yO=0,bO=1,xO=2,SO=29,CO=256,wO=286,TO=30,EO=19,DO=573,OO=15,kO=16,AO=7,jO=256,MO=16,NO=17,PO=18,FO=new Uint8Array([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]),IO=new Uint8Array([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]),LO=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),RO=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zO=512,BO=Array(288*2);vO(BO);var VO=Array(TO*2);vO(VO);var HO=Array(zO);vO(HO);var UO=Array(256);vO(UO);var WO=Array(SO);vO(WO);var GO=Array(TO);vO(GO);function KO(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var qO,JO,YO;function XO(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var ZO=e=>e<256?HO[e]:HO[256+(e>>>7)],QO=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},$O=(e,t,n)=>{e.bi_valid>kO-n?(e.bi_buf|=t<<e.bi_valid&65535,QO(e,e.bi_buf),e.bi_buf=t>>kO-e.bi_valid,e.bi_valid+=n-kO):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},ek=(e,t,n)=>{$O(e,n[t*2],n[t*2+1])},tk=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},nk=e=>{e.bi_valid===16?(QO(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},rk=(e,t)=>{let n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=OO;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<DO;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}},ik=(e,t,n)=>{let r=Array(16),i=0,a,o;for(a=1;a<=OO;a++)i=i+n[a-1]<<1,r[a]=i;for(o=0;o<=t;o++){let t=e[o*2+1];t!==0&&(e[o*2]=tk(r[t]++,t))}},ak=()=>{let e,t,n,r,i,a=Array(16);for(n=0,r=0;r<SO-1;r++)for(WO[r]=n,e=0;e<1<<FO[r];e++)UO[n++]=r;for(UO[n-1]=r,i=0,r=0;r<16;r++)for(GO[r]=i,e=0;e<1<<IO[r];e++)HO[i++]=r;for(i>>=7;r<TO;r++)for(GO[r]=i<<7,e=0;e<1<<IO[r]-7;e++)HO[256+ i++]=r;for(t=0;t<=OO;t++)a[t]=0;for(e=0;e<=143;)BO[e*2+1]=8,e++,a[8]++;for(;e<=255;)BO[e*2+1]=9,e++,a[9]++;for(;e<=279;)BO[e*2+1]=7,e++,a[7]++;for(;e<=287;)BO[e*2+1]=8,e++,a[8]++;for(ik(BO,287,a),e=0;e<TO;e++)VO[e*2+1]=5,VO[e*2]=tk(e,5);qO=new KO(BO,FO,257,wO,OO),JO=new KO(VO,IO,0,TO,OO),YO=new KO([],LO,0,EO,AO)},ok=e=>{let t;for(t=0;t<wO;t++)e.dyn_ltree[t*2]=0;for(t=0;t<TO;t++)e.dyn_dtree[t*2]=0;for(t=0;t<EO;t++)e.bl_tree[t*2]=0;e.dyn_ltree[jO*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},sk=e=>{e.bi_valid>8?QO(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ck=(e,t,n,r)=>{let i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},lk=(e,t,n)=>{let r=e.heap[n],i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&ck(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!ck(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},uk=(e,t,n)=>{let r,i,a=0,o,s;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+ a++]&255,r+=(e.pending_buf[e.sym_buf+ a++]&255)<<8,i=e.pending_buf[e.sym_buf+ a++],r===0?ek(e,i,t):(o=UO[i],ek(e,o+CO+1,t),s=FO[o],s!==0&&(i-=WO[o],$O(e,i,s)),r--,o=ZO(r),ek(e,o,n),s=IO[o],s!==0&&(r-=GO[o],$O(e,r,s)));while(a<e.sym_next);ek(e,jO,t)},dk=(e,t)=>{let n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=DO,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)lk(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],lk(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,lk(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],rk(e,t),ik(n,c,e.bl_count)},fk=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[NO*2]++:e.bl_tree[PO*2]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[MO*2]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},pk=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do ek(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(ek(e,NO,e.bl_tree),$O(e,s-3,3)):(ek(e,PO,e.bl_tree),$O(e,s-11,7)):(a!==i&&(ek(e,a,e.bl_tree),s--),ek(e,MO,e.bl_tree),$O(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},mk=e=>{let t;for(fk(e,e.dyn_ltree,e.l_desc.max_code),fk(e,e.dyn_dtree,e.d_desc.max_code),dk(e,e.bl_desc),t=EO-1;t>=3&&e.bl_tree[RO[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},hk=(e,t,n,r)=>{let i;for($O(e,t-257,5),$O(e,n-1,5),$O(e,r-4,4),i=0;i<r;i++)$O(e,e.bl_tree[RO[i]*2+1],3);pk(e,e.dyn_ltree,t-1),pk(e,e.dyn_dtree,n-1)},gk=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return hO;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return gO;for(n=32;n<CO;n++)if(e.dyn_ltree[n*2]!==0)return gO;return hO},_k=!1,vk=e=>{_k||=(ak(),!0),e.l_desc=new XO(e.dyn_ltree,qO),e.d_desc=new XO(e.dyn_dtree,JO),e.bl_desc=new XO(e.bl_tree,YO),e.bi_buf=0,e.bi_valid=0,ok(e)},yk=(e,t,n,r)=>{$O(e,(yO<<1)+ +!!r,3),sk(e),QO(e,n),QO(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},bk={_tr_init:vk,_tr_stored_block:yk,_tr_flush_block:(e,t,n,r)=>{let i,a,o=0;e.level>0?(e.strm.data_type===_O&&(e.strm.data_type=gk(e)),dk(e,e.l_desc),dk(e,e.d_desc),o=mk(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&t!==-1?yk(e,t,n,r):e.strategy===mO||a===i?($O(e,(bO<<1)+ +!!r,3),uk(e,BO,VO)):($O(e,(xO<<1)+ +!!r,3),hk(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),uk(e,e.dyn_ltree,e.dyn_dtree)),ok(e),r&&sk(e)},_tr_tally:(e,t,n)=>(e.pending_buf[e.sym_buf+ e.sym_next++]=t,e.pending_buf[e.sym_buf+ e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+ e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(UO[n]+CO+1)*2]++,e.dyn_dtree[ZO(t)*2]++),e.sym_next===e.sym_end),_tr_align:e=>{$O(e,bO<<1,3),ek(e,jO,BO),nk(e)}},xk=(e,t,n,r)=>{let i=e&65535|0,a=e>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0},Sk=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t})()),Ck=(e,t,n,r)=>{let i=Sk,a=r+n;e^=-1;for(let n=r;n<a;n++)e=e>>>8^i[(e^t[n])&255];return e^-1},wk={2:`need dictionary`,1:`stream end`,0:``,"-1":`file error`,"-2":`stream error`,"-3":`data error`,"-4":`insufficient memory`,"-5":`buffer error`,"-6":`incompatible version`},Tk={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:Ek,_tr_stored_block:Dk,_tr_flush_block:Ok,_tr_tally:kk,_tr_align:Ak}=bk,{Z_NO_FLUSH:jk,Z_PARTIAL_FLUSH:Mk,Z_FULL_FLUSH:Nk,Z_FINISH:Pk,Z_BLOCK:Fk,Z_OK:Ik,Z_STREAM_END:Lk,Z_STREAM_ERROR:Rk,Z_DATA_ERROR:zk,Z_BUF_ERROR:Bk,Z_DEFAULT_COMPRESSION:Vk,Z_FILTERED:Hk,Z_HUFFMAN_ONLY:Uk,Z_RLE:Wk,Z_FIXED:Gk,Z_DEFAULT_STRATEGY:Kk,Z_UNKNOWN:qk,Z_DEFLATED:Jk}=Tk,Yk=9,Xk=15,Zk=8,Qk=573,$k=3,eA=258,tA=262,nA=32,rA=42,iA=57,aA=69,oA=73,sA=91,cA=103,lA=113,uA=666,dA=1,fA=2,pA=3,mA=4,hA=3,gA=(e,t)=>(e.msg=wk[t],t),_A=e=>e*2-(e>4?9:0),vA=e=>{let t=e.length;for(;--t>=0;)e[t]=0},yA=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)},bA=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,xA=e=>{let t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},SA=(e,t)=>{Ok(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,xA(e.strm)},CA=(e,t)=>{e.pending_buf[e.pending++]=t},wA=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},TA=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=xk(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Ck(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},EA=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-tA?e.strstart-(e.w_size-tA):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+eA,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(i=t,l[i+o]!==m||l[i+o-1]!==p||l[i]!==l[r]||l[++i]!==l[r+1])continue;r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=eA-(f-r),r=f-eA,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead},DA=e=>{let t=e.w_size,n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-tA)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),yA(e),r+=t),e.strm.avail_in===0)break;if(n=TA(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=$k)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=bA(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=bA(e,e.ins_h,e.window[i+$k-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<$k)););}while(e.lookahead<tA&&e.strm.avail_in!==0)},OA=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,a,o=0,s=e.strm.avail_in;do{if(r=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>a&&(r=a),r<n&&(r===0&&t!==Pk||t===jk||r!==i+e.strm.avail_in)))break;o=+(t===Pk&&r===i+e.strm.avail_in),Dk(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,xA(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(TA(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(o===0);return s-=e.strm.avail_in,s&&(s>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=s&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?mA:t!==jk&&t!==Pk&&e.strm.avail_in===0&&e.strstart===e.block_start?fA:(a=e.window_size-e.strstart,e.strm.avail_in>a&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(TA(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,n=a>e.w_size?e.w_size:a,i=e.strstart-e.block_start,(i>=n||(i||t===Pk)&&t!==jk&&e.strm.avail_in===0&&i<=a)&&(r=i>a?a:i,o=+(t===Pk&&e.strm.avail_in===0&&r===i),Dk(e,e.block_start,r,o),e.block_start+=r,xA(e.strm)),o?pA:dA)},kA=(e,t)=>{let n,r;for(;;){if(e.lookahead<tA){if(DA(e),e.lookahead<tA&&t===jk)return dA;if(e.lookahead===0)break}if(n=0,e.lookahead>=$k&&(e.ins_h=bA(e,e.ins_h,e.window[e.strstart+$k-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-tA&&(e.match_length=EA(e,n)),e.match_length>=$k)if(r=kk(e,e.strstart-e.match_start,e.match_length-$k),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=$k){e.match_length--;do e.strstart++,e.ins_h=bA(e,e.ins_h,e.window[e.strstart+$k-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=bA(e,e.ins_h,e.window[e.strstart+1]);else r=kk(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(SA(e,!1),e.strm.avail_out===0))return dA}return e.insert=e.strstart<$k-1?e.strstart:$k-1,t===Pk?(SA(e,!0),e.strm.avail_out===0?pA:mA):e.sym_next&&(SA(e,!1),e.strm.avail_out===0)?dA:fA},AA=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<tA){if(DA(e),e.lookahead<tA&&t===jk)return dA;if(e.lookahead===0)break}if(n=0,e.lookahead>=$k&&(e.ins_h=bA(e,e.ins_h,e.window[e.strstart+$k-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=$k-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-tA&&(e.match_length=EA(e,n),e.match_length<=5&&(e.strategy===Hk||e.match_length===$k&&e.strstart-e.match_start>4096)&&(e.match_length=$k-1)),e.prev_length>=$k&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-$k,r=kk(e,e.strstart-1-e.prev_match,e.prev_length-$k),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=bA(e,e.ins_h,e.window[e.strstart+$k-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=$k-1,e.strstart++,r&&(SA(e,!1),e.strm.avail_out===0))return dA}else if(e.match_available){if(r=kk(e,0,e.window[e.strstart-1]),r&&SA(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return dA}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(r=kk(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<$k-1?e.strstart:$k-1,t===Pk?(SA(e,!0),e.strm.avail_out===0?pA:mA):e.sym_next&&(SA(e,!1),e.strm.avail_out===0)?dA:fA},jA=(e,t)=>{let n,r,i,a,o=e.window;for(;;){if(e.lookahead<=eA){if(DA(e),e.lookahead<=eA&&t===jk)return dA;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=$k&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+eA;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=eA-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=$k?(n=kk(e,1,e.match_length-$k),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=kk(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(SA(e,!1),e.strm.avail_out===0))return dA}return e.insert=0,t===Pk?(SA(e,!0),e.strm.avail_out===0?pA:mA):e.sym_next&&(SA(e,!1),e.strm.avail_out===0)?dA:fA},MA=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(DA(e),e.lookahead===0)){if(t===jk)return dA;break}if(e.match_length=0,n=kk(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(SA(e,!1),e.strm.avail_out===0))return dA}return e.insert=0,t===Pk?(SA(e,!0),e.strm.avail_out===0?pA:mA):e.sym_next&&(SA(e,!1),e.strm.avail_out===0)?dA:fA};function NA(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var PA=[new NA(0,0,0,0,OA),new NA(4,4,8,4,kA),new NA(4,5,16,8,kA),new NA(4,6,32,32,kA),new NA(4,4,16,16,AA),new NA(8,16,32,32,AA),new NA(8,16,128,128,AA),new NA(8,32,128,256,AA),new NA(32,128,258,1024,AA),new NA(32,258,258,4096,AA)],FA=e=>{e.window_size=2*e.w_size,vA(e.head),e.max_lazy_match=PA[e.level].max_lazy,e.good_match=PA[e.level].good_length,e.nice_match=PA[e.level].nice_length,e.max_chain_length=PA[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=$k-1,e.match_available=0,e.ins_h=0};function IA(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Jk,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Qk*2),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),vA(this.dyn_ltree),vA(this.dyn_dtree),vA(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),vA(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),vA(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var LA=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.status!==rA&&t.status!==iA&&t.status!==aA&&t.status!==oA&&t.status!==sA&&t.status!==cA&&t.status!==lA&&t.status!==uA)},RA=e=>{if(LA(e))return gA(e,Rk);e.total_in=e.total_out=0,e.data_type=qk;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?iA:t.wrap?rA:lA,e.adler=t.wrap===2?0:1,t.last_flush=-2,Ek(t),Ik},zA=e=>{let t=RA(e);return t===Ik&&FA(e.state),t},BA=(e,t)=>LA(e)||e.state.wrap!==2?Rk:(e.state.gzhead=t,Ik),VA=(e,t,n,r,i,a)=>{if(!e)return Rk;let o=1;if(t===Vk&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>Yk||n!==Jk||r<8||r>15||t<0||t>9||a<0||a>Gk||r===8&&o!==1)return gA(e,Rk);r===8&&(r=9);let s=new IA;return e.state=s,s.strm=e,s.status=rA,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+$k-1)/$k),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=(s.lit_bufsize-1)*3,s.level=t,s.strategy=a,s.method=n,zA(e)},HA={deflateInit:(e,t)=>VA(e,t,Jk,Xk,Zk,Kk),deflateInit2:VA,deflateReset:zA,deflateResetKeep:RA,deflateSetHeader:BA,deflate:(e,t)=>{if(LA(e)||t>Fk||t<0)return e?gA(e,Rk):Rk;let n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===uA&&t!==Pk)return gA(e,e.avail_out===0?Bk:Rk);let r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(xA(e),e.avail_out===0)return n.last_flush=-1,Ik}else if(e.avail_in===0&&_A(t)<=_A(r)&&t!==Pk)return gA(e,Bk);if(n.status===uA&&e.avail_in!==0)return gA(e,Bk);if(n.status===rA&&n.wrap===0&&(n.status=lA),n.status===rA){let t=Jk+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Uk||n.level<2?0:n.level<6?1:n.level===6?2:3,t|=r<<6,n.strstart!==0&&(t|=nA),t+=31-t%31,wA(n,t),n.strstart!==0&&(wA(n,e.adler>>>16),wA(n,e.adler&65535)),e.adler=1,n.status=lA,xA(e),n.pending!==0)return n.last_flush=-1,Ik}if(n.status===iA){if(e.adler=0,CA(n,31),CA(n,139),CA(n,8),n.gzhead)CA(n,+!!n.gzhead.text+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),CA(n,n.gzhead.time&255),CA(n,n.gzhead.time>>8&255),CA(n,n.gzhead.time>>16&255),CA(n,n.gzhead.time>>24&255),CA(n,n.level===9?2:n.strategy>=Uk||n.level<2?4:0),CA(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(CA(n,n.gzhead.extra.length&255),CA(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Ck(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=aA;else if(CA(n,0),CA(n,0),CA(n,0),CA(n,0),CA(n,0),CA(n,n.level===9?2:n.strategy>=Uk||n.level<2?4:0),CA(n,hA),n.status=lA,xA(e),n.pending!==0)return n.last_flush=-1,Ik}if(n.status===aA){if(n.gzhead.extra){let t=n.pending,r=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Ck(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,xA(e),n.pending!==0)return n.last_flush=-1,Ik;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=Ck(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=oA}if(n.status===oA){if(n.gzhead.name){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=Ck(e.adler,n.pending_buf,n.pending-t,t)),xA(e),n.pending!==0)return n.last_flush=-1,Ik;t=0}r=n.gzindex<n.gzhead.name.length?n.gzhead.name.charCodeAt(n.gzindex++)&255:0,CA(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=Ck(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=sA}if(n.status===sA){if(n.gzhead.comment){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=Ck(e.adler,n.pending_buf,n.pending-t,t)),xA(e),n.pending!==0)return n.last_flush=-1,Ik;t=0}r=n.gzindex<n.gzhead.comment.length?n.gzhead.comment.charCodeAt(n.gzindex++)&255:0,CA(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=Ck(e.adler,n.pending_buf,n.pending-t,t))}n.status=cA}if(n.status===cA){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(xA(e),n.pending!==0))return n.last_flush=-1,Ik;CA(n,e.adler&255),CA(n,e.adler>>8&255),e.adler=0}if(n.status=lA,xA(e),n.pending!==0)return n.last_flush=-1,Ik}if(e.avail_in!==0||n.lookahead!==0||t!==jk&&n.status!==uA){let r=n.level===0?OA(n,t):n.strategy===Uk?MA(n,t):n.strategy===Wk?jA(n,t):PA[n.level].func(n,t);if((r===pA||r===mA)&&(n.status=uA),r===dA||r===pA)return e.avail_out===0&&(n.last_flush=-1),Ik;if(r===fA&&(t===Mk?Ak(n):t!==Fk&&(Dk(n,0,0,!1),t===Nk&&(vA(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),xA(e),e.avail_out===0))return n.last_flush=-1,Ik}return t===Pk?n.wrap<=0?Lk:(n.wrap===2?(CA(n,e.adler&255),CA(n,e.adler>>8&255),CA(n,e.adler>>16&255),CA(n,e.adler>>24&255),CA(n,e.total_in&255),CA(n,e.total_in>>8&255),CA(n,e.total_in>>16&255),CA(n,e.total_in>>24&255)):(wA(n,e.adler>>>16),wA(n,e.adler&65535)),xA(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending===0?Lk:Ik):Ik},deflateEnd:e=>{if(LA(e))return Rk;let t=e.state.status;return e.state=null,t===lA?gA(e,zk):Ik},deflateSetDictionary:(e,t)=>{let n=t.length;if(LA(e))return Rk;let r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==rA||r.lookahead)return Rk;if(i===1&&(e.adler=xk(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(vA(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}let a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,DA(r);r.lookahead>=$k;){let e=r.strstart,t=r.lookahead-($k-1);do r.ins_h=bA(r,r.ins_h,r.window[e+$k-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++;while(--t);r.strstart=e,r.lookahead=$k-1,DA(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=$k-1,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,Ik},deflateInfo:`pako deflate (from Nodeca project)`},UA=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),WA={assign:function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let n=t.shift();if(n){if(typeof n!=`object`)throw TypeError(n+`must be non-object`);for(let t in n)UA(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;let n=new Uint8Array(t);for(let t=0,r=0,i=e.length;t<i;t++){let i=e[t];n.set(i,r),r+=i.length}return n}},GA=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{GA=!1}var KA=new Uint8Array(256);for(let e=0;e<256;e++)KA[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;KA[254]=KA[254]=1;var qA=e=>{if(typeof TextEncoder==`function`&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,a,o=e.length,s=0;for(i=0;i<o;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|n&63):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|n&63):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|n&63);return t},JA=(e,t)=>{if(t<65534&&e.subarray&&GA)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n=``;for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n},YA={string2buf:qA,buf2string:(e,t)=>{let n=t||e.length;if(typeof TextDecoder==`function`&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,i,a=Array(n*2);for(i=0,r=0;r<n;){let t=e[r++];if(t<128){a[i++]=t;continue}let o=KA[t];if(o>4){a[i++]=65533,r+=o-1;continue}for(t&=o===2?31:o===3?15:7;o>1&&r<n;)t=t<<6|e[r++]&63,o--;if(o>1){a[i++]=65533;continue}t<65536?a[i++]=t:(t-=65536,a[i++]=55296|t>>10&1023,a[i++]=56320|t&1023)}return JA(a,i)},utf8border:(e,t)=>{t||=e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)==128;)n--;return n<0||n===0?t:n+KA[e[n]]>t?n:t}};function XA(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}var ZA=XA,QA=Object.prototype.toString,{Z_NO_FLUSH:$A,Z_SYNC_FLUSH:ej,Z_FULL_FLUSH:tj,Z_FINISH:nj,Z_OK:rj,Z_STREAM_END:ij,Z_DEFAULT_COMPRESSION:aj,Z_DEFAULT_STRATEGY:oj,Z_DEFLATED:sj}=Tk;function cj(e){this.options=WA.assign({level:aj,method:sj,chunkSize:16384,windowBits:15,memLevel:8,strategy:oj},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new ZA,this.strm.avail_out=0;let n=HA.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==rj)throw Error(wk[n]);if(t.header&&HA.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=typeof t.dictionary==`string`?YA.string2buf(t.dictionary):QA.call(t.dictionary)===`[object ArrayBuffer]`?new Uint8Array(t.dictionary):t.dictionary,n=HA.deflateSetDictionary(this.strm,e),n!==rj)throw Error(wk[n]);this._dict_set=!0}}cj.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;for(a=t===~~t?t:t===!0?nj:$A,typeof e==`string`?n.input=YA.string2buf(e):QA.call(e)===`[object ArrayBuffer]`?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(a===ej||a===tj)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=HA.deflate(n,a),i===ij)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=HA.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===rj;if(n.avail_out===0){this.onData(n.output);continue}if(a>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0},cj.prototype.onData=function(e){this.chunks.push(e)},cj.prototype.onEnd=function(e){e===rj&&(this.result=WA.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function lj(e,t){let n=new cj(t);if(n.push(e,!0),n.err)throw n.msg||wk[n.err];return n.result}function uj(e,t){return t||={},t.raw=!0,lj(e,t)}function dj(e,t){return t||={},t.gzip=!0,lj(e,t)}var fj={Deflate:cj,deflate:lj,deflateRaw:uj,gzip:dj,constants:Tk},pj=16209,mj=16191,hj=function(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,l=E.whave,u=E.wnext,d=E.window,f=E.hold,p=E.bits,m=E.lencode,h=E.distcode,g=(1<<E.lenbits)-1,_=(1<<E.distbits)-1;top:do{p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=m[f&g];dolen:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y===0)T[i++]=v&65535;else if(y&16){b=v&65535,y&=15,y&&(p<y&&(f+=w[n++]<<p,p+=8),b+=f&(1<<y)-1,f>>>=y,p-=y),p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=h[f&_];dodist:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y&16){if(x=v&65535,y&=15,p<y&&(f+=w[n++]<<p,p+=8,p<y&&(f+=w[n++]<<p,p+=8)),x+=f&(1<<y)-1,x>s){e.msg=`invalid distance too far back`,E.mode=pj;break top}if(f>>>=y,p-=y,y=i-a,x>y){if(y=x-y,y>l&&E.sane){e.msg=`invalid distance too far back`,E.mode=pj;break top}if(S=0,C=d,u===0){if(S+=c-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}else if(u<y){if(S+=c+u-y,y-=u,y<b){b-=y;do T[i++]=d[S++];while(--y);if(S=0,u<b){y=u,b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}}else if(S+=u-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}for(;b>2;)T[i++]=C[S++],T[i++]=C[S++],T[i++]=C[S++],b-=3;b&&(T[i++]=C[S++],b>1&&(T[i++]=C[S++]))}else{S=i-x;do T[i++]=T[S++],T[i++]=T[S++],T[i++]=T[S++],b-=3;while(b>2);b&&(T[i++]=T[S++],b>1&&(T[i++]=T[S++]))}}else if(y&64){e.msg=`invalid distance code`,E.mode=pj;break top}else{v=h[(v&65535)+(f&(1<<y)-1)];continue dodist}break}}else if(!(y&64)){v=m[(v&65535)+(f&(1<<y)-1)];continue dolen}else if(y&32){E.mode=mj;break top}else{e.msg=`invalid literal/length code`,E.mode=pj;break top}break}}while(n<r&&i<o);b=p>>3,n-=b,p-=b<<3,f&=(1<<p)-1,e.next_in=n,e.next_out=i,e.avail_in=n<r?5+(r-n):5-(n-r),e.avail_out=i<o?257+(o-i):257-(i-o),E.hold=f,E.bits=p},gj=15,_j=852,vj=592,yj=0,bj=1,xj=2,Sj=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Cj=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),wj=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Tj=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),Ej=(e,t,n,r,i,a,o,s)=>{let c=s.bits,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y,b,x,S,C,w=null,T,E=new Uint16Array(16),D=new Uint16Array(16),O=null,k,A,j;for(l=0;l<=gj;l++)E[l]=0;for(u=0;u<r;u++)E[t[n+u]]++;for(p=c,f=gj;f>=1&&E[f]===0;f--);if(p>f&&(p=f),f===0)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(d=1;d<f&&E[d]===0;d++);for(p<d&&(p=d),g=1,l=1;l<=gj;l++)if(g<<=1,g-=E[l],g<0)return-1;if(g>0&&(e===yj||f!==1))return-1;for(D[1]=0,l=1;l<gj;l++)D[l+1]=D[l]+E[l];for(u=0;u<r;u++)t[n+u]!==0&&(o[D[t[n+u]]++]=u);if(e===yj?(w=O=o,T=20):e===bj?(w=Sj,O=Cj,T=257):(w=wj,O=Tj,T=0),v=0,u=0,l=d,C=a,m=p,h=0,x=-1,_=1<<p,S=_-1,e===bj&&_>_j||e===xj&&_>vj)return 1;for(;;){k=l-h,o[u]+1<T?(A=0,j=o[u]):o[u]>=T?(A=O[o[u]-T],j=w[o[u]-T]):(A=96,j=0),y=1<<l-h,b=1<<m,d=b;do b-=y,i[C+(v>>h)+b]=k<<24|A<<16|j|0;while(b!==0);for(y=1<<l-1;v&y;)y>>=1;if(y===0?v=0:(v&=y-1,v+=y),u++,--E[l]===0){if(l===f)break;l=t[n+o[u]]}if(l>p&&(v&S)!==x){for(h===0&&(h=p),C+=d,m=l-h,g=1<<m;m+h<f&&(g-=E[m+h],!(g<=0));)m++,g<<=1;if(_+=1<<m,e===bj&&_>_j||e===xj&&_>vj)return 1;x=v&S,i[x]=p<<24|m<<16|C-a|0}}return v!==0&&(i[C+v]=l-h<<24|4194304),s.bits=p,0},Dj=0,Oj=1,kj=2,{Z_FINISH:Aj,Z_BLOCK:jj,Z_TREES:Mj,Z_OK:Nj,Z_STREAM_END:Pj,Z_NEED_DICT:Fj,Z_STREAM_ERROR:Ij,Z_DATA_ERROR:Lj,Z_MEM_ERROR:Rj,Z_BUF_ERROR:zj,Z_DEFLATED:Bj}=Tk,Vj=16180,Hj=16181,Uj=16182,Wj=16183,Gj=16184,Kj=16185,qj=16186,Jj=16187,Yj=16188,Xj=16189,Zj=16190,Qj=16191,$j=16192,eM=16193,tM=16194,nM=16195,rM=16196,iM=16197,aM=16198,oM=16199,sM=16200,cM=16201,lM=16202,uM=16203,dM=16204,fM=16205,pM=16206,mM=16207,hM=16208,gM=16209,_M=16210,vM=16211,yM=852,bM=592,xM=15,SM=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function CM(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var wM=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.mode<Vj||t.mode>vM)},TM=e=>{if(wM(e))return Ij;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=t.wrap&1),t.mode=Vj,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(yM),t.distcode=t.distdyn=new Int32Array(bM),t.sane=1,t.back=-1,Nj},EM=e=>{if(wM(e))return Ij;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,TM(e)},DM=(e,t)=>{let n;if(wM(e))return Ij;let r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Ij:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,EM(e))},OM=(e,t)=>{if(!e)return Ij;let n=new CM;e.state=n,n.strm=e,n.window=null,n.mode=Vj;let r=DM(e,t);return r!==Nj&&(e.state=null),r},kM=e=>OM(e,xM),AM=!0,jM,MM,NM=e=>{if(AM){jM=new Int32Array(512),MM=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Ej(Oj,e.lens,0,288,jM,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ej(kj,e.lens,0,32,MM,0,e.work,{bits:5}),AM=!1}e.lencode=jM,e.lenbits=9,e.distcode=MM,e.distbits=5},PM=(e,t,n,r)=>{let i,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(t.subarray(n-r,n-r+i),a.wnext),r-=i,r?(a.window.set(t.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},FM={inflateReset:EM,inflateReset2:DM,inflateResetKeep:TM,inflateInit:kM,inflateInit2:OM,inflate:(e,t)=>{let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=0,_,v,y,b,x,S,C,w,T=new Uint8Array(4),E,D,O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(wM(e)||!e.output||!e.input&&e.avail_in!==0)return Ij;n=e.state,n.mode===Qj&&(n.mode=$j),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,d=s,f=c,w=Nj;inf_leave:for(;;)switch(n.mode){case Vj:if(n.wrap===0){n.mode=$j;break}for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&2&&l===35615){n.wbits===0&&(n.wbits=15),n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=Ck(n.check,T,2,0),l=0,u=0,n.mode=Hj;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg=`incorrect header check`,n.mode=gM;break}if((l&15)!==Bj){e.msg=`unknown compression method`,n.mode=gM;break}if(l>>>=4,u-=4,C=(l&15)+8,n.wbits===0&&(n.wbits=C),C>15||C>n.wbits){e.msg=`invalid window size`,n.mode=gM;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=l&512?Xj:Qj,l=0,u=0;break;case Hj:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.flags=l,(n.flags&255)!==Bj){e.msg=`unknown compression method`,n.mode=gM;break}if(n.flags&57344){e.msg=`unknown header flags set`,n.mode=gM;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ck(n.check,T,2,0)),l=0,u=0,n.mode=Uj;case Uj:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.time=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=Ck(n.check,T,4,0)),l=0,u=0,n.mode=Wj;case Wj:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ck(n.check,T,2,0)),l=0,u=0,n.mode=Gj;case Gj:if(n.flags&1024){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ck(n.check,T,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=Kj;case Kj:if(n.flags&1024&&(p=n.length,p>s&&(p=s),p&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+p),C)),n.flags&512&&n.wrap&4&&(n.check=Ck(n.check,r,p,a)),s-=p,a+=p,n.length-=p),n.length))break inf_leave;n.length=0,n.mode=qj;case qj:if(n.flags&2048){if(s===0)break inf_leave;p=0;do C=r[a+ p++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&n.wrap&4&&(n.check=Ck(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.name=null);n.length=0,n.mode=Jj;case Jj:if(n.flags&4096){if(s===0)break inf_leave;p=0;do C=r[a+ p++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&n.wrap&4&&(n.check=Ck(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.comment=null);n.mode=Yj;case Yj:if(n.flags&512){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&4&&l!==(n.check&65535)){e.msg=`header crc mismatch`,n.mode=gM;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Qj;break;case Xj:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}e.adler=n.check=SM(l),l=0,u=0,n.mode=Zj;case Zj:if(n.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,Fj;e.adler=n.check=1,n.mode=Qj;case Qj:if(t===jj||t===Mj)break inf_leave;case $j:if(n.last){l>>>=u&7,u-=u&7,n.mode=pM;break}for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}switch(n.last=l&1,l>>>=1,--u,l&3){case 0:n.mode=eM;break;case 1:if(NM(n),n.mode=oM,t===Mj){l>>>=2,u-=2;break inf_leave}break;case 2:n.mode=rM;break;case 3:e.msg=`invalid block type`,n.mode=gM}l>>>=2,u-=2;break;case eM:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if((l&65535)!=(l>>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=gM;break}if(n.length=l&65535,l=0,u=0,n.mode=tM,t===Mj)break inf_leave;case tM:n.mode=nM;case nM:if(p=n.length,p){if(p>s&&(p=s),p>c&&(p=c),p===0)break inf_leave;i.set(r.subarray(a,a+p),o),s-=p,a+=p,c-=p,o+=p,n.length-=p;break}n.mode=Qj;break;case rM:for(;u<14;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.nlen=(l&31)+257,l>>>=5,u-=5,n.ndist=(l&31)+1,l>>>=5,u-=5,n.ncode=(l&15)+4,l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg=`too many length or distance symbols`,n.mode=gM;break}n.have=0,n.mode=iM;case iM:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.lens[O[n.have++]]=l&7,l>>>=3,u-=3}for(;n.have<19;)n.lens[O[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},w=Ej(Dj,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid code lengths set`,n.mode=gM;break}n.have=0,n.mode=aM;case aM:for(;n.have<n.nlen+n.ndist;){for(;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(y<16)l>>>=_,u-=_,n.lens[n.have++]=y;else{if(y===16){for(D=_+2;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l>>>=_,u-=_,n.have===0){e.msg=`invalid bit length repeat`,n.mode=gM;break}C=n.lens[n.have-1],p=3+(l&3),l>>>=2,u-=2}else if(y===17){for(D=_+3;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=3+(l&7),l>>>=3,u-=3}else{for(D=_+7;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=11+(l&127),l>>>=7,u-=7}if(n.have+p>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=gM;break}for(;p--;)n.lens[n.have++]=C}}if(n.mode===gM)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=gM;break}if(n.lenbits=9,E={bits:n.lenbits},w=Ej(Oj,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid literal/lengths set`,n.mode=gM;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},w=Ej(kj,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,w){e.msg=`invalid distances set`,n.mode=gM;break}if(n.mode=oM,t===Mj)break inf_leave;case oM:n.mode=sM;case sM:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,hj(e,f),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===Qj&&(n.back=-1);break}for(n.back=0;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(v&&!(v&240)){for(b=_,x=v,S=y;g=n.lencode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,n.length=y,v===0){n.mode=fM;break}if(v&32){n.back=-1,n.mode=Qj;break}if(v&64){e.msg=`invalid literal/length code`,n.mode=gM;break}n.extra=v&15,n.mode=cM;case cM:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=lM;case lM:for(;g=n.distcode[l&(1<<n.distbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(!(v&240)){for(b=_,x=v,S=y;g=n.distcode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,v&64){e.msg=`invalid distance code`,n.mode=gM;break}n.offset=y,n.extra=v&15,n.mode=uM;case uM:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=gM;break}n.mode=dM;case dM:if(c===0)break inf_leave;if(p=f-c,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=gM;break}p>n.wnext?(p-=n.wnext,m=n.wsize-p):m=n.wnext-p,p>n.length&&(p=n.length),h=n.window}else h=i,m=o-n.offset,p=n.length;p>c&&(p=c),c-=p,n.length-=p;do i[o++]=h[m++];while(--p);n.length===0&&(n.mode=sM);break;case fM:if(c===0)break inf_leave;i[o++]=n.length,c--,n.mode=sM;break;case pM:if(n.wrap){for(;u<32;){if(s===0)break inf_leave;s--,l|=r[a++]<<u,u+=8}if(f-=c,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?Ck(n.check,i,f,o-f):xk(n.check,i,f,o-f)),f=c,n.wrap&4&&(n.flags?l:SM(l))!==n.check){e.msg=`incorrect data check`,n.mode=gM;break}l=0,u=0}n.mode=mM;case mM:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&4&&l!==(n.total&4294967295)){e.msg=`incorrect length check`,n.mode=gM;break}l=0,u=0}n.mode=hM;case hM:w=Pj;break inf_leave;case gM:w=Lj;break inf_leave;case _M:return Rj;case vM:default:return Ij}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||f!==e.avail_out&&n.mode<gM&&(n.mode<pM||t!==Aj))&&PM(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?Ck(n.check,i,f,e.next_out-f):xk(n.check,i,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Qj?128:0)+(n.mode===oM||n.mode===tM?256:0),(d===0&&f===0||t===Aj)&&w===Nj&&(w=zj),w},inflateEnd:e=>{if(wM(e))return Ij;let t=e.state;return t.window&&=null,e.state=null,Nj},inflateGetHeader:(e,t)=>{if(wM(e))return Ij;let n=e.state;return n.wrap&2?(n.head=t,t.done=!1,Nj):Ij},inflateSetDictionary:(e,t)=>{let n=t.length,r,i,a;return wM(e)||(r=e.state,r.wrap!==0&&r.mode!==Zj)?Ij:r.mode===Zj&&(i=1,i=xk(i,t,n,0),i!==r.check)?Lj:(a=PM(e,t,n,n),a?(r.mode=_M,Rj):(r.havedict=1,Nj))},inflateInfo:`pako inflate (from Nodeca project)`};function IM(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=``,this.comment=``,this.hcrc=0,this.done=!1}var LM=IM,RM=Object.prototype.toString,{Z_NO_FLUSH:zM,Z_FINISH:BM,Z_OK:VM,Z_STREAM_END:HM,Z_NEED_DICT:UM,Z_STREAM_ERROR:WM,Z_DATA_ERROR:GM,Z_MEM_ERROR:KM}=Tk;function qM(e){this.options=WA.assign({chunkSize:1024*64,windowBits:15,to:``},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new ZA,this.strm.avail_out=0;let n=FM.inflateInit2(this.strm,t.windowBits);if(n!==VM||(this.header=new LM,FM.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary==`string`?t.dictionary=YA.string2buf(t.dictionary):RM.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=FM.inflateSetDictionary(this.strm,t.dictionary),n!==VM))))throw Error(wk[n])}qM.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i=this.options.dictionary,a,o,s;if(this.ended)return!1;for(o=t===~~t?t:t===!0?BM:zM,RM.call(e)===`[object ArrayBuffer]`?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),a=FM.inflate(n,o),a===UM&&i&&(a=FM.inflateSetDictionary(n,i),a===VM?a=FM.inflate(n,o):a===GM&&(a=UM));n.avail_in>0&&a===HM&&n.state.wrap>0&&e[n.next_in]!==0;)FM.inflateReset(n),a=FM.inflate(n,o);switch(a){case WM:case GM:case UM:case KM:return this.onEnd(a),this.ended=!0,!1}if(s=n.avail_out,n.next_out&&(n.avail_out===0||a===HM))if(this.options.to===`string`){let e=YA.utf8border(n.output,n.next_out),t=n.next_out-e,i=YA.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(a===VM&&s===0)){if(a===HM)return a=FM.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(n.avail_in===0)break}}return!0},qM.prototype.onData=function(e){this.chunks.push(e)},qM.prototype.onEnd=function(e){e===VM&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=WA.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function JM(e,t){let n=new qM(t);if(n.push(e),n.err)throw n.msg||wk[n.err];return n.result}function YM(e,t){return t||={},t.raw=!0,JM(e,t)}var XM={Inflate:qM,inflate:JM,inflateRaw:YM,ungzip:JM,constants:Tk},{Deflate:ZM,deflate:QM,deflateRaw:$M,gzip:eN}=fj,{Inflate:tN,inflate:nN,inflateRaw:rN,ungzip:iN}=XM,aN=tN,oN=nN,sN=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;sN[e]=t}var cN=4294967295;function lN(e,t,n){let r=e;for(let e=0;e<n;e++)r=sN[(r^t[e])&255]^r>>>8;return r}function uN(e,t){return(lN(cN,e,t)^cN)>>>0}function dN(e,t,n){let r=e.readUint32(),i=uN(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==r)throw Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${i}`)}function fN(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function pN(e,t,n,r){let i=0;for(;i<r;i++)t[i]=e[i];for(;i<n;i++)t[i]=e[i]+t[i-r]&255}function mN(e,t,n,r){let i=0;if(n.length===0)for(;i<r;i++)t[i]=e[i];else for(;i<r;i++)t[i]=e[i]+n[i]&255}function hN(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+(t[a-i]>>1)&255}else{for(;a<i;a++)t[a]=e[a]+(n[a]>>1)&255;for(;a<r;a++)t[a]=e[a]+(t[a-i]+n[a]>>1)&255}}function gN(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+t[a-i]&255}else{for(;a<i;a++)t[a]=e[a]+n[a]&255;for(;a<r;a++)t[a]=e[a]+_N(t[a-i],n[a],n[a-i])&255}}function _N(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function vN(e,t,n,r,i,a){switch(e){case 0:fN(t,n,i);break;case 1:pN(t,n,i,a);break;case 2:mN(t,n,r,i);break;case 3:hN(t,n,r,i,a);break;case 4:gN(t,n,r,i,a);break;default:throw Error(`Unsupported filter: ${e}`)}}var yN=new Uint16Array([255]),bN=new Uint8Array(yN.buffer)[0]===255;function xN(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],s=Math.ceil(a/8)*i,c=new Uint8Array(r*n*s),l=0;for(let e=0;e<7;e++){let i=o[e],a=Math.ceil((n-i.x)/i.xStep),u=Math.ceil((r-i.y)/i.yStep);if(a<=0||u<=0)continue;let d=a*s,f=new Uint8Array(d);for(let e=0;e<u;e++){let o=t[l++],u=t.subarray(l,l+d);l+=d;let p=new Uint8Array(d);vN(o,u,p,f,d,s),f.set(p);for(let t=0;t<a;t++){let a=i.x+t*i.xStep,o=i.y+e*i.yStep;if(!(a>=n||o>=r))for(let e=0;e<s;e++)c[(o*n+a)*s+e]=p[t*s+e]}}}if(a===16){let e=new Uint16Array(c.buffer);if(bN)for(let t=0;t<e.length;t++)e[t]=SN(e[t]);return e}else return c}function SN(e){return(e&255)<<8|e>>8&255}var CN=new Uint16Array([255]),wN=new Uint8Array(CN.buffer)[0]===255,TN=new Uint8Array;function EN(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=Math.ceil(a/8)*i,s=Math.ceil(a/8*i*n),c=new Uint8Array(r*s),l=TN,u=0,d,f;for(let e=0;e<r;e++){switch(d=t.subarray(u+1,u+1+s),f=c.subarray(e*s,(e+1)*s),t[u]){case 0:fN(d,f,s);break;case 1:pN(d,f,s,o);break;case 2:mN(d,f,l,s);break;case 3:hN(d,f,l,s,o);break;case 4:gN(d,f,l,s,o);break;default:throw Error(`Unsupported filter: ${t[u]}`)}l=f,u+=s+1}if(a===16){let e=new Uint16Array(c.buffer);if(wN)for(let t=0;t<e.length;t++)e[t]=DN(e[t]);return e}else return c}function DN(e){return(e&255)<<8|e>>8&255}var ON=Uint8Array.of(137,80,78,71,13,10,26,10);function kN(e){if(!AN(e.readBytes(ON.length)))throw Error(`wrong PNG signature`)}function AN(e){if(e.length<ON.length)return!1;for(let t=0;t<ON.length;t++)if(e[t]!==ON[t])return!1;return!0}var jN=`tEXt`,MN=0,NN=new TextDecoder(`latin1`);function PN(e){if(IN(e),e.length===0||e.length>79)throw Error(`keyword length must be between 1 and 79`)}var FN=/^[\u0000-\u00FF]*$/;function IN(e){if(!FN.test(e))throw Error(`invalid latin1 text`)}function LN(e,t,n){let r=RN(t);e[r]=zN(t,n-r.length-1)}function RN(e){for(e.mark();e.readByte()!==MN;);let t=e.offset;e.reset();let n=NN.decode(e.readBytes(t-e.offset-1));return e.skip(1),PN(n),n}function zN(e,t){return NN.decode(e.readBytes(t))}var BN={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},VN={UNKNOWN:-1,DEFLATE:0},HN={UNKNOWN:-1,ADAPTIVE:0},UN={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},WN={NONE:0,BACKGROUND:1,PREVIOUS:2},GN={SOURCE:0,OVER:1},KN=class extends pO{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(e,t={}){super(e);let{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new aN,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array,depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array,this._compressionMethod=VN.UNKNOWN,this._filterMethod=HN.UNKNOWN,this._interlaceMethod=UN.UNKNOWN,this._colorType=BN.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(kN(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this.decodeImage(),this._png}decodeApng(){for(kN(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let n=this.offset;switch(t){case`IHDR`:this.decodeIHDR();break;case`PLTE`:this.decodePLTE(e);break;case`IDAT`:this.decodeIDAT(e);break;case`IEND`:this._end=!0;break;case`tRNS`:this.decodetRNS(e);break;case`iCCP`:this.decodeiCCP(e);break;case jN:LN(this._png.text,this,e);break;case`pHYs`:this.decodepHYs();break;default:this.skip(e);break}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?dN(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let n=this.offset;switch(t!==`fdAT`&&t!==`IDAT`&&this._writingDataChunks&&this.pushDataToFrame(),t){case`acTL`:this.decodeACTL();break;case`fcTL`:this.decodeFCTL();break;case`fdAT`:this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e;break}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?dN(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=qN(this.readUint8());let t=this.readUint8();this._colorType=t;let n;switch(t){case BN.GREYSCALE:n=1;break;case BN.TRUECOLOUR:n=3;break;case BN.INDEXED_COLOUR:n=1;break;case BN.GREYSCALE_ALPHA:n=2;break;case BN.TRUECOLOUR_ALPHA:n=4;break;case BN.UNKNOWN:default:throw Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==VN.DEFLATE)throw Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array};this._frames.push(e)}decodePLTE(e){if(e%3!=0)throw RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let n=[];this._palette=n;for(let e=0;e<t;e++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;if(n+=4,t-=4,this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodetRNS(e){switch(this._colorType){case BN.GREYSCALE:case BN.TRUECOLOUR:if(e%2!=0)throw RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break;case BN.INDEXED_COLOUR:{if(e>this._palette.length)throw Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let e=this.readByte();this._palette[t].push(e)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case BN.UNKNOWN:case BN.GREYSCALE_ALPHA:case BN.TRUECOLOUR_ALPHA:default:throw Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=RN(this),n=this.readUint8();if(n!==VN.DEFLATE)throw Error(`Unsupported iCCP compression method: ${n}`);let r=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:oN(r)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=EN({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{let r=this._apng.frames.at(e-1);this.disposeFrame(n,r,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case WN.NONE:break;case WN.BACKGROUND:for(let t=0;t<this._png.height;t++)for(let r=0;r<this._png.width;r++){let i=(t*e.width+r)*this._png.channels;for(let e=0;e<this._png.channels;e++)n.data[i+e]=0}break;case WN.PREVIOUS:n.data.set(t.data);break;default:throw Error(`Unknown disposeOp`)}}addFrameDataToCanvas(e,t){let n=1<<this._png.depth,r=(e,n)=>({index:((e+t.yOffset)*this._png.width+t.xOffset+n)*this._png.channels,frameIndex:(e*t.width+n)*this._png.channels});switch(t.blendOp){case GN.SOURCE:for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){let{index:a,frameIndex:o}=r(n,i);for(let n=0;n<this._png.channels;n++)e.data[a+n]=t.data[o+n]}break;case GN.OVER:for(let i=0;i<t.height;i++)for(let a=0;a<t.width;a++){let{index:o,frameIndex:s}=r(i,a);for(let r=0;r<this._png.channels;r++){let i=t.data[s+this._png.channels-1]/n,a=r%(this._png.channels-1)==0?1:t.data[s+r],c=Math.floor(i*a+(1-i)*e.data[o+r]);e.data[o+r]+=c}}break;default:throw Error(`Unknown blendOp`)}}decodeImage(){if(this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);let e=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==HN.ADAPTIVE)throw Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===UN.NO_INTERLACE)this._png.data=EN({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===UN.ADAM7)this._png.data=xN({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){let e=this._inflator.result,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:WN.NONE,blendOp:GN.SOURCE,data:e}),this._inflator=new aN,this._writingDataChunks=!1}};function qN(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw Error(`invalid bit depth: ${e}`);return e}var JN;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.METRE=1]=`METRE`})(JN||={});function YN(e,t){return new KN(e,t).decode()}var XN=function(){return typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this}();function ZN(){XN.console&&typeof XN.console.log==`function`&&XN.console.log.apply(XN.console,arguments)}var QN={log:ZN,warn:function(e){XN.console&&(typeof XN.console.warn==`function`?XN.console.warn.apply(XN.console,arguments):ZN.call(null,arguments))},error:function(e){XN.console&&(typeof XN.console.error==`function`?XN.console.error.apply(XN.console,arguments):ZN(e))}};function $N(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e),r.responseType=`blob`,r.onload=function(){nP(r.response,t,n)},r.onerror=function(){QN.error(`could not download file`)},r.send()}function eP(e){var t=new XMLHttpRequest;t.open(`HEAD`,e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function tP(e){try{e.dispatchEvent(new MouseEvent(`click`))}catch{var t=document.createEvent(`MouseEvents`);t.initMouseEvent(`click`,!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var nP=XN.saveAs||((typeof window>`u`?`undefined`:hD(window))!==`object`||window!==XN?function(){}:typeof HTMLAnchorElement<`u`&&`download`in HTMLAnchorElement.prototype?function(e,t,n){var r=XN.URL||XN.webkitURL,i=document.createElement(`a`);t=t||e.name||`download`,i.download=t,i.rel=`noopener`,typeof e==`string`?(i.href=e,i.origin===location.origin?tP(i):eP(i.href)?$N(e,t,n):tP(i,i.target=`_blank`)):(i.href=r.createObjectURL(e),setTimeout(function(){r.revokeObjectURL(i.href)},4e4),setTimeout(function(){tP(i)},0))}:`msSaveOrOpenBlob`in navigator?function(e,t,n){if(t=t||e.name||`download`,typeof e==`string`)if(eP(e))$N(e,t,n);else{var r=document.createElement(`a`);r.href=e,r.target=`_blank`,setTimeout(function(){tP(r)})}else navigator.msSaveOrOpenBlob(function(e,t){return t===void 0?t={autoBom:!1}:hD(t)!==`object`&&(QN.warn(`Deprecated: Expected third argument to be a object`),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([``,e],{type:e.type}):e}(e,n),t)}:function(e,t,n,r){if((r||=open(``,`_blank`))&&(r.document.title=r.document.body.innerText=`downloading...`),typeof e==`string`)return $N(e,t,n);var i=e.type===`application/octet-stream`,a=/constructor/i.test(XN.HTMLElement)||XN.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||i&&a)&&(typeof FileReader>`u`?`undefined`:hD(FileReader))===`object`){var s=new FileReader;s.onloadend=function(){var e=s.result;e=o?e:e.replace(/^data:[^;]*;/,`data:attachment/file;`),r?r.location.href=e:location=e,r=null},s.readAsDataURL(e)}else{var c=XN.URL||XN.webkitURL,l=c.createObjectURL(e);r?r.location=l:location.href=l,r=null,setTimeout(function(){c.revokeObjectURL(l)},4e4)}});function rP(e){var t;e||=``,this.ok=!1,e.charAt(0)==`#`&&(e=e.substr(1,6)),e={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dodgerblue:`1e90ff`,feldspar:`d19275`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgrey:`d3d3d3`,lightgreen:`90ee90`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslateblue:`8470ff`,lightslategray:`778899`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`00ff00`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`ff00ff`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370d8`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`d87093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,red:`ff0000`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,violetred:`d02090`,wheat:`f5deb3`,white:`ffffff`,whitesmoke:`f5f5f5`,yellow:`ffff00`,yellowgreen:`9acd32`}[e=(e=e.replace(/ /g,``)).toLowerCase()]||e;for(var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:[`rgb(123, 234, 45)`,`rgb(255,234,245)`],process:function(e){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:[`#00ff00`,`336699`],process:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:[`#fb0`,`f0f`],process:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}}],r=0;r<n.length;r++){var i=n[r].re,a=n[r].process,o=i.exec(e);o&&(t=a(o),this.r=t[0],this.g=t[1],this.b=t[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return`rgb(`+this.r+`, `+this.g+`, `+this.b+`)`},this.toHex=function(){var e=this.r.toString(16),t=this.g.toString(16),n=this.b.toString(16);return e.length==1&&(e=`0`+e),t.length==1&&(t=`0`+t),n.length==1&&(n=`0`+n),`#`+e+t+n}}var iP=XN.atob.bind(XN),aP=XN.btoa.bind(XN);function oP(e,t){var n=e[0],r=e[1],i=e[2],a=e[3];n=cP(n,r,i,a,t[0],7,-680876936),a=cP(a,n,r,i,t[1],12,-389564586),i=cP(i,a,n,r,t[2],17,606105819),r=cP(r,i,a,n,t[3],22,-1044525330),n=cP(n,r,i,a,t[4],7,-176418897),a=cP(a,n,r,i,t[5],12,1200080426),i=cP(i,a,n,r,t[6],17,-1473231341),r=cP(r,i,a,n,t[7],22,-45705983),n=cP(n,r,i,a,t[8],7,1770035416),a=cP(a,n,r,i,t[9],12,-1958414417),i=cP(i,a,n,r,t[10],17,-42063),r=cP(r,i,a,n,t[11],22,-1990404162),n=cP(n,r,i,a,t[12],7,1804603682),a=cP(a,n,r,i,t[13],12,-40341101),i=cP(i,a,n,r,t[14],17,-1502002290),n=lP(n,r=cP(r,i,a,n,t[15],22,1236535329),i,a,t[1],5,-165796510),a=lP(a,n,r,i,t[6],9,-1069501632),i=lP(i,a,n,r,t[11],14,643717713),r=lP(r,i,a,n,t[0],20,-373897302),n=lP(n,r,i,a,t[5],5,-701558691),a=lP(a,n,r,i,t[10],9,38016083),i=lP(i,a,n,r,t[15],14,-660478335),r=lP(r,i,a,n,t[4],20,-405537848),n=lP(n,r,i,a,t[9],5,568446438),a=lP(a,n,r,i,t[14],9,-1019803690),i=lP(i,a,n,r,t[3],14,-187363961),r=lP(r,i,a,n,t[8],20,1163531501),n=lP(n,r,i,a,t[13],5,-1444681467),a=lP(a,n,r,i,t[2],9,-51403784),i=lP(i,a,n,r,t[7],14,1735328473),n=uP(n,r=lP(r,i,a,n,t[12],20,-1926607734),i,a,t[5],4,-378558),a=uP(a,n,r,i,t[8],11,-2022574463),i=uP(i,a,n,r,t[11],16,1839030562),r=uP(r,i,a,n,t[14],23,-35309556),n=uP(n,r,i,a,t[1],4,-1530992060),a=uP(a,n,r,i,t[4],11,1272893353),i=uP(i,a,n,r,t[7],16,-155497632),r=uP(r,i,a,n,t[10],23,-1094730640),n=uP(n,r,i,a,t[13],4,681279174),a=uP(a,n,r,i,t[0],11,-358537222),i=uP(i,a,n,r,t[3],16,-722521979),r=uP(r,i,a,n,t[6],23,76029189),n=uP(n,r,i,a,t[9],4,-640364487),a=uP(a,n,r,i,t[12],11,-421815835),i=uP(i,a,n,r,t[15],16,530742520),n=dP(n,r=uP(r,i,a,n,t[2],23,-995338651),i,a,t[0],6,-198630844),a=dP(a,n,r,i,t[7],10,1126891415),i=dP(i,a,n,r,t[14],15,-1416354905),r=dP(r,i,a,n,t[5],21,-57434055),n=dP(n,r,i,a,t[12],6,1700485571),a=dP(a,n,r,i,t[3],10,-1894986606),i=dP(i,a,n,r,t[10],15,-1051523),r=dP(r,i,a,n,t[1],21,-2054922799),n=dP(n,r,i,a,t[8],6,1873313359),a=dP(a,n,r,i,t[15],10,-30611744),i=dP(i,a,n,r,t[6],15,-1560198380),r=dP(r,i,a,n,t[13],21,1309151649),n=dP(n,r,i,a,t[4],6,-145523070),a=dP(a,n,r,i,t[11],10,-1120210379),i=dP(i,a,n,r,t[2],15,718787259),r=dP(r,i,a,n,t[9],21,-343485551),e[0]=yP(n,e[0]),e[1]=yP(r,e[1]),e[2]=yP(i,e[2]),e[3]=yP(a,e[3])}function sP(e,t,n,r,i,a){return t=yP(yP(t,e),yP(r,a)),yP(t<<i|t>>>32-i,n)}function cP(e,t,n,r,i,a,o){return sP(t&n|~t&r,e,t,i,a,o)}function lP(e,t,n,r,i,a,o){return sP(t&r|n&~r,e,t,i,a,o)}function uP(e,t,n,r,i,a,o){return sP(t^n^r,e,t,i,a,o)}function dP(e,t,n,r,i,a,o){return sP(n^(t|~r),e,t,i,a,o)}function fP(e){var t,n=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)oP(r,pP(e.substring(t-64,t)));e=e.substring(t-64);var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(oP(r,i),t=0;t<16;t++)i[t]=0;return i[14]=8*n,oP(r,i),r}function pP(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}var mP=`0123456789abcdef`.split(``);function hP(e){for(var t=``,n=0;n<4;n++)t+=mP[e>>8*n+4&15]+mP[e>>8*n&15];return t}function gP(e){return String.fromCharCode(255&e,(65280&e)>>8,(16711680&e)>>16,(4278190080&e)>>24)}function _P(e){return fP(e).map(gP).join(``)}var vP=function(e){for(var t=0;t<e.length;t++)e[t]=hP(e[t]);return e.join(``)}(fP(`hello`))!=`5d41402abc4b2a76b9719d911017c592`;function yP(e,t){if(vP){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}return e+t&4294967295}function bP(e,t){var n,r,i,a;if(e!==n){for(var o=(i=e,a=1+(256/e.length|0),Array(a+1).join(i)),s=[],c=0;c<256;c++)s[c]=c;var l=0;for(c=0;c<256;c++){var u=s[c];l=(l+u+o.charCodeAt(c))%256,s[c]=s[l],s[l]=u}n=e,r=s}else s=r;var d=t.length,f=0,p=0,m=``;for(c=0;c<d;c++)p=(p+(u=s[f=(f+1)%256]))%256,s[f]=s[p],s[p]=u,o=s[(s[f]+s[p])%256],m+=String.fromCharCode(t.charCodeAt(c)^o);return m}var xP={print:4,modify:8,copy:16,"annot-forms":32};function SP(e,t,n,r){this.v=1,this.r=2;var i=192;e.forEach(function(e){if(xP.perm!==void 0)throw Error(`Invalid permission: `+e);i+=xP[e]}),this.padding=`(¿N^NuAd\0NVÿú\b..\0¶Ðh>/\f©þdSiz`;var a=(t+this.padding).substr(0,32),o=(n+this.padding).substr(0,32);this.O=this.processOwnerPassword(a,o),this.P=-(1+(255^i)),this.encryptionKey=_P(a+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(r)).substr(0,5),this.U=bP(this.encryptionKey,this.padding)}function CP(e){if(/[^\u0000-\u00ff]/.test(e))throw Error(`Invalid PDF Name Object: `+e+`, Only accept ASCII characters.`);for(var t=``,n=e.length,r=0;r<n;r++){var i=e.charCodeAt(r);t+=i<33||i===35||i===37||i===40||i===41||i===47||i===60||i===62||i===91||i===93||i===123||i===125||i>126?`#`+(`0`+i.toString(16)).slice(-2):e[r]}return t}function wP(e){if(hD(e)!==`object`)throw Error(`Invalid Context passed to initialize PubSub (jsPDF-module)`);var t={};this.subscribe=function(e,n,r){if(r||=!1,typeof e!=`string`||typeof n!=`function`||typeof r!=`boolean`)throw Error(`Invalid arguments passed to PubSub.subscribe (jsPDF-module)`);t.hasOwnProperty(e)||(t[e]={});var i=Math.random().toString(35);return t[e][i]=[n,!!r],i},this.unsubscribe=function(e){for(var n in t)if(t[n][e])return delete t[n][e],Object.keys(t[n]).length===0&&delete t[n],!0;return!1},this.publish=function(n){if(t.hasOwnProperty(n)){var r=Array.prototype.slice.call(arguments,1),i=[];for(var a in t[n]){var o=t[n][a];try{o[0].apply(e,r)}catch(e){XN.console&&QN.error(`jsPDF PubSub Error`,e.message,e)}o[1]&&i.push(a)}i.length&&i.forEach(this.unsubscribe)}},this.getTopics=function(){return t}}function TP(e){if(!(this instanceof TP))return new TP(e);var t=`opacity,stroke-opacity`.split(`,`);for(var n in e)e.hasOwnProperty(n)&&t.indexOf(n)>=0&&(this[n]=e[n]);this.id=``,this.objectNumber=-1}function EP(e,t){this.gState=e,this.matrix=t,this.id=``,this.objectNumber=-1}function DP(e,t,n,r,i){if(!(this instanceof DP))return new DP(e,t,n,r,i);this.type=e===`axial`?2:3,this.coords=t,this.colors=n,EP.call(this,r,i)}function OP(e,t,n,r,i){if(!(this instanceof OP))return new OP(e,t,n,r,i);this.boundingBox=e,this.xStep=t,this.yStep=n,this.stream=``,this.cloneIndex=0,EP.call(this,r,i)}function kP(e){var t,n=typeof arguments[0]==`string`?arguments[0]:`p`,r=arguments[1],i=arguments[2],a=arguments[3],o=[],s=1,c=16,l=`S`,u=null;hD(e||={})===`object`&&(n=e.orientation,r=e.unit||r,i=e.format||i,a=e.compress||e.compressPdf||a,(u=e.encryption||null)!==null&&(u.userPassword=u.userPassword||``,u.ownerPassword=u.ownerPassword||``,u.userPermissions=u.userPermissions||[]),s=typeof e.userUnit==`number`?Math.abs(e.userUnit):1,e.precision!==void 0&&(t=e.precision),e.floatPrecision!==void 0&&(c=e.floatPrecision),l=e.defaultPathOperation||`S`),o=e.filters||(!0===a?[`FlateEncode`]:o),r||=`mm`,n=(``+(n||`P`)).toLowerCase();var d=e.putOnlyUsedFonts||!1,f={},p={internal:{},__private__:{}};p.__private__.PubSub=wP;var m=`1.3`,h=p.__private__.getPdfVersion=function(){return m};p.__private__.setPdfVersion=function(e){m=e};var g={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};p.__private__.getPageFormats=function(){return g};var _=p.__private__.getPageFormat=function(e){return g[e]};i||=`a4`;var v=`compat`,y=`advanced`,b=v;function x(){this.saveGraphicsState(),H(new Be(U,0,0,-U,0,Cn()*U).toString()+` cm`),this.setFontSize(this.getFontSize()/U),l=`n`,b=y}function S(){this.restoreGraphicsState(),l=`S`,b=v}var C=p.__private__.combineFontStyleAndFontWeight=function(e,t){if(e==`bold`&&t==`normal`||e==`bold`&&t==400||e==`normal`&&t==`italic`||e==`bold`&&t==`italic`)throw Error(`Invalid Combination of fontweight and fontstyle`);return t&&(e=t==400||t===`normal`?e===`italic`?`italic`:`normal`:t!=700&&t!==`bold`||e!==`normal`?(t==700?`bold`:t)+``+e:`bold`),e};p.advancedAPI=function(e){var t=b===v;return t&&x.call(this),typeof e!=`function`||(e(this),t&&S.call(this)),this},p.compatAPI=function(e){var t=b===y;return t&&S.call(this),typeof e!=`function`||(e(this),t&&x.call(this)),this},p.isAdvancedAPI=function(){return b===y};var w,T=function(e){if(b!==y)throw Error(e+` is only available in 'advanced' API mode. You need to call advancedAPI() first.`)},E=p.roundToPrecision=p.__private__.roundToPrecision=function(e,n){var r=t||n;if(isNaN(e)||isNaN(r))throw Error(`Invalid argument passed to jsPDF.roundToPrecision`);return e.toFixed(r).replace(/0+$/,``)};w=p.hpf=p.__private__.hpf=typeof c==`number`?function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return E(e,c)}:c===`smart`?function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return E(e,e>-1&&e<1?16:5)}:function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return E(e,16)};var D=p.f2=p.__private__.f2=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.f2`);return E(e,2)},O=p.__private__.f3=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.f3`);return E(e,3)},k=p.scale=p.__private__.scale=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.scale`);return b===v?e*U:b===y?e:void 0},A=function(e){return k(function(e){return b===v?Cn()-e:b===y?e:void 0}(e))};p.__private__.setPrecision=p.setPrecision=function(e){typeof parseInt(e,10)==`number`&&(t=parseInt(e,10))};var j,M=`00000000000000000000000000000000`,N=p.__private__.getFileId=function(){return M},P=p.__private__.setFileId=function(e){return M=e!==void 0&&/^[a-fA-F0-9]{32}$/.test(e)?e.toUpperCase():M.split(``).map(function(){return`ABCDEF0123456789`.charAt(Math.floor(16*Math.random()))}).join(``),u!==null&&(kt=new SP(u.userPermissions,u.userPassword,u.ownerPassword,M)),M};p.setFileId=function(e){return P(e),this},p.getFileId=function(){return N()};var F=p.__private__.convertDateToPDFDate=function(e){var t=e.getTimezoneOffset(),n=t<0?`+`:`-`,r=Math.floor(Math.abs(t/60)),i=Math.abs(t%60),a=[n,te(r),`'`,te(i),`'`].join(``);return[`D:`,e.getFullYear(),te(e.getMonth()+1),te(e.getDate()),te(e.getHours()),te(e.getMinutes()),te(e.getSeconds()),a].join(``)},I=p.__private__.convertPDFDateToDate=function(e){var t=parseInt(e.substr(2,4),10),n=parseInt(e.substr(6,2),10)-1,r=parseInt(e.substr(8,2),10),i=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),o=parseInt(e.substr(14,2),10);return new Date(t,n,r,i,a,o,0)},L=p.__private__.setCreationDate=function(e){var t;if(e===void 0&&(e=new Date),e instanceof Date)t=F(e);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(e))throw Error(`Invalid argument passed to jsPDF.setCreationDate`);t=e}return j=t},ee=p.__private__.getCreationDate=function(e){var t=j;return e===`jsDate`&&(t=I(j)),t};p.setCreationDate=function(e){return L(e),this},p.getCreationDate=function(e){return ee(e)};var R,te=p.__private__.padd2=function(e){return(`0`+parseInt(e)).slice(-2)},z=p.__private__.padd2Hex=function(e){return(`00`+(e=e.toString())).substr(e.length)},B=0,V=[],ne=[],re=0,ie=[],ae=[],oe=!1,se=ne;p.__private__.setCustomOutputDestination=function(e){oe=!0,se=e};var ce=function(e){oe||(se=e)};p.__private__.resetCustomOutputDestination=function(){oe=!1,se=ne};var H=p.__private__.out=function(e){return e=e.toString(),re+=e.length+1,se.push(e),se},le=p.__private__.write=function(e){return H(arguments.length===1?e.toString():Array.prototype.join.call(arguments,` `))},ue=p.__private__.getArrayBuffer=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n);t--;)r[t]=e.charCodeAt(t);return n},de=[[`Helvetica`,`helvetica`,`normal`,`WinAnsiEncoding`],[`Helvetica-Bold`,`helvetica`,`bold`,`WinAnsiEncoding`],[`Helvetica-Oblique`,`helvetica`,`italic`,`WinAnsiEncoding`],[`Helvetica-BoldOblique`,`helvetica`,`bolditalic`,`WinAnsiEncoding`],[`Courier`,`courier`,`normal`,`WinAnsiEncoding`],[`Courier-Bold`,`courier`,`bold`,`WinAnsiEncoding`],[`Courier-Oblique`,`courier`,`italic`,`WinAnsiEncoding`],[`Courier-BoldOblique`,`courier`,`bolditalic`,`WinAnsiEncoding`],[`Times-Roman`,`times`,`normal`,`WinAnsiEncoding`],[`Times-Bold`,`times`,`bold`,`WinAnsiEncoding`],[`Times-Italic`,`times`,`italic`,`WinAnsiEncoding`],[`Times-BoldItalic`,`times`,`bolditalic`,`WinAnsiEncoding`],[`ZapfDingbats`,`zapfdingbats`,`normal`,null],[`Symbol`,`symbol`,`normal`,null]];p.__private__.getStandardFonts=function(){return de};var fe=e.fontSize||16;p.__private__.setFontSize=p.setFontSize=function(e){return fe=b===y?e/U:e,this};var pe,me=p.__private__.getFontSize=p.getFontSize=function(){return b===v?fe:fe*U},he=e.R2L||!1;p.__private__.setR2L=p.setR2L=function(e){return he=e,this},p.__private__.getR2L=p.getR2L=function(){return he};var ge,_e=p.__private__.setZoomMode=function(e){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(e))pe=e;else if(isNaN(e)){if([void 0,null,`fullwidth`,`fullheight`,`fullpage`,`original`].indexOf(e)===-1)throw Error(`zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "`+e+`" is not recognized.`);pe=e}else pe=parseInt(e,10)};p.__private__.getZoomMode=function(){return pe};var ve,ye=p.__private__.setPageMode=function(e){if([void 0,null,`UseNone`,`UseOutlines`,`UseThumbs`,`FullScreen`].indexOf(e)==-1)throw Error(`Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "`+e+`" is not recognized.`);ge=e};p.__private__.getPageMode=function(){return ge};var be=p.__private__.setLayoutMode=function(e){if([void 0,null,`continuous`,`single`,`twoleft`,`tworight`,`two`].indexOf(e)==-1)throw Error(`Layout mode must be one of continuous, single, twoleft, tworight. "`+e+`" is not recognized.`);ve=e};p.__private__.getLayoutMode=function(){return ve},p.__private__.setDisplayMode=p.setDisplayMode=function(e,t,n){return _e(e),be(t),ye(n),this};var xe={title:``,subject:``,author:``,keywords:``,creator:``};p.__private__.getDocumentProperty=function(e){if(Object.keys(xe).indexOf(e)===-1)throw Error(`Invalid argument passed to jsPDF.getDocumentProperty`);return xe[e]},p.__private__.getDocumentProperties=function(){return xe},p.__private__.setDocumentProperties=p.setProperties=p.setDocumentProperties=function(e){for(var t in xe)xe.hasOwnProperty(t)&&e[t]&&(xe[t]=e[t]);return this},p.__private__.setDocumentProperty=function(e,t){if(Object.keys(xe).indexOf(e)===-1)throw Error(`Invalid arguments passed to jsPDF.setDocumentProperty`);return xe[e]=t};var Se,U,Ce,we,Te,W={},Ee={},De=[],Oe={},ke={},Ae={},je={},Me=null,Ne=0,Pe=[],Fe=new wP(p),Ie=e.hotfixes||[],Le={},Re={},ze=[],Be=function e(t,n,r,i,a,o){if(!(this instanceof e))return new e(t,n,r,i,a,o);isNaN(t)&&(t=1),isNaN(n)&&(n=0),isNaN(r)&&(r=0),isNaN(i)&&(i=1),isNaN(a)&&(a=0),isNaN(o)&&(o=0),this._matrix=[t,n,r,i,a,o]};Object.defineProperty(Be.prototype,"sx",{get:function(){return this._matrix[0]},set:function(e){this._matrix[0]=e}}),Object.defineProperty(Be.prototype,"shy",{get:function(){return this._matrix[1]},set:function(e){this._matrix[1]=e}}),Object.defineProperty(Be.prototype,"shx",{get:function(){return this._matrix[2]},set:function(e){this._matrix[2]=e}}),Object.defineProperty(Be.prototype,"sy",{get:function(){return this._matrix[3]},set:function(e){this._matrix[3]=e}}),Object.defineProperty(Be.prototype,"tx",{get:function(){return this._matrix[4]},set:function(e){this._matrix[4]=e}}),Object.defineProperty(Be.prototype,"ty",{get:function(){return this._matrix[5]},set:function(e){this._matrix[5]=e}}),Object.defineProperty(Be.prototype,"a",{get:function(){return this._matrix[0]},set:function(e){this._matrix[0]=e}}),Object.defineProperty(Be.prototype,"b",{get:function(){return this._matrix[1]},set:function(e){this._matrix[1]=e}}),Object.defineProperty(Be.prototype,"c",{get:function(){return this._matrix[2]},set:function(e){this._matrix[2]=e}}),Object.defineProperty(Be.prototype,"d",{get:function(){return this._matrix[3]},set:function(e){this._matrix[3]=e}}),Object.defineProperty(Be.prototype,"e",{get:function(){return this._matrix[4]},set:function(e){this._matrix[4]=e}}),Object.defineProperty(Be.prototype,"f",{get:function(){return this._matrix[5]},set:function(e){this._matrix[5]=e}}),Object.defineProperty(Be.prototype,"rotation",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(Be.prototype,"scaleX",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(Be.prototype,"scaleY",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(Be.prototype,"isIdentity",{get:function(){return this.sx===1&&this.shy===0&&this.shx===0&&this.sy===1&&this.tx===0&&this.ty===0}}),Be.prototype.join=function(e){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(w).join(e)},Be.prototype.multiply=function(e){return new Be(e.sx*this.sx+e.shy*this.shx,e.sx*this.shy+e.shy*this.sy,e.shx*this.sx+e.sy*this.shx,e.shx*this.shy+e.sy*this.sy,e.tx*this.sx+e.ty*this.shx+this.tx,e.tx*this.shy+e.ty*this.sy+this.ty)},Be.prototype.decompose=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty,o=Math.sqrt(e*e+t*t),s=(e/=o)*n+(t/=o)*r;n-=e*s,r-=t*s;var c=Math.sqrt(n*n+r*r);return s/=c,e*(r/=c)<t*(n/=c)&&(e=-e,t=-t,s=-s,o=-o),{scale:new Be(o,0,0,c,0,0),translate:new Be(1,0,0,1,i,a),rotate:new Be(e,t,-t,e,0,0),skew:new Be(1,0,s,1,0,0)}},Be.prototype.toString=function(e){return this.join(` `)},Be.prototype.inversed=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty,o=1/(e*r-t*n),s=r*o,c=-t*o,l=-n*o,u=e*o;return new Be(s,c,l,u,-s*i-l*a,-c*i-u*a)},Be.prototype.applyToPoint=function(e){return new fn(e.x*this.sx+e.y*this.shx+this.tx,e.x*this.shy+e.y*this.sy+this.ty)},Be.prototype.applyToRectangle=function(e){var t=this.applyToPoint(e),n=this.applyToPoint(new fn(e.x+e.w,e.y+e.h));return new pn(t.x,t.y,n.x-t.x,n.y-t.y)},Be.prototype.clone=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty;return new Be(e,t,n,r,i,a)},p.Matrix=Be;var Ve=p.matrixMult=function(e,t){return t.multiply(e)},He=new Be(1,0,0,1,0,0);p.unitMatrix=p.identityMatrix=He;var Ue=function(e,t){if(!ke[e]){var n=(t instanceof DP?`Sh`:`P`)+(Object.keys(Oe).length+1).toString(10);t.id=n,ke[e]=n,Oe[n]=t,Fe.publish(`addPattern`,t)}};p.ShadingPattern=DP,p.TilingPattern=OP,p.addShadingPattern=function(e,t){return T(`addShadingPattern()`),Ue(e,t),this},p.beginTilingPattern=function(e){T(`beginTilingPattern()`),hn(e.boundingBox[0],e.boundingBox[1],e.boundingBox[2]-e.boundingBox[0],e.boundingBox[3]-e.boundingBox[1],e.matrix)},p.endTilingPattern=function(e,t){T(`endTilingPattern()`),t.stream=ae[R].join(`
|
||
`),Ue(e,t),Fe.publish(`endTilingPattern`,t),ze.pop().restore()};var We,Ge=p.__private__.newObject=function(){var e=Ke();return qe(e,!0),e},Ke=p.__private__.newObjectDeferred=function(){return B++,V[B]=function(){return re},B},qe=function(e,t){return t=typeof t==`boolean`&&t,V[e]=re,t&&H(e+` 0 obj`),e},Je=p.__private__.newAdditionalObject=function(){var e={objId:Ke(),content:``};return ie.push(e),e},Ye=Ke(),Xe=Ke(),Ze=p.__private__.decodeColorString=function(e){var t=e.split(` `);if(t.length!==2||t[1]!==`g`&&t[1]!==`G`)t.length!==5||t[4]!==`k`&&t[4]!==`K`||(t=[(1-t[0])*(1-t[3]),(1-t[1])*(1-t[3]),(1-t[2])*(1-t[3]),`r`]);else{var n=parseFloat(t[0]);t=[n,n,n,`r`]}for(var r=`#`,i=0;i<3;i++)r+=(`0`+Math.floor(255*parseFloat(t[i])).toString(16)).slice(-2);return r},Qe=p.__private__.encodeColorString=function(e){var t;typeof e==`string`&&(e={ch1:e});var n=e.ch1,r=e.ch2,i=e.ch3,a=e.ch4,o=e.pdfColorType===`draw`?[`G`,`RG`,`K`]:[`g`,`rg`,`k`];if(typeof n==`string`&&n.charAt(0)!==`#`){var s=new rP(n);if(s.ok)n=s.toHex();else if(!/^\d*\.?\d*$/.test(n))throw Error(`Invalid color "`+n+`" passed to jsPDF.encodeColorString.`)}if(typeof n==`string`&&/^#[0-9A-Fa-f]{3}$/.test(n)&&(n=`#`+n[1]+n[1]+n[2]+n[2]+n[3]+n[3]),typeof n==`string`&&/^#[0-9A-Fa-f]{6}$/.test(n)){var c=parseInt(n.substr(1),16);n=c>>16&255,r=c>>8&255,i=255&c}if(r===void 0||a===void 0&&n===r&&r===i)t=typeof n==`string`?n+` `+o[0]:e.precision===2?D(n/255)+` `+o[0]:O(n/255)+` `+o[0];else if(a===void 0||hD(a)===`object`){if(a&&!isNaN(a.a)&&a.a===0)return[`1.`,`1.`,`1.`,o[1]].join(` `);t=typeof n==`string`?[n,r,i,o[1]].join(` `):e.precision===2?[D(n/255),D(r/255),D(i/255),o[1]].join(` `):[O(n/255),O(r/255),O(i/255),o[1]].join(` `)}else t=typeof n==`string`?[n,r,i,a,o[2]].join(` `):e.precision===2?[D(n),D(r),D(i),D(a),o[2]].join(` `):[O(n),O(r),O(i),O(a),o[2]].join(` `);return t},$e=p.__private__.getFilters=function(){return o},et=p.__private__.putStream=function(e){var t=(e||={}).data||``,n=e.filters||$e(),r=e.alreadyAppliedFilters||[],i=e.addLength1||!1,a=t.length,o=e.objectId,s=function(e){return e};if(u!==null&&o===void 0)throw Error(`ObjectId must be passed to putStream for file encryption`);u!==null&&(s=kt.encryptor(o,0));var c={};!0===n&&(n=[`FlateEncode`]);var l=e.additionalKeyValues||[],d=(c=kP.API.processDataByFilters===void 0?{data:t,reverseChain:[]}:kP.API.processDataByFilters(t,n)).reverseChain+(Array.isArray(r)?r.join(` `):r.toString());if(c.data.length!==0&&(l.push({key:`Length`,value:c.data.length}),!0===i&&l.push({key:`Length1`,value:a})),d.length!=0)if(d.split(`/`).length-1==1)l.push({key:`Filter`,value:d});else{l.push({key:`Filter`,value:`[`+d+`]`});for(var f=0;f<l.length;f+=1)if(l[f].key===`DecodeParms`){for(var p=[],m=0;m<c.reverseChain.split(`/`).length-1;m+=1)p.push(`null`);p.push(l[f].value),l[f].value=`[`+p.join(` `)+`]`}}H(`<<`);for(var h=0;h<l.length;h++)H(`/`+l[h].key+` `+l[h].value);H(`>>`),c.data.length!==0&&(H(`stream`),H(s(c.data)),H(`endstream`))},tt=p.__private__.putPage=function(e){var t=e.number,n=e.data,r=e.objId,i=e.contentsObjId;qe(r,!0),H(`<</Type /Page`),H(`/Parent `+e.rootDictionaryObjId+` 0 R`),H(`/Resources `+e.resourceDictionaryObjId+` 0 R`),H(`/MediaBox [`+parseFloat(w(e.mediaBox.bottomLeftX))+` `+parseFloat(w(e.mediaBox.bottomLeftY))+` `+w(e.mediaBox.topRightX)+` `+w(e.mediaBox.topRightY)+`]`),e.cropBox!==null&&H(`/CropBox [`+w(e.cropBox.bottomLeftX)+` `+w(e.cropBox.bottomLeftY)+` `+w(e.cropBox.topRightX)+` `+w(e.cropBox.topRightY)+`]`),e.bleedBox!==null&&H(`/BleedBox [`+w(e.bleedBox.bottomLeftX)+` `+w(e.bleedBox.bottomLeftY)+` `+w(e.bleedBox.topRightX)+` `+w(e.bleedBox.topRightY)+`]`),e.trimBox!==null&&H(`/TrimBox [`+w(e.trimBox.bottomLeftX)+` `+w(e.trimBox.bottomLeftY)+` `+w(e.trimBox.topRightX)+` `+w(e.trimBox.topRightY)+`]`),e.artBox!==null&&H(`/ArtBox [`+w(e.artBox.bottomLeftX)+` `+w(e.artBox.bottomLeftY)+` `+w(e.artBox.topRightX)+` `+w(e.artBox.topRightY)+`]`),typeof e.userUnit==`number`&&e.userUnit!==1&&H(`/UserUnit `+e.userUnit),Fe.publish(`putPage`,{objId:r,pageContext:Pe[t],pageNumber:t,page:n}),H(`/Contents `+i+` 0 R`),H(`>>`),H(`endobj`);var a=n.join(`
|
||
`);return b===y&&(a+=`
|
||
Q`),qe(i,!0),et({data:a,filters:$e(),objectId:i}),H(`endobj`),r},nt=p.__private__.putPages=function(){var e,t,n=[];for(e=1;e<=Ne;e++)Pe[e].objId=Ke(),Pe[e].contentsObjId=Ke();for(e=1;e<=Ne;e++)n.push(tt({number:e,data:ae[e],objId:Pe[e].objId,contentsObjId:Pe[e].contentsObjId,mediaBox:Pe[e].mediaBox,cropBox:Pe[e].cropBox,bleedBox:Pe[e].bleedBox,trimBox:Pe[e].trimBox,artBox:Pe[e].artBox,userUnit:Pe[e].userUnit,rootDictionaryObjId:Ye,resourceDictionaryObjId:Xe}));qe(Ye,!0),H(`<</Type /Pages`);var r=`/Kids [`;for(t=0;t<Ne;t++)r+=n[t]+` 0 R `;H(r+`]`),H(`/Count `+Ne),H(`>>`),H(`endobj`),Fe.publish(`postPutPages`)},rt=function(e){Fe.publish(`putFont`,{font:e,out:H,newObject:Ge,putStream:et}),!0!==e.isAlreadyPutted&&(e.objectNumber=Ge(),H(`<<`),H(`/Type /Font`),H(`/BaseFont /`+CP(e.postScriptName)),H(`/Subtype /Type1`),typeof e.encoding==`string`&&H(`/Encoding /`+e.encoding),H(`/FirstChar 32`),H(`/LastChar 255`),H(`>>`),H(`endobj`))},it=function(e){e.objectNumber=Ge();var t=[];t.push({key:`Type`,value:`/XObject`}),t.push({key:`Subtype`,value:`/Form`}),t.push({key:`BBox`,value:`[`+[w(e.x),w(e.y),w(e.x+e.width),w(e.y+e.height)].join(` `)+`]`}),t.push({key:`Matrix`,value:`[`+e.matrix.toString()+`]`}),et({data:e.pages[1].join(`
|
||
`),additionalKeyValues:t,objectId:e.objectNumber}),H(`endobj`)},at=function(e,t){t||=21;var n=Ge(),r=function(e,t){var n,r=[],i=1/(t-1);for(n=0;n<1;n+=i)r.push(n);if(r.push(1),e[0].offset!=0){var a={offset:0,color:e[0].color};e.unshift(a)}if(e[e.length-1].offset!=1){var o={offset:1,color:e[e.length-1].color};e.push(o)}for(var s=``,c=0,l=0;l<r.length;l++){for(n=r[l];n>e[c+1].offset;)c++;var u=e[c].offset,d=(n-u)/(e[c+1].offset-u),f=e[c].color,p=e[c+1].color;s+=z(Math.round((1-d)*f[0]+d*p[0]).toString(16))+z(Math.round((1-d)*f[1]+d*p[1]).toString(16))+z(Math.round((1-d)*f[2]+d*p[2]).toString(16))}return s.trim()}(e.colors,t),i=[];i.push({key:`FunctionType`,value:`0`}),i.push({key:`Domain`,value:`[0.0 1.0]`}),i.push({key:`Size`,value:`[`+t+`]`}),i.push({key:`BitsPerSample`,value:`8`}),i.push({key:`Range`,value:`[0.0 1.0 0.0 1.0 0.0 1.0]`}),i.push({key:`Decode`,value:`[0.0 1.0 0.0 1.0 0.0 1.0]`}),et({data:r,additionalKeyValues:i,alreadyAppliedFilters:[`/ASCIIHexDecode`],objectId:n}),H(`endobj`),e.objectNumber=Ge(),H(`<< /ShadingType `+e.type),H(`/ColorSpace /DeviceRGB`);var a=`/Coords [`+w(parseFloat(e.coords[0]))+` `+w(parseFloat(e.coords[1]))+` `;e.type===2?a+=w(parseFloat(e.coords[2]))+` `+w(parseFloat(e.coords[3])):a+=w(parseFloat(e.coords[2]))+` `+w(parseFloat(e.coords[3]))+` `+w(parseFloat(e.coords[4]))+` `+w(parseFloat(e.coords[5])),H(a+=`]`),e.matrix&&H(`/Matrix [`+e.matrix.toString()+`]`),H(`/Function `+n+` 0 R`),H(`/Extend [true true]`),H(`>>`),H(`endobj`)},ot=function(e,t){var n=Ke(),r=Ge();t.push({resourcesOid:n,objectOid:r}),e.objectNumber=r;var i=[];i.push({key:`Type`,value:`/Pattern`}),i.push({key:`PatternType`,value:`1`}),i.push({key:`PaintType`,value:`1`}),i.push({key:`TilingType`,value:`1`}),i.push({key:`BBox`,value:`[`+e.boundingBox.map(w).join(` `)+`]`}),i.push({key:`XStep`,value:w(e.xStep)}),i.push({key:`YStep`,value:w(e.yStep)}),i.push({key:`Resources`,value:n+` 0 R`}),e.matrix&&i.push({key:`Matrix`,value:`[`+e.matrix.toString()+`]`}),et({data:e.stream,additionalKeyValues:i,objectId:e.objectNumber}),H(`endobj`)},st=function(e){for(var t in e.objectNumber=Ge(),H(`<<`),e)switch(t){case`opacity`:H(`/ca `+D(e[t]));break;case`stroke-opacity`:H(`/CA `+D(e[t]))}H(`>>`),H(`endobj`)},ct=function(e){qe(e.resourcesOid,!0),H(`<<`),H(`/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]`),function(){for(var e in H(`/Font <<`),W)W.hasOwnProperty(e)&&(!1===d||!0===d&&f.hasOwnProperty(e))&&H(`/`+e+` `+W[e].objectNumber+` 0 R`);H(`>>`)}(),function(){if(Object.keys(Oe).length>0){for(var e in H(`/Shading <<`),Oe)Oe.hasOwnProperty(e)&&Oe[e]instanceof DP&&Oe[e].objectNumber>=0&&H(`/`+e+` `+Oe[e].objectNumber+` 0 R`);Fe.publish(`putShadingPatternDict`),H(`>>`)}}(),function(e){if(Object.keys(Oe).length>0){for(var t in H(`/Pattern <<`),Oe)Oe.hasOwnProperty(t)&&Oe[t]instanceof p.TilingPattern&&Oe[t].objectNumber>=0&&Oe[t].objectNumber<e&&H(`/`+t+` `+Oe[t].objectNumber+` 0 R`);Fe.publish(`putTilingPatternDict`),H(`>>`)}}(e.objectOid),function(){if(Object.keys(Ae).length>0){for(var e in H(`/ExtGState <<`),Ae)Ae.hasOwnProperty(e)&&Ae[e].objectNumber>=0&&H(`/`+e+` `+Ae[e].objectNumber+` 0 R`);Fe.publish(`putGStateDict`),H(`>>`)}}(),function(){for(var e in H(`/XObject <<`),Le)Le.hasOwnProperty(e)&&Le[e].objectNumber>=0&&H(`/`+e+` `+Le[e].objectNumber+` 0 R`);Fe.publish(`putXobjectDict`),H(`>>`)}(),H(`>>`),H(`endobj`)},lt=function(e){Ee[e.fontName]=Ee[e.fontName]||{},Ee[e.fontName][e.fontStyle]=e.id},ut=function(e,t,n,r,i){var a={id:`F`+(Object.keys(W).length+1).toString(10),postScriptName:e,fontName:t,fontStyle:n,encoding:r,isStandardFont:i||!1,metadata:{}};return Fe.publish(`addFont`,{font:a,instance:this}),W[a.id]=a,lt(a),a.id},dt=p.__private__.pdfEscape=p.pdfEscape=function(e,t){return function(e,t){var n,r,i,a,o,s,c,l,u;if(i=(t||={}).sourceEncoding||`Unicode`,o=t.outputEncoding,(t.autoencode||o)&&W[Se].metadata&&W[Se].metadata[i]&&W[Se].metadata[i].encoding&&(a=W[Se].metadata[i].encoding,!o&&W[Se].encoding&&(o=W[Se].encoding),!o&&a.codePages&&(o=a.codePages[0]),typeof o==`string`&&(o=a[o]),o)){for(c=!1,s=[],n=0,r=e.length;n<r;n++)(l=o[e.charCodeAt(n)])?s.push(String.fromCharCode(l)):s.push(e[n]),s[n].charCodeAt(0)>>8&&(c=!0);e=s.join(``)}for(n=e.length;c===void 0&&n!==0;)e.charCodeAt(n-1)>>8&&(c=!0),n--;if(!c)return e;for(s=t.noBOM?[]:[254,255],n=0,r=e.length;n<r;n++){if((u=(l=e.charCodeAt(n))>>8)>>8)throw Error(`Character at position `+n+` of string '`+e+`' exceeds 16bits. Cannot be encoded into UCS-2 BE`);s.push(u),s.push(l-(u<<8))}return String.fromCharCode.apply(void 0,s)}(e,t).replace(/\\/g,`\\\\`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`)},ft=p.__private__.beginPage=function(e){ae[++Ne]=[],Pe[Ne]={objId:0,contentsObjId:0,userUnit:Number(s),artBox:null,bleedBox:null,cropBox:null,trimBox:null,mediaBox:{bottomLeftX:0,bottomLeftY:0,topRightX:Number(e[0]),topRightY:Number(e[1])}},ht(Ne),ce(ae[R])},pt=function(e,t){var r,a,o;switch(n=t||n,typeof e==`string`&&(r=_(e.toLowerCase()),Array.isArray(r)&&(a=r[0],o=r[1])),Array.isArray(e)&&(a=e[0]*U,o=e[1]*U),isNaN(a)&&(a=i[0],o=i[1]),(a>14400||o>14400)&&(QN.warn(`A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400`),a=Math.min(14400,a),o=Math.min(14400,o)),i=[a,o],n.substr(0,1)){case`l`:o>a&&(i=[o,a]);break;case`p`:a>o&&(i=[o,a])}ft(i),Yt(qt),H(nn),ln!==0&&H(ln+` J`),un!==0&&H(un+` j`),Fe.publish(`addPage`,{pageNumber:Ne})},mt=function(e){e>0&&e<=Ne&&(ae.splice(e,1),Pe.splice(e,1),Ne--,R>Ne&&(R=Ne),this.setPage(R))},ht=function(e){e>0&&e<=Ne&&(R=e)},gt=p.__private__.getNumberOfPages=p.getNumberOfPages=function(){return ae.length-1},_t=function(e,t,n){var r,i=void 0;return n||={},e=e===void 0?W[Se].fontName:e,t=t===void 0?W[Se].fontStyle:t,r=e.toLowerCase(),Ee[r]!==void 0&&Ee[r][t]!==void 0?i=Ee[r][t]:Ee[e]!==void 0&&Ee[e][t]!==void 0?i=Ee[e][t]:!1===n.disableWarning&&QN.warn(`Unable to look up font label for font '`+e+`', '`+t+`'. Refer to getFontList() for available fonts.`),i||n.noFallback||((i=Ee.times[t])??(i=Ee.times.normal)),i},vt=p.__private__.putInfo=function(){var e=Ge(),t=function(e){return e};for(var n in u!==null&&(t=kt.encryptor(e,0)),H(`<<`),H(`/Producer (`+dt(t(`jsPDF `+kP.version))+`)`),xe)xe.hasOwnProperty(n)&&xe[n]&&H(`/`+n.substr(0,1).toUpperCase()+n.substr(1)+` (`+dt(t(xe[n]))+`)`);H(`/CreationDate (`+dt(t(j))+`)`),H(`>>`),H(`endobj`)},yt=p.__private__.putCatalog=function(e){var t=(e||={}).rootDictionaryObjId||Ye;switch(Ge(),H(`<<`),H(`/Type /Catalog`),H(`/Pages `+t+` 0 R`),pe||=`fullwidth`,pe){case`fullwidth`:H(`/OpenAction [3 0 R /FitH null]`);break;case`fullheight`:H(`/OpenAction [3 0 R /FitV null]`);break;case`fullpage`:H(`/OpenAction [3 0 R /Fit]`);break;case`original`:H(`/OpenAction [3 0 R /XYZ null null 1]`);break;default:var n=``+pe;n.substr(n.length-1)===`%`&&(pe=parseInt(pe)/100),typeof pe==`number`&&H(`/OpenAction [3 0 R /XYZ null null `+D(pe)+`]`)}switch(ve||=`continuous`,ve){case`continuous`:H(`/PageLayout /OneColumn`);break;case`single`:H(`/PageLayout /SinglePage`);break;case`two`:case`twoleft`:H(`/PageLayout /TwoColumnLeft`);break;case`tworight`:H(`/PageLayout /TwoColumnRight`)}ge&&H(`/PageMode /`+ge),Fe.publish(`putCatalog`),H(`>>`),H(`endobj`)},bt=p.__private__.putTrailer=function(){H(`trailer`),H(`<<`),H(`/Size `+(B+1)),H(`/Root `+B+` 0 R`),H(`/Info `+(B-1)+` 0 R`),u!==null&&H(`/Encrypt `+kt.oid+` 0 R`),H(`/ID [ <`+M+`> <`+M+`> ]`),H(`>>`)},xt=p.__private__.putHeader=function(){H(`%PDF-`+m),H(`%ºß¬à`)},St=p.__private__.putXRef=function(){var e=`0000000000`;H(`xref`),H(`0 `+(B+1)),H(`0000000000 65535 f `);for(var t=1;t<=B;t++)typeof V[t]==`function`?H((e+V[t]()).slice(-10)+` 00000 n `):V[t]===void 0?H(`0000000000 00000 n `):H((e+V[t]).slice(-10)+` 00000 n `)},Ct=p.__private__.buildDocument=function(){var e;B=0,re=0,ne=[],V=[],ie=[],Ye=Ke(),Xe=Ke(),ce(ne),Fe.publish(`buildDocument`),xt(),nt(),function(){Fe.publish(`putAdditionalObjects`);for(var e=0;e<ie.length;e++){var t=ie[e];qe(t.objId,!0),H(t.content),H(`endobj`)}Fe.publish(`postPutAdditionalObjects`)}(),e=[],function(){for(var e in W)W.hasOwnProperty(e)&&(!1===d||!0===d&&f.hasOwnProperty(e))&&rt(W[e])}(),function(){for(var e in Ae)Ae.hasOwnProperty(e)&&st(Ae[e])}(),function(){for(var e in Le)Le.hasOwnProperty(e)&&it(Le[e])}(),function(e){for(var t in Oe)Oe.hasOwnProperty(t)&&(Oe[t]instanceof DP?at(Oe[t]):Oe[t]instanceof OP&&ot(Oe[t],e))}(e),Fe.publish(`putResources`),e.forEach(ct),ct({resourcesOid:Xe,objectOid:2**53-1}),Fe.publish(`postPutResources`),u!==null&&(kt.oid=Ge(),H(`<<`),H(`/Filter /Standard`),H(`/V `+kt.v),H(`/R `+kt.r),H(`/U <`+kt.toHexString(kt.U)+`>`),H(`/O <`+kt.toHexString(kt.O)+`>`),H(`/P `+kt.P),H(`>>`),H(`endobj`)),vt(),yt();var t=re;return St(),bt(),H(`startxref`),H(``+t),H(`%%EOF`),ce(ae[R]),ne.join(`
|
||
`)},wt=p.__private__.getBlob=function(e){return new Blob([ue(e)],{type:`application/pdf`})},Tt=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},Et=function(e){var t,n=e.document,r=n.documentElement,i=n.head,a=n.body;return i||(i=n.createElement(`head`),r.appendChild(i)),a||(a=n.createElement(`body`),r.appendChild(a)),Tt(i),Tt(a),(t=n.createElement(`style`)).appendChild(n.createTextNode(`html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}`)),i.appendChild(t),{document:n,body:a}},Dt=p.output=p.__private__.output=(We=function(e,t){switch(typeof(t||={})==`string`?t={filename:t}:t.filename=t.filename||`generated.pdf`,e){case void 0:return Ct();case`save`:p.save(t.filename);break;case`arraybuffer`:return ue(Ct());case`blob`:return wt(Ct());case`bloburi`:case`bloburl`:if(XN.URL!==void 0&&typeof XN.URL.createObjectURL==`function`)return XN.URL&&XN.URL.createObjectURL(wt(Ct()))||void 0;QN.warn(`bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.`);break;case`datauristring`:case`dataurlstring`:var n=``,r=Ct();try{n=aP(r)}catch{n=aP(unescape(encodeURIComponent(r)))}return`data:application/pdf;filename=`+encodeURIComponent(t.filename)+`;base64,`+n;case`pdfobjectnewwindow`:if(Object.prototype.toString.call(XN)===`[object Window]`){var i=`https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js`,a=!t.pdfObjectUrl;a||(i=t.pdfObjectUrl);var o=XN.open();if(o!==null){var s=Et(o),c=s.document.createElement(`script`),l=this;c.src=i,a&&(c.integrity=`sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==`,c.crossOrigin=`anonymous`),c.onload=function(){o.PDFObject.embed(l.output(`dataurlstring`),t)},s.body.appendChild(c)}return o}throw Error(`The option pdfobjectnewwindow just works in a browser-environment.`);case`pdfjsnewwindow`:if(Object.prototype.toString.call(XN)===`[object Window]`){var u=t.pdfJsUrl||`examples/PDF.js/web/viewer.html`,d=XN.open();if(d!==null){var f=Et(d),m=f.document.createElement(`iframe`),h=u.indexOf(`?`)===-1?`?`:`&`;l=this,m.id=`pdfViewer`,m.width=`500px`,m.height=`400px`,m.src=u+h+`file=&downloadName=`+encodeURIComponent(t.filename),m.onload=function(){d.document.title=t.filename,m.contentWindow.PDFViewerApplication.open(l.output(`bloburl`))},f.body.appendChild(m)}return d}throw Error(`The option pdfjsnewwindow just works in a browser-environment.`);case`dataurlnewwindow`:if(Object.prototype.toString.call(XN)!==`[object Window]`)throw Error(`The option dataurlnewwindow just works in a browser-environment.`);var g=XN.open();if(g!==null){var _=Et(g),v=_.document.createElement(`iframe`);v.src=this.output(`datauristring`,t),_.body.appendChild(v),g.document.title=t.filename}if(g||typeof safari>`u`)return g;break;case`datauri`:case`dataurl`:return XN.document.location.href=this.output(`datauristring`,t);default:return null}},We.foo=function(){try{return We.apply(this,arguments)}catch(n){var e=n.stack||``;~e.indexOf(` at `)&&(e=e.split(` at `)[1]);var t=`Error in function `+e.split(`
|
||
`)[0].split(`<`)[0]+`: `+n.message;if(!XN.console)throw Error(t);XN.console.error(t,n),XN.alert&&alert(t)}},We.foo.bar=We,We.foo),Ot=function(e){return!0===Array.isArray(Ie)&&Ie.indexOf(e)>-1};switch(r){case`pt`:U=1;break;case`mm`:U=72/25.4;break;case`cm`:U=72/2.54;break;case`in`:U=72;break;case`px`:U=Ot(`px_scaling`)==1?.75:96/72;break;case`pc`:case`em`:U=12;break;case`ex`:U=6;break;default:if(typeof r!=`number`)throw Error(`Invalid unit: `+r);U=r}var kt=null;L(),P();var At=p.__private__.getPageInfo=p.getPageInfo=function(e){if(isNaN(e)||e%1!=0)throw Error(`Invalid argument passed to jsPDF.getPageInfo`);return{objId:Pe[e].objId,pageNumber:e,pageContext:Pe[e]}},jt=p.__private__.getPageInfoByObjId=function(e){if(isNaN(e)||e%1!=0)throw Error(`Invalid argument passed to jsPDF.getPageInfoByObjId`);for(var t in Pe)if(Pe[t].objId===e)break;return At(t)},Mt=p.__private__.getCurrentPageInfo=p.getCurrentPageInfo=function(){return{objId:Pe[R].objId,pageNumber:R,pageContext:Pe[R]}};p.addPage=function(){return pt.apply(this,arguments),this},p.setPage=function(){return ht.apply(this,arguments),ce.call(this,ae[R]),this},p.insertPage=function(e){return this.addPage(),this.movePage(R,e),this},p.movePage=function(e,t){var n,r;if(e>t){n=ae[e],r=Pe[e];for(var i=e;i>t;i--)ae[i]=ae[i-1],Pe[i]=Pe[i-1];ae[t]=n,Pe[t]=r,this.setPage(t)}else if(e<t){n=ae[e],r=Pe[e];for(var a=e;a<t;a++)ae[a]=ae[a+1],Pe[a]=Pe[a+1];ae[t]=n,Pe[t]=r,this.setPage(t)}return this},p.deletePage=function(){return mt.apply(this,arguments),this},p.__private__.text=p.text=function(e,t,n,r,i){var a,o,s,c,l,u,d,p,m,h=(r||={}).scope||this;if(typeof e==`number`&&typeof t==`number`&&(typeof n==`string`||Array.isArray(n))){var g=n;n=t,t=e,e=g}if(arguments[3]instanceof Be==0?(s=arguments[4],c=arguments[5],hD(d=arguments[3])===`object`&&d!==null||(typeof s==`string`&&(c=s,s=null),typeof d==`string`&&(c=d,d=null),typeof d==`number`&&(s=d,d=null),r={flags:d,angle:s,align:c})):(T(`The transform parameter of text() with a Matrix value`),m=i),isNaN(t)||isNaN(n)||e==null)throw Error(`Invalid arguments passed to jsPDF.text`);if(e.length===0)return h;var _,v=``,x=typeof r.lineHeightFactor==`number`?r.lineHeightFactor:Kt,S=h.internal.scaleFactor;function C(e){return e=e.split(` `).join(Array(r.TabLen||9).join(` `)),dt(e,d)}function E(e){for(var t,n=e.concat(),r=[],i=n.length;i--;)typeof(t=n.shift())==`string`?r.push(t):Array.isArray(e)&&(t.length===1||t[1]===void 0&&t[2]===void 0)?r.push(t[0]):r.push([t[0],t[1],t[2]]);return r}function D(e,t){var n;if(typeof e==`string`)n=t(e)[0];else if(Array.isArray(e)){for(var r,i,a=e.concat(),o=[],s=a.length;s--;)typeof(r=a.shift())==`string`?o.push(t(r)[0]):Array.isArray(r)&&typeof r[0]==`string`&&(i=t(r[0],r[1],r[2]),o.push([i[0],i[1],i[2]]));n=o}return n}var O=!1,A=!0;if(typeof e==`string`)O=!0;else if(Array.isArray(e)){var j=e.concat();o=[];for(var M,N=j.length;N--;)(typeof(M=j.shift())!=`string`||Array.isArray(M)&&typeof M[0]!=`string`)&&(A=!1);O=A}if(!1===O)throw Error(`Type of text must be string or Array. "`+e+`" is not recognized.`);typeof e==`string`&&(e=e.match(/[\r?\n]/)?e.split(/\r\n|\r|\n/g):[e]);var P=fe/h.internal.scaleFactor,F=P*(x-1);switch(r.baseline){case`bottom`:n-=F;break;case`top`:n+=P-F;break;case`hanging`:n+=P-2*F;break;case`middle`:n+=P/2-F}if((u=r.maxWidth||0)>0&&(typeof e==`string`?e=h.splitTextToSize(e,u):Object.prototype.toString.call(e)===`[object Array]`&&(e=e.reduce(function(e,t){return e.concat(h.splitTextToSize(t,u))},[]))),a={text:e,x:t,y:n,options:r,mutex:{pdfEscape:dt,activeFontKey:Se,fonts:W,activeFontSize:fe}},Fe.publish(`preProcessText`,a),e=a.text,s=(r=a.options).angle,m instanceof Be==0&&s&&typeof s==`number`){s*=Math.PI/180,r.rotationDirection===0&&(s=-s),b===y&&(s=-s);var I=Math.cos(s),L=Math.sin(s);m=new Be(I,L,-L,I,0,0)}else s&&s instanceof Be&&(m=s);b!==y||m||(m=He),(l=r.charSpace||sn)!==void 0&&(v+=w(k(l))+` Tc
|
||
`,this.setCharSpace(this.getCharSpace()||0)),(p=r.horizontalScale)!==void 0&&(v+=w(100*p)+` Tz
|
||
`),r.lang;var ee=-1,R=r.renderingMode===void 0?r.stroke:r.renderingMode,te=h.internal.getCurrentPageInfo().pageContext;switch(R){case 0:case!1:case`fill`:ee=0;break;case 1:case!0:case`stroke`:ee=1;break;case 2:case`fillThenStroke`:ee=2;break;case 3:case`invisible`:ee=3;break;case 4:case`fillAndAddForClipping`:ee=4;break;case 5:case`strokeAndAddPathForClipping`:ee=5;break;case 6:case`fillThenStrokeAndAddToPathForClipping`:ee=6;break;case 7:case`addToPathForClipping`:ee=7}var z=te.usedRenderingMode===void 0?-1:te.usedRenderingMode;ee===-1?z!==-1&&(v+=`0 Tr
|
||
`):v+=ee+` Tr
|
||
`,ee!==-1&&(te.usedRenderingMode=ee),c=r.align||`left`;var B,V=fe*x,ne=h.internal.pageSize.getWidth(),re=W[Se];l=r.charSpace||sn,u=r.maxWidth||0,d=Object.assign({autoencode:!0,noBOM:!0},r.flags);var ie=[],ae=function(e){return h.getStringUnitWidth(e,{font:re,charSpace:l,fontSize:fe,doKerning:!1})*fe/S};if(Object.prototype.toString.call(e)===`[object Array]`){var oe;o=E(e),c!==`left`&&(B=o.map(ae));var se,ce=0;if(c===`right`){t-=B[0],e=[],N=o.length;for(var le=0;le<N;le++)le===0?(se=G(t),oe=$t(n)):(se=k(ce-B[le]),oe=-V),e.push([o[le],se,oe]),ce=B[le]}else if(c===`center`){t-=B[0]/2,e=[],N=o.length;for(var ue=0;ue<N;ue++)ue===0?(se=G(t),oe=$t(n)):(se=k((ce-B[ue])/2),oe=-V),e.push([o[ue],se,oe]),ce=B[ue]}else if(c===`left`){e=[],N=o.length;for(var de=0;de<N;de++)e.push(o[de])}else if(c===`justify`&&re.encoding===`Identity-H`){e=[],N=o.length,u=u===0?ne:u;for(var pe=0,me=0;me<N;me++)if(oe=me===0?$t(n):-V,se=me===0?G(t):pe,me<N-1){var ge=k((u-B[me])/(o[me].split(` `).length-1)),_e=o[me].split(` `);e.push([_e[0]+` `,se,oe]),pe=0;for(var ve=1;ve<_e.length;ve++){var ye=(ae(_e[ve-1]+` `+_e[ve])-ae(_e[ve]))*S+ge;ve==_e.length-1?e.push([_e[ve],ye,0]):e.push([_e[ve]+` `,ye,0]),pe-=ye}}else e.push([o[me],se,oe]);e.push([``,pe,0])}else{if(c!==`justify`)throw Error(`Unrecognized alignment option, use "left", "center", "right" or "justify".`);for(e=[],N=o.length,u=u===0?ne:u,me=0;me<N;me++){oe=me===0?$t(n):-V,se=me===0?G(t):0;var be=o[me].split(` `).length-1,xe=be>0?(u-B[me])/be:0;me<N-1?ie.push(w(k(xe))):ie.push(0),e.push([o[me],se,oe])}}}!0===(typeof r.R2L==`boolean`?r.R2L:he)&&(e=D(e,function(e,t,n){return[e.split(``).reverse().join(``),t,n]})),a={text:e,x:t,y:n,options:r,mutex:{pdfEscape:dt,activeFontKey:Se,fonts:W,activeFontSize:fe}},Fe.publish(`postProcessText`,a),e=a.text,_=a.mutex.isHex||!1;var U=W[Se].encoding;U!==`WinAnsiEncoding`&&U!==`StandardEncoding`||(e=D(e,function(e,t,n){return[C(e),t,n]})),o=E(e),e=[];for(var Ce,we,Te,Ee=+!!Array.isArray(o[0]),De=``,Oe=function(e,t,n){var i=``;return n instanceof Be?(n=typeof r.angle==`number`?Ve(n,new Be(1,0,0,1,e,t)):Ve(new Be(1,0,0,1,e,t),n),b===y&&(n=Ve(new Be(1,0,0,-1,0,0),n)),i=n.join(` `)+` Tm
|
||
`):i=w(e)+` `+w(t)+` Td
|
||
`,i},ke=0;ke<o.length;ke++){switch(De=``,Ee){case 1:Te=(_?`<`:`(`)+o[ke][0]+(_?`>`:`)`),Ce=parseFloat(o[ke][1]),we=parseFloat(o[ke][2]);break;case 0:Te=(_?`<`:`(`)+o[ke]+(_?`>`:`)`),Ce=G(t),we=$t(n)}ie!==void 0&&ie[ke]!==void 0&&(De=ie[ke]+` Tw
|
||
`),ke===0?e.push(De+Oe(Ce,we,m)+Te):Ee===0?e.push(De+Te):Ee===1&&e.push(De+Oe(Ce,we,m)+Te)}e=Ee===0?e.join(` Tj
|
||
T* `):e.join(` Tj
|
||
`),e+=` Tj
|
||
`;var Ae=`BT
|
||
/`;return Ae+=Se+` `+fe+` Tf
|
||
`,Ae+=w(fe*x)+` TL
|
||
`,Ae+=an+`
|
||
`,Ae+=v,Ae+=e,H(Ae+=`ET`),f[Se]=!0,h};var Nt=p.__private__.clip=p.clip=function(e){return H(e===`evenodd`?`W*`:`W`),this};p.clipEvenOdd=function(){return Nt(`evenodd`)},p.__private__.discardPath=p.discardPath=function(){return H(`n`),this};var Pt=p.__private__.isValidStyle=function(e){var t=!1;return[void 0,null,`S`,`D`,`F`,`DF`,`FD`,`f`,`f*`,`B`,`B*`,`n`].indexOf(e)!==-1&&(t=!0),t};p.__private__.setDefaultPathOperation=p.setDefaultPathOperation=function(e){return Pt(e)&&(l=e),this};var Ft=p.__private__.getStyle=p.getStyle=function(e){var t=l;switch(e){case`D`:case`S`:t=`S`;break;case`F`:t=`f`;break;case`FD`:case`DF`:t=`B`;break;case`f`:case`f*`:case`B`:case`B*`:t=e}return t},It=p.close=function(){return H(`h`),this};p.stroke=function(){return H(`S`),this},p.fill=function(e){return Lt(`f`,e),this},p.fillEvenOdd=function(e){return Lt(`f*`,e),this},p.fillStroke=function(e){return Lt(`B`,e),this},p.fillStrokeEvenOdd=function(e){return Lt(`B*`,e),this};var Lt=function(e,t){hD(t)===`object`?Bt(t,e):H(e)},Rt=function(e){e===null||b===y&&e===void 0||(e=Ft(e),H(e))};function zt(e,t,n,r,i){var a=new OP(t||this.boundingBox,n||this.xStep,r||this.yStep,this.gState,i||this.matrix);return a.stream=this.stream,Ue(e+`$$`+ this.cloneIndex+++`$$`,a),a}var Bt=function(e,t){var n=ke[e.key],r=Oe[n];if(r instanceof DP)H(`q`),H(Vt(t)),r.gState&&p.setGState(r.gState),H(e.matrix.toString()+` cm`),H(`/`+n+` sh`),H(`Q`);else if(r instanceof OP){var i=new Be(1,0,0,-1,0,Cn());e.matrix&&(i=i.multiply(e.matrix||He),n=zt.call(r,e.key,e.boundingBox,e.xStep,e.yStep,i).id),H(`q`),H(`/Pattern cs`),H(`/`+n+` scn`),r.gState&&p.setGState(r.gState),H(t),H(`Q`)}},Vt=function(e){switch(e){case`f`:case`F`:case`n`:return`W n`;case`f*`:return`W* n`;case`B`:case`S`:return`W S`;case`B*`:return`W* S`}},Ht=p.moveTo=function(e,t){return H(w(k(e))+` `+w(A(t))+` m`),this},Ut=p.lineTo=function(e,t){return H(w(k(e))+` `+w(A(t))+` l`),this},Wt=p.curveTo=function(e,t,n,r,i,a){return H([w(k(e)),w(A(t)),w(k(n)),w(A(r)),w(k(i)),w(A(a)),`c`].join(` `)),this};p.__private__.line=p.line=function(e,t,n,r,i){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||!Pt(i))throw Error(`Invalid arguments passed to jsPDF.line`);return b===v?this.lines([[n-e,r-t]],e,t,[1,1],i||`S`):this.lines([[n-e,r-t]],e,t,[1,1]).stroke()},p.__private__.lines=p.lines=function(e,t,n,r,i,a){var o,s,c,l,u,d,f,p,m,h,g,_;if(typeof e==`number`&&(_=n,n=t,t=e,e=_),r||=[1,1],a||=!1,isNaN(t)||isNaN(n)||!Array.isArray(e)||!Array.isArray(r)||!Pt(i)||typeof a!=`boolean`)throw Error(`Invalid arguments passed to jsPDF.lines`);for(Ht(t,n),o=r[0],s=r[1],l=e.length,h=t,g=n,c=0;c<l;c++)(u=e[c]).length===2?(h=u[0]*o+h,g=u[1]*s+g,Ut(h,g)):(d=u[0]*o+h,f=u[1]*s+g,p=u[2]*o+h,m=u[3]*s+g,h=u[4]*o+h,g=u[5]*s+g,Wt(d,f,p,m,h,g));return a&&It(),Rt(i),this},p.path=function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n.c;switch(n.op){case`m`:Ht(r[0],r[1]);break;case`l`:Ut(r[0],r[1]);break;case`c`:Wt.apply(this,r);break;case`h`:It()}}return this},p.__private__.rect=p.rect=function(e,t,n,r,i){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||!Pt(i))throw Error(`Invalid arguments passed to jsPDF.rect`);return b===v&&(r=-r),H([w(k(e)),w(A(t)),w(k(n)),w(k(r)),`re`].join(` `)),Rt(i),this},p.__private__.triangle=p.triangle=function(e,t,n,r,i,a,o){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||isNaN(i)||isNaN(a)||!Pt(o))throw Error(`Invalid arguments passed to jsPDF.triangle`);return this.lines([[n-e,r-t],[i-n,a-r],[e-i,t-a]],e,t,[1,1],o,!0),this},p.__private__.roundedRect=p.roundedRect=function(e,t,n,r,i,a,o){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||isNaN(i)||isNaN(a)||!Pt(o))throw Error(`Invalid arguments passed to jsPDF.roundedRect`);var s=4/3*(Math.SQRT2-1);return i=Math.min(i,.5*n),a=Math.min(a,.5*r),this.lines([[n-2*i,0],[i*s,0,i,a-a*s,i,a],[0,r-2*a],[0,a*s,-i*s,a,-i,a],[2*i-n,0],[-i*s,0,-i,-a*s,-i,-a],[0,2*a-r],[0,-a*s,i*s,-a,i,-a]],e+i,t,[1,1],o,!0),this},p.__private__.ellipse=p.ellipse=function(e,t,n,r,i){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||!Pt(i))throw Error(`Invalid arguments passed to jsPDF.ellipse`);var a=4/3*(Math.SQRT2-1)*n,o=4/3*(Math.SQRT2-1)*r;return Ht(e+n,t),Wt(e+n,t-o,e+a,t-r,e,t-r),Wt(e-a,t-r,e-n,t-o,e-n,t),Wt(e-n,t+o,e-a,t+r,e,t+r),Wt(e+a,t+r,e+n,t+o,e+n,t),Rt(i),this},p.__private__.circle=p.circle=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||!Pt(r))throw Error(`Invalid arguments passed to jsPDF.circle`);return this.ellipse(e,t,n,n,r)},p.setFont=function(e,t,n){return n&&(t=C(t,n)),Se=_t(e,t,{disableWarning:!1}),this};var Gt=p.__private__.getFont=p.getFont=function(){return W[_t.apply(p,arguments)]};p.__private__.getFontList=p.getFontList=function(){var e,t,n={};for(e in Ee)if(Ee.hasOwnProperty(e))for(t in n[e]=[],Ee[e])Ee[e].hasOwnProperty(t)&&n[e].push(t);return n},p.addFont=function(e,t,n,r,i){var a=[`StandardEncoding`,`MacRomanEncoding`,`Identity-H`,`WinAnsiEncoding`];return arguments[3]&&a.indexOf(arguments[3])!==-1?i=arguments[3]:arguments[3]&&a.indexOf(arguments[3])==-1&&(n=C(n,r)),ut.call(this,e,t,n,i||=`Identity-H`)};var Kt,qt=e.lineWidth||.200025,Jt=p.__private__.getLineWidth=p.getLineWidth=function(){return qt},Yt=p.__private__.setLineWidth=p.setLineWidth=function(e){return qt=e,H(w(k(e))+` w`),this};p.__private__.setLineDash=kP.API.setLineDash=kP.API.setLineDashPattern=function(e,t){if(e||=[],t||=0,isNaN(t)||!Array.isArray(e))throw Error(`Invalid arguments passed to jsPDF.setLineDash`);return e=e.map(function(e){return w(k(e))}).join(` `),t=w(k(t)),H(`[`+e+`] `+t+` d`),this};var Xt=p.__private__.getLineHeight=p.getLineHeight=function(){return fe*Kt};p.__private__.getLineHeight=p.getLineHeight=function(){return fe*Kt};var Zt=p.__private__.setLineHeightFactor=p.setLineHeightFactor=function(e){return typeof(e||=1.15)==`number`&&(Kt=e),this},Qt=p.__private__.getLineHeightFactor=p.getLineHeightFactor=function(){return Kt};Zt(e.lineHeight);var G=p.__private__.getHorizontalCoordinate=function(e){return k(e)},$t=p.__private__.getVerticalCoordinate=function(e){return b===y?e:Pe[R].mediaBox.topRightY-Pe[R].mediaBox.bottomLeftY-k(e)},en=p.__private__.getHorizontalCoordinateString=p.getHorizontalCoordinateString=function(e){return w(G(e))},tn=p.__private__.getVerticalCoordinateString=p.getVerticalCoordinateString=function(e){return w($t(e))},nn=e.strokeColor||`0 G`;p.__private__.getStrokeColor=p.getDrawColor=function(){return Ze(nn)},p.__private__.setStrokeColor=p.setDrawColor=function(e,t,n,r){return nn=Qe({ch1:e,ch2:t,ch3:n,ch4:r,pdfColorType:`draw`,precision:2}),H(nn),this};var rn=e.fillColor||`0 g`;p.__private__.getFillColor=p.getFillColor=function(){return Ze(rn)},p.__private__.setFillColor=p.setFillColor=function(e,t,n,r){return rn=Qe({ch1:e,ch2:t,ch3:n,ch4:r,pdfColorType:`fill`,precision:2}),H(rn),this};var an=e.textColor||`0 g`,on=p.__private__.getTextColor=p.getTextColor=function(){return Ze(an)};p.__private__.setTextColor=p.setTextColor=function(e,t,n,r){return an=Qe({ch1:e,ch2:t,ch3:n,ch4:r,pdfColorType:`text`,precision:3}),this};var sn=e.charSpace,cn=p.__private__.getCharSpace=p.getCharSpace=function(){return parseFloat(sn||0)};p.__private__.setCharSpace=p.setCharSpace=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.setCharSpace`);return sn=e,this};var ln=0;p.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},p.__private__.setLineCap=p.setLineCap=function(e){var t=p.CapJoinStyles[e];if(t===void 0)throw Error(`Line cap style of '`+e+`' is not recognized. See or extend .CapJoinStyles property for valid styles`);return ln=t,H(t+` J`),this};var un=0;p.__private__.setLineJoin=p.setLineJoin=function(e){var t=p.CapJoinStyles[e];if(t===void 0)throw Error(`Line join style of '`+e+`' is not recognized. See or extend .CapJoinStyles property for valid styles`);return un=t,H(t+` j`),this},p.__private__.setLineMiterLimit=p.__private__.setMiterLimit=p.setLineMiterLimit=p.setMiterLimit=function(e){if(e||=0,isNaN(e))throw Error(`Invalid argument passed to jsPDF.setLineMiterLimit`);return H(w(k(e))+` M`),this},p.GState=TP,p.setGState=function(e){(e=typeof e==`string`?Ae[je[e]]:dn(null,e)).equals(Me)||(H(`/`+e.id+` gs`),Me=e)};var dn=function(e,t){if(!e||!je[e]){var n=!1;for(var r in Ae)if(Ae.hasOwnProperty(r)&&Ae[r].equals(t)){n=!0;break}if(n)t=Ae[r];else{var i=`GS`+(Object.keys(Ae).length+1).toString(10);Ae[i]=t,t.id=i}return e&&(je[e]=t.id),Fe.publish(`addGState`,t),t}};p.addGState=function(e,t){return dn(e,t),this},p.saveGraphicsState=function(){return H(`q`),De.push({key:Se,size:fe,color:an}),this},p.restoreGraphicsState=function(){H(`Q`);var e=De.pop();return Se=e.key,fe=e.size,an=e.color,Me=null,this},p.setCurrentTransformationMatrix=function(e){return H(e.toString()+` cm`),this},p.comment=function(e){return H(`#`+e),this};var fn=function(e,t){var n=e||0;Object.defineProperty(this,"x",{enumerable:!0,get:function(){return n},set:function(e){isNaN(e)||(n=parseFloat(e))}});var r=t||0;Object.defineProperty(this,"y",{enumerable:!0,get:function(){return r},set:function(e){isNaN(e)||(r=parseFloat(e))}});var i=`pt`;return Object.defineProperty(this,"type",{enumerable:!0,get:function(){return i},set:function(e){i=e.toString()}}),this},pn=function(e,t,n,r){fn.call(this,e,t),this.type=`rect`;var i=n||0;Object.defineProperty(this,"w",{enumerable:!0,get:function(){return i},set:function(e){isNaN(e)||(i=parseFloat(e))}});var a=r||0;return Object.defineProperty(this,"h",{enumerable:!0,get:function(){return a},set:function(e){isNaN(e)||(a=parseFloat(e))}}),this},mn=function(){this.page=Ne,this.currentPage=R,this.pages=ae.slice(0),this.pagesContext=Pe.slice(0),this.x=Ce,this.y=we,this.matrix=Te,this.width=_n(R),this.height=yn(R),this.outputDestination=se,this.id=``,this.objectNumber=-1};mn.prototype.restore=function(){Ne=this.page,R=this.currentPage,Pe=this.pagesContext,ae=this.pages,Ce=this.x,we=this.y,Te=this.matrix,vn(R,this.width),bn(R,this.height),se=this.outputDestination};var hn=function(e,t,n,r,i){ze.push(new mn),Ne=R=0,ae=[],Ce=e,we=t,Te=i,ft([n,r])};for(var gn in p.beginFormObject=function(e,t,n,r,i){return hn(e,t,n,r,i),this},p.endFormObject=function(e){return function(e){if(Re[e])ze.pop().restore();else{var t=new mn,n=`Xo`+(Object.keys(Le).length+1).toString(10);t.id=n,Re[e]=n,Le[n]=t,Fe.publish(`addFormObject`,t),ze.pop().restore()}}(e),this},p.doFormObject=function(e,t){var n=Le[Re[e]];return H(`q`),H(t.toString()+` cm`),H(`/`+n.id+` Do`),H(`Q`),this},p.getFormObject=function(e){var t=Le[Re[e]];return{x:t.x,y:t.y,width:t.width,height:t.height,matrix:t.matrix}},p.save=function(e,t){return e||=`generated.pdf`,(t||={}).returnPromise=t.returnPromise||!1,!1===t.returnPromise?(nP(wt(Ct()),e),typeof nP.unload==`function`&&XN.setTimeout&&setTimeout(nP.unload,911),this):new Promise(function(t,n){try{var r=nP(wt(Ct()),e);typeof nP.unload==`function`&&XN.setTimeout&&setTimeout(nP.unload,911),t(r)}catch(e){n(e.message)}})},kP.API)kP.API.hasOwnProperty(gn)&&(gn===`events`&&kP.API.events.length?function(e,t){var n,r,i;for(i=t.length-1;i!==-1;i--)n=t[i][0],r=t[i][1],e.subscribe.apply(e,[n].concat(typeof r==`function`?[r]:r))}(Fe,kP.API.events):p[gn]=kP.API[gn]);function _n(e){return Pe[e].mediaBox.topRightX-Pe[e].mediaBox.bottomLeftX}function vn(e,t){Pe[e].mediaBox.topRightX=t+Pe[e].mediaBox.bottomLeftX}function yn(e){return Pe[e].mediaBox.topRightY-Pe[e].mediaBox.bottomLeftY}function bn(e,t){Pe[e].mediaBox.topRightY=t+Pe[e].mediaBox.bottomLeftY}var xn=p.getPageWidth=function(e){return _n(e||=R)/U},Sn=p.setPageWidth=function(e,t){vn(e,t*U)},Cn=p.getPageHeight=function(e){return yn(e||=R)/U},wn=p.setPageHeight=function(e,t){bn(e,t*U)};return p.internal={pdfEscape:dt,getStyle:Ft,getFont:Gt,getFontSize:me,getCharSpace:cn,getTextColor:on,getLineHeight:Xt,getLineHeightFactor:Qt,getLineWidth:Jt,write:le,getHorizontalCoordinate:G,getVerticalCoordinate:$t,getCoordinateString:en,getVerticalCoordinateString:tn,collections:{},newObject:Ge,newAdditionalObject:Je,newObjectDeferred:Ke,newObjectDeferredBegin:qe,getFilters:$e,putStream:et,events:Fe,scaleFactor:U,pageSize:{getWidth:function(){return xn(R)},setWidth:function(e){Sn(R,e)},getHeight:function(){return Cn(R)},setHeight:function(e){wn(R,e)}},encryptionOptions:u,encryption:kt,getEncryptor:function(e){return u===null?function(e){return e}:kt.encryptor(e,0)},output:Dt,getNumberOfPages:gt,get pages(){return ae},out:H,f2:D,f3:O,getPageInfo:At,getPageInfoByObjId:jt,getCurrentPageInfo:Mt,getPDFVersion:h,Point:fn,Rectangle:pn,Matrix:Be,hasHotfix:Ot},Object.defineProperty(p.internal.pageSize,"width",{get:function(){return xn(R)},set:function(e){Sn(R,e)},enumerable:!0,configurable:!0}),Object.defineProperty(p.internal.pageSize,"height",{get:function(){return Cn(R)},set:function(e){wn(R,e)},enumerable:!0,configurable:!0}),function(e){for(var t=0,n=de.length;t<n;t++){var r=ut.call(this,e[t][0],e[t][1],e[t][2],de[t][3],!0);!1===d&&(f[r]=!0);var i=e[t][0].split(`-`);lt({id:r,fontName:i[0],fontStyle:i[1]||``})}Fe.publish(`addFonts`,{fonts:W,dictionary:Ee})}.call(p,de),Se=`F1`,pt(i,n),Fe.publish(`initialized`),p}SP.prototype.lsbFirstWord=function(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)},SP.prototype.toHexString=function(e){return e.split(``).map(function(e){return(`0`+(255&e.charCodeAt(0)).toString(16)).slice(-2)}).join(``)},SP.prototype.hexToBytes=function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(String.fromCharCode(parseInt(e.substr(n,2),16)));return t.join(``)},SP.prototype.processOwnerPassword=function(e,t){return bP(_P(t).substr(0,5),e)},SP.prototype.encryptor=function(e,t){var n=_P(this.encryptionKey+String.fromCharCode(255&e,e>>8&255,e>>16&255,255&t,t>>8&255)).substr(0,10);return function(e){return bP(n,e)}},TP.prototype.equals=function(e){var t,n=`id,objectNumber,equals`;if(!e||hD(e)!==hD(this))return!1;var r=0;for(t in this)if(!(n.indexOf(t)>=0)){if(this.hasOwnProperty(t)&&!e.hasOwnProperty(t)||this[t]!==e[t])return!1;r++}for(t in e)e.hasOwnProperty(t)&&n.indexOf(t)<0&&r--;return r===0},kP.API={events:[]},kP.version=`4.2.1`;var AP=kP.API,jP=1,MP=function(e){return e.replace(/\\/g,`\\\\`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`)},NP=function(e){return e.replace(/\\\\/g,`\\`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)},PP=function(e){return e.toString().replace(/#/g,`#23`).replace(/[\s\n\r()<>[\]{}\/%]/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return`#`+(t.length===1?`0`+t:t)})},FP=function(e){return e.toFixed(2)},IP=function(e){return e.toFixed(5)};AP.__acroform__={};var LP=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e},RP=function(e){return e*jP},zP=function(e){var t=new nF,n=gF.internal.getHeight(e)||0,r=gF.internal.getWidth(e)||0;return t.BBox=[0,0,Number(FP(r)),Number(FP(n))],t},BP=AP.__acroform__.setBit=function(e,t){if(e||=0,t||=0,isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.setBit`);return e|1<<t},VP=AP.__acroform__.clearBit=function(e,t){if(e||=0,t||=0,isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.clearBit`);return e&~(1<<t)},HP=AP.__acroform__.getBit=function(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.getBit`);return e&1<<t?1:0},UP=AP.__acroform__.getBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf`);return HP(e,t-1)},WP=AP.__acroform__.setBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf`);return BP(e,t-1)},GP=AP.__acroform__.clearBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf`);return VP(e,t-1)},KP=AP.__acroform__.calculateCoordinates=function(e,t){var n=t.internal.getHorizontalCoordinate,r=t.internal.getVerticalCoordinate,i=e[0],a=e[1],o=e[2],s=e[3],c={};return c.lowerLeft_X=n(i)||0,c.lowerLeft_Y=r(a+s)||0,c.upperRight_X=n(i+o)||0,c.upperRight_Y=r(a)||0,[Number(FP(c.lowerLeft_X)),Number(FP(c.lowerLeft_Y)),Number(FP(c.upperRight_X)),Number(FP(c.upperRight_Y))]},qP=function(e){if(e.appearanceStreamContent)return e.appearanceStreamContent;if(e.V||e.DV){var t=[],n=JP(e,e._V||e.DV),r=e.scope.internal.getFont(e.fontName,e.fontStyle).id;t.push(`/Tx BMC`),t.push(`q`),t.push(`BT`),t.push(e.scope.__private__.encodeColorString(e.color)),t.push(`/`+r+` `+FP(n.fontSize)+` Tf`),t.push(`1 0 0 1 0 0 Tm`),t.push(n.text),t.push(`ET`),t.push(`Q`),t.push(`EMC`);var i=zP(e);return i.scope=e.scope,i.stream=t.join(`
|
||
`),i}},JP=function(e,t){var n=e.fontSize===0?e.maxFontSize:e.fontSize,r={text:``,fontSize:``},i=(t=(t=t.substr(0,1)==`(`?t.substr(1):t).substr(t.length-1)==`)`?t.substr(0,t.length-1):t).split(` `);i=e.multiline?i.map(function(e){return e.split(`
|
||
`)}):i.map(function(e){return[e]});var a=n,o=gF.internal.getHeight(e)||0;o=o<0?-o:o;var s=gF.internal.getWidth(e)||0;s=s<0?-s:s;var c=function(t,n,r){return t+1<i.length?YP(n+` `+i[t+1][0],e,r).width<=s-4:!1};a++;t:for(;a>0;){t=``,a--;var l,u,d=YP(`3`,e,a).height,f=e.multiline?o-a:(o-d)/2,p=f+=2,m=0,h=0,g=0;if(a<=0){t=`(...) Tj
|
||
`,t+=`% Width of Text: `+YP(t,e,a=12).width+`, FieldWidth:`+s+`
|
||
`;break}for(var _=``,v=0,y=0;y<i.length;y++)if(i.hasOwnProperty(y)){var b=!1;if(i[y].length!==1&&g!==i[y].length-1){if((d+2)*(v+2)+2>o)continue t;_+=i[y][g],b=!0,h=y,y--}else{_=(_+=i[y][g]+` `).substr(_.length-1)==` `?_.substr(0,_.length-1):_;var x=parseInt(y),S=c(x,_,a),C=y>=i.length-1;if(S&&!C){_+=` `,g=0;continue}if(S||C){if(C)h=x;else if(e.multiline&&(d+2)*(v+2)+2>o)continue t}else{if(!e.multiline||(d+2)*(v+2)+2>o)continue t;h=x}}for(var w=``,T=m;T<=h;T++){var E=i[T];if(e.multiline){if(T===h){w+=E[g]+` `,g=(g+1)%E.length;continue}if(T===m){w+=E[E.length-1]+` `;continue}}w+=E[0]+` `}switch(w=w.substr(w.length-1)==` `?w.substr(0,w.length-1):w,u=YP(w,e,a).width,e.textAlign){case`right`:l=s-u-2;break;case`center`:l=(s-u)/2;break;default:l=2}t+=FP(l)+` `+FP(p)+` Td
|
||
`,t+=`(`+MP(w)+`) Tj
|
||
`,t+=-FP(l)+` 0 Td
|
||
`,p=-(a+2),u=0,m=b?h:h+1,v++,_=``}break}return r.text=t,r.fontSize=a,r},YP=function(e,t,n){var r=t.scope.internal.getFont(t.fontName,t.fontStyle),i=t.scope.getStringUnitWidth(e,{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n);return{height:t.scope.getStringUnitWidth(`3`,{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n)*1.5,width:i}},XP={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},ZP=function(e,t){var n={type:`reference`,object:e};t.internal.getPageInfo(e.page).pageContext.annotations.find(function(e){return e.type===n.type&&e.object===n.object})===void 0&&t.internal.getPageInfo(e.page).pageContext.annotations.push(n)},QP=function(e,t){if(t.scope=e,e.internal!==void 0&&(e.internal.acroformPlugin===void 0||!1===e.internal.acroformPlugin.isInitialized)){if(iF.FieldNum=0,e.internal.acroformPlugin=JSON.parse(JSON.stringify(XP)),e.internal.acroformPlugin.acroFormDictionaryRoot)throw Error(`Exception while creating AcroformDictionary`);jP=e.internal.scaleFactor,e.internal.acroformPlugin.acroFormDictionaryRoot=new rF,e.internal.acroformPlugin.acroFormDictionaryRoot.scope=e,e.internal.acroformPlugin.acroFormDictionaryRoot._eventID=e.internal.events.subscribe(`postPutResources`,function(){(function(e){e.internal.events.unsubscribe(e.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete e.internal.acroformPlugin.acroFormDictionaryRoot._eventID,e.internal.acroformPlugin.printedOut=!0})(e)}),e.internal.events.subscribe(`buildDocument`,function(){(function(e){e.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var t=e.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];r.objId=void 0,r.hasAnnotation&&ZP(r,e)}})(e)}),e.internal.events.subscribe(`putCatalog`,function(){(function(e){if(e.internal.acroformPlugin.acroFormDictionaryRoot===void 0)throw Error(`putCatalogCallback: Root missing.`);e.internal.write(`/AcroForm `+e.internal.acroformPlugin.acroFormDictionaryRoot.objId+` 0 R`)})(e)}),e.internal.events.subscribe(`postPutPages`,function(t){(function(e,t){var n=!e;for(var r in e||(t.internal.newObjectDeferredBegin(t.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),t.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),e||=t.internal.acroformPlugin.acroFormDictionaryRoot.Kids)if(e.hasOwnProperty(r)){var i=e[r],a=[],o=i.Rect;if(i.Rect&&=KP(i.Rect,t),t.internal.newObjectDeferredBegin(i.objId,!0),i.DA=gF.createDefaultAppearanceStream(i),hD(i)===`object`&&typeof i.getKeyValueListForStream==`function`&&(a=i.getKeyValueListForStream()),i.Rect=o,i.hasAppearanceStream&&!i.appearanceStreamContent){var s=qP(i);a.push({key:`AP`,value:`<</N `+s+`>>`}),t.internal.acroformPlugin.xForms.push(s)}if(i.appearanceStreamContent){var c=``;for(var l in i.appearanceStreamContent)if(i.appearanceStreamContent.hasOwnProperty(l)){var u=i.appearanceStreamContent[l];if(c+=`/`+l+` `,c+=`<<`,Object.keys(u).length>=1||Array.isArray(u)){for(var r in u)if(u.hasOwnProperty(r)){var d=u[r];typeof d==`function`&&(d=d.call(t,i)),c+=`/`+r+` `+d+` `,t.internal.acroformPlugin.xForms.indexOf(d)>=0||t.internal.acroformPlugin.xForms.push(d)}}else typeof(d=u)==`function`&&(d=d.call(t,i)),c+=`/`+r+` `+d,t.internal.acroformPlugin.xForms.indexOf(d)>=0||t.internal.acroformPlugin.xForms.push(d);c+=`>>`}a.push({key:`AP`,value:`<<
|
||
`+c+`>>`})}t.internal.putStream({additionalKeyValues:a,objectId:i.objId}),t.internal.out(`endobj`)}n&&function(e,t){for(var n in e)if(e.hasOwnProperty(n)){var r=n,i=e[n];t.internal.newObjectDeferredBegin(i.objId,!0),hD(i)===`object`&&typeof i.putStream==`function`&&i.putStream(),delete e[r]}}(t.internal.acroformPlugin.xForms,t)})(t,e)}),e.internal.acroformPlugin.isInitialized=!0}},$P=AP.__acroform__.arrayToPdfArray=function(e,t,n){var r=function(e){return e};if(Array.isArray(e)){for(var i=`[`,a=0;a<e.length;a++)switch(a!==0&&(i+=` `),hD(e[a])){case`boolean`:case`number`:case`object`:i+=e[a].toString();break;case`string`:e[a].substr(0,1)===`/`?i+=`/`+PP(e[a].substr(1)):(t!==void 0&&n&&(r=n.internal.getEncryptor(t)),i+=`(`+MP(r(e[a].toString()))+`)`)}return i+`]`}throw Error(`Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray`)},eF=function(e,t,n){var r=function(e){return e};return t!==void 0&&n&&(r=n.internal.getEncryptor(t)),(e||=``).toString(),`(`+MP(r(e))+`)`},tF=function(){this._objId=void 0,this._scope=void 0,Object.defineProperty(this,"objId",{get:function(){if(this._objId===void 0){if(this.scope===void 0)return;this._objId=this.scope.internal.newObjectDeferred()}return this._objId},set:function(e){this._objId=e}}),Object.defineProperty(this,"scope",{value:this._scope,writable:!0})};tF.prototype.toString=function(){return this.objId+` 0 R`},tF.prototype.putStream=function(){var e=this.getKeyValueListForStream();this.scope.internal.putStream({data:this.stream,additionalKeyValues:e,objectId:this.objId}),this.scope.internal.out(`endobj`)},tF.prototype.getKeyValueListForStream=function(){var e=[],t=Object.getOwnPropertyNames(this).filter(function(e){return e!=`content`&&e!=`appearanceStreamContent`&&e!=`scope`&&e!=`objId`&&e.substring(0,1)!=`_`});for(var n in t)if(!1===Object.getOwnPropertyDescriptor(this,t[n]).configurable){var r=t[n],i=this[r];i&&(Array.isArray(i)?e.push({key:r,value:$P(i,this.objId,this.scope)}):i instanceof tF?(i.scope=this.scope,e.push({key:r,value:i.objId+` 0 R`})):typeof i!=`function`&&e.push({key:r,value:i}))}return e};var nF=function(){tF.call(this),Object.defineProperty(this,"Type",{value:`/XObject`,configurable:!1,writable:!0}),Object.defineProperty(this,"Subtype",{value:`/Form`,configurable:!1,writable:!0}),Object.defineProperty(this,"FormType",{value:1,configurable:!1,writable:!0});var e,t=[];Object.defineProperty(this,"BBox",{configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"Resources",{value:`2 0 R`,configurable:!1,writable:!0}),Object.defineProperty(this,"stream",{enumerable:!1,configurable:!0,set:function(t){e=t.trim()},get:function(){return e||null}})};LP(nF,tF);var rF=function(){tF.call(this);var e,t=[];Object.defineProperty(this,"Kids",{enumerable:!1,configurable:!0,get:function(){return t.length>0?t:void 0}}),Object.defineProperty(this,"Fields",{enumerable:!1,configurable:!1,get:function(){return t}}),Object.defineProperty(this,"DA",{enumerable:!1,configurable:!1,get:function(){if(e){var t=function(e){return e};return this.scope&&(t=this.scope.internal.getEncryptor(this.objId)),`(`+MP(t(e))+`)`}},set:function(t){e=t}})};LP(rF,tF);var iF=function e(){tF.call(this);var t=4;Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){if(isNaN(e))throw Error(`Invalid value "`+e+`" for attribute F supplied.`);t=e}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return!!UP(t,3)},set:function(e){!!e==1?this.F=WP(t,3):this.F=GP(t,3)}});var n=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return n},set:function(e){if(isNaN(e))throw Error(`Invalid value "`+e+`" for attribute Ff supplied.`);n=e}});var r=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(r.length!==0)return r},set:function(e){r=e===void 0?[]:e}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[0])?0:r[0]},set:function(e){r[0]=e}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[1])?0:r[1]},set:function(e){r[1]=e}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[2])?0:r[2]},set:function(e){r[2]=e}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[3])?0:r[3]},set:function(e){r[3]=e}});var i=``;Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return i},set:function(e){switch(e){case`/Btn`:case`/Tx`:case`/Ch`:case`/Sig`:i=e;break;default:throw Error(`Invalid value "`+e+`" for attribute FT supplied.`)}}});var a=null;Object.defineProperty(this,"T",{enumerable:!0,configurable:!1,get:function(){if(!a||a.length<1){if(this instanceof fF)return;a=`FieldObject`+ e.FieldNum++}var t=function(e){return e};return this.scope&&(t=this.scope.internal.getEncryptor(this.objId)),`(`+MP(t(a))+`)`},set:function(e){a=e.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return a},set:function(e){a=e}});var o=`helvetica`;Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return o},set:function(e){o=e}});var s=`normal`;Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return s},set:function(e){s=e}});var c=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return c},set:function(e){c=e}});var l=void 0;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return l===void 0?50/jP:l},set:function(e){l=e}});var u=`black`;Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return u},set:function(e){u=e}});var d=`/F1 0 Tf 0 g`;Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!d||this instanceof fF||this instanceof mF))return eF(d,this.objId,this.scope)},set:function(e){e=e.toString(),d=e}});var f=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(f)return this instanceof lF==0?eF(f,this.objId,this.scope):f},set:function(e){e=e.toString(),f=this instanceof lF==0?e.substr(0,1)===`(`?NP(e.substr(1,e.length-2)):NP(e):e}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof lF==1?NP(f.substr(1,f.length-1)):f},set:function(e){e=e.toString(),f=this instanceof lF==1?`/`+PP(e):e}});var p=null;Object.defineProperty(this,"_V",{enumerable:!1,configurable:!1,get:function(){if(p)return p},set:function(e){this.V=e}}),Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(p)return this instanceof lF==0?eF(p,this.objId,this.scope):p},set:function(e){e=e.toString(),p=this instanceof lF==0?e.substr(0,1)===`(`?NP(e.substr(1,e.length-2)):NP(e):e}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this instanceof lF==1?NP(p.substr(1,p.length-1)):p},set:function(e){e=e.toString(),p=this instanceof lF==1?`/`+PP(e):e}}),Object.defineProperty(this,"hasAnnotation",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,"Type",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?`/Annot`:null}}),Object.defineProperty(this,"Subtype",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?`/Widget`:null}});var m,h=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return h},set:function(e){e=!!e,h=e}}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,get:function(){if(m)return m},set:function(e){m=e}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,1)},set:function(e){!!e==1?this.Ff=WP(this.Ff,1):this.Ff=GP(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,2)},set:function(e){!!e==1?this.Ff=WP(this.Ff,2):this.Ff=GP(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,3)},set:function(e){!!e==1?this.Ff=WP(this.Ff,3):this.Ff=GP(this.Ff,3)}});var g=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(g!==null)return g},set:function(e){if([0,1,2].indexOf(e)===-1)throw Error(`Invalid value "`+e+`" for attribute Q supplied.`);g=e}}),Object.defineProperty(this,"textAlign",{get:function(){var e;switch(g){case 0:default:e=`left`;break;case 1:e=`center`;break;case 2:e=`right`}return e},configurable:!0,enumerable:!0,set:function(e){switch(e){case`right`:case 2:g=2;break;case`center`:case 1:g=1;break;default:g=0}}})};LP(iF,tF);var aF=function(){iF.call(this),this.FT=`/Ch`,this.V=`()`,this.fontName=`zapfdingbats`;var e=0;Object.defineProperty(this,"TI",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"topIndex",{enumerable:!0,configurable:!0,get:function(){return e},set:function(t){e=t}});var t=[];Object.defineProperty(this,"Opt",{enumerable:!0,configurable:!1,get:function(){return $P(t,this.objId,this.scope)},set:function(e){var n,r=[];typeof(n=e)==`string`&&(r=function(e,t,n){n||=1;for(var r,i=[];r=t.exec(e);)i.push(r[n]);return i}(n,/\((.*?)\)/g)),t=r}}),this.getOptions=function(){return t},this.setOptions=function(e){t=e,this.sort&&t.sort()},this.addOption=function(e){e=(e||=``).toString(),t.push(e),this.sort&&t.sort()},this.removeOption=function(e,n){for(n||=!1,e=(e||=``).toString();t.indexOf(e)!==-1&&(t.splice(t.indexOf(e),1),!1!==n););},Object.defineProperty(this,"combo",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,18)},set:function(e){!!e==1?this.Ff=WP(this.Ff,18):this.Ff=GP(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,19)},set:function(e){!0===this.combo&&(!!e==1?this.Ff=WP(this.Ff,19):this.Ff=GP(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,20)},set:function(e){!!e==1?(this.Ff=WP(this.Ff,20),t.sort()):this.Ff=GP(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,22)},set:function(e){!!e==1?this.Ff=WP(this.Ff,22):this.Ff=GP(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,23)},set:function(e){!!e==1?this.Ff=WP(this.Ff,23):this.Ff=GP(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,27)},set:function(e){!!e==1?this.Ff=WP(this.Ff,27):this.Ff=GP(this.Ff,27)}}),this.hasAppearanceStream=!1};LP(aF,iF);var oF=function(){aF.call(this),this.fontName=`helvetica`,this.combo=!1};LP(oF,aF);var sF=function(){oF.call(this),this.combo=!0};LP(sF,oF);var cF=function(){sF.call(this),this.edit=!0};LP(cF,sF);var lF=function(){iF.call(this),this.FT=`/Btn`,Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,15)},set:function(e){!!e==1?this.Ff=WP(this.Ff,15):this.Ff=GP(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,16)},set:function(e){!!e==1?this.Ff=WP(this.Ff,16):this.Ff=GP(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,17)},set:function(e){!!e==1?this.Ff=WP(this.Ff,17):this.Ff=GP(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,26)},set:function(e){!!e==1?this.Ff=WP(this.Ff,26):this.Ff=GP(this.Ff,26)}});var e,t={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var e=function(e){return e};if(this.scope&&(e=this.scope.internal.getEncryptor(this.objId)),Object.keys(t).length!==0){var n,r=[];for(n in r.push(`<<`),t)r.push(`/`+n+` (`+MP(e(t[n]))+`)`);return r.push(`>>`),r.join(`
|
||
`)}},set:function(e){hD(e)===`object`&&(t=e)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return t.CA||``},set:function(e){typeof e==`string`&&(t.CA=e)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){var n=t==null?``:t.toString();n.substr(0,1)===`/`&&(n=n.substr(1)),e=`/`+PP(n)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return e.substr(1,e.length-1)},set:function(t){e=`/`+PP(t)}})};LP(lF,iF);var uF=function(){lF.call(this),this.pushButton=!0};LP(uF,lF);var dF=function(){lF.call(this),this.radio=!0,this.pushButton=!1;var e=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t===void 0?[]:t}})};LP(dF,lF);var fF=function(){var e,t;iF.call(this),Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return t},set:function(e){t=e}});var n,r={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var e=function(e){return e};this.scope&&(e=this.scope.internal.getEncryptor(this.objId));var t,n=[];for(t in n.push(`<<`),r)n.push(`/`+t+` (`+MP(e(r[t]))+`)`);return n.push(`>>`),n.join(`
|
||
`)},set:function(e){hD(e)===`object`&&(r=e)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return r.CA||``},set:function(e){typeof e==`string`&&(r.CA=e)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return n},set:function(e){var t=e==null?``:e.toString();t.substr(0,1)===`/`&&(t=t.substr(1)),n=`/`+PP(t)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return n.substr(1,n.length-1)},set:function(e){var t=e==null?``:e.toString();t.substr(0,1)===`/`&&(t=t.substr(1)),n=`/`+PP(t)}}),this.caption=`l`,this.appearanceState=`Off`,this._AppearanceType=gF.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};LP(fF,iF),dF.prototype.setAppearance=function(e){if(!(`createAppearanceStream`in e)||!(`getCA`in e))throw Error(`Couldn't assign Appearance to RadioButton. Appearance was Invalid!`);for(var t in this.Kids)if(this.Kids.hasOwnProperty(t)){var n=this.Kids[t];n.appearanceStreamContent=e.createAppearanceStream(n.optionName),n.caption=e.getCA()}},dF.prototype.createOption=function(e){var t=new fF;return t.Parent=this,t.optionName=e,this.Kids.push(t),_F.call(this.scope,t),t};var pF=function(){lF.call(this),this.fontName=`zapfdingbats`,this.caption=`3`,this.appearanceState=`On`,this.value=`On`,this.textAlign=`center`,this.appearanceStreamContent=gF.CheckBox.createAppearanceStream()};LP(pF,lF);var mF=function(){iF.call(this),this.FT=`/Tx`,Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,13)},set:function(e){!!e==1?this.Ff=WP(this.Ff,13):this.Ff=GP(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,21)},set:function(e){!!e==1?this.Ff=WP(this.Ff,21):this.Ff=GP(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,23)},set:function(e){!!e==1?this.Ff=WP(this.Ff,23):this.Ff=GP(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,24)},set:function(e){!!e==1?this.Ff=WP(this.Ff,24):this.Ff=GP(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,25)},set:function(e){!!e==1?this.Ff=WP(this.Ff,25):this.Ff=GP(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,26)},set:function(e){!!e==1?this.Ff=WP(this.Ff,26):this.Ff=GP(this.Ff,26)}});var e=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return e},set:function(t){Number.isInteger(t)&&(e=t)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};LP(mF,iF);var hF=function(){mF.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return!!UP(this.Ff,14)},set:function(e){!!e==1?this.Ff=WP(this.Ff,14):this.Ff=GP(this.Ff,14)}}),this.password=!0};LP(hF,mF);var gF={CheckBox:{createAppearanceStream:function(){return{N:{On:gF.CheckBox.YesNormal},D:{On:gF.CheckBox.YesPushDown,Off:gF.CheckBox.OffPushDown}}},YesPushDown:function(e){var t=zP(e);t.scope=e.scope;var n=[],r=e.scope.internal.getFont(e.fontName,e.fontStyle).id,i=e.scope.__private__.encodeColorString(e.color),a=JP(e,e.caption);return n.push(`0.749023 g`),n.push(`0 0 `+FP(gF.internal.getWidth(e))+` `+FP(gF.internal.getHeight(e))+` re`),n.push(`f`),n.push(`BMC`),n.push(`q`),n.push(`0 0 1 rg`),n.push(`/`+r+` `+FP(a.fontSize)+` Tf `+i),n.push(`BT`),n.push(a.text),n.push(`ET`),n.push(`Q`),n.push(`EMC`),t.stream=n.join(`
|
||
`),t},YesNormal:function(e){var t=zP(e);t.scope=e.scope;var n=e.scope.internal.getFont(e.fontName,e.fontStyle).id,r=e.scope.__private__.encodeColorString(e.color),i=[],a=gF.internal.getHeight(e),o=gF.internal.getWidth(e),s=JP(e,e.caption);return i.push(`1 g`),i.push(`0 0 `+FP(o)+` `+FP(a)+` re`),i.push(`f`),i.push(`q`),i.push(`0 0 1 rg`),i.push(`0 0 `+FP(o-1)+` `+FP(a-1)+` re`),i.push(`W`),i.push(`n`),i.push(`0 g`),i.push(`BT`),i.push(`/`+n+` `+FP(s.fontSize)+` Tf `+r),i.push(s.text),i.push(`ET`),i.push(`Q`),t.stream=i.join(`
|
||
`),t},OffPushDown:function(e){var t=zP(e);t.scope=e.scope;var n=[];return n.push(`0.749023 g`),n.push(`0 0 `+FP(gF.internal.getWidth(e))+` `+FP(gF.internal.getHeight(e))+` re`),n.push(`f`),t.stream=n.join(`
|
||
`),t}},RadioButton:{Circle:{createAppearanceStream:function(e){var t={D:{Off:gF.RadioButton.Circle.OffPushDown},N:{}};return t.N[e]=gF.RadioButton.Circle.YesNormal,t.D[e]=gF.RadioButton.Circle.YesPushDown,t},getCA:function(){return`l`},YesNormal:function(e){var t=zP(e);t.scope=e.scope;var n=[],r=gF.internal.getWidth(e)<=gF.internal.getHeight(e)?gF.internal.getWidth(e)/4:gF.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var i=gF.internal.Bezier_C,a=Number((r*i).toFixed(5));return n.push(`q`),n.push(`1 0 0 1 `+IP(gF.internal.getWidth(e)/2)+` `+IP(gF.internal.getHeight(e)/2)+` cm`),n.push(r+` 0 m`),n.push(r+` `+a+` `+a+` `+r+` 0 `+r+` c`),n.push(`-`+a+` `+r+` -`+r+` `+a+` -`+r+` 0 c`),n.push(`-`+r+` -`+a+` -`+a+` -`+r+` 0 -`+r+` c`),n.push(a+` -`+r+` `+r+` -`+a+` `+r+` 0 c`),n.push(`f`),n.push(`Q`),t.stream=n.join(`
|
||
`),t},YesPushDown:function(e){var t=zP(e);t.scope=e.scope;var n=[],r=gF.internal.getWidth(e)<=gF.internal.getHeight(e)?gF.internal.getWidth(e)/4:gF.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var i=Number((2*r).toFixed(5)),a=Number((i*gF.internal.Bezier_C).toFixed(5)),o=Number((r*gF.internal.Bezier_C).toFixed(5));return n.push(`0.749023 g`),n.push(`q`),n.push(`1 0 0 1 `+IP(gF.internal.getWidth(e)/2)+` `+IP(gF.internal.getHeight(e)/2)+` cm`),n.push(i+` 0 m`),n.push(i+` `+a+` `+a+` `+i+` 0 `+i+` c`),n.push(`-`+a+` `+i+` -`+i+` `+a+` -`+i+` 0 c`),n.push(`-`+i+` -`+a+` -`+a+` -`+i+` 0 -`+i+` c`),n.push(a+` -`+i+` `+i+` -`+a+` `+i+` 0 c`),n.push(`f`),n.push(`Q`),n.push(`0 g`),n.push(`q`),n.push(`1 0 0 1 `+IP(gF.internal.getWidth(e)/2)+` `+IP(gF.internal.getHeight(e)/2)+` cm`),n.push(r+` 0 m`),n.push(r+` `+o+` `+o+` `+r+` 0 `+r+` c`),n.push(`-`+o+` `+r+` -`+r+` `+o+` -`+r+` 0 c`),n.push(`-`+r+` -`+o+` -`+o+` -`+r+` 0 -`+r+` c`),n.push(o+` -`+r+` `+r+` -`+o+` `+r+` 0 c`),n.push(`f`),n.push(`Q`),t.stream=n.join(`
|
||
`),t},OffPushDown:function(e){var t=zP(e);t.scope=e.scope;var n=[],r=gF.internal.getWidth(e)<=gF.internal.getHeight(e)?gF.internal.getWidth(e)/4:gF.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var i=Number((2*r).toFixed(5)),a=Number((i*gF.internal.Bezier_C).toFixed(5));return n.push(`0.749023 g`),n.push(`q`),n.push(`1 0 0 1 `+IP(gF.internal.getWidth(e)/2)+` `+IP(gF.internal.getHeight(e)/2)+` cm`),n.push(i+` 0 m`),n.push(i+` `+a+` `+a+` `+i+` 0 `+i+` c`),n.push(`-`+a+` `+i+` -`+i+` `+a+` -`+i+` 0 c`),n.push(`-`+i+` -`+a+` -`+a+` -`+i+` 0 -`+i+` c`),n.push(a+` -`+i+` `+i+` -`+a+` `+i+` 0 c`),n.push(`f`),n.push(`Q`),t.stream=n.join(`
|
||
`),t}},Cross:{createAppearanceStream:function(e){var t={D:{Off:gF.RadioButton.Cross.OffPushDown},N:{}};return t.N[e]=gF.RadioButton.Cross.YesNormal,t.D[e]=gF.RadioButton.Cross.YesPushDown,t},getCA:function(){return`8`},YesNormal:function(e){var t=zP(e);t.scope=e.scope;var n=[],r=gF.internal.calculateCross(e);return n.push(`q`),n.push(`1 1 `+FP(gF.internal.getWidth(e)-2)+` `+FP(gF.internal.getHeight(e)-2)+` re`),n.push(`W`),n.push(`n`),n.push(FP(r.x1.x)+` `+FP(r.x1.y)+` m`),n.push(FP(r.x2.x)+` `+FP(r.x2.y)+` l`),n.push(FP(r.x4.x)+` `+FP(r.x4.y)+` m`),n.push(FP(r.x3.x)+` `+FP(r.x3.y)+` l`),n.push(`s`),n.push(`Q`),t.stream=n.join(`
|
||
`),t},YesPushDown:function(e){var t=zP(e);t.scope=e.scope;var n=gF.internal.calculateCross(e),r=[];return r.push(`0.749023 g`),r.push(`0 0 `+FP(gF.internal.getWidth(e))+` `+FP(gF.internal.getHeight(e))+` re`),r.push(`f`),r.push(`q`),r.push(`1 1 `+FP(gF.internal.getWidth(e)-2)+` `+FP(gF.internal.getHeight(e)-2)+` re`),r.push(`W`),r.push(`n`),r.push(FP(n.x1.x)+` `+FP(n.x1.y)+` m`),r.push(FP(n.x2.x)+` `+FP(n.x2.y)+` l`),r.push(FP(n.x4.x)+` `+FP(n.x4.y)+` m`),r.push(FP(n.x3.x)+` `+FP(n.x3.y)+` l`),r.push(`s`),r.push(`Q`),t.stream=r.join(`
|
||
`),t},OffPushDown:function(e){var t=zP(e);t.scope=e.scope;var n=[];return n.push(`0.749023 g`),n.push(`0 0 `+FP(gF.internal.getWidth(e))+` `+FP(gF.internal.getHeight(e))+` re`),n.push(`f`),t.stream=n.join(`
|
||
`),t}}},createDefaultAppearanceStream:function(e){var t=e.scope.internal.getFont(e.fontName,e.fontStyle).id,n=e.scope.__private__.encodeColorString(e.color);return`/`+t+` `+e.fontSize+` Tf `+n}};gF.internal={Bezier_C:.551915024494,calculateCross:function(e){var t=gF.internal.getWidth(e),n=gF.internal.getHeight(e),r=Math.min(t,n);return{x1:{x:(t-r)/2,y:(n-r)/2+r},x2:{x:(t-r)/2+r,y:(n-r)/2},x3:{x:(t-r)/2,y:(n-r)/2},x4:{x:(t-r)/2+r,y:(n-r)/2+r}}}},gF.internal.getWidth=function(e){var t=0;return hD(e)===`object`&&(t=RP(e.Rect[2])),t},gF.internal.getHeight=function(e){var t=0;return hD(e)===`object`&&(t=RP(e.Rect[3])),t};var _F=AP.addField=function(e){if(QP(this,e),!(e instanceof iF))throw Error(`Invalid argument passed to jsPDF.addField.`);var t;return(t=e).scope.internal.acroformPlugin.printedOut&&(t.scope.internal.acroformPlugin.printedOut=!1,t.scope.internal.acroformPlugin.acroFormDictionaryRoot=null),t.scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(t),e.page=e.scope.internal.getCurrentPageInfo().pageNumber,this};AP.AcroFormChoiceField=aF,AP.AcroFormListBox=oF,AP.AcroFormComboBox=sF,AP.AcroFormEditBox=cF,AP.AcroFormButton=lF,AP.AcroFormPushButton=uF,AP.AcroFormRadioButton=dF,AP.AcroFormCheckBox=pF,AP.AcroFormTextField=mF,AP.AcroFormPasswordField=hF,AP.AcroFormAppearance=gF,AP.AcroForm={ChoiceField:aF,ListBox:oF,ComboBox:sF,EditBox:cF,Button:lF,PushButton:uF,RadioButton:dF,CheckBox:pF,TextField:mF,PasswordField:hF,Appearance:gF},kP.AcroForm={ChoiceField:aF,ListBox:oF,ComboBox:sF,EditBox:cF,Button:lF,PushButton:uF,RadioButton:dF,CheckBox:pF,TextField:mF,PasswordField:hF,Appearance:gF},kP.AcroForm;function vF(e){return e.reduce(function(e,t,n){return e[t]=n,e},{})}(function(e){var t=`addImage_`;e.__addimage__={};var n=`UNKNOWN`,r={PNG:[[137,80,78,71]],TIFF:[[77,77,0,42],[73,73,42,0]],JPEG:[[255,216,255,224,void 0,void 0,74,70,73,70,0],[255,216,255,225,void 0,void 0,69,120,105,102,0,0],[255,216,255,219],[255,216,255,238]],JPEG2000:[[0,0,0,12,106,80,32,32]],GIF87a:[[71,73,70,56,55,97]],GIF89a:[[71,73,70,56,57,97]],WEBP:[[82,73,70,70,void 0,void 0,void 0,void 0,87,69,66,80]],BMP:[[66,77],[66,65],[67,73],[67,80],[73,67],[80,84]]},i=e.__addimage__.getImageFileTypeByImageData=function(e,t){var i,a,o,s,c,l=n;if((t||=n)===`RGBA`||e.data!==void 0&&e.data instanceof Uint8ClampedArray&&`height`in e&&`width`in e)return`RGBA`;if(S(e))for(c in r)for(o=r[c],i=0;i<o.length;i+=1){for(s=!0,a=0;a<o[i].length;a+=1)if(o[i][a]!==void 0&&o[i][a]!==e[a]){s=!1;break}if(!0===s){l=c;break}}else for(c in r)for(o=r[c],i=0;i<o.length;i+=1){for(s=!0,a=0;a<o[i].length;a+=1)if(o[i][a]!==void 0&&o[i][a]!==e.charCodeAt(a)){s=!1;break}if(!0===s){l=c;break}}return l===n&&t!==n&&(l=t),l},a=function e(t){for(var n=this.internal.write,r=this.internal.putStream,i=(0,this.internal.getFilters)();i.indexOf(`FlateEncode`)!==-1;)i.splice(i.indexOf(`FlateEncode`),1);t.objectId=this.internal.newObject();var a=[];if(a.push({key:`Type`,value:`/XObject`}),a.push({key:`Subtype`,value:`/Image`}),a.push({key:`Width`,value:t.width}),a.push({key:`Height`,value:t.height}),t.colorSpace===_.INDEXED?a.push({key:`ColorSpace`,value:`[/Indexed /DeviceRGB `+(t.palette.length/3-1)+` `+(`sMask`in t&&t.sMask!==void 0?t.objectId+2:t.objectId+1)+` 0 R]`}):(a.push({key:`ColorSpace`,value:`/`+t.colorSpace}),t.colorSpace===_.DEVICE_CMYK&&a.push({key:`Decode`,value:`[1 0 1 0 1 0 1 0]`})),a.push({key:`BitsPerComponent`,value:t.bitsPerComponent}),`decodeParameters`in t&&t.decodeParameters!==void 0&&a.push({key:`DecodeParms`,value:`<<`+t.decodeParameters+`>>`}),`transparency`in t&&Array.isArray(t.transparency)&&t.transparency.length>0){for(var o=``,s=0,c=t.transparency.length;s<c;s++)o+=t.transparency[s]+` `+t.transparency[s]+` `;a.push({key:`Mask`,value:`[`+o+`]`})}t.sMask!==void 0&&a.push({key:`SMask`,value:t.objectId+1+` 0 R`});var l=t.filter===void 0?void 0:[`/`+t.filter];if(r({data:t.data,additionalKeyValues:a,alreadyAppliedFilters:l,objectId:t.objectId}),n(`endobj`),`sMask`in t&&t.sMask!==void 0){var u=t.sMaskBitsPerComponent??t.bitsPerComponent,d={width:t.width,height:t.height,colorSpace:`DeviceGray`,bitsPerComponent:u,data:t.sMask};`filter`in t&&(d.decodeParameters=`/Predictor ${t.predictor} /Colors 1 /BitsPerComponent ${u} /Columns ${t.width}`,d.filter=t.filter),e.call(this,d)}if(t.colorSpace===_.INDEXED){var f=this.internal.newObject();r({data:w(new Uint8Array(t.palette)),objectId:f}),n(`endobj`)}},o=function(){var e=this.internal.collections[t+`images`];for(var n in e)a.call(this,e[n])},s=function(){var e,n=this.internal.collections[t+`images`],r=this.internal.write;for(var i in n)r(`/I`+(e=n[i]).index,e.objectId,`0`,`R`)},c=function(){this.internal.collections[t+`images`]||(this.internal.collections[t+`images`]={},this.internal.events.subscribe(`putResources`,o),this.internal.events.subscribe(`putXobjectDict`,s))},l=function(){var e=this.internal.collections[t+`images`];return c.call(this),e},u=function(){return Object.keys(this.internal.collections[t+`images`]).length},d=function(t){return typeof e[`process`+t.toUpperCase()]==`function`},f=function(e){return hD(e)===`object`&&e.nodeType===1},p=function(t,n){if(t.nodeName===`IMG`&&t.hasAttribute(`src`)){var r=``+t.getAttribute(`src`);if(r.indexOf(`data:image/`)===0)return iP(unescape(r).split(`base64,`).pop());var i=e.loadFile(r,!0);if(i!==void 0)return i}if(t.nodeName===`CANVAS`){if(t.width===0||t.height===0)throw Error(`Given canvas must have data. Canvas width: `+t.width+`, height: `+t.height);var a;switch(n){case`PNG`:a=`image/png`;break;case`WEBP`:a=`image/webp`;break;default:a=`image/jpeg`}return iP(t.toDataURL(a,1).split(`base64,`).pop())}},m=function(e){var n=this.internal.collections[t+`images`];if(n){for(var r in n)if(e===n[r].alias)return n[r]}},h=function(e,t,n){return e||t||(e=-96,t=-96),e<0&&(e=-1*n.width*72/e/this.internal.scaleFactor),t<0&&(t=-1*n.height*72/t/this.internal.scaleFactor),e===0&&(e=t*n.width/n.height),t===0&&(t=e*n.height/n.width),[e,t]},g=function(e,t,n,r,i,a){var o=h.call(this,n,r,i),s=this.internal.getCoordinateString,c=this.internal.getVerticalCoordinateString,u=l.call(this);if(n=o[0],r=o[1],u[i.index]=i,a){a*=Math.PI/180;var d=Math.cos(a),f=Math.sin(a),p=function(e){return e.toFixed(4)},m=[p(d),p(f),p(-1*f),p(d),0,0,`cm`]}this.internal.write(`q`),a?(this.internal.write([1,`0`,`0`,1,s(e),c(t+r),`cm`].join(` `)),this.internal.write(m.join(` `)),this.internal.write([s(n),`0`,`0`,s(r),`0`,`0`,`cm`].join(` `))):this.internal.write([s(n),`0`,`0`,s(r),s(e),c(t+r),`cm`].join(` `)),this.isAdvancedAPI()&&this.internal.write([1,0,0,-1,0,0,`cm`].join(` `)),this.internal.write(`/I`+i.index+` Do`),this.internal.write(`Q`)},_=e.color_spaces={DEVICE_RGB:`DeviceRGB`,DEVICE_GRAY:`DeviceGray`,DEVICE_CMYK:`DeviceCMYK`,CAL_GREY:`CalGray`,CAL_RGB:`CalRGB`,LAB:`Lab`,ICC_BASED:`ICCBased`,INDEXED:`Indexed`,PATTERN:`Pattern`,SEPARATION:`Separation`,DEVICE_N:`DeviceN`};e.decode={DCT_DECODE:`DCTDecode`,FLATE_DECODE:`FlateDecode`,LZW_DECODE:`LZWDecode`,JPX_DECODE:`JPXDecode`,JBIG2_DECODE:`JBIG2Decode`,ASCII85_DECODE:`ASCII85Decode`,ASCII_HEX_DECODE:`ASCIIHexDecode`,RUN_LENGTH_DECODE:`RunLengthDecode`,CCITT_FAX_DECODE:`CCITTFaxDecode`};var v=e.image_compression={NONE:`NONE`,FAST:`FAST`,MEDIUM:`MEDIUM`,SLOW:`SLOW`},y=e.__addimage__.sHashCode=function(e){var t,n,r=0;if(typeof e==`string`)for(n=e.length,t=0;t<n;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;else if(S(e))for(n=e.byteLength/2,t=0;t<n;t++)r=(r<<5)-r+e[t],r|=0;return r},b=e.__addimage__.validateStringAsBase64=function(e){(e||=``).toString().trim();var t=!0;return e.length===0&&(t=!1),e.length%4!=0&&(t=!1),!1===/^[A-Za-z0-9+/]+$/.test(e.substr(0,e.length-2))&&(t=!1),!1===/^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test(e.substr(-2))&&(t=!1),t},x=e.__addimage__.extractImageFromDataUrl=function(e){if(e==null||!(e=e.trim()).startsWith(`data:`))return null;var t=e.indexOf(`,`);return t<0?null:e.substring(0,t).trim().endsWith(`base64`)?e.substring(t+1):null};e.__addimage__.isArrayBuffer=function(e){return e instanceof ArrayBuffer};var S=e.__addimage__.isArrayBufferView=function(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array},C=e.__addimage__.binaryStringToUint8Array=function(e){for(var t=e.length,n=new Uint8Array(t),r=0;r<t;r++)n[r]=e.charCodeAt(r);return n},w=e.__addimage__.arrayBufferToBinaryString=function(e){for(var t=``,n=S(e)?e:new Uint8Array(e),r=0;r<n.length;r+=8192)t+=String.fromCharCode.apply(null,n.subarray(r,r+8192));return t};e.addImage=function(){var e,t,r,i,a,o,s,l,u;if(typeof arguments[1]==`number`?(t=n,r=arguments[1],i=arguments[2],a=arguments[3],o=arguments[4],s=arguments[5],l=arguments[6],u=arguments[7]):(t=arguments[1],r=arguments[2],i=arguments[3],a=arguments[4],o=arguments[5],s=arguments[6],l=arguments[7],u=arguments[8]),hD(e=arguments[0])===`object`&&!f(e)&&`imageData`in e){var d=e;e=d.imageData,t=d.format||t||n,r=d.x||r||0,i=d.y||i||0,a=d.w||d.width||a,o=d.h||d.height||o,s=d.alias||s,l=d.compression||l,u=d.rotation||d.angle||u}var p=this.internal.getFilters();if(l===void 0&&p.indexOf(`FlateEncode`)!==-1&&(l=`SLOW`),isNaN(r)||isNaN(i))throw Error(`Invalid coordinates passed to jsPDF.addImage`);c.call(this);var m=T.call(this,e,t,s,l);return g.call(this,r,i,a,o,m,u),this};var T=function(t,r,a,o){var s,c,l;if(typeof t==`string`&&i(t)===n){t=unescape(t);var h=E(t,!1);(h!==``||(h=e.loadFile(t,!0))!==void 0)&&(t=h)}if(f(t)&&(t=p(t,r)),r=i(t,r),!d(r))throw Error(`addImage does not support files of type '`+r+`', please ensure that a plugin for '`+r+`' support is added.`);if(((l=a)==null||l.length===0)&&(a=function(e){return typeof e==`string`||S(e)?y(e):S(e.data)?y(e.data):null}(t)),(s=m.call(this,a))||(t instanceof Uint8Array||r===`RGBA`||(c=t,t=C(t)),s=this[`process`+r.toUpperCase()](t,u.call(this),a,function(t){return t&&typeof t==`string`&&(t=t.toUpperCase()),t in e.image_compression?t:v.NONE}(o),c)),!s)throw Error(`An unknown error occurred whilst processing the image.`);return s},E=e.__addimage__.convertBase64ToBinaryString=function(e,t){t=typeof t!=`boolean`||t;var n,r=``;if(typeof e==`string`){n=x(e)??e;try{r=iP(n)}catch(e){if(t)throw b(n)?Error(`atob-Error in jsPDF.convertBase64ToBinaryString `+e.message):Error(`Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString `)}}return r};e.getImageProperties=function(t){var r,a,o=``;if(f(t)&&(t=p(t)),typeof t==`string`&&i(t)===n&&((o=E(t,!1))===``&&(o=e.loadFile(t)||``),t=o),a=i(t),!d(a))throw Error(`addImage does not support files of type '`+a+`', please ensure that a plugin for '`+a+`' support is added.`);if(t instanceof Uint8Array||(t=C(t)),!(r=this[`process`+a.toUpperCase()](t)))throw Error(`An unknown error occurred whilst processing the image`);return r.fileType=a,r}})(kP.API),function(e){var t=function(e){if(e!==void 0&&e!=``)return!0};kP.API.events.push([`addPage`,function(e){this.internal.getPageInfo(e.pageNumber).pageContext.annotations=[]}]),e.events.push([`putPage`,function(e){for(var n,r,i,a=this.internal.getCoordinateString,o=this.internal.getVerticalCoordinateString,s=this.internal.getPageInfoByObjId(e.objId),c=e.pageContext.annotations,l=!1,u=0;u<c.length&&!l;u++)switch((n=c[u]).type){case`link`:(t(n.options.url)||t(n.options.pageNumber))&&(l=!0);break;case`reference`:case`text`:case`freetext`:l=!0}if(l!=0){this.internal.write(`/Annots [`);for(var d=0;d<c.length;d++){n=c[d];var f=this.internal.pdfEscape,p=this.internal.getEncryptor(e.objId);switch(n.type){case`reference`:this.internal.write(` `+n.object.objId+` 0 R `);break;case`text`:var m=this.internal.newAdditionalObject(),h=this.internal.newAdditionalObject(),g=this.internal.getEncryptor(m.objId),_=n.title||`Note`;i=`<</Type /Annot /Subtype /Text `+(r=`/Rect [`+a(n.bounds.x)+` `+o(n.bounds.y+n.bounds.h)+` `+a(n.bounds.x+n.bounds.w)+` `+o(n.bounds.y)+`] `)+`/Contents (`+f(g(n.contents))+`)`,i+=` /Popup `+h.objId+` 0 R`,i+=` /P `+s.objId+` 0 R`,i+=` /T (`+f(g(_))+`) >>`,m.content=i;var v=m.objId+` 0 R`;i=`<</Type /Annot /Subtype /Popup `+(r=`/Rect [`+a(n.bounds.x+30)+` `+o(n.bounds.y+n.bounds.h)+` `+a(n.bounds.x+n.bounds.w+30)+` `+o(n.bounds.y)+`] `)+` /Parent `+v,n.open&&(i+=` /Open true`),i+=` >>`,h.content=i,this.internal.write(m.objId,`0 R`,h.objId,`0 R`);break;case`freetext`:r=`/Rect [`+a(n.bounds.x)+` `+o(n.bounds.y)+` `+a(n.bounds.x+n.bounds.w)+` `+o(n.bounds.y+n.bounds.h)+`] `;var y=`font: Helvetica,sans-serif 12.0pt; text-align:left; color:#`+(n.color||`#000000`);i=`<</Type /Annot /Subtype /FreeText `+r+`/Contents (`+f(p(n.contents))+`)`,i+=` /DS(`+f(p(y))+`)`,i+=` /Border [0 0 0]`,i+=` >>`,this.internal.write(i);break;case`link`:if(n.options.name){var b=this.annotations._nameMap[n.options.name];n.options.pageNumber=b.page,n.options.top=b.y}else n.options.top||(n.options.top=0);if(r=`/Rect [`+n.finalBounds.x+` `+n.finalBounds.y+` `+n.finalBounds.w+` `+n.finalBounds.h+`] `,i=``,n.options.url)i=`<</Type /Annot /Subtype /Link `+r+`/Border [0 0 0] /A <</S /URI /URI (`+f(p(n.options.url))+`) >>`;else if(n.options.pageNumber)switch(i=`<</Type /Annot /Subtype /Link `+r+`/Border [0 0 0] /Dest [`+this.internal.getPageInfo(n.options.pageNumber).objId+` 0 R`,n.options.magFactor=n.options.magFactor||`XYZ`,n.options.magFactor){case`Fit`:i+=` /Fit]`;break;case`FitH`:i+=` /FitH `+n.options.top+`]`;break;case`FitV`:n.options.left=n.options.left||0,i+=` /FitV `+n.options.left+`]`;break;default:var x=o(n.options.top);n.options.left=n.options.left||0,n.options.zoom===void 0&&(n.options.zoom=0),i+=` /XYZ `+n.options.left+` `+x+` `+n.options.zoom+`]`}i!=``&&(i+=` >>`,this.internal.write(i))}}this.internal.write(`]`)}}]),e.createAnnotation=function(e){var t=this.internal.getCurrentPageInfo();switch(e.type){case`link`:this.link(e.bounds.x,e.bounds.y,e.bounds.w,e.bounds.h,e);break;case`text`:case`freetext`:t.pageContext.annotations.push(e)}},e.link=function(e,t,n,r,i){var a=this.internal.getCurrentPageInfo(),o=this.internal.getCoordinateString,s=this.internal.getVerticalCoordinateString;a.pageContext.annotations.push({finalBounds:{x:o(e),y:s(t),w:o(e+n),h:s(t+r)},options:i,type:`link`})},e.textWithLink=function(e,t,n,r){var i,a,o=this.getTextWidth(e),s=this.internal.getLineHeight()/this.internal.scaleFactor;if(r.maxWidth!==void 0){a=r.maxWidth;var c=this.splitTextToSize(e,a).length;i=Math.ceil(s*c)}else a=o,i=s;return this.text(e,t,n,r),n+=.2*s,r.align===`center`&&(t-=o/2),r.align===`right`&&(t-=o),this.link(t,n-s,a,i,r),o},e.getTextWidth=function(e){var t=this.internal.getFontSize();return this.getStringUnitWidth(e)*t/this.internal.scaleFactor}}(kP.API),function(e){var t={1569:[65152],1570:[65153,65154],1571:[65155,65156],1572:[65157,65158],1573:[65159,65160],1574:[65161,65162,65163,65164],1575:[65165,65166],1576:[65167,65168,65169,65170],1577:[65171,65172],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194],1584:[65195,65196],1585:[65197,65198],1586:[65199,65200],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1649:[64336,64337],1655:[64477],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393],1676:[64388,64389],1677:[64386,64387],1678:[64390,64391],1681:[64396,64397],1688:[64394,64395],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421],1729:[64422,64423,64424,64425],1733:[64480,64481],1734:[64473,64474],1735:[64471,64472],1736:[64475,64476],1737:[64482,64483],1739:[64478,64479],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431],1747:[64432,64433]},n={65247:{65154:65269,65156:65271,65160:65273,65166:65275},65248:{65154:65270,65156:65272,65160:65274,65166:65276},65165:{65247:{65248:{65258:65010}}},1617:{1612:64606,1613:64607,1614:64608,1615:64609,1616:64610}},r={1612:64606,1613:64607,1614:64608,1615:64609,1616:64610},i=[1570,1571,1573,1575];e.__arabicParser__={};var a=e.__arabicParser__.isInArabicSubstitutionA=function(e){return t[e.charCodeAt(0)]!==void 0},o=e.__arabicParser__.isArabicLetter=function(e){return typeof e==`string`&&/^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(e)},s=e.__arabicParser__.isArabicEndLetter=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length<=2},c=e.__arabicParser__.isArabicAlfLetter=function(e){return o(e)&&i.indexOf(e.charCodeAt(0))>=0};e.__arabicParser__.arabicLetterHasIsolatedForm=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length>=1};var l=e.__arabicParser__.arabicLetterHasFinalForm=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length>=2};e.__arabicParser__.arabicLetterHasInitialForm=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length>=3};var u=e.__arabicParser__.arabicLetterHasMedialForm=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length==4},d=e.__arabicParser__.resolveLigatures=function(e){var t=0,r=n,i=``,a=0;for(t=0;t<e.length;t+=1)r[e.charCodeAt(t)]===void 0?(r=n,i+=e.charAt(t-a),t-=a,a=0):(a++,typeof(r=r[e.charCodeAt(t)])==`number`&&(i+=String.fromCharCode(r),r=n,a=0),t===e.length-1&&(r=n,i+=e.charAt(t-(a-1)),t-=a-1,a=0));return i};e.__arabicParser__.isArabicDiacritic=function(e){return e!==void 0&&r[e.charCodeAt(0)]!==void 0};var f=e.__arabicParser__.getCorrectForm=function(e,t,n){return o(e)?!1===a(e)?-1:!l(e)||!o(t)&&!o(n)||!o(n)&&s(t)||s(e)&&!o(t)||s(e)&&c(t)||s(e)&&s(t)?0:u(e)&&o(t)&&!s(t)&&o(n)&&l(n)?3:s(e)||!o(n)?1:2:-1},p=function(e){var n=0,r=0,i=0,a=``,s=``,c=``,l=(e||=``).split(`\\s+`),u=[];for(n=0;n<l.length;n+=1){for(u.push(``),r=0;r<l[n].length;r+=1)a=l[n][r],s=l[n][r-1],c=l[n][r+1],o(a)?(i=f(a,s,c),u[n]+=i===-1?a:String.fromCharCode(t[a.charCodeAt(0)][i])):u[n]+=a;u[n]=d(u[n])}return u.join(` `)},m=e.__arabicParser__.processArabic=e.processArabic=function(){var e,t=typeof arguments[0]==`string`?arguments[0]:arguments[0].text,n=[];if(Array.isArray(t)){var r=0;for(n=[],r=0;r<t.length;r+=1)Array.isArray(t[r])?n.push([p(t[r][0]),t[r][1],t[r][2]]):n.push([p(t[r])]);e=n}else e=p(t);return typeof arguments[0]==`string`?e:(arguments[0].text=e,arguments[0])};e.events.push([`preProcessText`,m])}(kP.API),kP.API.autoPrint=function(e){var t;return(e||={}).variant=e.variant||`non-conform`,e.variant===`javascript`?this.addJS(`print({});`):(this.internal.events.subscribe(`postPutResources`,function(){t=this.internal.newObject(),this.internal.out(`<<`),this.internal.out(`/S /Named`),this.internal.out(`/Type /Action`),this.internal.out(`/N /Print`),this.internal.out(`>>`),this.internal.out(`endobj`)}),this.internal.events.subscribe(`putCatalog`,function(){this.internal.out(`/OpenAction `+t+` 0 R`)})),this},function(e){var t=function(){var e=void 0;Object.defineProperty(this,"pdf",{get:function(){return e},set:function(t){e=t}});var t=150;Object.defineProperty(this,"width",{get:function(){return t},set:function(e){t=isNaN(e)||!1===Number.isInteger(e)||e<0?150:e,this.getContext(`2d`).pageWrapXEnabled&&(this.getContext(`2d`).pageWrapX=t+1)}});var n=300;Object.defineProperty(this,"height",{get:function(){return n},set:function(e){n=isNaN(e)||!1===Number.isInteger(e)||e<0?300:e,this.getContext(`2d`).pageWrapYEnabled&&(this.getContext(`2d`).pageWrapY=n+1)}});var r=[];Object.defineProperty(this,"childNodes",{get:function(){return r},set:function(e){r=e}});var i={};Object.defineProperty(this,"style",{get:function(){return i},set:function(e){i=e}}),Object.defineProperty(this,"parentNode",{})};t.prototype.getContext=function(e,t){var n;if((e||=`2d`)!==`2d`)return null;for(n in t)this.pdf.context2d.hasOwnProperty(n)&&(this.pdf.context2d[n]=t[n]);return this.pdf.context2d._canvas=this,this.pdf.context2d},t.prototype.toDataURL=function(){throw Error(`toDataURL is not implemented.`)},e.events.push([`initialized`,function(){this.canvas=new t,this.canvas.pdf=this}])}(kP.API),function(e){var t={left:0,top:0,bottom:0,right:0},n=!1,r=function(){this.internal.__cell__===void 0&&(this.internal.__cell__={},this.internal.__cell__.padding=3,this.internal.__cell__.headerFunction=void 0,this.internal.__cell__.margins=Object.assign({},t),this.internal.__cell__.margins.width=this.getPageWidth(),i.call(this))},i=function(){this.internal.__cell__.lastCell=new a,this.internal.__cell__.pages=1},a=function(){var e=arguments[0];Object.defineProperty(this,"x",{enumerable:!0,get:function(){return e},set:function(t){e=t}});var t=arguments[1];Object.defineProperty(this,"y",{enumerable:!0,get:function(){return t},set:function(e){t=e}});var n=arguments[2];Object.defineProperty(this,"width",{enumerable:!0,get:function(){return n},set:function(e){n=e}});var r=arguments[3];Object.defineProperty(this,"height",{enumerable:!0,get:function(){return r},set:function(e){r=e}});var i=arguments[4];Object.defineProperty(this,"text",{enumerable:!0,get:function(){return i},set:function(e){i=e}});var a=arguments[5];Object.defineProperty(this,"lineNumber",{enumerable:!0,get:function(){return a},set:function(e){a=e}});var o=arguments[6];return Object.defineProperty(this,"align",{enumerable:!0,get:function(){return o},set:function(e){o=e}}),this};a.prototype.clone=function(){return new a(this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align)},a.prototype.toArray=function(){return[this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align]},e.setHeaderFunction=function(e){return r.call(this),this.internal.__cell__.headerFunction=typeof e==`function`?e:void 0,this},e.getTextDimensions=function(e,t){r.call(this);var n=(t||={}).fontSize||this.getFontSize(),i=t.font||this.getFont(),a=t.scaleFactor||this.internal.scaleFactor,o=0,s=0,c=0,l=this;if(!Array.isArray(e)&&typeof e!=`string`){if(typeof e!=`number`)throw Error(`getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.`);e=String(e)}var u=t.maxWidth;u>0?typeof e==`string`?e=this.splitTextToSize(e,u):Object.prototype.toString.call(e)===`[object Array]`&&(e=e.reduce(function(e,t){return e.concat(l.splitTextToSize(t,u))},[])):e=Array.isArray(e)?e:[e];for(var d=0;d<e.length;d++)o<(c=this.getStringUnitWidth(e[d],{font:i})*n)&&(o=c);return o!==0&&(s=e.length),{w:o/=a,h:Math.max((s*n*this.getLineHeightFactor()-n*(this.getLineHeightFactor()-1))/a,0)}},e.cellAddPage=function(){r.call(this),this.addPage();var e=this.internal.__cell__.margins||t;return this.internal.__cell__.lastCell=new a(e.left,e.top,void 0,void 0),this.internal.__cell__.pages+=1,this};var o=e.cell=function(){var e=arguments[0]instanceof a?arguments[0]:new a(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]);r.call(this);var i=this.internal.__cell__.lastCell,o=this.internal.__cell__.padding,s=this.internal.__cell__.margins||t,c=this.internal.__cell__.tableHeaderRow,l=this.internal.__cell__.printHeaders;return i.lineNumber!==void 0&&(i.lineNumber===e.lineNumber?(e.x=(i.x||0)+(i.width||0),e.y=i.y||0):i.y+i.height+e.height+s.bottom>this.getPageHeight()?(this.cellAddPage(),e.y=s.top,l&&c&&(this.printHeaderRow(e.lineNumber,!0),e.y+=c[0].height)):e.y=i.y+i.height||e.y),e.text[0]!==void 0&&(this.rect(e.x,e.y,e.width,e.height,!0===n?`FD`:void 0),e.align===`right`?this.text(e.text,e.x+e.width-o,e.y+o,{align:`right`,baseline:`top`}):e.align===`center`?this.text(e.text,e.x+e.width/2,e.y+o,{align:`center`,baseline:`top`,maxWidth:e.width-o-o}):this.text(e.text,e.x+o,e.y+o,{align:`left`,baseline:`top`,maxWidth:e.width-o-o})),this.internal.__cell__.lastCell=e,this};e.table=function(e,n,c,l,u){if(r.call(this),!c)throw Error(`No data for PDF table.`);var d,f,p,m,h=[],g=[],_=[],v={},y={},b=[],x=[],S=(u||={}).autoSize||!1,C=!1!==u.printHeaders,w=u.css&&u.css[`font-size`]!==void 0?16*u.css[`font-size`]:u.fontSize||12,T=u.margins||Object.assign({width:this.getPageWidth()},t),E=typeof u.padding==`number`?u.padding:3,D=u.headerBackgroundColor||`#c8c8c8`,O=u.headerTextColor||`#000`;if(i.call(this),this.internal.__cell__.printHeaders=C,this.internal.__cell__.margins=T,this.internal.__cell__.table_font_size=w,this.internal.__cell__.padding=E,this.internal.__cell__.headerBackgroundColor=D,this.internal.__cell__.headerTextColor=O,this.setFontSize(w),l==null)g=h=Object.keys(c[0]),_=h.map(function(){return`left`});else if(Array.isArray(l)&&hD(l[0])===`object`)for(h=l.map(function(e){return e.name}),g=l.map(function(e){return e.prompt||e.name||``}),_=l.map(function(e){return e.align||`left`}),d=0;d<l.length;d+=1)y[l[d].name]=.7499990551181103*l[d].width;else Array.isArray(l)&&typeof l[0]==`string`&&(g=h=l,_=h.map(function(){return`left`}));if(S||Array.isArray(l)&&typeof l[0]==`string`)for(d=0;d<h.length;d+=1){for(v[m=h[d]]=c.map(function(e){return e[m]}),this.setFont(void 0,`bold`),b.push(this.getTextDimensions(g[d],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w),f=v[m],this.setFont(void 0,`normal`),p=0;p<f.length;p+=1)b.push(this.getTextDimensions(f[p],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w);y[m]=Math.max.apply(null,b)+E+E,b=[]}if(C){var k={};for(d=0;d<h.length;d+=1)k[h[d]]={},k[h[d]].text=g[d],k[h[d]].align=_[d];var A=s.call(this,k,y);x=h.map(function(t){return new a(e,n,y[t],A,k[t].text,void 0,k[t].align)}),this.setTableHeaderRow(x),this.printHeaderRow(1,!1)}var j=l.reduce(function(e,t){return e[t.name]=t.align,e},{});for(d=0;d<c.length;d+=1){`rowStart`in u&&u.rowStart instanceof Function&&u.rowStart({row:d,data:c[d]},this);var M=s.call(this,c[d],y);for(p=0;p<h.length;p+=1){var N=c[d][h[p]];`cellStart`in u&&u.cellStart instanceof Function&&u.cellStart({row:d,col:p,data:N},this),o.call(this,new a(e,n,y[h[p]],M,N,d+2,j[h[p]]))}}return this.internal.__cell__.table_x=e,this.internal.__cell__.table_y=n,this};var s=function(e,t){var n=this.internal.__cell__.padding,r=this.internal.__cell__.table_font_size,i=this.internal.scaleFactor;return Object.keys(e).map(function(r){var i=e[r];return this.splitTextToSize(i.hasOwnProperty(`text`)?i.text:i,t[r]-n-n)},this).map(function(e){return this.getLineHeightFactor()*e.length*r/i+n+n},this).reduce(function(e,t){return Math.max(e,t)},0)};e.setTableHeaderRow=function(e){r.call(this),this.internal.__cell__.tableHeaderRow=e},e.printHeaderRow=function(e,t){if(r.call(this),!this.internal.__cell__.tableHeaderRow)throw Error(`Property tableHeaderRow does not exist.`);var i;if(n=!0,typeof this.internal.__cell__.headerFunction==`function`){var s=this.internal.__cell__.headerFunction(this,this.internal.__cell__.pages);this.internal.__cell__.lastCell=new a(s[0],s[1],s[2],s[3],void 0,-1)}this.setFont(void 0,`bold`);for(var c=[],l=0;l<this.internal.__cell__.tableHeaderRow.length;l+=1){i=this.internal.__cell__.tableHeaderRow[l].clone(),t&&(i.y=this.internal.__cell__.margins.top||0,c.push(i)),i.lineNumber=e;var u=this.getTextColor();this.setTextColor(this.internal.__cell__.headerTextColor),this.setFillColor(this.internal.__cell__.headerBackgroundColor),o.call(this,i),this.setTextColor(u)}c.length>0&&this.setTableHeaderRow(c),this.setFont(void 0,`normal`),n=!1}}(kP.API);var yF={italic:[`italic`,`oblique`,`normal`],oblique:[`oblique`,`italic`,`normal`],normal:[`normal`,`oblique`,`italic`]},bF=[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`],xF=vF(bF),SF=[100,200,300,400,500,600,700,800,900],CF=vF(SF);function wF(e){var t=e.family.replace(/"|'/g,``).toLowerCase(),n=function(e){return yF[e||=`normal`]?e:`normal`}(e.style),r=function(e){return e?typeof e==`number`?e>=100&&e<=900&&e%100==0?e:400:/^\d00$/.test(e)?parseInt(e):e===`bold`?700:400:400}(e.weight),i=function(e){return typeof xF[e||=`normal`]==`number`?e:`normal`}(e.stretch);return{family:t,style:n,weight:r,stretch:i,src:e.src||[],ref:e.ref||{name:t,style:[i,n,r].join(` `)}}}function TF(e,t,n,r){var i;for(i=n;i>=0&&i<t.length;i+=r)if(e[t[i]])return e[t[i]];for(i=n;i>=0&&i<t.length;i-=r)if(e[t[i]])return e[t[i]]}var EF={"sans-serif":`helvetica`,fixed:`courier`,monospace:`courier`,terminal:`courier`,cursive:`times`,fantasy:`times`,serif:`times`},DF={caption:`times`,icon:`times`,menu:`times`,"message-box":`times`,"small-caption":`times`,"status-bar":`times`};function OF(e){return[e.stretch,e.style,e.weight,e.family].join(` `)}function kF(e){return e.trimLeft()}function AF(e,t){for(var n=0;n<e.length;){if(e.charAt(n)===t)return[e.substring(0,n),e.substring(n+1)];n+=1}return null}function jF(e){var t=e.match(/^(-[a-z_]|[a-z_])[a-z0-9_-]*/i);return t===null?null:[t[0],e.substring(t[0].length)]}var MF,NF,PF,FF,IF,LF=[`times`];function RF(e,t,n,r,i){var a=4,o=VF;switch(i){case kP.API.image_compression.FAST:a=1,o=BF;break;case kP.API.image_compression.MEDIUM:a=6,o=HF;break;case kP.API.image_compression.SLOW:a=9,o=UF}e=function(e,t,n,r){for(var i,a=e.length/t,o=new Uint8Array(e.length+a),s=[zF,BF,VF,HF,UF],c=0;c<a;c+=1){var l=c*t,u=e.subarray(l,l+t);if(r)o.set(r(u,n,i),l+c);else{for(var d=s.length,f=[],p=0;p<d;p+=1)f[p]=s[p](u,n,i);var m=GF(f.concat());o.set(f[m],l+c)}i=u}return o}(e,t,Math.ceil(n*r/8),o);var s=$D(e,{level:a});return kP.API.__addimage__.arrayBufferToBinaryString(s)}function zF(e){var t=Array.apply([],e);return t.unshift(0),t}function BF(e,t){var n=e.length,r=[];r[0]=1;for(var i=0;i<n;i+=1){var a=e[i-t]||0;r[i+1]=e[i]-a+256&255}return r}function VF(e,t,n){var r=e.length,i=[];i[0]=2;for(var a=0;a<r;a+=1){var o=n&&n[a]||0;i[a+1]=e[a]-o+256&255}return i}function HF(e,t,n){var r=e.length,i=[];i[0]=3;for(var a=0;a<r;a+=1){var o=e[a-t]||0,s=n&&n[a]||0;i[a+1]=e[a]+256-(o+s>>>1)&255}return i}function UF(e,t,n){var r=e.length,i=[];i[0]=4;for(var a=0;a<r;a+=1){var o=WF(e[a-t]||0,n&&n[a]||0,n&&n[a-t]||0);i[a+1]=e[a]-o+256&255}return i}function WF(e,t,n){if(e===t&&t===n)return e;var r=Math.abs(t-n),i=Math.abs(e-n),a=Math.abs(e+t-n-n);return r<=i&&r<=a?e:i<=a?t:n}function GF(e){var t=e.map(function(e){return e.reduce(function(e,t){return e+Math.abs(t)},0)});return t.indexOf(Math.min.apply(null,t))}function KF(e,t,n){var r=t*n,i=Math.floor(r/8),a=16-(r-8*i+n),o=(1<<n)-1;return JF(e,i)>>a&o}function qF(e,t,n,r){var i=n*r,a=Math.floor(i/8),o=16-(i-8*a+r),s=(1<<r)-1,c=(t&s)<<o;(function(e,t,n){if(t+1<e.byteLength)e.setUint16(t,n,!1);else{var r=n>>8&255;e.setUint8(t,r)}})(e,a,JF(e,a)&~(s<<o)&65535|c)}function JF(e,t){return t+1<e.byteLength?e.getUint16(t,!1):e.getUint8(t)<<8}function YF(e){var t=0;if(e[t++]!==71||e[t++]!==73||e[t++]!==70||e[t++]!==56||(e[t++]+1&253)!=56||e[t++]!==97)throw Error(`Invalid GIF 87a/89a header.`);var n=e[t++]|e[t++]<<8,r=e[t++]|e[t++]<<8,i=e[t++],a=i>>7,o=1<<1+(7&i);e[t++],e[t++];var s=null,c=null;a&&(s=t,c=o,t+=3*o);var l=!0,u=[],d=0,f=null,p=0,m=null;for(this.width=n,this.height=r;l&&t<e.length;)switch(e[t++]){case 33:switch(e[t++]){case 255:if(e[t]!==11||e[t+1]==78&&e[t+2]==69&&e[t+3]==84&&e[t+4]==83&&e[t+5]==67&&e[t+6]==65&&e[t+7]==80&&e[t+8]==69&&e[t+9]==50&&e[t+10]==46&&e[t+11]==48&&e[t+12]==3&&e[t+13]==1&&e[t+16]==0)t+=14,m=e[t++]|e[t++]<<8,t++;else for(t+=12;;){if(!((D=e[t++])>=0))throw Error(`Invalid block size`);if(D===0)break;t+=D}break;case 249:if(e[t++]!==4||e[t+4]!==0)throw Error(`Invalid graphics extension block.`);var h=e[t++];d=e[t++]|e[t++]<<8,f=e[t++],1&h||(f=null),p=h>>2&7,t++;break;case 254:for(;;){if(!((D=e[t++])>=0))throw Error(`Invalid block size`);if(D===0)break;t+=D}break;default:throw Error(`Unknown graphic control label: 0x`+e[t-1].toString(16))}break;case 44:var g=e[t++]|e[t++]<<8,_=e[t++]|e[t++]<<8,v=e[t++]|e[t++]<<8,y=e[t++]|e[t++]<<8,b=e[t++],x=b>>6&1,S=1<<1+(7&b),C=s,w=c,T=!1;b>>7&&(T=!0,C=t,w=S,t+=3*S);var E=t;for(t++;;){var D;if(!((D=e[t++])>=0))throw Error(`Invalid block size`);if(D===0)break;t+=D}u.push({x:g,y:_,width:v,height:y,has_local_palette:T,palette_offset:C,palette_size:w,data_offset:E,data_length:t-E,transparent_index:f,interlaced:!!x,delay:d,disposal:p});break;case 59:l=!1;break;default:throw Error(`Unknown gif block: 0x`+e[t-1].toString(16))}this.numFrames=function(){return u.length},this.loopCount=function(){return m},this.frameInfo=function(e){if(e<0||e>=u.length)throw Error(`Frame index out of range.`);return u[e]},this.decodeAndBlitFrameBGRA=function(t,r){var i=this.frameInfo(t),a=i.width*i.height;if(a>536870912)throw Error(`Image dimensions exceed 512MB, which is too large.`);var o=new Uint8Array(a);XF(e,i.data_offset,o,a);var s=i.palette_offset,c=i.transparent_index;c===null&&(c=256);var l=i.width,u=n-l,d=l,f=4*(i.y*n+i.x),p=4*((i.y+i.height)*n+i.x),m=f,h=4*u;!0===i.interlaced&&(h+=4*n*7);for(var g=8,_=0,v=o.length;_<v;++_){var y=o[_];if(d===0&&(d=l,(m+=h)>=p&&(h=4*u+4*n*(g-1),m=f+(l+u)*(g<<1),g>>=1)),y===c)m+=4;else{var b=e[s+3*y],x=e[s+3*y+1],S=e[s+3*y+2];r[m++]=S,r[m++]=x,r[m++]=b,r[m++]=255}--d}},this.decodeAndBlitFrameRGBA=function(t,r){var i=this.frameInfo(t),a=i.width*i.height;if(a>536870912)throw Error(`Image dimensions exceed 512MB, which is too large.`);var o=new Uint8Array(a);XF(e,i.data_offset,o,a);var s=i.palette_offset,c=i.transparent_index;c===null&&(c=256);var l=i.width,u=n-l,d=l,f=4*(i.y*n+i.x),p=4*((i.y+i.height)*n+i.x),m=f,h=4*u;!0===i.interlaced&&(h+=4*n*7);for(var g=8,_=0,v=o.length;_<v;++_){var y=o[_];if(d===0&&(d=l,(m+=h)>=p&&(h=4*u+4*n*(g-1),m=f+(l+u)*(g<<1),g>>=1)),y===c)m+=4;else{var b=e[s+3*y],x=e[s+3*y+1],S=e[s+3*y+2];r[m++]=b,r[m++]=x,r[m++]=S,r[m++]=255}--d}}}function XF(e,t,n,r){for(var i=e[t++],a=1<<i,o=a+1,s=o+1,c=i+1,l=(1<<c)-1,u=0,d=0,f=0,p=e[t++],m=new Int32Array(4096),h=null;;){for(;u<16&&p!==0;)d|=e[t++]<<u,u+=8,p===1?p=e[t++]:--p;if(u<c)break;var g=d&l;if(d>>=c,u-=c,g!==a){if(g===o)break;for(var _=g<s?g:h,v=0,y=_;y>a;)y=m[y]>>8,++v;var b=y;if(f+v+(_===g?0:1)>r)return void QN.log(`Warning, gif stream longer than expected.`);n[f++]=b;var x=f+=v;for(_!==g&&(n[f++]=b),y=_;v--;)y=m[y],n[--x]=255&y,y>>=8;h!==null&&s<4096&&(m[s++]=h<<8|b,s>=l+1&&c<12&&(++c,l=l<<1|1)),h=g}else s=o+1,l=(1<<(c=i+1))-1,h=null}return f!==r&&QN.log(`Warning, gif stream shorter than expected.`),n}function ZF(e){var t,n,r,i,a,o=Math.floor,s=Array(64),c=Array(64),l=Array(64),u=Array(64),d=Array(65535),f=Array(65535),p=Array(64),m=Array(64),h=[],g=0,_=7,v=Array(64),y=Array(64),b=Array(64),x=Array(256),S=Array(2048),C=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],w=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],T=[0,1,2,3,4,5,6,7,8,9,10,11],E=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],D=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],O=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],k=[0,1,2,3,4,5,6,7,8,9,10,11],A=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],j=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function M(e,t){for(var n=0,r=0,i=[],a=1;a<=16;a++){for(var o=1;o<=e[a];o++)i[t[r]]=[],i[t[r]][0]=n,i[t[r]][1]=a,r++,n++;n*=2}return i}function N(e){for(var t=e[0],n=e[1]-1;n>=0;)t&1<<n&&(g|=1<<_),n--,--_<0&&(g==255?(P(255),P(0)):P(g),_=7,g=0)}function P(e){h.push(e)}function F(e){P(e>>8&255),P(255&e)}function I(e,t,n,r,i){for(var a,o=i[0],s=i[240],c=function(e,t){var n,r,i,a,o,s,c,l,u,d,f=0;for(u=0;u<8;++u){n=e[f],r=e[f+1],i=e[f+2],a=e[f+3],o=e[f+4],s=e[f+5],c=e[f+6];var m=n+(l=e[f+7]),h=n-l,g=r+c,_=r-c,v=i+s,y=i-s,b=a+o,x=a-o,S=m+b,C=m-b,w=g+v,T=g-v;e[f]=S+w,e[f+4]=S-w;var E=.707106781*(T+C);e[f+2]=C+E,e[f+6]=C-E;var D=.382683433*((S=x+y)-(T=_+h)),O=.5411961*S+D,k=1.306562965*T+D,A=.707106781*(w=y+_),j=h+A,M=h-A;e[f+5]=M+O,e[f+3]=M-O,e[f+1]=j+k,e[f+7]=j-k,f+=8}for(f=0,u=0;u<8;++u){n=e[f],r=e[f+8],i=e[f+16],a=e[f+24],o=e[f+32],s=e[f+40],c=e[f+48];var N=n+(l=e[f+56]),P=n-l,F=r+c,I=r-c,L=i+s,ee=i-s,R=a+o,te=a-o,z=N+R,B=N-R,V=F+L,ne=F-L;e[f]=z+V,e[f+32]=z-V;var re=.707106781*(ne+B);e[f+16]=B+re,e[f+48]=B-re;var ie=.382683433*((z=te+ee)-(ne=I+P)),ae=.5411961*z+ie,oe=1.306562965*ne+ie,se=.707106781*(V=ee+I),ce=P+se,H=P-se;e[f+40]=H+ae,e[f+24]=H-ae,e[f+8]=ce+oe,e[f+56]=ce-oe,f++}for(u=0;u<64;++u)d=e[u]*t[u],p[u]=d>0?d+.5|0:d-.5|0;return p}(e,t),l=0;l<64;++l)m[C[l]]=c[l];var u=m[0]-n;n=m[0],u==0?N(r[0]):(N(r[f[a=32767+u]]),N(d[a]));for(var h=63;h>0&&m[h]==0;)h--;if(h==0)return N(o),n;for(var g,_=1;_<=h;){for(var v=_;m[_]==0&&_<=h;)++_;var y=_-v;if(y>=16){g=y>>4;for(var b=1;b<=g;++b)N(s);y&=15}a=32767+m[_],N(i[(y<<4)+f[a]]),N(d[a]),_++}return h!=63&&N(o),n}function L(e){e=Math.min(Math.max(e,1),100),a!=e&&(function(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],n=0;n<64;n++){var r=o((t[n]*e+50)/100);r=Math.min(Math.max(r,1),255),s[C[n]]=r}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;a<64;a++){var d=o((i[a]*e+50)/100);d=Math.min(Math.max(d,1),255),c[C[a]]=d}for(var f=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],p=0,m=0;m<8;m++)for(var h=0;h<8;h++)l[p]=1/(s[C[p]]*f[m]*f[h]*8),u[p]=1/(c[C[p]]*f[m]*f[h]*8),p++}(Math.floor(e<50?5e3/e:200-2*e)),a=e)}this.encode=function(e,a){a&&L(a),h=[],g=0,_=7,F(65496),F(65504),F(16),P(74),P(70),P(73),P(70),P(0),P(1),P(1),P(0),F(1),F(1),P(0),P(0),function(){F(65499),F(132),P(0);for(var e=0;e<64;e++)P(s[e]);P(1);for(var t=0;t<64;t++)P(c[t])}(),function(e,t){F(65472),F(17),P(8),F(t),F(e),P(3),P(1),P(17),P(0),P(2),P(17),P(1),P(3),P(17),P(1)}(e.width,e.height),function(){F(65476),F(418),P(0);for(var e=0;e<16;e++)P(w[e+1]);for(var t=0;t<=11;t++)P(T[t]);P(16);for(var n=0;n<16;n++)P(E[n+1]);for(var r=0;r<=161;r++)P(D[r]);P(1);for(var i=0;i<16;i++)P(O[i+1]);for(var a=0;a<=11;a++)P(k[a]);P(17);for(var o=0;o<16;o++)P(A[o+1]);for(var s=0;s<=161;s++)P(j[s])}(),F(65498),F(12),P(3),P(1),P(0),P(2),P(17),P(3),P(17),P(0),P(63),P(0);var o=0,d=0,f=0;g=0,_=7,this.encode.displayName=`_encode_`;for(var p,m,x,C,M,ee,R,te,z,B=e.data,V=e.width,ne=e.height,re=4*V,ie=0;ie<ne;){for(p=0;p<re;){for(M=re*ie+p,R=-1,te=0,z=0;z<64;z++)ee=M+(te=z>>3)*re+(R=4*(7&z)),ie+te>=ne&&(ee-=re*(ie+1+te-ne)),p+R>=re&&(ee-=p+R-re+4),m=B[ee++],x=B[ee++],C=B[ee++],v[z]=(S[m]+S[x+256|0]+S[C+512|0]>>16)-128,y[z]=(S[m+768|0]+S[x+1024|0]+S[C+1280|0]>>16)-128,b[z]=(S[m+1280|0]+S[x+1536|0]+S[C+1792|0]>>16)-128;o=I(v,l,o,t,r),d=I(y,u,d,n,i),f=I(b,u,f,n,i),p+=32}ie+=8}if(_>=0){var ae=[];ae[1]=_+1,ae[0]=(1<<_+1)-1,N(ae)}return F(65497),new Uint8Array(h)},e||=50,function(){for(var e=String.fromCharCode,t=0;t<256;t++)x[t]=e(t)}(),t=M(w,T),n=M(O,k),r=M(E,D),i=M(A,j),function(){for(var e=1,t=2,n=1;n<=15;n++){for(var r=e;r<t;r++)f[32767+r]=n,d[32767+r]=[],d[32767+r][1]=n,d[32767+r][0]=r;for(var i=-(t-1);i<=-e;i++)f[32767+i]=n,d[32767+i]=[],d[32767+i][1]=n,d[32767+i][0]=t-1+i;e<<=1,t<<=1}}(),function(){for(var e=0;e<256;e++)S[e]=19595*e,S[e+256|0]=38470*e,S[e+512|0]=7471*e+32768,S[e+768|0]=-11059*e,S[e+1024|0]=-21709*e,S[e+1280|0]=32768*e+8421375,S[e+1536|0]=-27439*e,S[e+1792|0]=-5329*e}(),L(e)}function QF(e,t){if(this.pos=0,this.buffer=e,this.datav=new DataView(e.buffer),this.is_with_alpha=!!t,this.bottom_up=!0,this.flag=String.fromCharCode(this.buffer[0])+String.fromCharCode(this.buffer[1]),this.pos+=2,[`BM`,`BA`,`CI`,`CP`,`IC`,`PT`].indexOf(this.flag)===-1)throw Error(`Invalid BMP File`);this.parseHeader(),this.parseBGR()}function $F(e){function t(e){if(!e)throw Error(`assert :P`)}function n(e,t,n){for(var r=0;4>r;r++)if(e[t+r]!=n.charCodeAt(r))return!0;return!1}function r(e,t,n,r,i){for(var a=0;a<i;a++)e[t+a]=n[r+a]}function i(e,t,n,r){for(var i=0;i<r;i++)e[t+i]=n}function a(e){return new Int32Array(e)}function o(e,t){for(var n=[],r=0;r<e;r++)n.push(new t);return n}function s(e,t){var n=[];return function e(n,r,i){for(var a=i[r],o=0;o<a&&(n.push(i.length>r+1?[]:new t),!(i.length<r+1));o++)e(n[o],r+1,i)}(n,0,e),n}var c=function(){var e=this;function c(e,t){for(var n=1<<t-1>>>0;e&n;)n>>>=1;return n?(e&n-1)+n:e}function l(e,n,r,i,a){t(!(i%r));do e[n+(i-=r)]=a;while(0<i)}function u(e,n,r,i,o){if(t(2328>=o),512>=o)var s=a(512);else if((s=a(o))==null)return 0;return function(e,n,r,i,o,s){var u,f,p=n,m=1<<r,h=a(16),g=a(16);for(t(o!=0),t(i!=null),t(e!=null),t(0<r),f=0;f<o;++f){if(15<i[f])return 0;++h[i[f]]}if(h[0]==o)return 0;for(g[1]=0,u=1;15>u;++u){if(h[u]>1<<u)return 0;g[u+1]=g[u]+h[u]}for(f=0;f<o;++f)u=i[f],0<i[f]&&(s[g[u]++]=f);if(g[15]==1)return(i=new d).g=0,i.value=s[0],l(e,p,1,m,i),m;var _,v=-1,y=m-1,b=0,x=1,S=1,C=1<<r;for(f=0,u=1,o=2;u<=r;++u,o<<=1){if(x+=S<<=1,0>(S-=h[u]))return 0;for(;0<h[u];--h[u])(i=new d).g=u,i.value=s[f++],l(e,p+b,o,C,i),b=c(b,u)}for(u=r+1,o=2;15>=u;++u,o<<=1){if(x+=S<<=1,0>(S-=h[u]))return 0;for(;0<h[u];--h[u]){if(i=new d,(b&y)!=v){for(p+=C,_=1<<(v=u)-r;15>v&&!(0>=(_-=h[v]));)++v,_<<=1;m+=C=1<<(_=v-r),e[n+(v=b&y)].g=_+r,e[n+v].value=p-n-v}i.g=u-r,i.value=s[f++],l(e,p+(b>>r),o,C,i),b=c(b,u)}}return x==2*g[15]-1?m:0}(e,n,r,i,o,s)}function d(){this.value=this.g=0}function f(){this.value=this.g=0}function p(){this.G=o(5,d),this.H=a(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=o(Wn,f)}function m(e,n,r,i){t(e!=null),t(n!=null),t(2147483648>i),e.Ca=254,e.I=0,e.b=-8,e.Ka=0,e.oa=n,e.pa=r,e.Jd=n,e.Yc=r+i,e.Zc=4<=i?r+i-4+1:r,E(e)}function h(e,t){for(var n=0;0<t--;)n|=O(e,128)<<t;return n}function g(e,t){var n=h(e,t);return D(e)?-n:n}function _(e,n,r,i){var a,o=0;for(t(e!=null),t(n!=null),t(4294967288>i),e.Sb=i,e.Ra=0,e.u=0,e.h=0,4<i&&(i=4),a=0;a<i;++a)o+=n[r+a]<<8*a;e.Ra=o,e.bb=i,e.oa=n,e.pa=r}function v(e){for(;8<=e.u&&e.bb<e.Sb;)e.Ra>>>=8,e.Ra+=e.oa[e.pa+e.bb]<<qn-8>>>0,++e.bb,e.u-=8;C(e)&&(e.h=1,e.u=0)}function y(e,n){if(t(0<=n),!e.h&&n<=Kn){var r=S(e)&Gn[n];return e.u+=n,v(e),r}return e.h=1,e.u=0}function b(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function x(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function S(e){return e.Ra>>>(e.u&qn-1)>>>0}function C(e){return t(e.bb<=e.Sb),e.h||e.bb==e.Sb&&e.u>qn}function w(e,t){e.u=t,e.h=C(e)}function T(e){e.u>=Jn&&(t(e.u>=Jn),v(e))}function E(e){t(e!=null&&e.oa!=null),e.pa<e.Zc?(e.I=(e.oa[e.pa++]|e.I<<8)>>>0,e.b+=8):(t(e!=null&&e.oa!=null),e.pa<e.Yc?(e.b+=8,e.I=e.oa[e.pa++]|e.I<<8):e.Ka?e.b=0:(e.I<<=8,e.b+=8,e.Ka=1))}function D(e){return h(e,1)}function O(e,t){var n=e.Ca;0>e.b&&E(e);var r=e.b,i=n*t>>>8,a=(e.I>>>r>i)+0;for(a?(n-=i,e.I-=i+1<<r>>>0):n=i+1,r=n,i=0;256<=r;)i+=8,r>>=8;return r=7^i+Yn[r],e.b-=r,e.Ca=(n<<r)-1,a}function k(e,t,n){e[t+0]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n}function A(e,t){return e[t+0]|e[t+1]<<8}function j(e,t){return A(e,t)|e[t+2]<<16}function M(e,t){return A(e,t)|A(e,t+2)<<16}function N(e,n){var r=1<<n;return t(e!=null),t(0<n),e.X=a(r),e.X==null?0:(e.Mb=32-n,e.Xa=n,1)}function P(e,n){t(e!=null),t(n!=null),t(e.Xa==n.Xa),r(n.X,0,e.X,0,1<<n.Xa)}function F(){this.X=[],this.Xa=this.Mb=0}function I(e,n,r,i){t(r!=null),t(i!=null);var a=r[0],o=i[0];return a==0&&(a=(e*o+n/2)/n),o==0&&(o=(n*a+e/2)/e),0>=a||0>=o?0:(r[0]=a,i[0]=o,1)}function L(e,t){return e+(1<<t)-1>>>t}function ee(e,t){return((4278255360&e)+(4278255360&t)>>>0&4278255360)+((16711935&e)+(16711935&t)>>>0&16711935)>>>0}function R(t,n){e[n]=function(n,r,i,a,o,s,c){var l;for(l=0;l<o;++l){var u=e[t](s[c+l-1],i,a+l);s[c+l]=ee(n[r+l],u)}}}function te(){this.ud=this.hd=this.jd=0}function z(e,t){return((4278124286&(e^t))>>>1)+(e&t)>>>0}function B(e){return 0<=e&&256>e?e:0>e?0:255<e?255:void 0}function V(e,t){return B(e+(e-t+.5>>1))}function ne(e,t,n){return Math.abs(t-n)-Math.abs(e-n)}function re(e,t,n,r,i,a,o){for(r=a[o-1],n=0;n<i;++n)a[o+n]=r=ee(e[t+n],r)}function ie(e,t,n,r,i){var a;for(a=0;a<n;++a){var o=e[t+a],s=o>>8&255,c=16711935&(c=(c=16711935&o)+((s<<16)+s));r[i+a]=(4278255360&o)+c>>>0}}function ae(e,t){t.jd=255&e,t.hd=e>>8&255,t.ud=e>>16&255}function oe(e,t,n,r,i,a){var o;for(o=0;o<r;++o){var s=t[n+o],c=s>>>8,l=s,u=255&(u=(u=s>>>16)+((e.jd<<24>>24)*(c<<24>>24)>>>5));l=255&(l=(l+=(e.hd<<24>>24)*(c<<24>>24)>>>5)+((e.ud<<24>>24)*(u<<24>>24)>>>5)),i[a+o]=(4278255360&s)+(u<<16)+l}}function se(t,n,r,i,a){e[n]=function(e,t,n,r,o,s,c,l,u){for(r=c;r<l;++r)for(c=0;c<u;++c)o[s++]=a(n[i(e[t++])])},e[t]=function(t,n,o,s,c,l,u){var d=8>>t.b,f=t.Ea,p=t.K[0],m=t.w;if(8>d)for(t=(1<<t.b)-1,m=(1<<d)-1;n<o;++n){var h,g=0;for(h=0;h<f;++h)h&t||(g=i(s[c++])),l[u++]=a(p[g&m]),g>>=d}else e[`VP8LMapColor`+r](s,c,p,m,l,u,n,o,f)}}function ce(e,t,n,r,i){for(n=t+n;t<n;){var a=e[t++];r[i++]=a>>16&255,r[i++]=a>>8&255,r[i++]=255&a}}function H(e,t,n,r,i){for(n=t+n;t<n;){var a=e[t++];r[i++]=a>>16&255,r[i++]=a>>8&255,r[i++]=255&a,r[i++]=a>>24&255}}function le(e,t,n,r,i){for(n=t+n;t<n;){var a=(o=e[t++])>>16&240|o>>12&15,o=240&o|o>>28&15;r[i++]=a,r[i++]=o}}function ue(e,t,n,r,i){for(n=t+n;t<n;){var a=(o=e[t++])>>16&248|o>>13&7,o=o>>5&224|o>>3&31;r[i++]=a,r[i++]=o}}function de(e,t,n,r,i){for(n=t+n;t<n;){var a=e[t++];r[i++]=255&a,r[i++]=a>>8&255,r[i++]=a>>16&255}}function fe(e,t,n,i,a,o){if(o==0)for(n=t+n;t<n;)k(i,((o=e[t++])[0]>>24|o[1]>>8&65280|o[2]<<8&16711680|o[3]<<24)>>>0),a+=32;else r(i,a,e,t,n)}function pe(t,n){e[n][0]=e[t+`0`],e[n][1]=e[t+`1`],e[n][2]=e[t+`2`],e[n][3]=e[t+`3`],e[n][4]=e[t+`4`],e[n][5]=e[t+`5`],e[n][6]=e[t+`6`],e[n][7]=e[t+`7`],e[n][8]=e[t+`8`],e[n][9]=e[t+`9`],e[n][10]=e[t+`10`],e[n][11]=e[t+`11`],e[n][12]=e[t+`12`],e[n][13]=e[t+`13`],e[n][14]=e[t+`0`],e[n][15]=e[t+`0`]}function me(e){return e==Kr||e==qr||e==Jr||e==Yr}function he(){this.eb=[],this.size=this.A=this.fb=0}function ge(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function _e(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new he,this.f.kb=new ge,this.sd=null}function ve(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function ye(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function be(e){return alert(`todo:WebPSamplerProcessPlane`),e.T}function xe(e,t){var n=e.T,i=t.ba.f.RGBA,a=i.eb,o=i.fb+e.ka*i.A,s=bi[t.ba.S],c=e.y,l=e.O,u=e.f,d=e.N,f=e.ea,p=e.W,m=t.cc,h=t.dc,g=t.Mc,_=t.Nc,v=e.ka,y=e.ka+e.T,b=e.U,x=b+1>>1;for(v==0?s(c,l,null,null,u,d,f,p,u,d,f,p,a,o,null,null,b):(s(t.ec,t.fc,c,l,m,h,g,_,u,d,f,p,a,o-i.A,a,o,b),++n);v+2<y;v+=2)m=u,h=d,g=f,_=p,d+=e.Rc,p+=e.Rc,o+=2*i.A,s(c,(l+=2*e.fa)-e.fa,c,l,m,h,g,_,u,d,f,p,a,o-i.A,a,o,b);return l+=e.fa,e.j+y<e.o?(r(t.ec,t.fc,c,l,b),r(t.cc,t.dc,u,d,x),r(t.Mc,t.Nc,f,p,x),n--):1&y||s(c,l,null,null,u,d,f,p,u,d,f,p,a,o+i.A,null,null,b),n}function Se(e,n,r){var i=e.F,a=[e.J];if(i!=null){var o=e.U,s=n.ba.S,c=s==Ur||s==Jr;n=n.ba.f.RGBA;var l=[0],u=e.ka;l[0]=e.T,e.Kb&&(u==0?--l[0]:(--u,a[0]-=e.width),e.j+e.ka+e.T==e.o&&(l[0]=e.o-e.j-u));var d=n.eb;u=n.fb+u*n.A,e=kr(i,a[0],e.width,o,l,d,u+(c?0:3),n.A),t(r==l),e&&me(s)&&Dr(d,u,c,o,l,n.A)}return 0}function U(e){var t=e.ma,n=t.ba.S,r=11>n,i=n==Br||n==Hr||n==Ur||n==Wr||n==12||me(n);if(t.memory=null,t.Ib=null,t.Jb=null,t.Nd=null,!Vn(t.Oa,e,i?11:12))return 0;if(i&&me(n)&&En(),e.da)alert(`todo:use_scaling`);else{if(r){if(t.Ib=be,e.Kb){if(n=e.U+1>>1,t.memory=a(e.U+2*n),t.memory==null)return 0;t.ec=t.memory,t.fc=0,t.cc=t.ec,t.dc=t.fc+e.U,t.Mc=t.cc,t.Nc=t.dc+n,t.Ib=xe,En()}}else alert(`todo:EmitYUV`);i&&(t.Jb=Se,r&&wn())}if(r&&!Pi){for(e=0;256>e;++e)Fi[e]=89858*(e-128)+ki>>Oi,Ri[e]=-22014*(e-128)+ki,Li[e]=-45773*(e-128),Ii[e]=113618*(e-128)+ki>>Oi;for(e=Ai;e<ji;++e)t=76283*(e-16)+ki>>Oi,zi[e-Ai]=et(t,255),Bi[e-Ai]=et(t+8>>4,15);Pi=1}return 1}function Ce(e){var n=e.ma,r=e.U,i=e.T;return t(!(1&e.ka)),0>=r||0>=i?0:(r=n.Ib(e,n),n.Jb!=null&&n.Jb(e,n,r),n.Dc+=r,1)}function we(e){e.ma.memory=null}function Te(e,t,n,r){return y(e,8)==47?(t[0]=y(e,14)+1,n[0]=y(e,14)+1,r[0]=y(e,1),y(e,3)==0?!e.h:0):0}function W(e,t){if(4>e)return e+1;var n=e-2>>1;return(2+(1&e)<<n)+y(t,n)+1}function Ee(e,t){return 120<t?t-120:1<=(n=((n=ti[t-1])>>4)*e+(8-(15&n)))?n:1;var n}function De(e,t,n){var r=S(n),i=e[t+=255&r].g-8;return 0<i&&(w(n,n.u+8),r=S(n),t+=e[t].value,t+=r&(1<<i)-1),w(n,n.u+e[t].g),e[t].value}function Oe(e,n,r){return r.g+=e.g,r.value+=e.value<<n>>>0,t(8>=r.g),e.g}function ke(e,n,r){var i=e.xc;return t((n=i==0?0:e.vc[e.md*(r>>i)+(n>>i)])<e.Wb),e.Ya[n]}function Ae(e,n,i,a){var o=e.ab,s=e.c*n,c=e.C;n=c+n;var l=i,u=a;for(a=e.Ta,i=e.Ua;0<o--;){var d=e.gc[o],f=c,p=n,m=l,h=u,g=(u=a,l=i,d.Ea);switch(t(f<p),t(p<=d.nc),d.hc){case 2:Qn(m,h,(p-f)*g,u,l);break;case 0:var _=f,v=p,y=u,b=l,x=(E=d).Ea;_==0&&(Xn(m,h,null,null,1,y,b),re(m,h+1,0,0,x-1,y,b+1),h+=x,b+=x,++_);for(var S=1<<E.b,C=S-1,w=L(x,E.b),T=E.K,E=E.w+(_>>E.b)*w;_<v;){var D=T,O=E,k=1;for(Zn(m,h,y,b-x,1,y,b);k<x;){var A=(k&~C)+S;A>x&&(A=x),(0,rr[D[O++]>>8&15])(m,h+ +k,y,b+k-x,A-k,y,b+k),k=A}h+=x,b+=x,++_&C||(E+=w)}p!=d.nc&&r(u,l-g,u,l+(p-f-1)*g,g);break;case 1:for(g=m,v=h,x=(m=d.Ea)-(b=m&~(y=(h=1<<d.b)-1)),_=L(m,d.b),S=d.K,d=d.w+(f>>d.b)*_;f<p;){for(C=S,w=d,T=new te,E=v+b,D=v+m;v<E;)ae(C[w++],T),J(T,g,v,h,u,l),v+=h,l+=h;v<D&&(ae(C[w++],T),J(T,g,v,x,u,l),v+=x,l+=x),++f&y||(d+=_)}break;case 3:if(m==u&&h==l&&0<d.b){for(v=u,m=g=l+(p-f)*g-(b=(p-f)*L(d.Ea,d.b)),h=u,y=l,_=[],b=(x=b)-1;0<=b;--b)_[b]=h[y+b];for(b=x-1;0<=b;--b)v[m+b]=_[b];$n(d,f,p,u,g,u,l)}else $n(d,f,p,m,h,u,l)}l=a,u=i}u!=i&&r(a,i,l,u,s)}function je(e,n){var r=e.V,i=e.Ba+e.c*e.C,a=n-e.C;if(t(n<=e.l.o),t(16>=a),0<a){var o=e.l,s=e.Ta,c=e.Ua,l=o.width;if(Ae(e,a,r,i),a=c=[c],t((r=e.C)<(i=n)),t(o.v<o.va),i>o.o&&(i=o.o),r<o.j){var u=o.j-r;r=o.j,a[0]+=u*l}if(r>=i?r=0:(a[0]+=4*o.v,o.ka=r-o.j,o.U=o.va-o.v,o.T=i-r,r=1),r){if(c=c[0],11>(r=e.ca).S){var d=r.f.RGBA,f=(i=r.S,a=o.U,o=o.T,u=d.eb,d.A),p=o;for(d=d.fb+e.Ma*d.A;0<p--;){var m=s,h=c,g=a,_=u,v=d;switch(i){case zr:ir(m,h,g,_,v);break;case Br:ar(m,h,g,_,v);break;case Kr:ar(m,h,g,_,v),Dr(_,v,0,g,1,0);break;case Vr:cr(m,h,g,_,v);break;case Hr:fe(m,h,g,_,v,1);break;case qr:fe(m,h,g,_,v,1),Dr(_,v,0,g,1,0);break;case Ur:fe(m,h,g,_,v,0);break;case Jr:fe(m,h,g,_,v,0),Dr(_,v,1,g,1,0);break;case Wr:or(m,h,g,_,v);break;case Yr:or(m,h,g,_,v),Or(_,v,g,1,0);break;case Gr:sr(m,h,g,_,v);break;default:t(0)}c+=l,d+=f}e.Ma+=o}else alert(`todo:EmitRescaledRowsYUVA`);t(e.Ma<=r.height)}}e.C=n,t(e.C<=e.i)}function Me(e){var t;if(0<e.ua)return 0;for(t=0;t<e.Wb;++t){var n=e.Ya[t].G,r=e.Ya[t].H;if(0<n[1][r[1]+0].g||0<n[2][r[2]+0].g||0<n[3][r[3]+0].g)return 0}return 1}function Ne(e,n,r,i,a,o){if(e.Z!=0){var s=e.qd,c=e.rd;for(t(yi[e.Z]!=null);n<r;++n)yi[e.Z](s,c,i,a,i,a,o),s=i,c=a,a+=o;e.qd=s,e.rd=c}}function Pe(e,n){var r=e.l.ma,i=r.Z==0||r.Z==1?e.l.j:e.C;if(i=e.C<i?i:e.C,t(n<=e.l.o),n>i){var a=e.l.width,o=r.ca,s=r.tb+a*i,c=e.V,l=e.Ba+e.c*i,u=e.gc;t(e.ab==1),t(u[0].hc==3),tr(u[0],i,n,c,l,o,s),Ne(r,i,n,o,s,a)}e.C=e.Ma=n}function Fe(e,n,r,i,a,o,s){var c=e.$/i,l=e.$%i,u=e.m,d=e.s,f=r+e.$,p=f;a=r+i*a;var m=r+i*o,h=280+d.ua,g=e.Pb?c:16777216,_=0<d.ua?d.Wa:null,v=d.wc,y=f<m?ke(d,l,c):null;t(e.C<o),t(m<=a);var b=!1;t:for(;;){for(;b||f<m;){var x=0;if(c>=g){var E=f-r;t((g=e).Pb),g.wd=g.m,g.xd=E,0<g.s.ua&&P(g.s.Wa,g.s.vb),g=c+ri}if(l&v||(y=ke(d,l,c)),t(y!=null),y.Qb&&(n[f]=y.qb,b=!0),!b)if(T(u),y.jc){x=u,E=n;var D=f,O=y.pd[S(x)&Wn-1];t(y.jc),256>O.g?(w(x,x.u+O.g),E[D]=O.value,x=0):(w(x,x.u+O.g-256),t(256<=O.value),x=O.value),x==0&&(b=!0)}else x=De(y.G[0],y.H[0],u);if(u.h)break;if(b||256>x){if(!b)if(y.nd)n[f]=(y.qb|x<<8)>>>0;else{if(T(u),b=De(y.G[1],y.H[1],u),T(u),E=De(y.G[2],y.H[2],u),D=De(y.G[3],y.H[3],u),u.h)break;n[f]=(D<<24|b<<16|x<<8|E)>>>0}if(b=!1,++f,++l>=i&&(l=0,++c,s!=null&&c<=o&&!(c%16)&&s(e,c),_!=null))for(;p<f;)x=n[p++],_.X[(506832829*x&4294967295)>>>_.Mb]=x}else if(280>x){if(x=W(x-256,u),E=De(y.G[4],y.H[4],u),T(u),E=Ee(i,E=W(E,u)),u.h)break;if(f-r<E||a-f<x)break t;for(D=0;D<x;++D)n[f+D]=n[f+D-E];for(f+=x,l+=x;l>=i;)l-=i,++c,s!=null&&c<=o&&!(c%16)&&s(e,c);if(t(f<=a),l&v&&(y=ke(d,l,c)),_!=null)for(;p<f;)x=n[p++],_.X[(506832829*x&4294967295)>>>_.Mb]=x}else{if(!(x<h))break t;for(b=x-280,t(_!=null);p<f;)x=n[p++],_.X[(506832829*x&4294967295)>>>_.Mb]=x;x=f,t(!(b>>>(E=_).Xa)),n[x]=E.X[b],b=!0}b||t(u.h==C(u))}if(e.Pb&&u.h&&f<a)t(e.m.h),e.a=5,e.m=e.wd,e.$=e.xd,0<e.s.ua&&P(e.s.vb,e.s.Wa);else{if(u.h)break t;s?.(e,c>o?o:c),e.a=0,e.$=f-r}return 1}return e.a=3,0}function Ie(e){t(e!=null),e.vc=null,e.yc=null,e.Ya=null;var n=e.Wa;n!=null&&(n.X=null),e.vb=null,t(e!=null)}function Le(){var t=new mn;return t==null?null:(t.a=0,t.xb=vi,pe(`Predictor`,`VP8LPredictors`),pe(`Predictor`,`VP8LPredictors_C`),pe(`PredictorAdd`,`VP8LPredictorsAdd`),pe(`PredictorAdd`,`VP8LPredictorsAdd_C`),Qn=ie,J=oe,ir=ce,ar=H,or=le,sr=ue,cr=de,e.VP8LMapColor32b=er,e.VP8LMapColor8b=nr,t)}function Re(e,n,r,s,c){var l=1,f=[e],m=[n],h=s.m,g=s.s,_=null,v=0;t:for(;;){if(r)for(;l&&y(h,1);){var b=f,x=m,C=s,E=1,D=C.m,O=C.gc[C.ab],k=y(D,2);if(C.Oc&1<<k)l=0;else{switch(C.Oc|=1<<k,O.hc=k,O.Ea=b[0],O.nc=x[0],O.K=[null],++C.ab,t(4>=C.ab),k){case 0:case 1:O.b=y(D,3)+2,E=Re(L(O.Ea,O.b),L(O.nc,O.b),0,C,O.K),O.K=O.K[0];break;case 3:var A,j=y(D,8)+1,M=16<j?0:4<j?1:2<j?2:3;if(b[0]=L(O.Ea,M),O.b=M,A=E=Re(j,1,0,C,O.K)){var P,F=j,I=O,R=1<<(8>>I.b),te=a(R);if(te==null)A=0;else{var z=I.K[0],B=I.w;for(te[0]=I.K[0][0],P=1;P<1*F;++P)te[P]=ee(z[B+P],te[P-1]);for(;P<4*R;++P)te[P]=0;I.K[0]=null,I.K[0]=te,A=1}}E=A;break;case 2:break;default:t(0)}l=E}}if(f=f[0],m=m[0],l&&y(h,1)&&!(l=1<=(v=y(h,4))&&11>=v)){s.a=3;break t}var V;if(V=l)e:{var ne,re,ie,ae=s,oe=f,se=m,ce=v,H=r,le=ae.m,ue=ae.s,de=[null],fe=1,pe=0,me=ni[ce];r:for(;;){if(H&&y(le,1)){var he=y(le,3)+2,ge=L(oe,he),_e=L(se,he),ve=ge*_e;if(!Re(ge,_e,0,ae,de))break r;for(de=de[0],ue.xc=he,ne=0;ne<ve;++ne){var ye=de[ne]>>8&65535;de[ne]=ye,ye>=fe&&(fe=ye+1)}}if(le.h)break r;for(re=0;5>re;++re){var be=Qr[re];!re&&0<ce&&(be+=1<<ce),pe<be&&(pe=be)}var xe=o(fe*me,d),Se=fe,U=o(Se,p);if(U==null)var Ce=null;else t(65536>=Se),Ce=U;var we=a(pe);if(Ce==null||we==null||xe==null){ae.a=1;break r}var Te=xe;for(ne=ie=0;ne<fe;++ne){var W=Ce[ne],Ee=W.G,De=W.H,ke=0,Ae=1,je=0;for(re=0;5>re;++re){be=Qr[re],Ee[re]=Te,De[re]=ie,!re&&0<ce&&(be+=1<<ce);n:{var Me,Ne=be,Pe=ae,Le=we,ze=Te,Be=ie,Ve=0,He=Pe.m,Ue=y(He,1);if(i(Le,0,0,Ne),Ue){var We=y(He,1)+1,Ge=y(He,y(He,1)==0?1:8);Le[Ge]=1,We==2&&(Le[Ge=y(He,8)]=1);var Ke=1}else{var qe=a(19),Je=y(He,4)+4;if(19<Je){Pe.a=3;var Ye=0;break n}for(Me=0;Me<Je;++Me)qe[ei[Me]]=y(He,3);var Xe=void 0,Ze=void 0,Qe=Pe,$e=qe,et=Ne,tt=Le,nt=0,rt=Qe.m,it=8,at=o(128,d);i:for(;u(at,0,7,$e,19);){if(y(rt,1)){if((Xe=2+y(rt,2+2*y(rt,3)))>et)break i}else Xe=et;for(Ze=0;Ze<et&&Xe--;){T(rt);var ot=at[0+(127&S(rt))];w(rt,rt.u+ot.g);var st=ot.value;if(16>st)tt[Ze++]=st,st!=0&&(it=st);else{var ct=st==16,lt=st-16,ut=Zr[lt],dt=y(rt,Xr[lt])+ut;if(Ze+dt>et)break i;for(var ft=ct?it:0;0<dt--;)tt[Ze++]=ft}}nt=1;break i}nt||(Qe.a=3),Ke=nt}(Ke&&=!He.h)&&(Ve=u(ze,Be,8,Le,Ne)),Ke&&Ve!=0?Ye=Ve:(Pe.a=3,Ye=0)}if(Ye==0)break r;if(Ae&&$r[re]==1&&(Ae=Te[ie].g==0),ke+=Te[ie].g,ie+=Ye,3>=re){var pt,mt=we[0];for(pt=1;pt<be;++pt)we[pt]>mt&&(mt=we[pt]);je+=mt}}if(W.nd=Ae,W.Qb=0,Ae&&(W.qb=(Ee[3][De[3]+0].value<<24|Ee[1][De[1]+0].value<<16|Ee[2][De[2]+0].value)>>>0,ke==0&&256>Ee[0][De[0]+0].value&&(W.Qb=1,W.qb+=Ee[0][De[0]+0].value<<8)),W.jc=!W.Qb&&6>je,W.jc){var ht,gt=W;for(ht=0;ht<Wn;++ht){var _t=ht,vt=gt.pd[_t],yt=gt.G[0][gt.H[0]+_t];256<=yt.value?(vt.g=yt.g+256,vt.value=yt.value):(vt.g=0,vt.value=0,_t>>=Oe(yt,8,vt),_t>>=Oe(gt.G[1][gt.H[1]+_t],16,vt),_t>>=Oe(gt.G[2][gt.H[2]+_t],0,vt),Oe(gt.G[3][gt.H[3]+_t],24,vt))}}}ue.vc=de,ue.Wb=fe,ue.Ya=Ce,ue.yc=xe,V=1;break e}V=0}if(!(l=V)){s.a=3;break t}if(0<v){if(g.ua=1<<v,!N(g.Wa,v)){s.a=1,l=0;break t}}else g.ua=0;var bt=s,xt=f,St=m,Ct=bt.s,wt=Ct.xc;if(bt.c=xt,bt.i=St,Ct.md=L(xt,wt),Ct.wc=wt==0?-1:(1<<wt)-1,r){s.xb=_i;break t}if((_=a(f*m))==null){s.a=1,l=0;break t}l=(l=Fe(s,_,0,f,m,m,null))&&!h.h;break t}return l?(c==null?(t(_==null),t(r)):c[0]=_,s.$=0,r||Ie(g)):Ie(g),l}function ze(e,n){var r=e.c*e.i,i=r+n+16*n;return t(e.c<=n),e.V=a(i),e.V==null?(e.Ta=null,e.Ua=0,e.a=1,0):(e.Ta=e.V,e.Ua=e.Ba+r+n,1)}function Be(e,n){var r=e.C,i=n-r,a=e.V,o=e.Ba+e.c*r;for(t(n<=e.l.o);0<i;){var s=16<i?16:i,c=e.l.ma,l=e.l.width,u=l*s,d=c.ca,f=c.tb+l*r,p=e.Ta,m=e.Ua;Ae(e,s,a,o),Ar(p,m,d,f,u),Ne(c,r,r+s,d,f,l),i-=s,a+=s*e.c,r+=s}t(r==n),e.C=e.Ma=n}function Ve(){this.ub=this.yd=this.td=this.Rb=0}function He(){this.Kd=this.Ld=this.Ud=this.Td=this.i=this.c=0}function Ue(){this.Fb=this.Bb=this.Cb=0,this.Zb=a(4),this.Lb=a(4)}function We(){this.Yb=function(){var e=[];return function e(t,n,r){for(var i=r[n],a=0;a<i&&(t.push(r.length>n+1?[]:0),!(r.length<n+1));a++)e(t[a],n+1,r)}(e,0,[3,11]),e}()}function Ge(){this.jb=a(3),this.Wc=s([4,8],We),this.Xc=s([4,17],We)}function Ke(){this.Pc=this.wb=this.Tb=this.zd=0,this.vd=new a(4),this.od=new a(4)}function qe(){this.ld=this.La=this.dd=this.tc=0}function Je(){this.Na=this.la=0}function Ye(){this.Sc=[0,0],this.Eb=[0,0],this.Qc=[0,0],this.ia=this.lc=0}function Xe(){this.ad=a(384),this.Za=0,this.Ob=a(16),this.$b=this.Ad=this.ia=this.Gc=this.Hc=this.Dd=0}function Ze(){this.uc=this.M=this.Nb=0,this.wa=Array(new qe),this.Y=0,this.ya=Array(new Xe),this.aa=0,this.l=new tt}function Qe(){this.y=a(16),this.f=a(8),this.ea=a(8)}function $e(){this.cb=this.a=0,this.sc=``,this.m=new b,this.Od=new Ve,this.Kc=new He,this.ed=new Ke,this.Qa=new Ue,this.Ic=this.$c=this.Aa=0,this.D=new Ze,this.Xb=this.Va=this.Hb=this.zb=this.yb=this.Ub=this.za=0,this.Jc=o(8,b),this.ia=0,this.pb=o(4,Ye),this.Pa=new Ge,this.Bd=this.kc=0,this.Ac=[],this.Bc=0,this.zc=[0,0,0,0],this.Gd=Array(new Qe),this.Hd=0,this.rb=Array(new Je),this.sb=0,this.wa=Array(new qe),this.Y=0,this.oc=[],this.pc=0,this.sa=[],this.ta=0,this.qa=[],this.ra=0,this.Ha=[],this.B=this.R=this.Ia=0,this.Ec=[],this.M=this.ja=this.Vb=this.Fc=0,this.ya=Array(new Xe),this.L=this.aa=0,this.gd=s([4,2],qe),this.ga=null,this.Fa=[],this.Cc=this.qc=this.P=0,this.Gb=[],this.Uc=0,this.mb=[],this.nb=0,this.rc=[],this.Ga=this.Vc=0}function et(e,t){return 0>e?0:e>t?t:e}function tt(){this.T=this.U=this.ka=this.height=this.width=0,this.y=[],this.f=[],this.ea=[],this.Rc=this.fa=this.W=this.N=this.O=0,this.ma=`void`,this.put=`VP8IoPutHook`,this.ac=`VP8IoSetupHook`,this.bc=`VP8IoTeardownHook`,this.ha=this.Kb=0,this.data=[],this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0,this.F=[],this.J=0}function nt(){var e=new $e;return e!=null&&(e.a=0,e.sc=`OK`,e.cb=0,e.Xb=0,oi||=ot),e}function rt(e,t,n){return e.a==0&&(e.a=t,e.sc=n,e.cb=0),0}function it(e,t,n){return 3<=n&&e[t+0]==157&&e[t+1]==1&&e[t+2]==42}function at(e,n){if(e==null)return 0;if(e.a=0,e.sc=`OK`,n==null)return rt(e,2,`null VP8Io passed to VP8GetHeaders()`);var r=n.data,a=n.w,o=n.ha;if(4>o)return rt(e,7,`Truncated header.`);var s=r[a+0]|r[a+1]<<8|r[a+2]<<16,c=e.Od;if(c.Rb=!(1&s),c.td=s>>1&7,c.yd=s>>4&1,c.ub=s>>5,3<c.td)return rt(e,3,`Incorrect keyframe parameters.`);if(!c.yd)return rt(e,4,`Frame not displayable.`);a+=3,o-=3;var l=e.Kc;if(c.Rb){if(7>o)return rt(e,7,`cannot parse picture header`);if(!it(r,a,o))return rt(e,3,`Bad code word`);l.c=16383&(r[a+4]<<8|r[a+3]),l.Td=r[a+4]>>6,l.i=16383&(r[a+6]<<8|r[a+5]),l.Ud=r[a+6]>>6,a+=7,o-=7,e.za=l.c+15>>4,e.Ub=l.i+15>>4,n.width=l.c,n.height=l.i,n.Da=0,n.j=0,n.v=0,n.va=n.width,n.o=n.height,n.da=0,n.ib=n.width,n.hb=n.height,n.U=n.width,n.T=n.height,i((s=e.Pa).jb,0,255,s.jb.length),t((s=e.Qa)!=null),s.Cb=0,s.Bb=0,s.Fb=1,i(s.Zb,0,0,s.Zb.length),i(s.Lb,0,0,s.Lb)}if(c.ub>o)return rt(e,7,`bad partition length`);m(s=e.m,r,a,c.ub),a+=c.ub,o-=c.ub,c.Rb&&(l.Ld=D(s),l.Kd=D(s)),l=e.Qa;var u,d=e.Pa;if(t(s!=null),t(l!=null),l.Cb=D(s),l.Cb){if(l.Bb=D(s),D(s)){for(l.Fb=D(s),u=0;4>u;++u)l.Zb[u]=D(s)?g(s,7):0;for(u=0;4>u;++u)l.Lb[u]=D(s)?g(s,6):0}if(l.Bb)for(u=0;3>u;++u)d.jb[u]=D(s)?h(s,8):255}else l.Bb=0;if(s.Ka)return rt(e,3,`cannot parse segment header`);if((l=e.ed).zd=D(s),l.Tb=h(s,6),l.wb=h(s,3),l.Pc=D(s),l.Pc&&D(s)){for(d=0;4>d;++d)D(s)&&(l.vd[d]=g(s,6));for(d=0;4>d;++d)D(s)&&(l.od[d]=g(s,6))}if(e.L=l.Tb==0?0:l.zd?1:2,s.Ka)return rt(e,3,`cannot parse filter header`);var f=o;if(o=u=a,a=u+f,l=f,e.Xb=(1<<h(e.m,2))-1,f<3*(d=e.Xb))r=7;else{for(u+=3*d,l-=3*d,f=0;f<d;++f){var p=r[o+0]|r[o+1]<<8|r[o+2]<<16;p>l&&(p=l),m(e.Jc[+f],r,u,p),u+=p,l-=p,o+=3}m(e.Jc[+d],r,u,l),r=u<a?0:5}if(r!=0)return rt(e,r,`cannot parse partitions`);for(r=h(u=e.m,7),o=D(u)?g(u,4):0,a=D(u)?g(u,4):0,l=D(u)?g(u,4):0,d=D(u)?g(u,4):0,u=D(u)?g(u,4):0,f=e.Qa,p=0;4>p;++p){if(f.Cb){var _=f.Zb[p];f.Fb||(_+=r)}else{if(0<p){e.pb[p]=e.pb[0];continue}_=r}var v=e.pb[p];v.Sc[0]=ii[et(_+o,127)],v.Sc[1]=ai[et(_+0,127)],v.Eb[0]=2*ii[et(_+a,127)],v.Eb[1]=101581*ai[et(_+l,127)]>>16,8>v.Eb[1]&&(v.Eb[1]=8),v.Qc[0]=ii[et(_+d,117)],v.Qc[1]=ai[et(_+u,127)],v.lc=_+u}if(!c.Rb)return rt(e,4,`Not a key frame.`);for(D(s),c=e.Pa,r=0;4>r;++r){for(o=0;8>o;++o)for(a=0;3>a;++a)for(l=0;11>l;++l)d=O(s,fi[r][o][a][l])?h(s,8):ui[r][o][a][l],c.Wc[r][o].Yb[a][l]=d;for(o=0;17>o;++o)c.Xc[r][o]=c.Wc[r][pi[o]]}return e.kc=D(s),e.kc&&(e.Bd=h(s,8)),e.cb=1}function ot(e,t,n,r,i,a,o){var s=t[i].Yb[n];for(n=0;16>i;++i){if(!O(e,s[n+0]))return i;for(;!O(e,s[n+1]);)if(s=t[++i].Yb[0],n=0,i==16)return 16;var c=t[i+1].Yb;if(O(e,s[n+2])){var l=e,u=0;if(O(l,(f=s)[(d=n)+3]))if(O(l,f[d+6])){for(s=0,d=2*(u=O(l,f[d+8]))+(f=O(l,f[d+9+u])),u=0,f=si[d];f[s];++s)u+=u+O(l,f[s]);u+=3+(8<<d)}else O(l,f[d+7])?(u=7+2*O(l,165),u+=O(l,145)):u=5+O(l,159);else u=O(l,f[d+4])?3+O(l,f[d+5]):2;s=c[2]}else u=1,s=c[1];c=o+ci[i],0>(l=e).b&&E(l);var d,f=l.b,p=(d=l.Ca>>1)-(l.I>>f)>>31;--l.b,l.Ca+=p,l.Ca|=1,l.I-=(d+1&p)<<f,a[c]=((u^p)-p)*r[(0<i)+0]}return 16}function st(e){var t=e.rb[e.sb-1];t.la=0,t.Na=0,i(e.zc,0,0,e.zc.length),e.ja=0}function ct(e,t,n,r,i){i=e[t+n+32*r]+(i>>3),e[t+n+32*r]=-256&i?0>i?0:255:i}function lt(e,t,n,r,i,a){ct(e,t,0,n,r+i),ct(e,t,1,n,r+a),ct(e,t,2,n,r-a),ct(e,t,3,n,r-i)}function ut(e){return(20091*e>>16)+e}function dt(e,t,n,r){var i,o=0,s=a(16);for(i=0;4>i;++i){var c=e[t+0]+e[t+8],l=e[t+0]-e[t+8],u=(35468*e[t+4]>>16)-ut(e[t+12]),d=ut(e[t+4])+(35468*e[t+12]>>16);s[o+0]=c+d,s[o+1]=l+u,s[o+2]=l-u,s[o+3]=c-d,o+=4,t++}for(i=o=0;4>i;++i)c=(e=s[o+0]+4)+s[o+8],l=e-s[o+8],u=(35468*s[o+4]>>16)-ut(s[o+12]),ct(n,r,0,0,c+(d=ut(s[o+4])+(35468*s[o+12]>>16))),ct(n,r,1,0,l+u),ct(n,r,2,0,l-u),ct(n,r,3,0,c-d),o++,r+=32}function ft(e,t,n,r){var i=e[t+0]+4,a=35468*e[t+4]>>16,o=ut(e[t+4]),s=35468*e[t+1]>>16;lt(n,r,0,i+o,e=ut(e[t+1]),s),lt(n,r,1,i+a,e,s),lt(n,r,2,i-a,e,s),lt(n,r,3,i-o,e,s)}function pt(e,t,n,r,i){dt(e,t,n,r),i&&dt(e,t+16,n,r+4)}function mt(e,t,n,r){ur(e,t+0,n,r,1),ur(e,t+32,n,r+128,1)}function ht(e,t,n,r){var i;for(e=e[t+0]+4,i=0;4>i;++i)for(t=0;4>t;++t)ct(n,r,t,i,e)}function gt(e,t,n,r){e[t+0]&&pr(e,t+0,n,r),e[t+16]&&pr(e,t+16,n,r+4),e[t+32]&&pr(e,t+32,n,r+128),e[t+48]&&pr(e,t+48,n,r+128+4)}function _t(e,t,n,r){var i,o=a(16);for(i=0;4>i;++i){var s=e[t+0+i]+e[t+12+i],c=e[t+4+i]+e[t+8+i],l=e[t+4+i]-e[t+8+i],u=e[t+0+i]-e[t+12+i];o[0+i]=s+c,o[8+i]=s-c,o[4+i]=u+l,o[12+i]=u-l}for(i=0;4>i;++i)s=(e=o[0+4*i]+3)+o[3+4*i],c=o[1+4*i]+o[2+4*i],l=o[1+4*i]-o[2+4*i],u=e-o[3+4*i],n[r+0]=s+c>>3,n[r+16]=u+l>>3,n[r+32]=s-c>>3,n[r+48]=u-l>>3,r+=64}function vt(e,t,n){var r,i=t-32,a=Y,o=255-e[i-1];for(r=0;r<n;++r){var s,c=a,l=o+e[t-1];for(s=0;s<n;++s)e[t+s]=c[l+e[i+s]];t+=32}}function yt(e,t){vt(e,t,4)}function bt(e,t){vt(e,t,8)}function xt(e,t){vt(e,t,16)}function St(e,t){var n;for(n=0;16>n;++n)r(e,t+32*n,e,t-32,16)}function Ct(e,t){var n;for(n=16;0<n;--n)i(e,t,e[t-1],16),t+=32}function wt(e,t,n){var r;for(r=0;16>r;++r)i(t,n+32*r,e,16)}function Tt(e,t){var n,r=16;for(n=0;16>n;++n)r+=e[t-1+32*n]+e[t+n-32];wt(r>>5,e,t)}function Et(e,t){var n,r=8;for(n=0;16>n;++n)r+=e[t-1+32*n];wt(r>>4,e,t)}function Dt(e,t){var n,r=8;for(n=0;16>n;++n)r+=e[t+n-32];wt(r>>4,e,t)}function Ot(e,t){wt(128,e,t)}function kt(e,t,n){return e+2*t+n+2>>2}function At(e,t){var n,i=t-32;for(i=new Uint8Array([kt(e[i-1],e[i+0],e[i+1]),kt(e[i+0],e[i+1],e[i+2]),kt(e[i+1],e[i+2],e[i+3]),kt(e[i+2],e[i+3],e[i+4])]),n=0;4>n;++n)r(e,t+32*n,i,0,i.length)}function jt(e,t){var n=e[t-1],r=e[t-1+32],i=e[t-1+64],a=e[t-1+96];k(e,t+0,16843009*kt(e[t-1-32],n,r)),k(e,t+32,16843009*kt(n,r,i)),k(e,t+64,16843009*kt(r,i,a)),k(e,t+96,16843009*kt(i,a,a))}function Mt(e,t){var n,r=4;for(n=0;4>n;++n)r+=e[t+n-32]+e[t-1+32*n];for(r>>=3,n=0;4>n;++n)i(e,t+32*n,r,4)}function Nt(e,t){var n=e[t-1+0],r=e[t-1+32],i=e[t-1+64],a=e[t-1-32],o=e[t+0-32],s=e[t+1-32],c=e[t+2-32],l=e[t+3-32];e[t+0+96]=kt(r,i,e[t-1+96]),e[t+1+96]=e[t+0+64]=kt(n,r,i),e[t+2+96]=e[t+1+64]=e[t+0+32]=kt(a,n,r),e[t+3+96]=e[t+2+64]=e[t+1+32]=e[t+0+0]=kt(o,a,n),e[t+3+64]=e[t+2+32]=e[t+1+0]=kt(s,o,a),e[t+3+32]=e[t+2+0]=kt(c,s,o),e[t+3+0]=kt(l,c,s)}function Pt(e,t){var n=e[t+1-32],r=e[t+2-32],i=e[t+3-32],a=e[t+4-32],o=e[t+5-32],s=e[t+6-32],c=e[t+7-32];e[t+0+0]=kt(e[t+0-32],n,r),e[t+1+0]=e[t+0+32]=kt(n,r,i),e[t+2+0]=e[t+1+32]=e[t+0+64]=kt(r,i,a),e[t+3+0]=e[t+2+32]=e[t+1+64]=e[t+0+96]=kt(i,a,o),e[t+3+32]=e[t+2+64]=e[t+1+96]=kt(a,o,s),e[t+3+64]=e[t+2+96]=kt(o,s,c),e[t+3+96]=kt(s,c,c)}function Ft(e,t){var n=e[t-1+0],r=e[t-1+32],i=e[t-1+64],a=e[t-1-32],o=e[t+0-32],s=e[t+1-32],c=e[t+2-32],l=e[t+3-32];e[t+0+0]=e[t+1+64]=a+o+1>>1,e[t+1+0]=e[t+2+64]=o+s+1>>1,e[t+2+0]=e[t+3+64]=s+c+1>>1,e[t+3+0]=c+l+1>>1,e[t+0+96]=kt(i,r,n),e[t+0+64]=kt(r,n,a),e[t+0+32]=e[t+1+96]=kt(n,a,o),e[t+1+32]=e[t+2+96]=kt(a,o,s),e[t+2+32]=e[t+3+96]=kt(o,s,c),e[t+3+32]=kt(s,c,l)}function It(e,t){var n=e[t+0-32],r=e[t+1-32],i=e[t+2-32],a=e[t+3-32],o=e[t+4-32],s=e[t+5-32],c=e[t+6-32],l=e[t+7-32];e[t+0+0]=n+r+1>>1,e[t+1+0]=e[t+0+64]=r+i+1>>1,e[t+2+0]=e[t+1+64]=i+a+1>>1,e[t+3+0]=e[t+2+64]=a+o+1>>1,e[t+0+32]=kt(n,r,i),e[t+1+32]=e[t+0+96]=kt(r,i,a),e[t+2+32]=e[t+1+96]=kt(i,a,o),e[t+3+32]=e[t+2+96]=kt(a,o,s),e[t+3+64]=kt(o,s,c),e[t+3+96]=kt(s,c,l)}function Lt(e,t){var n=e[t-1+0],r=e[t-1+32],i=e[t-1+64],a=e[t-1+96];e[t+0+0]=n+r+1>>1,e[t+2+0]=e[t+0+32]=r+i+1>>1,e[t+2+32]=e[t+0+64]=i+a+1>>1,e[t+1+0]=kt(n,r,i),e[t+3+0]=e[t+1+32]=kt(r,i,a),e[t+3+32]=e[t+1+64]=kt(i,a,a),e[t+3+64]=e[t+2+64]=e[t+0+96]=e[t+1+96]=e[t+2+96]=e[t+3+96]=a}function Rt(e,t){var n=e[t-1+0],r=e[t-1+32],i=e[t-1+64],a=e[t-1+96],o=e[t-1-32],s=e[t+0-32],c=e[t+1-32],l=e[t+2-32];e[t+0+0]=e[t+2+32]=n+o+1>>1,e[t+0+32]=e[t+2+64]=r+n+1>>1,e[t+0+64]=e[t+2+96]=i+r+1>>1,e[t+0+96]=a+i+1>>1,e[t+3+0]=kt(s,c,l),e[t+2+0]=kt(o,s,c),e[t+1+0]=e[t+3+32]=kt(n,o,s),e[t+1+32]=e[t+3+64]=kt(r,n,o),e[t+1+64]=e[t+3+96]=kt(i,r,n),e[t+1+96]=kt(a,i,r)}function zt(e,t){var n;for(n=0;8>n;++n)r(e,t+32*n,e,t-32,8)}function Bt(e,t){var n;for(n=0;8>n;++n)i(e,t,e[t-1],8),t+=32}function Vt(e,t,n){var r;for(r=0;8>r;++r)i(t,n+32*r,e,8)}function Ht(e,t){var n,r=8;for(n=0;8>n;++n)r+=e[t+n-32]+e[t-1+32*n];Vt(r>>4,e,t)}function Ut(e,t){var n,r=4;for(n=0;8>n;++n)r+=e[t+n-32];Vt(r>>3,e,t)}function Wt(e,t){var n,r=4;for(n=0;8>n;++n)r+=e[t-1+32*n];Vt(r>>3,e,t)}function Gt(e,t){Vt(128,e,t)}function Kt(e,t,n){var r=e[t-n],i=e[t+0],a=3*(i-r)+Ir[1020+e[t-2*n]-e[t+n]],o=Lr[112+(a+4>>3)];e[t-n]=Y[255+r+Lr[112+(a+3>>3)]],e[t+0]=Y[255+i-o]}function qt(e,t,n,r){var i=e[t+0],a=e[t+n];return Rr[255+e[t-2*n]-e[t-n]]>r||Rr[255+a-i]>r}function Jt(e,t,n,r){return 4*Rr[255+e[t-n]-e[t+0]]+Rr[255+e[t-2*n]-e[t+n]]<=r}function Yt(e,t,n,r,i){var a=e[t-3*n],o=e[t-2*n],s=e[t-n],c=e[t+0],l=e[t+n],u=e[t+2*n],d=e[t+3*n];return 4*Rr[255+s-c]+Rr[255+o-l]>r?0:Rr[255+e[t-4*n]-a]<=i&&Rr[255+a-o]<=i&&Rr[255+o-s]<=i&&Rr[255+d-u]<=i&&Rr[255+u-l]<=i&&Rr[255+l-c]<=i}function Xt(e,t,n,r){var i=2*r+1;for(r=0;16>r;++r)Jt(e,t+r,n,i)&&Kt(e,t+r,n)}function Zt(e,t,n,r){var i=2*r+1;for(r=0;16>r;++r)Jt(e,t+r*n,1,i)&&Kt(e,t+r*n,1)}function Qt(e,t,n,r){var i;for(i=3;0<i;--i)Xt(e,t+=4*n,n,r)}function G(e,t,n,r){var i;for(i=3;0<i;--i)Zt(e,t+=4,n,r)}function $t(e,t,n,r,i,a,o,s){for(a=2*a+1;0<i--;){if(Yt(e,t,n,a,o))if(qt(e,t,n,s))Kt(e,t,n);else{var c=e,l=t,u=n,d=c[l-2*u],f=c[l-u],p=c[l+0],m=c[l+u],h=c[l+2*u],g=27*(v=Ir[1020+3*(p-f)+Ir[1020+d-m]])+63>>7,_=18*v+63>>7,v=9*v+63>>7;c[l-3*u]=Y[255+c[l-3*u]+v],c[l-2*u]=Y[255+d+_],c[l-u]=Y[255+f+g],c[l+0]=Y[255+p-g],c[l+u]=Y[255+m-_],c[l+2*u]=Y[255+h-v]}t+=r}}function en(e,t,n,r,i,a,o,s){for(a=2*a+1;0<i--;){if(Yt(e,t,n,a,o))if(qt(e,t,n,s))Kt(e,t,n);else{var c=e,l=t,u=n,d=c[l-u],f=c[l+0],p=c[l+u],m=Lr[112+(4+(h=3*(f-d))>>3)],h=Lr[112+(h+3>>3)],g=m+1>>1;c[l-2*u]=Y[255+c[l-2*u]+g],c[l-u]=Y[255+d+h],c[l+0]=Y[255+f-m],c[l+u]=Y[255+p-g]}t+=r}}function tn(e,t,n,r,i,a){$t(e,t,n,1,16,r,i,a)}function nn(e,t,n,r,i,a){$t(e,t,1,n,16,r,i,a)}function rn(e,t,n,r,i,a){var o;for(o=3;0<o;--o)en(e,t+=4*n,n,1,16,r,i,a)}function an(e,t,n,r,i,a){var o;for(o=3;0<o;--o)en(e,t+=4,1,n,16,r,i,a)}function on(e,t,n,r,i,a,o,s){$t(e,t,i,1,8,a,o,s),$t(n,r,i,1,8,a,o,s)}function sn(e,t,n,r,i,a,o,s){$t(e,t,1,i,8,a,o,s),$t(n,r,1,i,8,a,o,s)}function cn(e,t,n,r,i,a,o,s){en(e,t+4*i,i,1,8,a,o,s),en(n,r+4*i,i,1,8,a,o,s)}function ln(e,t,n,r,i,a,o,s){en(e,t+4,1,i,8,a,o,s),en(n,r+4,1,i,8,a,o,s)}function un(){this.ba=new _e,this.ec=[],this.cc=[],this.Mc=[],this.Dc=this.Nc=this.dc=this.fc=0,this.Oa=new ye,this.memory=0,this.Ib=`OutputFunc`,this.Jb=`OutputAlphaFunc`,this.Nd=`OutputRowFunc`}function dn(){this.data=[],this.offset=this.kd=this.ha=this.w=0,this.na=[],this.xa=this.gb=this.Ja=this.Sa=this.P=0}function fn(){this.nc=this.Ea=this.b=this.hc=0,this.K=[],this.w=0}function pn(){this.ua=0,this.Wa=new F,this.vb=new F,this.md=this.xc=this.wc=0,this.vc=[],this.Wb=0,this.Ya=new p,this.yc=new d}function mn(){this.xb=this.a=0,this.l=new tt,this.ca=new _e,this.V=[],this.Ba=0,this.Ta=[],this.Ua=0,this.m=new x,this.Pb=0,this.wd=new x,this.Ma=this.$=this.C=this.i=this.c=this.xd=0,this.s=new pn,this.ab=0,this.gc=o(4,fn),this.Oc=0}function hn(){this.Lc=this.Z=this.$a=this.i=this.c=0,this.l=new tt,this.ic=0,this.ca=[],this.tb=0,this.qd=null,this.rd=0}function gn(e,t,n,r,i,a,o){for(e=e==null?0:e[t+0],t=0;t<o;++t)i[a+t]=e+n[r+t]&255,e=i[a+t]}function _n(e,t,n,r,i,a,o){var s;if(e==null)gn(null,null,n,r,i,a,o);else for(s=0;s<o;++s)i[a+s]=e[t+s]+n[r+s]&255}function vn(e,t,n,r,i,a,o){if(e==null)gn(null,null,n,r,i,a,o);else{var s,c=e[t+0],l=c,u=c;for(s=0;s<o;++s)l=u+(c=e[t+s])-l,u=n[r+s]+(-256&l?0>l?0:255:l)&255,l=c,i[a+s]=u}}function yn(e,n,i,o){var s=n.width,c=n.o;if(t(e!=null&&n!=null),0>i||0>=o||i+o>c)return null;if(!e.Cc){if(e.ga==null){var l;if(e.ga=new hn,(l=e.ga==null)||(l=n.width*n.o,t(e.Gb.length==0),e.Gb=a(l),e.Uc=0,e.Gb==null?l=0:(e.mb=e.Gb,e.nb=e.Uc,e.rc=null,l=1),l=!l),!l){l=e.ga;var u=e.Fa,d=e.P,f=e.qc,p=e.mb,m=e.nb,h=d+1,g=f-1,v=l.l;if(t(u!=null&&p!=null&&n!=null),yi[0]=null,yi[1]=gn,yi[2]=_n,yi[3]=vn,l.ca=p,l.tb=m,l.c=n.width,l.i=n.height,t(0<l.c&&0<l.i),1>=f)n=0;else if(l.$a=3&u[d+0],l.Z=u[d+0]>>2&3,l.Lc=u[d+0]>>4&3,d=u[d+0]>>6&3,0>l.$a||1<l.$a||4<=l.Z||1<l.Lc||d)n=0;else if(v.put=Ce,v.ac=U,v.bc=we,v.ma=l,v.width=n.width,v.height=n.height,v.Da=n.Da,v.v=n.v,v.va=n.va,v.j=n.j,v.o=n.o,l.$a)t:{t(l.$a==1),n=Le();e:for(;;){if(n==null){n=0;break t}if(t(l!=null),l.mc=n,n.c=l.c,n.i=l.i,n.l=l.l,n.l.ma=l,n.l.width=l.c,n.l.height=l.i,n.a=0,_(n.m,u,h,g),!Re(l.c,l.i,1,n,null)||(n.ab==1&&n.gc[0].hc==3&&Me(n.s)?(l.ic=1,u=n.c*n.i,n.Ta=null,n.Ua=0,n.V=a(u),n.Ba=0,n.V==null?(n.a=1,n=0):n=1):(l.ic=0,n=ze(n,l.c)),!n))break e;n=1;break t}l.mc=null,n=0}else n=g>=l.c*l.i;l=!n}if(l)return null;e.ga.Lc==1?o=c-i:e.Ga=0}t(e.ga!=null),t(i+o<=c);t:{if(n=(u=e.ga).c,c=u.l.o,u.$a==0){if(h=e.rc,g=e.Vc,v=e.Fa,d=e.P+1+i*n,f=e.mb,p=e.nb+i*n,t(d<=e.P+e.qc),u.Z!=0)for(t(yi[u.Z]!=null),l=0;l<o;++l)yi[u.Z](h,g,v,d,f,p,n),h=f,g=p,p+=n,d+=n;else for(l=0;l<o;++l)r(f,p,v,d,n),h=f,g=p,p+=n,d+=n;e.rc=h,e.Vc=g}else{if(t(u.mc!=null),n=i+o,t((l=u.mc)!=null),t(n<=l.i),l.C>=n)n=1;else if(u.ic||wn(),u.ic){u=l.V,h=l.Ba,g=l.c;var y=l.i,b=(v=1,d=l.$/g,f=l.$%g,p=l.m,m=l.s,l.$),x=g*y,S=g*n,w=m.wc,E=b<S?ke(m,f,d):null;t(b<=x),t(n<=y),t(Me(m));e:for(;;){for(;!p.h&&b<S;){if(f&w||(E=ke(m,f,d)),t(E!=null),T(p),256>(y=De(E.G[0],E.H[0],p)))u[h+b]=y,++b,++f>=g&&(f=0,++d<=n&&!(d%16)&&Pe(l,d));else{if(!(280>y)){v=0;break e}y=W(y-256,p);var D,O=De(E.G[4],E.H[4],p);if(T(p),!(b>=(O=Ee(g,O=W(O,p)))&&x-b>=y)){v=0;break e}for(D=0;D<y;++D)u[h+b+D]=u[h+b+D-O];for(b+=y,f+=y;f>=g;)f-=g,++d<=n&&!(d%16)&&Pe(l,d);b<S&&f&w&&(E=ke(m,f,d))}t(p.h==C(p))}Pe(l,d>n?n:d);break e}!v||p.h&&b<x?(v=0,l.a=p.h?5:3):l.$=b,n=v}else n=Fe(l,l.V,l.Ba,l.c,l.i,n,Be);if(!n){o=0;break t}}i+o>=c&&(e.Cc=1),o=1}if(!o)return null;if(e.Cc&&((o=e.ga)!=null&&(o.mc=null),e.ga=null,0<e.Ga))return alert(`todo:WebPDequantizeLevels`),null}return e.nb+i*s}function bn(e,t,n,r,i,a){for(;0<i--;){var o,s=e,c=t+ +!!n,l=e,u=t+(n?0:3);for(o=0;o<r;++o){var d=l[u+4*o];d!=255&&(d*=32897,s[c+4*o+0]=s[c+4*o+0]*d>>23,s[c+4*o+1]=s[c+4*o+1]*d>>23,s[c+4*o+2]=s[c+4*o+2]*d>>23)}t+=a}}function xn(e,t,n,r,i){for(;0<r--;){var a;for(a=0;a<n;++a){var o=e[t+2*a+0],s=15&(l=e[t+2*a+1]),c=4369*s,l=(240&l|l>>4)*c>>16;e[t+2*a+0]=(240&o|o>>4)*c>>16&240|(15&o|o<<4)*c>>16>>4&15,e[t+2*a+1]=240&l|s}t+=i}}function Sn(e,t,n,r,i,a,o,s){var c,l,u=255;for(l=0;l<i;++l){for(c=0;c<r;++c){var d=e[t+c];a[o+4*c]=d,u&=d}t+=n,o+=s}return u!=255}function Cn(e,t,n,r,i){var a;for(a=0;a<i;++a)n[r+a]=e[t+a]>>8}function wn(){Dr=bn,Or=xn,kr=Sn,Ar=Cn}function Tn(n,r,i){e[n]=function(e,n,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y){var b,x=y-1>>1,S=s[c+0]|l[u+0]<<16,C=d[f+0]|p[m+0]<<16;t(e!=null);var w=3*S+C+131074>>2;for(r(e[n+0],255&w,w>>16,h,g),a!=null&&(w=3*C+S+131074>>2,r(a[o+0],255&w,w>>16,_,v)),b=1;b<=x;++b){var T=s[c+b]|l[u+b]<<16,E=d[f+b]|p[m+b]<<16,D=S+T+C+E+524296,O=D+2*(T+C)>>3;w=O+S>>1,S=(D=D+2*(S+E)>>3)+T>>1,r(e[n+2*b-1],255&w,w>>16,h,g+(2*b-1)*i),r(e[n+2*b-0],255&S,S>>16,h,g+(2*b-0)*i),a!=null&&(w=D+C>>1,S=O+E>>1,r(a[o+2*b-1],255&w,w>>16,_,v+(2*b-1)*i),r(a[o+2*b+0],255&S,S>>16,_,v+(2*b+0)*i)),S=T,C=E}1&y||(w=3*S+C+131074>>2,r(e[n+y-1],255&w,w>>16,h,g+(y-1)*i),a!=null&&(w=3*C+S+131074>>2,r(a[o+y-1],255&w,w>>16,_,v+(y-1)*i)))}}function En(){bi[zr]=xi,bi[Br]=Ci,bi[Vr]=Si,bi[Hr]=wi,bi[Ur]=Ti,bi[Wr]=Ei,bi[Gr]=Di,bi[Kr]=Ci,bi[qr]=wi,bi[Jr]=Ti,bi[Yr]=Ei}function Dn(e){return e&~Ni?0>e?0:255:e>>Mi}function On(e,t){return Dn((19077*e>>8)+(26149*t>>8)-14234)}function kn(e,t,n){return Dn((19077*e>>8)-(6419*t>>8)-(13320*n>>8)+8708)}function An(e,t){return Dn((19077*e>>8)+(33050*t>>8)-17685)}function jn(e,t,n,r,i){r[i+0]=On(e,n),r[i+1]=kn(e,t,n),r[i+2]=An(e,t)}function K(e,t,n,r,i){r[i+0]=An(e,t),r[i+1]=kn(e,t,n),r[i+2]=On(e,n)}function Mn(e,t,n,r,i){var a=kn(e,t,n);t=a<<3&224|An(e,t)>>3,r[i+0]=248&On(e,n)|a>>5,r[i+1]=t}function q(e,t,n,r,i){var a=240&An(e,t)|15;r[i+0]=240&On(e,n)|kn(e,t,n)>>4,r[i+1]=a}function Nn(e,t,n,r,i){r[i+0]=255,jn(e,t,n,r,i+1)}function Pn(e,t,n,r,i){K(e,t,n,r,i),r[i+3]=255}function Fn(e,t,n,r,i){jn(e,t,n,r,i),r[i+3]=255}function In(t,n,r){e[t]=function(e,t,i,a,o,s,c,l,u){for(var d=l+(-2&u)*r;l!=d;)n(e[t+0],i[a+0],o[s+0],c,l),n(e[t+1],i[a+0],o[s+0],c,l+r),t+=2,++a,++s,l+=2*r;1&u&&n(e[t+0],i[a+0],o[s+0],c,l)}}function Ln(e,t,n){return n==0?e==0?t==0?6:5:t==0?4:0:n}function Rn(e,t,n,r,i){switch(e>>>30){case 3:ur(t,n,r,i,0);break;case 2:dr(t,n,r,i);break;case 1:pr(t,n,r,i)}}function zn(e,t){var n,a,o=t.M,s=t.Nb,c=e.oc,l=e.pc+40,u=e.oc,d=e.pc+584,f=e.oc,p=e.pc+600;for(n=0;16>n;++n)c[l+32*n-1]=129;for(n=0;8>n;++n)u[d+32*n-1]=129,f[p+32*n-1]=129;for(0<o?c[l-1-32]=u[d-1-32]=f[p-1-32]=129:(i(c,l-32-1,127,21),i(u,d-32-1,127,9),i(f,p-32-1,127,9)),a=0;a<e.za;++a){var m=t.ya[t.aa+a];if(0<a){for(n=-1;16>n;++n)r(c,l+32*n-4,c,l+32*n+12,4);for(n=-1;8>n;++n)r(u,d+32*n-4,u,d+32*n+4,4),r(f,p+32*n-4,f,p+32*n+4,4)}var h=e.Gd,g=e.Hd+a,_=m.ad,v=m.Hc;if(0<o&&(r(c,l-32,h[g].y,0,16),r(u,d-32,h[g].f,0,8),r(f,p-32,h[g].ea,0,8)),m.Za){var y=c,b=l-32+16;for(0<o&&(a>=e.za-1?i(y,b,h[g].y[15],4):r(y,b,h[g+1].y,0,4)),n=0;4>n;n++)y[b+128+n]=y[b+256+n]=y[b+384+n]=y[b+0+n];for(n=0;16>n;++n,v<<=2)y=c,b=l+Vi[n],hi[m.Ob[n]](y,b),Rn(v,_,16*n,y,b)}else if(y=Ln(a,o,m.Ob[0]),mi[y](c,l),v!=0)for(n=0;16>n;++n,v<<=2)Rn(v,_,16*n,c,l+Vi[n]);for(n=m.Gc,y=Ln(a,o,m.Dd),gi[y](u,d),gi[y](f,p),v=_,y=u,b=d,255&(m=0|n)&&(170&m?fr(v,256,y,b):mr(v,256,y,b)),m=f,v=p,255&(n>>=8)&&(170&n?fr(_,320,m,v):mr(_,320,m,v)),o<e.Ub-1&&(r(h[g].y,0,c,l+480,16),r(h[g].f,0,u,d+224,8),r(h[g].ea,0,f,p+224,8)),n=8*s*e.B,h=e.sa,g=e.ta+16*a+16*s*e.R,_=e.qa,m=e.ra+8*a+n,v=e.Ha,y=e.Ia+8*a+n,n=0;16>n;++n)r(h,g+n*e.R,c,l+32*n,16);for(n=0;8>n;++n)r(_,m+n*e.B,u,d+32*n,8),r(v,y+n*e.B,f,p+32*n,8)}}function Bn(e,r,i,a,o,s,c,l,u){var d=[0],f=[0],p=0,m=u==null?0:u.kd,h=u??new dn;if(e==null||12>i)return 7;h.data=e,h.w=r,h.ha=i,r=[r],i=[i],h.gb=[h.gb];t:{var g=r,v=i,y=h.gb;if(t(e!=null),t(v!=null),t(y!=null),y[0]=0,12<=v[0]&&!n(e,g[0],`RIFF`)){if(n(e,g[0]+8,`WEBP`)){y=3;break t}var b=M(e,g[0]+4);if(12>b||4294967286<b){y=3;break t}if(m&&b>v[0]-8){y=7;break t}y[0]=b,g[0]+=12,v[0]-=12}y=0}if(y!=0)return y;for(b=0<h.gb[0],i=i[0];;){t:{var S=e;v=r,y=i;var C=d,w=f,T=g=[0];if((O=p=[p])[0]=0,8>y[0])y=7;else{if(!n(S,v[0],`VP8X`)){if(M(S,v[0]+4)!=10){y=3;break t}if(18>y[0]){y=7;break t}var E=M(S,v[0]+8),D=1+j(S,v[0]+12);if(2147483648<=D*(S=1+j(S,v[0]+15))){y=3;break t}T!=null&&(T[0]=E),C!=null&&(C[0]=D),w!=null&&(w[0]=S),v[0]+=18,y[0]-=18,O[0]=1}y=0}}if(p=p[0],g=g[0],y!=0)return y;if(v=!!(2&g),!b&&p)return 3;if(s!=null&&(s[0]=!!(16&g)),c!=null&&(c[0]=v),l!=null&&(l[0]=0),c=d[0],g=f[0],p&&v&&u==null){y=0;break}if(4>i){y=7;break}if(b&&p||!b&&!p&&!n(e,r[0],`ALPH`)){i=[i],h.na=[h.na],h.P=[h.P],h.Sa=[h.Sa];t:{E=e,y=r,b=i;var O=h.gb;C=h.na,w=h.P,T=h.Sa,D=22,t(E!=null),t(b!=null),S=y[0];var k=b[0];for(t(C!=null),t(T!=null),C[0]=null,w[0]=null,T[0]=0;;){if(y[0]=S,b[0]=k,8>k){y=7;break t}var A=M(E,S+4);if(4294967286<A){y=3;break t}var N=8+A+1&-2;if(D+=N,0<O&&D>O){y=3;break t}if(!n(E,S,`VP8 `)||!n(E,S,`VP8L`)){y=0;break t}if(k[0]<N){y=7;break t}n(E,S,`ALPH`)||(C[0]=E,w[0]=S+8,T[0]=A),S+=N,k-=N}}if(i=i[0],h.na=h.na[0],h.P=h.P[0],h.Sa=h.Sa[0],y!=0)break}i=[i],h.Ja=[h.Ja],h.xa=[h.xa];t:if(O=e,y=r,b=i,C=h.gb[0],w=h.Ja,T=h.xa,E=y[0],S=!n(O,E,`VP8 `),D=!n(O,E,`VP8L`),t(O!=null),t(b!=null),t(w!=null),t(T!=null),8>b[0])y=7;else{if(S||D){if(O=M(O,E+4),12<=C&&O>C-12){y=3;break t}if(m&&O>b[0]-8){y=7;break t}w[0]=O,y[0]+=8,b[0]-=8,T[0]=D}else T[0]=5<=b[0]&&O[E+0]==47&&!(O[E+4]>>5),w[0]=b[0];y=0}if(i=i[0],h.Ja=h.Ja[0],h.xa=h.xa[0],r=r[0],y!=0)break;if(4294967286<h.Ja)return 3;if(l==null||v||(l[0]=h.xa?2:1),c=[c],g=[g],h.xa){if(5>i){y=7;break}l=c,m=g,v=s,e==null||5>i?e=0:5<=i&&e[r+0]==47&&!(e[r+4]>>5)?(b=[0],O=[0],C=[0],_(w=new x,e,r,i),Te(w,b,O,C)?(l!=null&&(l[0]=b[0]),m!=null&&(m[0]=O[0]),v!=null&&(v[0]=C[0]),e=1):e=0):e=0}else{if(10>i){y=7;break}l=g,e==null||10>i||!it(e,r+3,i-3)?e=0:(m=e[r+0]|e[r+1]<<8|e[r+2]<<16,v=16383&(e[r+7]<<8|e[r+6]),e=16383&(e[r+9]<<8|e[r+8]),1&m||3<(m>>1&7)||!(m>>4&1)||m>>5>=h.Ja||!v||!e?e=0:(c&&(c[0]=v),l&&(l[0]=e),e=1))}if(!e||(c=c[0],g=g[0],p&&(d[0]!=c||f[0]!=g)))return 3;u!=null&&(u[0]=h,u.offset=r-u.w,t(4294967286>r-u.w),t(u.offset==u.ha-i));break}return y==0||y==7&&p&&u==null?(s!=null&&(s[0]|=h.na!=null&&0<h.na.length),a!=null&&(a[0]=c),o!=null&&(o[0]=g),0):y}function Vn(e,t,n){var r=t.width,i=t.height,a=0,o=0,s=r,c=i;if(t.Da=e!=null&&0<e.Da,t.Da&&(s=e.cd,c=e.bd,a=e.v,o=e.j,11>n||(a&=-2,o&=-2),0>a||0>o||0>=s||0>=c||a+s>r||o+c>i))return 0;if(t.v=a,t.j=o,t.va=a+s,t.o=o+c,t.U=s,t.T=c,t.da=e!=null&&0<e.da,t.da){if(!I(s,c,n=[e.ib],a=[e.hb]))return 0;t.ib=n[0],t.hb=a[0]}return t.ob=e!=null&&e.ob,t.Kb=e==null||!e.Sd,t.da&&(t.ob=t.ib<3*r/4&&t.hb<3*i/4,t.Kb=0),1}function Hn(e){if(e==null)return 2;if(11>e.S){var t=e.f.RGBA;t.fb+=(e.height-1)*t.A,t.A=-t.A}else t=e.f.kb,e=e.height,t.O+=(e-1)*t.fa,t.fa=-t.fa,t.N+=(e-1>>1)*t.Ab,t.Ab=-t.Ab,t.W+=(e-1>>1)*t.Db,t.Db=-t.Db,t.F!=null&&(t.J+=(e-1)*t.lb,t.lb=-t.lb);return 0}function Un(e,t,n,r){if(r==null||0>=e||0>=t)return 2;if(n!=null){if(n.Da){var i=n.cd,o=n.bd,s=-2&n.v,c=-2&n.j;if(0>s||0>c||0>=i||0>=o||s+i>e||c+o>t)return 2;e=i,t=o}if(n.da){if(!I(e,t,i=[n.ib],o=[n.hb]))return 2;e=i[0],t=o[0]}}r.width=e,r.height=t;t:{var l=r.width,u=r.height;if(e=r.S,0>=l||0>=u||!(e>=zr&&13>e))e=2;else{if(0>=r.Rd&&r.sd==null){s=o=i=t=0;var d=(c=l*Gi[e])*u;if(11>e||(o=(u+1)/2*(t=(l+1)/2),e==12&&(s=(i=l)*u)),(u=a(d+2*o+s))==null){e=1;break t}r.sd=u,11>e?((l=r.f.RGBA).eb=u,l.fb=0,l.A=c,l.size=d):((l=r.f.kb).y=u,l.O=0,l.fa=c,l.Fd=d,l.f=u,l.N=0+d,l.Ab=t,l.Cd=o,l.ea=u,l.W=0+d+o,l.Db=t,l.Ed=o,e==12&&(l.F=u,l.J=0+d+2*o),l.Tc=s,l.lb=i)}if(t=1,i=r.S,o=r.width,s=r.height,i>=zr&&13>i)if(11>i)e=r.f.RGBA,t&=(c=Math.abs(e.A))*(s-1)+o<=e.size,t&=c>=o*Gi[i],t&=e.eb!=null;else{e=r.f.kb,c=(o+1)/2,d=(s+1)/2,l=Math.abs(e.fa),u=Math.abs(e.Ab);var f=Math.abs(e.Db),p=Math.abs(e.lb),m=p*(s-1)+o;t&=l*(s-1)+o<=e.Fd,t&=u*(d-1)+c<=e.Cd,t=(t&=f*(d-1)+c<=e.Ed)&l>=o&u>=c&f>=c,t&=e.y!=null,t&=e.f!=null,t&=e.ea!=null,i==12&&(t&=p>=o,t&=m<=e.Tc,t&=e.F!=null)}else t=0;e=t?0:2}}return e!=0||n!=null&&n.fd&&(e=Hn(r)),e}var Wn=64,Gn=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],Kn=24,qn=32,Jn=8,Yn=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];R(`Predictor0`,`PredictorAdd0`),e.Predictor0=function(){return 4278190080},e.Predictor1=function(e){return e},e.Predictor2=function(e,t,n){return t[n+0]},e.Predictor3=function(e,t,n){return t[n+1]},e.Predictor4=function(e,t,n){return t[n-1]},e.Predictor5=function(e,t,n){return z(z(e,t[n+1]),t[n+0])},e.Predictor6=function(e,t,n){return z(e,t[n-1])},e.Predictor7=function(e,t,n){return z(e,t[n+0])},e.Predictor8=function(e,t,n){return z(t[n-1],t[n+0])},e.Predictor9=function(e,t,n){return z(t[n+0],t[n+1])},e.Predictor10=function(e,t,n){return z(z(e,t[n-1]),z(t[n+0],t[n+1]))},e.Predictor11=function(e,t,n){var r=t[n+0];return 0>=ne(r>>24&255,e>>24&255,(t=t[n-1])>>24&255)+ne(r>>16&255,e>>16&255,t>>16&255)+ne(r>>8&255,e>>8&255,t>>8&255)+ne(255&r,255&e,255&t)?r:e},e.Predictor12=function(e,t,n){var r=t[n+0];return(B((e>>24&255)+(r>>24&255)-((t=t[n-1])>>24&255))<<24|B((e>>16&255)+(r>>16&255)-(t>>16&255))<<16|B((e>>8&255)+(r>>8&255)-(t>>8&255))<<8|B((255&e)+(255&r)-(255&t)))>>>0},e.Predictor13=function(e,t,n){var r=t[n-1];return(V((e=z(e,t[n+0]))>>24&255,r>>24&255)<<24|V(e>>16&255,r>>16&255)<<16|V(e>>8&255,r>>8&255)<<8|V(255&e,255&r))>>>0};var Xn=e.PredictorAdd0;e.PredictorAdd1=re,R(`Predictor2`,`PredictorAdd2`),R(`Predictor3`,`PredictorAdd3`),R(`Predictor4`,`PredictorAdd4`),R(`Predictor5`,`PredictorAdd5`),R(`Predictor6`,`PredictorAdd6`),R(`Predictor7`,`PredictorAdd7`),R(`Predictor8`,`PredictorAdd8`),R(`Predictor9`,`PredictorAdd9`),R(`Predictor10`,`PredictorAdd10`),R(`Predictor11`,`PredictorAdd11`),R(`Predictor12`,`PredictorAdd12`),R(`Predictor13`,`PredictorAdd13`);var Zn=e.PredictorAdd2;se(`ColorIndexInverseTransform`,`MapARGB`,`32b`,function(e){return e>>8&255},function(e){return e}),se(`VP8LColorIndexInverseTransformAlpha`,`MapAlpha`,`8b`,function(e){return e},function(e){return e>>8&255});var Qn,$n=e.ColorIndexInverseTransform,er=e.MapARGB,tr=e.VP8LColorIndexInverseTransformAlpha,nr=e.MapAlpha,rr=e.VP8LPredictorsAdd=[];rr.length=16,(e.VP8LPredictors=[]).length=16,(e.VP8LPredictorsAdd_C=[]).length=16,(e.VP8LPredictors_C=[]).length=16;var J,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr=a(511),Mr=a(2041),Nr=a(225),Pr=a(767),Fr=0,Ir=Mr,Lr=Nr,Y=Pr,Rr=jr,zr=0,Br=1,Vr=2,Hr=3,Ur=4,Wr=5,Gr=6,Kr=7,qr=8,Jr=9,Yr=10,Xr=[2,3,7],Zr=[3,3,11],Qr=[280,256,256,256,40],$r=[0,1,1,1,0],ei=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],ti=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],ni=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],ri=8,ii=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],ai=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],oi=null,si=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],ci=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],li=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],ui=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],di=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],fi=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],pi=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],mi=[],hi=[],gi=[],_i=1,vi=2,yi=[],bi=[];Tn(`UpsampleRgbLinePair`,jn,3),Tn(`UpsampleBgrLinePair`,K,3),Tn(`UpsampleRgbaLinePair`,Fn,4),Tn(`UpsampleBgraLinePair`,Pn,4),Tn(`UpsampleArgbLinePair`,Nn,4),Tn(`UpsampleRgba4444LinePair`,q,2),Tn(`UpsampleRgb565LinePair`,Mn,2);var xi=e.UpsampleRgbLinePair,Si=e.UpsampleBgrLinePair,Ci=e.UpsampleRgbaLinePair,wi=e.UpsampleBgraLinePair,Ti=e.UpsampleArgbLinePair,Ei=e.UpsampleRgba4444LinePair,Di=e.UpsampleRgb565LinePair,Oi=16,ki=1<<Oi-1,Ai=-227,ji=482,Mi=6,Ni=(256<<Mi)-1,Pi=0,Fi=a(256),Ii=a(256),Li=a(256),Ri=a(256),zi=a(ji-Ai),Bi=a(ji-Ai);In(`YuvToRgbRow`,jn,3),In(`YuvToBgrRow`,K,3),In(`YuvToRgbaRow`,Fn,4),In(`YuvToBgraRow`,Pn,4),In(`YuvToArgbRow`,Nn,4),In(`YuvToRgba4444Row`,q,2),In(`YuvToRgb565Row`,Mn,2);var Vi=[0,4,8,12,128,132,136,140,256,260,264,268,384,388,392,396],Hi=[0,2,8],Ui=[8,7,6,4,4,2,2,2,1,1,1,1],Wi=1;this.WebPDecodeRGBA=function(e,n,s,c,l){var u=Br,d=new un,f=new _e;d.ba=f,f.S=u,f.width=[f.width],f.height=[f.height];var p=f.width,m=f.height,h=new ve;if(h==null||e==null)var g=2;else t(h!=null),g=Bn(e,n,s,h.width,h.height,h.Pd,h.Qd,h.format,null);if(g==0?(p!=null&&(p[0]=h.width[0]),m!=null&&(m[0]=h.height[0]),p=1):p=0,p){f.width=f.width[0],f.height=f.height[0],c!=null&&(c[0]=f.width),l!=null&&(l[0]=f.height);t:{if(c=new tt,(l=new dn).data=e,l.w=n,l.ha=s,l.kd=1,n=[0],t(l!=null),((e=Bn(l.data,l.w,l.ha,null,null,null,n,null,l))==0||e==7)&&n[0]&&(e=4),(n=e)==0){if(t(d!=null),c.data=l.data,c.w=l.w+l.offset,c.ha=l.ha-l.offset,c.put=Ce,c.ac=U,c.bc=we,c.ma=d,l.xa){if((e=Le())==null){d=1;break t}if(function(e,n){var r=[0],i=[0],a=[0];e:for(;;){if(e==null)return 0;if(n==null)return e.a=2,0;if(e.l=n,e.a=0,_(e.m,n.data,n.w,n.ha),!Te(e.m,r,i,a)){e.a=3;break e}if(e.xb=vi,n.width=r[0],n.height=i[0],!Re(r[0],i[0],1,e,null))break e;return 1}return t(e.a!=0),0}(e,c)){if(c=(n=Un(c.width,c.height,d.Oa,d.ba))==0){e:{c=e;r:for(;;){if(c==null){c=0;break e}if(t(c.s.yc!=null),t(c.s.Ya!=null),t(0<c.s.Wb),t((s=c.l)!=null),t((l=s.ma)!=null),c.xb!=0){if(c.ca=l.ba,c.tb=l.tb,t(c.ca!=null),!Vn(l.Oa,s,Hr)){c.a=2;break r}if(!ze(c,s.width)||s.da)break r;if((s.da||me(c.ca.S))&&wn(),11>c.ca.S||(alert(`todo:WebPInitConvertARGBToYUV`),c.ca.f.kb.F!=null&&wn()),c.Pb&&0<c.s.ua&&c.s.vb.X==null&&!N(c.s.vb,c.s.Wa.Xa)){c.a=1;break r}c.xb=0}if(!Fe(c,c.V,c.Ba,c.c,c.i,s.o,je))break r;l.Dc=c.Ma,c=1;break e}t(c.a!=0),c=0}c=!c}c&&(n=e.a)}else n=e.a}else{if((e=new nt)==null){d=1;break t}if(e.Fa=l.na,e.P=l.P,e.qc=l.Sa,at(e,c)){if((n=Un(c.width,c.height,d.Oa,d.ba))==0){if(e.Aa=0,s=d.Oa,t((l=e)!=null),s!=null){if(0<(p=0>(p=s.Md)?0:100<p?255:255*p/100)){for(m=h=0;4>m;++m)12>(g=l.pb[m]).lc&&(g.ia=p*Ui[0>g.lc?0:g.lc]>>3),h|=g.ia;h&&(alert(`todo:VP8InitRandom`),l.ia=1)}l.Ga=s.Id,100<l.Ga?l.Ga=100:0>l.Ga&&(l.Ga=0)}(function(e,n){if(e==null)return 0;if(n==null)return rt(e,2,`NULL VP8Io parameter in VP8Decode().`);if(!e.cb&&!at(e,n))return 0;if(t(e.cb),n.ac==null||n.ac(n)){n.ob&&(e.L=0);var s=Hi[e.L];if(e.L==2?(e.yb=0,e.zb=0):(e.yb=n.v-s>>4,e.zb=n.j-s>>4,0>e.yb&&(e.yb=0),0>e.zb&&(e.zb=0)),e.Va=n.o+15+s>>4,e.Hb=n.va+15+s>>4,e.Hb>e.za&&(e.Hb=e.za),e.Va>e.Ub&&(e.Va=e.Ub),0<e.L){var c=e.ed;for(s=0;4>s;++s){var l;if(e.Qa.Cb){var u=e.Qa.Lb[s];e.Qa.Fb||(u+=c.Tb)}else u=c.Tb;for(l=0;1>=l;++l){var d=e.gd[s][l],f=u;if(c.Pc&&(f+=c.vd[0],l&&(f+=c.od[0])),0<(f=0>f?0:63<f?63:f)){var p=f;0<c.wb&&(p=4<c.wb?p>>2:p>>1)>9-c.wb&&(p=9-c.wb),1>p&&(p=1),d.dd=p,d.tc=2*f+p,d.ld=40<=f?2:+(15<=f)}else d.tc=0;d.La=l}}}s=0}else rt(e,6,`Frame setup failed`),s=e.a;if(s=s==0){if(s){e.$c=0,0<e.Aa||(e.Ic=Wi);e:{s=e.Ic,c=4*(p=e.za);var m=32*p,h=p+1,g=0<e.L?p*(0<e.Aa?2:1):0,_=(e.Aa==2?2:1)*p;if((d=c+832+(l=3*(16*s+Hi[e.L])/2*m)+(u=e.Fa!=null&&0<e.Fa.length?e.Kc.c*e.Kc.i:0))!=d)s=0;else{if(d>e.Vb){if(e.Vb=0,e.Ec=a(d),e.Fc=0,e.Ec==null){s=rt(e,1,`no memory during frame initialization.`);break e}e.Vb=d}d=e.Ec,f=e.Fc,e.Ac=d,e.Bc=f,f+=c,e.Gd=o(m,Qe),e.Hd=0,e.rb=o(h+1,Je),e.sb=1,e.wa=g?o(g,qe):null,e.Y=0,e.D.Nb=0,e.D.wa=e.wa,e.D.Y=e.Y,0<e.Aa&&(e.D.Y+=p),t(!0),e.oc=d,e.pc=f,f+=832,e.ya=o(_,Xe),e.aa=0,e.D.ya=e.ya,e.D.aa=e.aa,e.Aa==2&&(e.D.aa+=p),e.R=16*p,e.B=8*p,p=(m=Hi[e.L])*e.R,m=m/2*e.B,e.sa=d,e.ta=f+p,e.qa=e.sa,e.ra=e.ta+16*s*e.R+m,e.Ha=e.qa,e.Ia=e.ra+8*s*e.B+m,e.$c=0,f+=l,e.mb=u?d:null,e.nb=u?f:null,t(f+u<=e.Fc+e.Vb),st(e),i(e.Ac,e.Bc,0,c),s=1}}if(s){if(n.ka=0,n.y=e.sa,n.O=e.ta,n.f=e.qa,n.N=e.ra,n.ea=e.Ha,n.Vd=e.Ia,n.fa=e.R,n.Rc=e.B,n.F=null,n.J=0,!Fr){for(s=-255;255>=s;++s)jr[255+s]=0>s?-s:s;for(s=-1020;1020>=s;++s)Mr[1020+s]=-128>s?-128:127<s?127:s;for(s=-112;112>=s;++s)Nr[112+s]=-16>s?-16:15<s?15:s;for(s=-255;510>=s;++s)Pr[255+s]=0>s?0:255<s?255:s;Fr=1}lr=_t,ur=pt,fr=mt,pr=ht,mr=gt,dr=ft,hr=tn,gr=nn,_r=on,vr=sn,yr=rn,br=an,xr=cn,Sr=ln,Cr=Xt,wr=Zt,Tr=Qt,Er=G,hi[0]=Mt,hi[1]=yt,hi[2]=At,hi[3]=jt,hi[4]=Nt,hi[5]=Ft,hi[6]=Pt,hi[7]=It,hi[8]=Rt,hi[9]=Lt,mi[0]=Tt,mi[1]=xt,mi[2]=St,mi[3]=Ct,mi[4]=Et,mi[5]=Dt,mi[6]=Ot,gi[0]=Ht,gi[1]=bt,gi[2]=zt,gi[3]=Bt,gi[4]=Wt,gi[5]=Ut,gi[6]=Gt,s=1}else s=0}s&&=function(e,n){for(e.M=0;e.M<e.Va;++e.M){var o,s=e.Jc[e.M&e.Xb],c=e.m,l=e;for(o=0;o<l.za;++o){var u=c,d=l,f=d.Ac,p=d.Bc+4*o,m=d.zc,h=d.ya[d.aa+o];if(d.Qa.Bb?h.$b=O(u,d.Pa.jb[0])?2+O(u,d.Pa.jb[2]):O(u,d.Pa.jb[1]):h.$b=0,d.kc&&(h.Ad=O(u,d.Bd)),h.Za=!O(u,145)+0,h.Za){var g=h.Ob,_=0;for(d=0;4>d;++d){var v,y=m[0+d];for(v=0;4>v;++v){y=di[f[p+v]][y];for(var b=li[O(u,y[0])];0<b;)b=li[2*b+O(u,y[b])];y=-b,f[p+v]=y}r(g,_,f,p,4),_+=4,m[0+d]=y}}else y=O(u,156)?O(u,128)?1:3:O(u,163)?2:0,h.Ob[0]=y,i(f,p,y,4),i(m,0,y,4);h.Dd=O(u,142)?O(u,114)?O(u,183)?1:3:2:0}if(l.m.Ka)return rt(e,7,`Premature end-of-partition0 encountered.`);for(;e.ja<e.za;++e.ja){if(l=s,u=(c=e).rb[c.sb-1],f=c.rb[c.sb+c.ja],o=c.ya[c.aa+c.ja],p=c.kc?o.Ad:0)u.la=f.la=0,o.Za||(u.Na=f.Na=0),o.Hc=0,o.Gc=0,o.ia=0;else{var x,S;if(u=f,f=l,p=c.Pa.Xc,m=c.ya[c.aa+c.ja],h=c.pb[m.$b],d=m.ad,g=0,_=c.rb[c.sb-1],y=v=0,i(d,g,0,384),m.Za)var C=0,w=p[3];else{b=a(16);var T=u.Na+_.Na;if(T=oi(f,p[1],T,h.Eb,0,b,0),u.Na=_.Na=(0<T)+0,1<T)lr(b,0,d,g);else{var E=b[0]+3>>3;for(b=0;256>b;b+=16)d[g+b]=E}C=1,w=p[0]}var D=15&u.la,k=15&_.la;for(b=0;4>b;++b){var A=1&k;for(E=S=0;4>E;++E)D=D>>1|(A=(T=oi(f,w,T=A+(1&D),h.Sc,C,d,g))>C)<<7,S=S<<2|(3<T?3:1<T?2:d[g+0]!=0),g+=16;D>>=4,k=k>>1|A<<7,v=(v<<8|S)>>>0}for(w=D,C=k>>4,x=0;4>x;x+=2){for(S=0,D=u.la>>4+x,k=_.la>>4+x,b=0;2>b;++b){for(A=1&k,E=0;2>E;++E)T=A+(1&D),D=D>>1|(A=0<(T=oi(f,p[2],T,h.Qc,0,d,g)))<<3,S=S<<2|(3<T?3:1<T?2:d[g+0]!=0),g+=16;D>>=2,k=k>>1|A<<5}y|=S<<4*x,w|=D<<4<<x,C|=(240&k)<<x}u.la=w,_.la=C,m.Hc=v,m.Gc=y,m.ia=43690&y?0:h.ia,p=!(v|y)}if(0<c.L&&(c.wa[c.Y+c.ja]=c.gd[o.$b][o.Za],c.wa[c.Y+c.ja].La|=!p),l.Ka)return rt(e,7,`Premature end-of-file encountered.`)}if(st(e),c=n,l=1,o=(s=e).D,u=0<s.L&&s.M>=s.zb&&s.M<=s.Va,s.Aa==0)e:{if(o.M=s.M,o.uc=u,zn(s,o),l=1,o=(S=s.D).Nb,u=(y=Hi[s.L])*s.R,f=y/2*s.B,b=16*o*s.R,E=8*o*s.B,p=s.sa,m=s.ta-u+b,h=s.qa,d=s.ra-f+E,g=s.Ha,_=s.Ia-f+E,k=(D=S.M)==0,v=D>=s.Va-1,s.Aa==2&&zn(s,S),S.uc)for(A=(T=s).D.M,t(T.D.uc),S=T.yb;S<T.Hb;++S){C=S,w=A;var j=(M=(z=T).D).Nb;x=z.R;var M=M.wa[M.Y+C],N=z.sa,P=z.ta+16*j*x+16*C,F=M.dd,I=M.tc;if(I!=0)if(t(3<=I),z.L==1)0<C&&wr(N,P,x,I+4),M.La&&Er(N,P,x,I),0<w&&Cr(N,P,x,I+4),M.La&&Tr(N,P,x,I);else{var L=z.B,ee=z.qa,R=z.ra+8*j*L+8*C,te=z.Ha,z=z.Ia+8*j*L+8*C;j=M.ld,0<C&&(gr(N,P,x,I+4,F,j),vr(ee,R,te,z,L,I+4,F,j)),M.La&&(br(N,P,x,I,F,j),Sr(ee,R,te,z,L,I,F,j)),0<w&&(hr(N,P,x,I+4,F,j),_r(ee,R,te,z,L,I+4,F,j)),M.La&&(yr(N,P,x,I,F,j),xr(ee,R,te,z,L,I,F,j))}}if(s.ia&&alert(`todo:DitherRow`),c.put!=null){if(S=16*D,D=16*(D+1),k?(c.y=s.sa,c.O=s.ta+b,c.f=s.qa,c.N=s.ra+E,c.ea=s.Ha,c.W=s.Ia+E):(S-=y,c.y=p,c.O=m,c.f=h,c.N=d,c.ea=g,c.W=_),v||(D-=y),D>c.o&&(D=c.o),c.F=null,c.J=null,s.Fa!=null&&0<s.Fa.length&&S<D&&(c.J=yn(s,c,S,D-S),c.F=s.mb,c.F==null&&c.F.length==0)){l=rt(s,3,`Could not decode alpha data.`);break e}S<c.j&&(y=c.j-S,S=c.j,t(!(1&y)),c.O+=s.R*y,c.N+=s.B*(y>>1),c.W+=s.B*(y>>1),c.F!=null&&(c.J+=c.width*y)),S<D&&(c.O+=c.v,c.N+=c.v>>1,c.W+=c.v>>1,c.F!=null&&(c.J+=c.v),c.ka=S-c.j,c.U=c.va-c.v,c.T=D-S,l=c.put(c))}o+1!=s.Ic||v||(r(s.sa,s.ta-u,p,m+16*s.R,u),r(s.qa,s.ra-f,h,d+8*s.B,f),r(s.Ha,s.Ia-f,g,_+8*s.B,f))}if(!l)return rt(e,6,`Output aborted.`)}return 1}(e,n),n.bc!=null&&n.bc(n),s&=1}return s?(e.cb=0,s):0})(e,c)||(n=e.a)}}else n=e.a}n==0&&d.Oa!=null&&d.Oa.fd&&(n=Hn(d.ba))}d=n}u=d==0?11>u?f.f.RGBA.eb:f.f.kb.y:null}else u=null;return u};var Gi=[3,4,3,4,4,2,2,4,4,4,2,1,1]};function l(e,t){for(var n=``,r=0;r<4;r++)n+=String.fromCharCode(e[t++]);return n}function u(e,t){return e[t+0]|e[t+1]<<8}function d(e,t){return(e[t+0]|e[t+1]<<8|e[t+2]<<16)>>>0}function f(e,t){return(e[t+0]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}new c;var p=[0],m=[0],h=[],g=new c,_=e,v=function(e,t){var n={},r=0,i=!1,a=0,o=0;if(n.frames=[],!function(e,t){for(var n=0;n<4;n++)if(e[t+n]!=`RIFF`.charCodeAt(n))return!0;return!1}(e,t)){for(f(e,t+=4),t+=8;t<e.length;){var s=l(e,t),c=f(e,t+=4);t+=4;var p=c+(1&c);switch(s){case`VP8 `:case`VP8L`:n.frames[r]===void 0&&(n.frames[r]={}),(g=n.frames[r]).src_off=i?o:t-8,g.src_size=a+c+8,r++,i&&(i=!1,a=0,o=0);break;case`VP8X`:(g=n.header={}).feature_flags=e[t];var m=t+4;g.canvas_width=1+d(e,m),m+=3,g.canvas_height=1+d(e,m),m+=3;break;case`ALPH`:i=!0,a=p+8,o=t-8;break;case`ANIM`:(g=n.header).bgcolor=f(e,t),m=t+4,g.loop_count=u(e,m),m+=2;break;case`ANMF`:var h,g;(g=n.frames[r]={}).offset_x=2*d(e,t),t+=3,g.offset_y=2*d(e,t),t+=3,g.width=1+d(e,t),t+=3,g.height=1+d(e,t),t+=3,g.duration=d(e,t),t+=3,h=e[t++],g.dispose=1&h,g.blend=h>>1&1}s!=`ANMF`&&(t+=p)}return n}}(_,0);v.response=_,v.rgbaoutput=!0,v.dataurl=!1;var y=v.header?v.header:null,b=v.frames?v.frames:null;if(y){y.loop_counter=y.loop_count,p=[y.canvas_height],m=[y.canvas_width];for(var x=0;x<b.length&&b[x].blend!=0;x++);}var S=b[0],C=g.WebPDecodeRGBA(_,S.src_off,S.src_size,m,p);S.rgba=C,S.imgwidth=m[0],S.imgheight=p[0];for(var w=0;w<m[0]*p[0]*4;w++)h[w]=C[w];return this.width=m,this.height=p,this.data=h,this}function eI(){var e,t=this.internal.__metadata__.metadata,n=unescape(encodeURIComponent(t));e=this.internal.__metadata__.rawXml?n:`<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:jspdf="`+this.internal.__metadata__.namespaceUri+`"><jspdf:metadata>`+n.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)+`</jspdf:metadata></rdf:Description></rdf:RDF></x:xmpmeta>`,this.internal.__metadata__.metadataObjectNumber=this.internal.newObject(),this.internal.write(`<< /Type /Metadata /Subtype /XML /Length `+e.length+` >>`),this.internal.write(`stream`),this.internal.write(e),this.internal.write(`endstream`),this.internal.write(`endobj`)}function tI(){this.internal.__metadata__.metadataObjectNumber&&this.internal.write(`/Metadata `+this.internal.__metadata__.metadataObjectNumber+` 0 R`)}(function(e){var t,n,r,i,a,o,s,c,l,u=function(e){return e||={},this.isStrokeTransparent=e.isStrokeTransparent||!1,this.strokeOpacity=e.strokeOpacity||1,this.strokeStyle=e.strokeStyle||`#000000`,this.fillStyle=e.fillStyle||`#000000`,this.isFillTransparent=e.isFillTransparent||!1,this.fillOpacity=e.fillOpacity||1,this.font=e.font||`10px sans-serif`,this.textBaseline=e.textBaseline||`alphabetic`,this.textAlign=e.textAlign||`left`,this.lineWidth=e.lineWidth||1,this.lineJoin=e.lineJoin||`miter`,this.lineCap=e.lineCap||`butt`,this.path=e.path||[],this.transform=e.transform===void 0?new c:e.transform.clone(),this.globalCompositeOperation=e.globalCompositeOperation||`normal`,this.globalAlpha=e.globalAlpha||1,this.clip_path=e.clip_path||[],this.currentPoint=e.currentPoint||new o,this.miterLimit=e.miterLimit||10,this.lastPoint=e.lastPoint||new o,this.lineDashOffset=e.lineDashOffset||0,this.lineDash=e.lineDash||[],this.margin=e.margin||[0,0,0,0],this.prevPageLastElemOffset=e.prevPageLastElemOffset||0,this.ignoreClearRect=typeof e.ignoreClearRect!=`boolean`||e.ignoreClearRect,this};e.events.push([`initialized`,function(){this.context2d=new d(this),t=this.internal.f2,n=this.internal.getCoordinateString,r=this.internal.getVerticalCoordinateString,i=this.internal.getHorizontalCoordinate,a=this.internal.getVerticalCoordinate,o=this.internal.Point,s=this.internal.Rectangle,c=this.internal.Matrix,l=new u}]);var d=function(e){Object.defineProperty(this,"canvas",{get:function(){return{parentNode:!1,style:!1}}});var t=e;Object.defineProperty(this,"pdf",{get:function(){return t}});var n=!1;Object.defineProperty(this,"pageWrapXEnabled",{get:function(){return n},set:function(e){n=!!e}});var r=!1;Object.defineProperty(this,"pageWrapYEnabled",{get:function(){return r},set:function(e){r=!!e}});var i=0;Object.defineProperty(this,"posX",{get:function(){return i},set:function(e){isNaN(e)||(i=e)}});var a=0;Object.defineProperty(this,"posY",{get:function(){return a},set:function(e){isNaN(e)||(a=e)}}),Object.defineProperty(this,"margin",{get:function(){return l.margin},set:function(e){var t;typeof e==`number`?t=[e,e,e,e]:((t=[,,,,])[0]=e[0],t[1]=e.length>=2?e[1]:t[0],t[2]=e.length>=3?e[2]:t[0],t[3]=e.length>=4?e[3]:t[1]),l.margin=t}});var o=!1;Object.defineProperty(this,"autoPaging",{get:function(){return o},set:function(e){o=e}});var s=0;Object.defineProperty(this,"lastBreak",{get:function(){return s},set:function(e){s=e}});var c=[];Object.defineProperty(this,"pageBreaks",{get:function(){return c},set:function(e){c=e}}),Object.defineProperty(this,"ctx",{get:function(){return l},set:function(e){e instanceof u&&(l=e)}}),Object.defineProperty(this,"path",{get:function(){return l.path},set:function(e){l.path=e}});var d=[];Object.defineProperty(this,"ctxStack",{get:function(){return d},set:function(e){d=e}}),Object.defineProperty(this,"fillStyle",{get:function(){return this.ctx.fillStyle},set:function(e){var t=f(e);this.ctx.fillStyle=t.style,this.ctx.isFillTransparent=t.a===0,this.ctx.fillOpacity=t.a,this.pdf.setFillColor(t.r,t.g,t.b,{a:t.a}),this.pdf.setTextColor(t.r,t.g,t.b,{a:t.a})}}),Object.defineProperty(this,"strokeStyle",{get:function(){return this.ctx.strokeStyle},set:function(e){var t=f(e);this.ctx.strokeStyle=t.style,this.ctx.isStrokeTransparent=t.a===0,this.ctx.strokeOpacity=t.a,t.a===0?this.pdf.setDrawColor(255,255,255):(t.a,this.pdf.setDrawColor(t.r,t.g,t.b))}}),Object.defineProperty(this,"lineCap",{get:function(){return this.ctx.lineCap},set:function(e){[`butt`,`round`,`square`].indexOf(e)!==-1&&(this.ctx.lineCap=e,this.pdf.setLineCap(e))}}),Object.defineProperty(this,"lineWidth",{get:function(){return this.ctx.lineWidth},set:function(e){isNaN(e)||(this.ctx.lineWidth=e,this.pdf.setLineWidth(e))}}),Object.defineProperty(this,"lineJoin",{get:function(){return this.ctx.lineJoin},set:function(e){[`bevel`,`round`,`miter`].indexOf(e)!==-1&&(this.ctx.lineJoin=e,this.pdf.setLineJoin(e))}}),Object.defineProperty(this,"miterLimit",{get:function(){return this.ctx.miterLimit},set:function(e){isNaN(e)||(this.ctx.miterLimit=e,this.pdf.setMiterLimit(e))}}),Object.defineProperty(this,"textBaseline",{get:function(){return this.ctx.textBaseline},set:function(e){this.ctx.textBaseline=e}}),Object.defineProperty(this,"textAlign",{get:function(){return this.ctx.textAlign},set:function(e){[`right`,`end`,`center`,`left`,`start`].indexOf(e)!==-1&&(this.ctx.textAlign=e)}});var p=null,m=null,h=null;Object.defineProperty(this,"fontFaces",{get:function(){return h},set:function(e){p=null,m=null,h=e}}),Object.defineProperty(this,"font",{get:function(){return this.ctx.font},set:function(e){var t;if(this.ctx.font=e,(t=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z0-9]+?)\s*$/i.exec(e))!==null){var n=t[1];t[2];var r=t[3],i=t[4];t[5];var a=t[6],o=/^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i.exec(i)[2];i=Math.floor(o===`px`?parseFloat(i)*this.pdf.internal.scaleFactor:o===`em`?parseFloat(i)*this.pdf.getFontSize():parseFloat(i)*this.pdf.internal.scaleFactor),this.pdf.setFontSize(i);var s=function(e){var t,n,r=[],i=e.trim();if(i===``)return LF;if(i in DF)return[DF[i]];for(;i!==``;){switch(n=null,t=(i=kF(i)).charAt(0)){case`"`:case`'`:n=AF(i.substring(1),t);break;default:n=jF(i)}if(n===null||(r.push(n[0]),(i=kF(n[1]))!==``&&i.charAt(0)!==`,`))return LF;i=i.replace(/^,/,``)}return r}(a);if(this.fontFaces){var c=function(e,t,n){for(var r=(n||={}).defaultFontFamily||`times`,i=Object.assign({},EF,n.genericFontFamilies||{}),a=null,o=null,s=0;s<t.length;++s)if(i[(a=wF(t[s])).family]&&(a.family=i[a.family]),e.hasOwnProperty(a.family)){o=e[a.family];break}if(!(o||=e[r]))throw Error(`Could not find a font-family for the rule '`+OF(a)+`' and default family '`+r+`'.`);if(o=function(e,t){if(t[e])return t[e];var n=xF[e],r=TF(t,bF,n,n<=xF.normal?-1:1);if(!r)throw Error(`Could not find a matching font-stretch value for `+e);return r}(a.stretch,o),o=function(e,t){if(t[e])return t[e];for(var n=yF[e],r=0;r<n.length;++r)if(t[n[r]])return t[n[r]];throw Error(`Could not find a matching font-style for `+e)}(a.style,o),!(o=function(e,t){if(t[e])return t[e];if(e===400&&t[500])return t[500];if(e===500&&t[400])return t[400];var n=CF[e],r=TF(t,SF,n,e<400?-1:1);if(!r)throw Error(`Could not find a matching font-weight for value `+e);return r}(a.weight,o)))throw Error(`Failed to resolve a font for the rule '`+OF(a)+`'.`);return o}(function(e,t){var n=e.getFontList(),r=JSON.stringify(n);return(p===null||m!==r)&&(p=function(e){for(var t={},n=0;n<e.length;++n){var r=wF(e[n]),i=r.family,a=r.stretch,o=r.style,s=r.weight;t[i]=t[i]||{},t[i][a]=t[i][a]||{},t[i][a][o]=t[i][a][o]||{},t[i][a][o][s]=r}return t}(function(e){var t=[];return Object.keys(e).forEach(function(n){e[n].forEach(function(e){var r=null;switch(e){case`bold`:r={family:n,weight:`bold`};break;case`italic`:r={family:n,style:`italic`};break;case`bolditalic`:r={family:n,weight:`bold`,style:`italic`};break;case``:case`normal`:r={family:n}}r!==null&&(r.ref={name:n,style:e},t.push(r))})}),t}(n).concat(t)),m=r),p}(this.pdf,this.fontFaces),s.map(function(e){return{family:e,stretch:`normal`,weight:r,style:n}}));this.pdf.setFont(c.ref.name,c.ref.style)}else{var l=``;(r===`bold`||parseInt(r,10)>=700||n===`bold`)&&(l=`bold`),n===`italic`&&(l+=`italic`),l.length===0&&(l=`normal`);for(var u=``,d={arial:`Helvetica`,Arial:`Helvetica`,verdana:`Helvetica`,Verdana:`Helvetica`,helvetica:`Helvetica`,Helvetica:`Helvetica`,"sans-serif":`Helvetica`,fixed:`Courier`,monospace:`Courier`,terminal:`Courier`,cursive:`Times`,fantasy:`Times`,serif:`Times`},f=0;f<s.length;f++){if(this.pdf.internal.getFont(s[f],l,{noFallback:!0,disableWarning:!0})!==void 0){u=s[f];break}if(l===`bolditalic`&&this.pdf.internal.getFont(s[f],`bold`,{noFallback:!0,disableWarning:!0})!==void 0)u=s[f],l=`bold`;else if(this.pdf.internal.getFont(s[f],`normal`,{noFallback:!0,disableWarning:!0})!==void 0){u=s[f],l=`normal`;break}}if(u===``){for(var h=0;h<s.length;h++)if(d[s[h]]){u=d[s[h]];break}}u=u===``?`Times`:u,this.pdf.setFont(u,l)}}}}),Object.defineProperty(this,"globalCompositeOperation",{get:function(){return this.ctx.globalCompositeOperation},set:function(e){this.ctx.globalCompositeOperation=e}}),Object.defineProperty(this,"globalAlpha",{get:function(){return this.ctx.globalAlpha},set:function(e){this.ctx.globalAlpha=e}}),Object.defineProperty(this,"lineDashOffset",{get:function(){return this.ctx.lineDashOffset},set:function(e){this.ctx.lineDashOffset=e,L.call(this)}}),Object.defineProperty(this,"lineDash",{get:function(){return this.ctx.lineDash},set:function(e){this.ctx.lineDash=e,L.call(this)}}),Object.defineProperty(this,"ignoreClearRect",{get:function(){return this.ctx.ignoreClearRect},set:function(e){this.ctx.ignoreClearRect=!!e}})};d.prototype.setLineDash=function(e){this.lineDash=e},d.prototype.getLineDash=function(){return this.lineDash.length%2?this.lineDash.concat(this.lineDash):this.lineDash.slice()},d.prototype.fill=function(){b.call(this,`fill`,!1)},d.prototype.stroke=function(){b.call(this,`stroke`,!1)},d.prototype.beginPath=function(){this.path=[{type:`begin`}]},d.prototype.moveTo=function(e,t){if(isNaN(e)||isNaN(t))throw QN.error(`jsPDF.context2d.moveTo: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.moveTo`);var n=this.ctx.transform.applyToPoint(new o(e,t));this.path.push({type:`mt`,x:n.x,y:n.y}),this.ctx.lastPoint=new o(e,t)},d.prototype.closePath=function(){var e=new o(0,0),t=0;for(t=this.path.length-1;t!==-1;t--)if(this.path[t].type===`begin`&&hD(this.path[t+1])===`object`&&typeof this.path[t+1].x==`number`){e=new o(this.path[t+1].x,this.path[t+1].y);break}this.path.push({type:`close`}),this.ctx.lastPoint=new o(e.x,e.y)},d.prototype.lineTo=function(e,t){if(isNaN(e)||isNaN(t))throw QN.error(`jsPDF.context2d.lineTo: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.lineTo`);var n=this.ctx.transform.applyToPoint(new o(e,t));this.path.push({type:`lt`,x:n.x,y:n.y}),this.ctx.lastPoint=new o(n.x,n.y)},d.prototype.clip=function(){this.ctx.clip_path=JSON.parse(JSON.stringify(this.path)),b.call(this,null,!0)},d.prototype.quadraticCurveTo=function(e,t,n,r){if(isNaN(n)||isNaN(r)||isNaN(e)||isNaN(t))throw QN.error(`jsPDF.context2d.quadraticCurveTo: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.quadraticCurveTo`);var i=this.ctx.transform.applyToPoint(new o(n,r)),a=this.ctx.transform.applyToPoint(new o(e,t));this.path.push({type:`qct`,x1:a.x,y1:a.y,x:i.x,y:i.y}),this.ctx.lastPoint=new o(i.x,i.y)},d.prototype.bezierCurveTo=function(e,t,n,r,i,a){if(isNaN(i)||isNaN(a)||isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw QN.error(`jsPDF.context2d.bezierCurveTo: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.bezierCurveTo`);var s=this.ctx.transform.applyToPoint(new o(i,a)),c=this.ctx.transform.applyToPoint(new o(e,t)),l=this.ctx.transform.applyToPoint(new o(n,r));this.path.push({type:`bct`,x1:c.x,y1:c.y,x2:l.x,y2:l.y,x:s.x,y:s.y}),this.ctx.lastPoint=new o(s.x,s.y)},d.prototype.arc=function(e,t,n,r,i,a){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||isNaN(i))throw QN.error(`jsPDF.context2d.arc: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.arc`);if(a=!!a,!this.ctx.transform.isIdentity){var s=this.ctx.transform.applyToPoint(new o(e,t));e=s.x,t=s.y;var c=this.ctx.transform.applyToPoint(new o(0,n)),l=this.ctx.transform.applyToPoint(new o(0,0));n=Math.sqrt((c.x-l.x)**2+(c.y-l.y)**2)}Math.abs(i-r)>=2*Math.PI&&(r=0,i=2*Math.PI),this.path.push({type:`arc`,x:e,y:t,radius:n,startAngle:r,endAngle:i,counterclockwise:a})},d.prototype.arcTo=function(e,t,n,r,i){throw Error(`arcTo not implemented.`)},d.prototype.rect=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw QN.error(`jsPDF.context2d.rect: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.rect`);this.moveTo(e,t),this.lineTo(e+n,t),this.lineTo(e+n,t+r),this.lineTo(e,t+r),this.lineTo(e,t),this.lineTo(e+n,t),this.lineTo(e,t)},d.prototype.fillRect=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw QN.error(`jsPDF.context2d.fillRect: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.fillRect`);if(!p.call(this)){var i={};this.lineCap!==`butt`&&(i.lineCap=this.lineCap,this.lineCap=`butt`),this.lineJoin!==`miter`&&(i.lineJoin=this.lineJoin,this.lineJoin=`miter`),this.beginPath(),this.rect(e,t,n,r),this.fill(),i.hasOwnProperty(`lineCap`)&&(this.lineCap=i.lineCap),i.hasOwnProperty(`lineJoin`)&&(this.lineJoin=i.lineJoin)}},d.prototype.strokeRect=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw QN.error(`jsPDF.context2d.strokeRect: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.strokeRect`);m.call(this)||(this.beginPath(),this.rect(e,t,n,r),this.stroke())},d.prototype.clearRect=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw QN.error(`jsPDF.context2d.clearRect: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.clearRect`);this.ignoreClearRect||(this.fillStyle=`#ffffff`,this.fillRect(e,t,n,r))},d.prototype.save=function(e){e=typeof e!=`boolean`||e;for(var t=this.pdf.internal.getCurrentPageInfo().pageNumber,n=0;n<this.pdf.internal.getNumberOfPages();n++)this.pdf.setPage(n+1),this.pdf.internal.out(`q`);if(this.pdf.setPage(t),e){this.ctx.fontSize=this.pdf.internal.getFontSize();var r=new u(this.ctx);this.ctxStack.push(this.ctx),this.ctx=r}},d.prototype.restore=function(e){e=typeof e!=`boolean`||e;for(var t=this.pdf.internal.getCurrentPageInfo().pageNumber,n=0;n<this.pdf.internal.getNumberOfPages();n++)this.pdf.setPage(n+1),this.pdf.internal.out(`Q`);this.pdf.setPage(t),e&&this.ctxStack.length!==0&&(this.ctx=this.ctxStack.pop(),this.fillStyle=this.ctx.fillStyle,this.strokeStyle=this.ctx.strokeStyle,this.font=this.ctx.font,this.lineCap=this.ctx.lineCap,this.lineWidth=this.ctx.lineWidth,this.lineJoin=this.ctx.lineJoin,this.lineDash=this.ctx.lineDash,this.lineDashOffset=this.ctx.lineDashOffset)},d.prototype.toDataURL=function(){throw Error(`toDataUrl not implemented.`)};var f=function(e){var t,n,r,i;if(!0===e.isCanvasGradient&&(e=e.getColor()),!e)return{r:0,g:0,b:0,a:0,style:e};if(/transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/.test(e))t=0,n=0,r=0,i=0;else{var a=/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(e);if(a!==null)t=parseInt(a[1]),n=parseInt(a[2]),r=parseInt(a[3]),i=1;else if((a=/rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/.exec(e))!==null)t=parseInt(a[1]),n=parseInt(a[2]),r=parseInt(a[3]),i=parseFloat(a[4]);else{if(i=1,typeof e==`string`&&e.charAt(0)!==`#`){var o=new rP(e);e=o.ok?o.toHex():`#000000`}e.length===4?(t=e.substring(1,2),t+=t,n=e.substring(2,3),n+=n,r=e.substring(3,4),r+=r):(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7)),t=parseInt(t,16),n=parseInt(n,16),r=parseInt(r,16)}}return{r:t,g:n,b:r,a:i,style:e}},p=function(){return this.ctx.isFillTransparent||this.globalAlpha==0},m=function(){return!!(this.ctx.isStrokeTransparent||this.globalAlpha==0)};d.prototype.fillText=function(e,t,n,r){if(isNaN(t)||isNaN(n)||typeof e!=`string`)throw QN.error(`jsPDF.context2d.fillText: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.fillText`);if(r=isNaN(r)?void 0:r,!p.call(this)){var i=P(this.ctx.transform.rotation),a=this.ctx.transform.scaleX;O.call(this,{text:e,x:t,y:n,scale:a,angle:i,align:this.textAlign,maxWidth:r})}},d.prototype.strokeText=function(e,t,n,r){if(isNaN(t)||isNaN(n)||typeof e!=`string`)throw QN.error(`jsPDF.context2d.strokeText: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.strokeText`);if(!m.call(this)){r=isNaN(r)?void 0:r;var i=P(this.ctx.transform.rotation),a=this.ctx.transform.scaleX;O.call(this,{text:e,x:t,y:n,scale:a,renderingMode:`stroke`,angle:i,align:this.textAlign,maxWidth:r})}},d.prototype.measureText=function(e){if(typeof e!=`string`)throw QN.error(`jsPDF.context2d.measureText: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.measureText`);var t=this.pdf,n=this.pdf.internal.scaleFactor,r=t.internal.getFontSize(),i=t.getStringUnitWidth(e)*r/t.internal.scaleFactor;return new function(e){var t=(e||={}).width||0;return Object.defineProperty(this,"width",{get:function(){return t}}),this}({width:i*=Math.round(96*n/72*1e4)/1e4})},d.prototype.scale=function(e,t){if(isNaN(e)||isNaN(t))throw QN.error(`jsPDF.context2d.scale: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.scale`);var n=new c(e,0,0,t,0,0);this.ctx.transform=this.ctx.transform.multiply(n)},d.prototype.rotate=function(e){if(isNaN(e))throw QN.error(`jsPDF.context2d.rotate: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.rotate`);var t=new c(Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0);this.ctx.transform=this.ctx.transform.multiply(t)},d.prototype.translate=function(e,t){if(isNaN(e)||isNaN(t))throw QN.error(`jsPDF.context2d.translate: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.translate`);var n=new c(1,0,0,1,e,t);this.ctx.transform=this.ctx.transform.multiply(n)},d.prototype.transform=function(e,t,n,r,i,a){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||isNaN(i)||isNaN(a))throw QN.error(`jsPDF.context2d.transform: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.transform`);var o=new c(e,t,n,r,i,a);this.ctx.transform=this.ctx.transform.multiply(o)},d.prototype.setTransform=function(e,t,n,r,i,a){e=isNaN(e)?1:e,t=isNaN(t)?0:t,n=isNaN(n)?0:n,r=isNaN(r)?1:r,i=isNaN(i)?0:i,a=isNaN(a)?0:a,this.ctx.transform=new c(e,t,n,r,i,a)};var h=function(){return this.margin[0]>0||this.margin[1]>0||this.margin[2]>0||this.margin[3]>0};d.prototype.drawImage=function(e,t,n,r,i,a,o,l,u){var d=this.pdf.getImageProperties(e),f=1,p=1,m=1,_=1;r!==void 0&&l!==void 0&&(m=l/r,_=u/i,f=d.width/r*l/r,p=d.height/i*u/i),a===void 0&&(a=t,o=n,t=0,n=0),r!==void 0&&l===void 0&&(l=r,u=i),r===void 0&&l===void 0&&(l=d.width,u=d.height);var b=this.ctx.transform.decompose(),S=P(b.rotate.shx),C=new c,w=(C=(C=(C=C.multiply(b.translate)).multiply(b.skew)).multiply(b.scale)).applyToRectangle(new s(a-t*m,o-n*_,r*f,i*p));if(this.autoPaging){for(var T,E=g.call(this,w),D=[],O=0;O<E.length;O+=1)D.indexOf(E[O])===-1&&D.push(E[O]);y(D);for(var k=D[0],A=D[D.length-1],j=k;j<A+1;j++){this.pdf.setPage(j);var M=this.pdf.internal.pageSize.width-this.margin[3]-this.margin[1],N=j===1?this.posY+this.margin[0]:this.margin[0],F=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],I=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2],L=j===1?0:F+(j-2)*I;if(this.ctx.clip_path.length!==0){var ee=this.path;T=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=v(T,this.posX+this.margin[3],-L+N+this.ctx.prevPageLastElemOffset),x.call(this,`fill`,!0),this.path=ee}var R=JSON.parse(JSON.stringify(w));R=v([R],this.posX+this.margin[3],-L+N+this.ctx.prevPageLastElemOffset)[0];var te=(j>k||j<A)&&h.call(this);te&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],M,I,null).clip().discardPath()),this.pdf.addImage(e,`JPEG`,R.x,R.y,R.w,R.h,null,null,S),te&&this.pdf.restoreGraphicsState()}}else this.pdf.addImage(e,`JPEG`,w.x,w.y,w.w,w.h,null,null,S)};var g=function(e,t,n){var r=[];t||=this.pdf.internal.pageSize.width,n||=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2];var i=this.posY+this.ctx.prevPageLastElemOffset;switch(e.type){default:case`mt`:case`lt`:r.push(Math.floor((e.y+i)/n)+1);break;case`arc`:r.push(Math.floor((e.y+i-e.radius)/n)+1),r.push(Math.floor((e.y+i+e.radius)/n)+1);break;case`qct`:var a=F(this.ctx.lastPoint.x,this.ctx.lastPoint.y,e.x1,e.y1,e.x,e.y);r.push(Math.floor((a.y+i)/n)+1),r.push(Math.floor((a.y+a.h+i)/n)+1);break;case`bct`:var o=I(this.ctx.lastPoint.x,this.ctx.lastPoint.y,e.x1,e.y1,e.x2,e.y2,e.x,e.y);r.push(Math.floor((o.y+i)/n)+1),r.push(Math.floor((o.y+o.h+i)/n)+1);break;case`rect`:r.push(Math.floor((e.y+i)/n)+1),r.push(Math.floor((e.y+e.h+i)/n)+1)}for(var s=0;s<r.length;s+=1)for(;this.pdf.internal.getNumberOfPages()<r[s];)_.call(this);return r},_=function(){var e=this.fillStyle,t=this.strokeStyle,n=this.font,r=this.lineCap,i=this.lineWidth,a=this.lineJoin;this.pdf.addPage(),this.fillStyle=e,this.strokeStyle=t,this.font=n,this.lineCap=r,this.lineWidth=i,this.lineJoin=a},v=function(e,t,n){for(var r=0;r<e.length;r++)switch(e[r].type){case`bct`:e[r].x2+=t,e[r].y2+=n;case`qct`:e[r].x1+=t,e[r].y1+=n;default:e[r].x+=t,e[r].y+=n}return e},y=function(e){return e.sort(function(e,t){return e-t})},b=function(e,t){var n=this.fillStyle,r=this.strokeStyle,i=this.lineCap,a=this.lineWidth,o=Math.abs(a*this.ctx.transform.scaleX),s=this.lineJoin;if(this.autoPaging){for(var c,l,u=JSON.parse(JSON.stringify(this.path)),d=JSON.parse(JSON.stringify(this.path)),f=[],p=0;p<d.length;p++)if(d[p].x!==void 0)for(var m=g.call(this,d[p]),b=0;b<m.length;b+=1)f.indexOf(m[b])===-1&&f.push(m[b]);for(var S=0;S<f.length;S++)for(;this.pdf.internal.getNumberOfPages()<f[S];)_.call(this);y(f);for(var C=f[0],w=f[f.length-1],T=C;T<w+1;T++){this.pdf.setPage(T),this.fillStyle=n,this.strokeStyle=r,this.lineCap=i,this.lineWidth=o,this.lineJoin=s;var E=this.pdf.internal.pageSize.width-this.margin[3]-this.margin[1],D=T===1?this.posY+this.margin[0]:this.margin[0],O=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],k=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2],A=T===1?0:O+(T-2)*k;if(this.ctx.clip_path.length!==0){var j=this.path;c=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=v(c,this.posX+this.margin[3],-A+D+this.ctx.prevPageLastElemOffset),x.call(this,e,!0),this.path=j}if(l=JSON.parse(JSON.stringify(u)),this.path=v(l,this.posX+this.margin[3],-A+D+this.ctx.prevPageLastElemOffset),!1===t||T===0){var M=(T>C||T<w)&&h.call(this);M&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],E,k,null).clip().discardPath()),x.call(this,e,t),M&&this.pdf.restoreGraphicsState()}this.lineWidth=a}this.path=u}else this.lineWidth=o,x.call(this,e,t),this.lineWidth=a},x=function(e,t){if((e!==`stroke`||t||!m.call(this))&&(e===`stroke`||t||!p.call(this))){for(var n,r,i=[],a=this.path,o=0;o<a.length;o++){var s=a[o];switch(s.type){case`begin`:i.push({begin:!0});break;case`close`:i.push({close:!0});break;case`mt`:i.push({start:s,deltas:[],abs:[]});break;case`lt`:var c=i.length;if(a[o-1]&&!isNaN(a[o-1].x)&&(n=[s.x-a[o-1].x,s.y-a[o-1].y],c>0)){for(;c>=0;c--)if(!0!==i[c-1].close&&!0!==i[c-1].begin){i[c-1].deltas.push(n),i[c-1].abs.push(s);break}}break;case`bct`:n=[s.x1-a[o-1].x,s.y1-a[o-1].y,s.x2-a[o-1].x,s.y2-a[o-1].y,s.x-a[o-1].x,s.y-a[o-1].y],i[i.length-1].deltas.push(n);break;case`qct`:var l=a[o-1].x+2/3*(s.x1-a[o-1].x),u=a[o-1].y+2/3*(s.y1-a[o-1].y),d=s.x+2/3*(s.x1-s.x),f=s.y+2/3*(s.y1-s.y),h=s.x,g=s.y;n=[l-a[o-1].x,u-a[o-1].y,d-a[o-1].x,f-a[o-1].y,h-a[o-1].x,g-a[o-1].y],i[i.length-1].deltas.push(n);break;case`arc`:i.push({deltas:[],abs:[],arc:!0}),Array.isArray(i[i.length-1].abs)&&i[i.length-1].abs.push(s)}}r=t?null:e===`stroke`?`stroke`:`fill`;for(var _=!1,v=0;v<i.length;v++)if(i[v].arc)for(var y=i[v].abs,b=0;b<y.length;b++){var x=y[b];x.type===`arc`?w.call(this,x.x,x.y,x.radius,x.startAngle,x.endAngle,x.counterclockwise,void 0,t,!_):k.call(this,x.x,x.y),_=!0}else if(!0===i[v].close)this.pdf.internal.out(`h`),_=!1;else if(!0!==i[v].begin){var S=i[v].start.x,C=i[v].start.y;A.call(this,i[v].deltas,S,C),_=!0}r&&T.call(this,r),t&&E.call(this)}},S=function(e){var t=this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor,n=t*(this.pdf.internal.getLineHeightFactor()-1);switch(this.ctx.textBaseline){case`bottom`:return e-n;case`top`:return e+t-n;case`hanging`:return e+t-2*n;case`middle`:return e+t/2-n;default:return e}},C=function(e){return e+this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor*(this.pdf.internal.getLineHeightFactor()-1)};d.prototype.createLinearGradient=function(){var e=function(){};return e.colorStops=[],e.addColorStop=function(e,t){this.colorStops.push([e,t])},e.getColor=function(){return this.colorStops.length===0?`#000000`:this.colorStops[0][1]},e.isCanvasGradient=!0,e},d.prototype.createPattern=function(){return this.createLinearGradient()},d.prototype.createRadialGradient=function(){return this.createLinearGradient()};var w=function(e,t,n,r,i,a,o,s,c){for(var l=M.call(this,n,r,i,a),u=0;u<l.length;u++){var d=l[u];u===0&&(c?D.call(this,d.x1+e,d.y1+t):k.call(this,d.x1+e,d.y1+t)),j.call(this,e,t,d.x2,d.y2,d.x3,d.y3,d.x4,d.y4)}s?E.call(this):T.call(this,o)},T=function(e){switch(e){case`stroke`:this.pdf.internal.out(`S`);break;case`fill`:this.pdf.internal.out(`f`)}},E=function(){this.pdf.clip(),this.pdf.discardPath()},D=function(e,t){this.pdf.internal.out(n(e)+` `+r(t)+` m`)},O=function(e){var t;switch(e.align){case`right`:case`end`:t=`right`;break;case`center`:t=`center`;break;default:t=`left`}var n,r,i,a=this.pdf.getTextDimensions(e.text),l=S.call(this,e.y),u=C.call(this,l)-a.h,d=this.ctx.transform.applyToPoint(new o(e.x,l));if(this.autoPaging){var f=this.ctx.transform.decompose(),p=new c;p=(p=(p=p.multiply(f.translate)).multiply(f.skew)).multiply(f.scale);for(var m=this.ctx.transform.applyToRectangle(new s(e.x,l,a.w,a.h)),_=p.applyToRectangle(new s(e.x,u,a.w,a.h)),b=g.call(this,_),w=[],T=0;T<b.length;T+=1)w.indexOf(b[T])===-1&&w.push(b[T]);y(w);for(var E=w[0],D=w[w.length-1],O=E;O<D+1;O++){this.pdf.setPage(O);var k=O===1?this.posY+this.margin[0]:this.margin[0],A=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],j=this.pdf.internal.pageSize.height-this.margin[2],M=j-this.margin[0],N=this.pdf.internal.pageSize.width-this.margin[1],P=N-this.margin[3],F=O===1?0:A+(O-2)*M;if(this.ctx.clip_path.length!==0){var I=this.path;n=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=v(n,this.posX+this.margin[3],-1*F+k),x.call(this,`fill`,!0),this.path=I}var L=v([JSON.parse(JSON.stringify(_))],this.posX+this.margin[3],-F+k+this.ctx.prevPageLastElemOffset)[0];e.scale>=.01&&(r=this.pdf.internal.getFontSize(),this.pdf.setFontSize(r*e.scale),i=this.lineWidth,this.lineWidth=i*e.scale);var ee=this.autoPaging!==`text`;if(ee||L.y+L.h<=j){if(ee||L.y>=k&&L.x<=N){var R=ee?e.text:this.pdf.splitTextToSize(e.text,e.maxWidth||N-L.x)[0],te=v([JSON.parse(JSON.stringify(m))],this.posX+this.margin[3],-F+k+this.ctx.prevPageLastElemOffset)[0],z=ee&&(O>E||O<D)&&h.call(this);z&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],P,M,null).clip().discardPath()),this.pdf.text(R,te.x,te.y,{angle:e.angle,align:t,renderingMode:e.renderingMode}),z&&this.pdf.restoreGraphicsState()}}else L.y<j&&(this.ctx.prevPageLastElemOffset+=j-L.y);e.scale>=.01&&(this.pdf.setFontSize(r),this.lineWidth=i)}}else e.scale>=.01&&(r=this.pdf.internal.getFontSize(),this.pdf.setFontSize(r*e.scale),i=this.lineWidth,this.lineWidth=i*e.scale),this.pdf.text(e.text,d.x+this.posX,d.y+this.posY,{angle:e.angle,align:t,renderingMode:e.renderingMode,maxWidth:e.maxWidth}),e.scale>=.01&&(this.pdf.setFontSize(r),this.lineWidth=i)},k=function(e,t,i,a){i||=0,a||=0,this.pdf.internal.out(n(e+i)+` `+r(t+a)+` l`)},A=function(e,t,n){return this.pdf.lines(e,t,n,null,null)},j=function(e,n,r,o,s,c,l,u){this.pdf.internal.out([t(i(r+e)),t(a(o+n)),t(i(s+e)),t(a(c+n)),t(i(l+e)),t(a(u+n)),`c`].join(` `))},M=function(e,t,n,r){for(var i=2*Math.PI,a=Math.PI/2;t>n;)t-=i;var o=Math.abs(n-t);o<i&&r&&(o=i-o);for(var s=[],c=r?-1:1,l=t;o>1e-5;){var u=l+c*Math.min(o,a);s.push(N.call(this,e,l,u)),o-=Math.abs(u-l),l=u}return s},N=function(e,t,n){var r=(n-t)/2,i=e*Math.cos(r),a=e*Math.sin(r),o=i,s=-a,c=o*o+s*s,l=c+o*i+s*a,u=4/3*(Math.sqrt(2*c*l)-l)/(o*a-s*i),d=o-u*s,f=s+u*o,p=d,m=-f,h=r+t,g=Math.cos(h),_=Math.sin(h);return{x1:e*Math.cos(t),y1:e*Math.sin(t),x2:d*g-f*_,y2:d*_+f*g,x3:p*g-m*_,y3:p*_+m*g,x4:e*Math.cos(n),y4:e*Math.sin(n)}},P=function(e){return 180*e/Math.PI},F=function(e,t,n,r,i,a){var o=e+.5*(n-e),c=t+.5*(r-t),l=i+.5*(n-i),u=a+.5*(r-a),d=Math.min(e,i,o,l),f=Math.max(e,i,o,l),p=Math.min(t,a,c,u),m=Math.max(t,a,c,u);return new s(d,p,f-d,m-p)},I=function(e,t,n,r,i,a,o,c){var l,u,d,f,p,m,h,g,_,v,y,b,x,S,C=n-e,w=r-t,T=i-n,E=a-r,D=o-i,O=c-a;for(u=0;u<41;u++)_=(h=(d=e+(l=u/40)*C)+l*((p=n+l*T)-d))+l*(p+l*(i+l*D-p)-h),v=(g=(f=t+l*w)+l*((m=r+l*E)-f))+l*(m+l*(a+l*O-m)-g),u==0?(y=_,b=v,x=_,S=v):(y=Math.min(y,_),b=Math.min(b,v),x=Math.max(x,_),S=Math.max(S,v));return new s(Math.round(y),Math.round(b),Math.round(x-y),Math.round(S-b))},L=function(){if(this.prevLineDash||this.ctx.lineDash.length||this.ctx.lineDashOffset){var e,t,n=(e=this.ctx.lineDash,t=this.ctx.lineDashOffset,JSON.stringify({lineDash:e,lineDashOffset:t}));this.prevLineDash!==n&&(this.pdf.setLineDash(this.ctx.lineDash,this.ctx.lineDashOffset),this.prevLineDash=n)}}})(kP.API),function(e){var t=function(e){var t,n,r,i,a,o,s,c,l,u;for(/[^\x00-\xFF]/.test(e),n=[],r=0,i=(e+=t=`\0\0\0\0`.slice(e.length%4||4)).length;i>r;r+=4)(a=(e.charCodeAt(r)<<24)+(e.charCodeAt(r+1)<<16)+(e.charCodeAt(r+2)<<8)+e.charCodeAt(r+3))===0?n.push(122):(o=(a=((a=((a=((a=(a-(u=a%85))/85)-(l=a%85))/85)-(c=a%85))/85)-(s=a%85))/85)%85,n.push(o+33,s+33,c+33,l+33,u+33));return function(e,t){for(var n=t;n>0;n--)e.pop()}(n,t.length),String.fromCharCode.apply(String,n)+`~>`},n=function(e){var t,n,r,i,a,o=String,s=`length`,c=255,l=`charCodeAt`,u=`slice`,d=`replace`;for(e[u](-2),e=e[u](0,-2)[d](/\s/g,``)[d](`z`,`!!!!!`),r=[],i=0,a=(e+=t=`uuuuu`[u](e[s]%5||5))[s];a>i;i+=5)n=52200625*(e[l](i)-33)+614125*(e[l](i+1)-33)+7225*(e[l](i+2)-33)+85*(e[l](i+3)-33)+(e[l](i+4)-33),r.push(c&n>>24,c&n>>16,c&n>>8,c&n);return function(e,t){for(var n=t;n>0;n--)e.pop()}(r,t[s]),o.fromCharCode.apply(o,r)},r=function(e){return e.split(``).map(function(e){return(`0`+e.charCodeAt().toString(16)).slice(-2)}).join(``)+`>`},i=function(e){var t=new RegExp(/^([0-9A-Fa-f]{2})+$/);if((e=e.replace(/\s/g,``)).indexOf(`>`)!==-1&&(e=e.substr(0,e.indexOf(`>`))),e.length%2&&(e+=`0`),!1===t.test(e))return``;for(var n=``,r=0;r<e.length;r+=2)n+=String.fromCharCode(`0x`+(e[r]+e[r+1]));return n},a=function(e){for(var t=new Uint8Array(e.length),n=e.length;n--;)t[n]=e.charCodeAt(n);return(t=$D(t)).reduce(function(e,t){return e+String.fromCharCode(t)},``)};e.processDataByFilters=function(e,o){var s=0,c=e||``,l=[];for(typeof(o||=[])==`string`&&(o=[o]),s=0;s<o.length;s+=1)switch(o[s]){case`ASCII85Decode`:case`/ASCII85Decode`:c=n(c),l.push(`/ASCII85Encode`);break;case`ASCII85Encode`:case`/ASCII85Encode`:c=t(c),l.push(`/ASCII85Decode`);break;case`ASCIIHexDecode`:case`/ASCIIHexDecode`:c=i(c),l.push(`/ASCIIHexEncode`);break;case`ASCIIHexEncode`:case`/ASCIIHexEncode`:c=r(c),l.push(`/ASCIIHexDecode`);break;case`FlateEncode`:case`/FlateEncode`:c=a(c),l.push(`/FlateDecode`);break;default:throw Error(`The filter: "`+o[s]+`" is not implemented`)}return{data:c,reverseChain:l.reverse().join(` `)}}}(kP.API),function(e){e.loadFile=function(e,t,n){return function(e,t,n){t=!1!==t,n=typeof n==`function`?n:function(){};var r=void 0;try{r=function(e,t,n){var r=new XMLHttpRequest,i=0,a=function(e){var t=e.length,n=[],r=String.fromCharCode;for(i=0;i<t;i+=1)n.push(r(255&e.charCodeAt(i)));return n.join(``)};if(r.open(`GET`,e,!t),r.overrideMimeType(`text/plain; charset=x-user-defined`),!1===t&&(r.onload=function(){r.status===200?n(a(this.responseText)):n(void 0)}),r.send(null),t&&r.status===200)return a(r.responseText)}(e,t,n)}catch{}return r}(e,t,n)},e.allowFsRead=void 0,e.loadImageFile=e.loadFile}(kP.API),function(e){function t(){return(XN.html2canvas?Promise.resolve(XN.html2canvas):Gb(()=>import(`./html2canvas-B1jts0tz.js`).then(e=>l(e.default)),[])).catch(function(e){return Promise.reject(Error(`Could not load html2canvas: `+e))}).then(function(e){return e.default?e.default:e})}function n(){return(XN.DOMPurify?Promise.resolve(XN.DOMPurify):Gb(()=>import(`./purify.es-DlxR2Lg_.js`),[])).catch(function(e){return Promise.reject(Error(`Could not load dompurify: `+e))}).then(function(e){return e.default?e.default:e})}var r=function(e){var t=hD(e);return t===`undefined`?`undefined`:t===`string`||e instanceof String?`string`:t===`number`||e instanceof Number?`number`:t===`function`||e instanceof Function?`function`:e&&e.constructor===Array?`array`:e&&e.nodeType===1?`element`:t===`object`?`object`:`unknown`},i=function(e,t){var n=document.createElement(e);for(var r in t.className&&(n.className=t.className),t.innerHTML&&t.dompurify&&(n.innerHTML=t.dompurify.sanitize(t.innerHTML)),t.style)n.style[r]=t.style[r];return n},a=function e(t,n){for(var r=t.nodeType===3?document.createTextNode(t.nodeValue):t.cloneNode(!1),i=t.firstChild;i;i=i.nextSibling)!0!==n&&i.nodeType===1&&i.nodeName===`SCRIPT`||r.appendChild(e(i,n));return t.nodeType===1&&(t.nodeName===`CANVAS`?(r.width=t.width,r.height=t.height,r.getContext(`2d`).drawImage(t,0,0)):t.nodeName!==`TEXTAREA`&&t.nodeName!==`SELECT`||(r.value=t.value),r.addEventListener(`load`,function(){r.scrollTop=t.scrollTop,r.scrollLeft=t.scrollLeft},!0)),r},o=function e(t){var n=Object.assign(e.convert(Promise.resolve()),JSON.parse(JSON.stringify(e.template))),r=e.convert(Promise.resolve(),n);return(r=r.setProgress(1,e,1,[e])).set(t)};(o.prototype=Object.create(Promise.prototype)).constructor=o,o.convert=function(e,t){return e.__proto__=t||o.prototype,e},o.template={prop:{src:null,container:null,overlay:null,canvas:null,img:null,pdf:null,pageSize:null,callback:function(){}},progress:{val:0,state:null,n:0,stack:[]},opt:{filename:`file.pdf`,margin:[0,0,0,0],enableLinks:!0,x:0,y:0,html2canvas:{},jsPDF:{},backgroundColor:`transparent`}},o.prototype.from=function(e,t){return this.then(function(){switch(t||=function(e){switch(r(e)){case`string`:return`string`;case`element`:return e.nodeName.toLowerCase()===`canvas`?`canvas`:`element`;default:return`unknown`}}(e),t){case`string`:return this.then(n).then(function(t){return this.set({src:i(`div`,{innerHTML:e,dompurify:t})})});case`element`:return this.set({src:e});case`canvas`:return this.set({canvas:e});case`img`:return this.set({img:e});default:return this.error(`Unknown source type.`)}})},o.prototype.to=function(e){switch(e){case`container`:return this.toContainer();case`canvas`:return this.toCanvas();case`img`:return this.toImg();case`pdf`:return this.toPdf();default:return this.error(`Invalid target.`)}},o.prototype.toContainer=function(){return this.thenList([function(){return this.prop.src||this.error(`Cannot duplicate - no source HTML.`)},function(){return this.prop.pageSize||this.setPageSize()}]).then(function(){var e={position:`relative`,display:`inline-block`,width:(typeof this.opt.width!=`number`||isNaN(this.opt.width)||typeof this.opt.windowWidth!=`number`||isNaN(this.opt.windowWidth)?Math.max(this.prop.src.clientWidth,this.prop.src.scrollWidth,this.prop.src.offsetWidth):this.opt.windowWidth)+`px`,left:0,right:0,top:0,margin:`auto`,backgroundColor:this.opt.backgroundColor},t=a(this.prop.src,this.opt.html2canvas.javascriptEnabled);t.tagName===`BODY`&&(e.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)+`px`),this.prop.overlay=i(`div`,{className:`html2pdf__overlay`,style:{position:`fixed`,overflow:`hidden`,zIndex:1e3,left:`-100000px`,right:0,bottom:0,top:0}}),this.prop.container=i(`div`,{className:`html2pdf__container`,style:e}),this.prop.container.appendChild(t),this.prop.container.firstChild.appendChild(i(`div`,{style:{clear:`both`,border:`0 none transparent`,margin:0,padding:0,height:0}})),this.prop.container.style.float=`none`,this.prop.overlay.appendChild(this.prop.container),document.body.appendChild(this.prop.overlay),this.prop.container.firstChild.style.position=`relative`,this.prop.container.height=Math.max(this.prop.container.firstChild.clientHeight,this.prop.container.firstChild.scrollHeight,this.prop.container.firstChild.offsetHeight)+`px`})},o.prototype.toCanvas=function(){return this.thenList([function(){return document.body.contains(this.prop.container)||this.toContainer()}]).then(t).then(function(e){var t=Object.assign({},this.opt.html2canvas);return delete t.onrendered,e(this.prop.container,t)}).then(function(e){(this.opt.html2canvas.onrendered||function(){})(e),this.prop.canvas=e,document.body.removeChild(this.prop.overlay)})},o.prototype.toContext2d=function(){return this.thenList([function(){return document.body.contains(this.prop.container)||this.toContainer()}]).then(t).then(function(e){var t=this.opt.jsPDF,n=this.opt.fontFaces,r=typeof this.opt.width!=`number`||isNaN(this.opt.width)||typeof this.opt.windowWidth!=`number`||isNaN(this.opt.windowWidth)?1:this.opt.width/this.opt.windowWidth,i=Object.assign({async:!0,allowTaint:!0,scale:r,scrollX:this.opt.scrollX||0,scrollY:this.opt.scrollY||0,backgroundColor:`#ffffff`,imageTimeout:15e3,logging:!0,proxy:null,removeContainer:!0,foreignObjectRendering:!1,useCORS:!1},this.opt.html2canvas);if(delete i.onrendered,t.context2d.autoPaging=this.opt.autoPaging===void 0||this.opt.autoPaging,t.context2d.posX=this.opt.x,t.context2d.posY=this.opt.y,t.context2d.margin=this.opt.margin,t.context2d.fontFaces=n,n)for(var a=0;a<n.length;++a){var o=n[a],s=o.src.find(function(e){return e.format===`truetype`});s&&t.addFont(s.url,o.ref.name,o.ref.style)}return i.windowHeight=i.windowHeight||0,i.windowHeight=i.windowHeight==0?Math.max(this.prop.container.clientHeight,this.prop.container.scrollHeight,this.prop.container.offsetHeight):i.windowHeight,t.context2d.save(!0),e(this.prop.container,i)}).then(function(e){this.opt.jsPDF.context2d.restore(!0),(this.opt.html2canvas.onrendered||function(){})(e),this.prop.canvas=e,document.body.removeChild(this.prop.overlay)})},o.prototype.toImg=function(){return this.thenList([function(){return this.prop.canvas||this.toCanvas()}]).then(function(){var e=this.prop.canvas.toDataURL(`image/`+this.opt.image.type,this.opt.image.quality);this.prop.img=document.createElement(`img`),this.prop.img.src=e})},o.prototype.toPdf=function(){return this.thenList([function(){return this.toContext2d()}]).then(function(){this.prop.pdf=this.prop.pdf||this.opt.jsPDF})},o.prototype.output=function(e,t,n){return(n||=`pdf`).toLowerCase()===`img`||n.toLowerCase()===`image`?this.outputImg(e,t):this.outputPdf(e,t)},o.prototype.outputPdf=function(e,t){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then(function(){return this.prop.pdf.output(e,t)})},o.prototype.outputImg=function(e){return this.thenList([function(){return this.prop.img||this.toImg()}]).then(function(){switch(e){case void 0:case`img`:return this.prop.img;case`datauristring`:case`dataurlstring`:return this.prop.img.src;case`datauri`:case`dataurl`:return document.location.href=this.prop.img.src;default:throw`Image output type "`+e+`" is not supported.`}})},o.prototype.save=function(e){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).set(e?{filename:e}:null).then(function(){this.prop.pdf.save(this.opt.filename)})},o.prototype.doCallback=function(){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then(function(){this.prop.callback(this.prop.pdf)})},o.prototype.set=function(e){if(r(e)!==`object`)return this;var t=Object.keys(e||{}).map(function(t){if(t in o.template.prop)return function(){this.prop[t]=e[t]};switch(t){case`margin`:return this.setMargin.bind(this,e.margin);case`jsPDF`:return function(){return this.opt.jsPDF=e.jsPDF,this.setPageSize()};case`pageSize`:return this.setPageSize.bind(this,e.pageSize);default:return function(){this.opt[t]=e[t]}}},this);return this.then(function(){return this.thenList(t)})},o.prototype.get=function(e,t){return this.then(function(){var n=e in o.template.prop?this.prop[e]:this.opt[e];return t?t(n):n})},o.prototype.setMargin=function(e){return this.then(function(){switch(r(e)){case`number`:e=[e,e,e,e];case`array`:if(e.length===2&&(e=[e[0],e[1],e[0],e[1]]),e.length===4)break;default:return this.error(`Invalid margin array.`)}this.opt.margin=e}).then(this.setPageSize)},o.prototype.setPageSize=function(e){function t(e,t){return Math.floor(e*t/72*96)}return this.then(function(){(e||=kP.getPageSize(this.opt.jsPDF)).hasOwnProperty(`inner`)||(e.inner={width:e.width-this.opt.margin[1]-this.opt.margin[3],height:e.height-this.opt.margin[0]-this.opt.margin[2]},e.inner.px={width:t(e.inner.width,e.k),height:t(e.inner.height,e.k)},e.inner.ratio=e.inner.height/e.inner.width),this.prop.pageSize=e})},o.prototype.setProgress=function(e,t,n,r){return e!=null&&(this.progress.val=e),t!=null&&(this.progress.state=t),n!=null&&(this.progress.n=n),r!=null&&(this.progress.stack=r),this.progress.ratio=this.progress.val/this.progress.state,this},o.prototype.updateProgress=function(e,t,n,r){return this.setProgress(e?this.progress.val+e:null,t||null,n?this.progress.n+n:null,r?this.progress.stack.concat(r):null)},o.prototype.then=function(e,t){var n=this;return this.thenCore(e,t,function(e,t){return n.updateProgress(null,null,1,[e]),Promise.prototype.then.call(this,function(t){return n.updateProgress(null,e),t}).then(e,t).then(function(e){return n.updateProgress(1),e})})},o.prototype.thenCore=function(e,t,n){n||=Promise.prototype.then;var r=this;e&&=e.bind(r),t&&=t.bind(r);var i=Promise.toString().indexOf(`[native code]`)!==-1&&Promise.name===`Promise`?r:o.convert(Object.assign({},r),Promise.prototype),a=n.call(i,e,t);return o.convert(a,r.__proto__)},o.prototype.thenExternal=function(e,t){return Promise.prototype.then.call(this,e,t)},o.prototype.thenList=function(e){var t=this;return e.forEach(function(e){t=t.thenCore(e)}),t},o.prototype.catch=function(e){e&&=e.bind(this);var t=Promise.prototype.catch.call(this,e);return o.convert(t,this)},o.prototype.catchExternal=function(e){return Promise.prototype.catch.call(this,e)},o.prototype.error=function(e){return this.then(function(){throw Error(e)})},o.prototype.using=o.prototype.set,o.prototype.saveAs=o.prototype.save,o.prototype.export=o.prototype.output,o.prototype.run=o.prototype.then,kP.getPageSize=function(e,t,n){if(hD(e)===`object`){var r=e;e=r.orientation,t=r.unit||t,n=r.format||n}t||=`mm`,n||=`a4`,e=(``+(e||`P`)).toLowerCase();var i,a=(``+n).toLowerCase(),o={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};switch(t){case`pt`:i=1;break;case`mm`:i=72/25.4;break;case`cm`:i=72/2.54;break;case`in`:i=72;break;case`px`:i=.75;break;case`pc`:case`em`:i=12;break;case`ex`:i=6;break;default:throw`Invalid unit: `+t}var s,c=0,l=0;if(o.hasOwnProperty(a))c=o[a][1]/i,l=o[a][0]/i;else try{c=n[1],l=n[0]}catch{throw Error(`Invalid format: `+n)}if(e===`p`||e===`portrait`)e=`p`,l>c&&(s=l,l=c,c=s);else{if(e!==`l`&&e!==`landscape`)throw`Invalid orientation: `+e;e=`l`,c>l&&(s=l,l=c,c=s)}return{width:l,height:c,unit:t,k:i,orientation:e}},e.html=function(e,t){(t||={}).callback=t.callback||function(){},t.html2canvas=t.html2canvas||{},t.html2canvas.canvas=t.html2canvas.canvas||this.canvas,t.jsPDF=t.jsPDF||this,t.fontFaces=t.fontFaces?t.fontFaces.map(wF):null;var n=new o(t);return t.worker?n:n.from(e).doCallback()}}(kP.API),kP.API.addJS=function(e){var t,n,r=function(e){for(var t=``,n=0;n<e.length;n++){var r=e[n];if(r===`(`||r===`)`){for(var i=0,a=n-1;a>=0&&e[a]===`\\`;a--)i++;t+=i%2==0?`\\`+r:r}else t+=r}return t}(e);return this.internal.events.subscribe(`postPutResources`,function(){t=this.internal.newObject(),this.internal.out(`<<`),this.internal.out(`/Names [(EmbeddedJS) `+(t+1)+` 0 R]`),this.internal.out(`>>`),this.internal.out(`endobj`),n=this.internal.newObject(),this.internal.out(`<<`),this.internal.out(`/S /JavaScript`),this.internal.out(`/JS (`+r+`)`),this.internal.out(`>>`),this.internal.out(`endobj`)}),this.internal.events.subscribe(`putCatalog`,function(){t!==void 0&&n!==void 0&&this.internal.out(`/Names <</JavaScript `+t+` 0 R>>`)}),this},function(e){var t;e.events.push([`postPutResources`,function(){var e=this,n=/^(\d+) 0 obj$/;if(this.outline.root.children.length>0)for(var r=e.outline.render().split(/\r\n/),i=0;i<r.length;i++){var a=r[i],o=n.exec(a);if(o!=null){var s=o[1];e.internal.newObjectDeferredBegin(s,!1)}e.internal.write(a)}if(this.outline.createNamedDestinations){var c=this.internal.pages.length,l=[];for(i=0;i<c;i++){var u=e.internal.newObject();l.push(u);var d=e.internal.getPageInfo(i+1);e.internal.write(`<< /D[`+d.objId+` 0 R /XYZ null null null]>> endobj`)}var f=e.internal.newObject();for(e.internal.write(`<< /Names [ `),i=0;i<l.length;i++)e.internal.write(`(page_`+(i+1)+`)`+l[i]+` 0 R`);e.internal.write(` ] >>`,`endobj`),t=e.internal.newObject(),e.internal.write(`<< /Dests `+f+` 0 R`),e.internal.write(`>>`,`endobj`)}}]),e.events.push([`putCatalog`,function(){var e=this;e.outline.root.children.length>0&&(e.internal.write(`/Outlines`,this.outline.makeRef(this.outline.root)),this.outline.createNamedDestinations&&e.internal.write(`/Names `+t+` 0 R`))}]),e.events.push([`initialized`,function(){var e=this;e.outline={createNamedDestinations:!1,root:{children:[]}},e.outline.add=function(e,t,n){var r={title:t,options:n,children:[]};return e??=this.root,e.children.push(r),r},e.outline.render=function(){return this.ctx={},this.ctx.val=``,this.ctx.pdf=e,this.genIds_r(this.root),this.renderRoot(this.root),this.renderItems(this.root),this.ctx.val},e.outline.genIds_r=function(t){t.id=e.internal.newObjectDeferred();for(var n=0;n<t.children.length;n++)this.genIds_r(t.children[n])},e.outline.renderRoot=function(e){this.objStart(e),this.line(`/Type /Outlines`),e.children.length>0&&(this.line(`/First `+this.makeRef(e.children[0])),this.line(`/Last `+this.makeRef(e.children[e.children.length-1]))),this.line(`/Count `+this.count_r({count:0},e)),this.objEnd()},e.outline.renderItems=function(t){for(var n=this.ctx.pdf.internal.getVerticalCoordinateString,r=0;r<t.children.length;r++){var i=t.children[r];this.objStart(i),this.line(`/Title `+this.makeString(i.title)),this.line(`/Parent `+this.makeRef(t)),r>0&&this.line(`/Prev `+this.makeRef(t.children[r-1])),r<t.children.length-1&&this.line(`/Next `+this.makeRef(t.children[r+1])),i.children.length>0&&(this.line(`/First `+this.makeRef(i.children[0])),this.line(`/Last `+this.makeRef(i.children[i.children.length-1])));var a=this.count=this.count_r({count:0},i);if(a>0&&this.line(`/Count `+a),i.options&&i.options.pageNumber){var o=e.internal.getPageInfo(i.options.pageNumber);this.line(`/Dest [`+o.objId+` 0 R /XYZ 0 `+n(0)+` 0]`)}this.objEnd()}for(var s=0;s<t.children.length;s++)this.renderItems(t.children[s])},e.outline.line=function(e){this.ctx.val+=e+`\r
|
||
`},e.outline.makeRef=function(e){return e.id+` 0 R`},e.outline.makeString=function(t){return`(`+e.internal.pdfEscape(t)+`)`},e.outline.objStart=function(e){this.ctx.val+=`\r
|
||
`+e.id+` 0 obj\r
|
||
<<\r
|
||
`},e.outline.objEnd=function(){this.ctx.val+=`>> \r
|
||
endobj\r
|
||
`},e.outline.count_r=function(e,t){for(var n=0;n<t.children.length;n++)e.count++,this.count_r(e,t.children[n]);return e.count}}])}(kP.API),function(e){var t=[192,193,194,195,196,197,198,199];e.processJPEG=function(e,n,r,i,a,o){var s,c=this.decode.DCT_DECODE,l=null;if(typeof e==`string`||this.__addimage__.isArrayBuffer(e)||this.__addimage__.isArrayBufferView(e)){switch(e=a||e,e=this.__addimage__.isArrayBuffer(e)?new Uint8Array(e):e,s=function(e){for(var n,r=256*e.charCodeAt(4)+e.charCodeAt(5),i=e.length,a={width:0,height:0,numcomponents:1},o=4;o<i;o+=2){if(o+=r,t.indexOf(e.charCodeAt(o+1))!==-1){n=256*e.charCodeAt(o+5)+e.charCodeAt(o+6),a={width:256*e.charCodeAt(o+7)+e.charCodeAt(o+8),height:n,numcomponents:e.charCodeAt(o+9)};break}r=256*e.charCodeAt(o+2)+e.charCodeAt(o+3)}return a}(e=this.__addimage__.isArrayBufferView(e)?this.__addimage__.arrayBufferToBinaryString(e):e),s.numcomponents){case 1:o=this.color_spaces.DEVICE_GRAY;break;case 4:o=this.color_spaces.DEVICE_CMYK;break;case 3:o=this.color_spaces.DEVICE_RGB}l={data:e,width:s.width,height:s.height,colorSpace:o,bitsPerComponent:8,filter:c,index:n,alias:r}}return l}}(kP.API),kP.API.processPNG=function(e,t,n,r){if(this.__addimage__.isArrayBuffer(e)&&(e=new Uint8Array(e)),this.__addimage__.isArrayBufferView(e)){var i,a=YN(e,{checkCrc:!0}),o=a.width,s=a.height,c=a.channels,l=a.palette,u=a.depth;i=l&&c===1?function(e){for(var t=e.width,n=e.height,r=e.data,i=e.palette,a=e.depth,o=!1,s=[],c=[],l=void 0,u=!1,d=0,f=0;f<i.length;f++){var p=oO(i[f],4),m=p[0],h=p[1],g=p[2],_=p[3];s.push(m,h,g),_!=null&&(_===0?(d++,c.length<1&&c.push(f)):_<255&&(u=!0))}if(u||d>1){o=!0,c=void 0;var v=t*n;l=new Uint8Array(v);for(var y=new DataView(r.buffer),b=0;b<v;b++){var x=oO(i[KF(y,b,a)],4)[3];l[b]=x}}else d===0&&(c=void 0);return{colorSpace:`Indexed`,colorsPerPixel:1,sMaskBitsPerComponent:o?8:void 0,colorBytes:r,alphaBytes:l,needSMask:o,palette:s,mask:c}}(a):c===2||c===4?function(e){for(var t=e.data,n=e.width,r=e.height,i=e.channels,a=e.depth,o=i===2?`DeviceGray`:`DeviceRGB`,s=i-1,c=n*r,l=s,u=c*l,d=1*c,f=Math.ceil(u*a/8),p=Math.ceil(d*a/8),m=new Uint8Array(f),h=new Uint8Array(p),g=new DataView(t.buffer),_=new DataView(m.buffer),v=new DataView(h.buffer),y=!1,b=0;b<c;b++){for(var x=b*i,S=0;S<l;S++)qF(_,KF(g,x+S,a),b*l+S,a);var C=KF(g,x+l,a);C<(1<<a)-1&&(y=!0),qF(v,C,1*b,a)}return{colorSpace:o,colorsPerPixel:s,sMaskBitsPerComponent:y?a:void 0,colorBytes:m,alphaBytes:h,needSMask:y}}(a):function(e){var t=e.data,n=e.channels===1?`DeviceGray`:`DeviceRGB`;return{colorSpace:n,colorsPerPixel:n===`DeviceGray`?1:3,colorBytes:t instanceof Uint16Array?function(e){for(var t=e.length,n=new Uint8Array(2*t),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=0;i<t;i++)r.setUint16(2*i,e[i],!1);return n}(t):t,needSMask:!1}}(a);var d,f,p,m=i,h=m.colorSpace,g=m.colorsPerPixel,_=m.sMaskBitsPerComponent,v=m.colorBytes,y=m.alphaBytes,b=m.needSMask,x=m.palette,S=m.mask,C=null;return r!==kP.API.image_compression.NONE&&typeof $D==`function`?(C=function(e){var t;switch(e){case kP.API.image_compression.FAST:t=11;break;case kP.API.image_compression.MEDIUM:t=13;break;case kP.API.image_compression.SLOW:t=14;break;default:t=12}return t}(r),d=this.decode.FLATE_DECODE,f=`/Predictor ${C} /Colors ${g} /BitsPerComponent ${u} /Columns ${o}`,e=RF(v,Math.ceil(o*g*u/8),g,u,r),b&&(p=RF(y,Math.ceil(o*_/8),1,_,r))):(d=void 0,f=void 0,e=v,b&&(p=y)),(this.__addimage__.isArrayBuffer(e)||this.__addimage__.isArrayBufferView(e))&&(e=this.__addimage__.arrayBufferToBinaryString(e)),(p&&this.__addimage__.isArrayBuffer(p)||this.__addimage__.isArrayBufferView(p))&&(p=this.__addimage__.arrayBufferToBinaryString(p)),{alias:n,data:e,index:t,filter:d,decodeParameters:f,transparency:S,palette:x,sMask:p,predictor:C,width:o,height:s,bitsPerComponent:u,sMaskBitsPerComponent:_,colorSpace:h}}},function(e){e.processGIF89A=function(t,n,r,i){var a=new YF(t),o=a.width,s=a.height,c=[];a.decodeAndBlitFrameRGBA(0,c);var l={data:c,width:o,height:s},u=new ZF(100).encode(l,100);return e.processJPEG.call(this,u,n,r,i)},e.processGIF87A=e.processGIF89A}(kP.API),QF.prototype.parseHeader=function(){if(this.fileSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.reserved=this.datav.getUint32(this.pos,!0),this.pos+=4,this.offset=this.datav.getUint32(this.pos,!0),this.pos+=4,this.headerSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.width=this.datav.getUint32(this.pos,!0),this.pos+=4,this.height=this.datav.getInt32(this.pos,!0),this.pos+=4,this.planes=this.datav.getUint16(this.pos,!0),this.pos+=2,this.bitPP=this.datav.getUint16(this.pos,!0),this.pos+=2,this.compress=this.datav.getUint32(this.pos,!0),this.pos+=4,this.rawSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.hr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.vr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.colors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.importantColors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.bitPP===16&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var e=this.colors===0?1<<this.bitPP:this.colors;this.palette=Array(e);for(var t=0;t<e;t++){var n=this.datav.getUint8(this.pos++,!0),r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0);this.palette[t]={red:i,green:r,blue:n,quad:a}}}this.height<0&&(this.height*=-1,this.bottom_up=!1)},QF.prototype.parseBGR=function(){this.pos=this.offset;var e=`bit`+this.bitPP,t=this.width*this.height*4;if(t>536870912)throw Error(`Image dimensions exceed 512MB, which is too large.`);this.data=new Uint8Array(t);try{this[e]()}catch(e){QN.log(`bit decode error:`+e)}},QF.prototype.bit1=function(){var e,t=Math.ceil(this.width/8),n=t%4;for(e=this.height-1;e>=0;e--){for(var r=this.bottom_up?e:this.height-1-e,i=0;i<t;i++)for(var a=this.datav.getUint8(this.pos++,!0),o=r*this.width*4+8*i*4,s=0;s<8&&8*i+s<this.width;s++){var c=this.palette[a>>7-s&1];this.data[o+4*s]=c.blue,this.data[o+4*s+1]=c.green,this.data[o+4*s+2]=c.red,this.data[o+4*s+3]=255}n!==0&&(this.pos+=4-n)}},QF.prototype.bit4=function(){for(var e=Math.ceil(this.width/2),t=e%4,n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,i=0;i<e;i++){var a=this.datav.getUint8(this.pos++,!0),o=r*this.width*4+2*i*4,s=a>>4,c=15&a,l=this.palette[s];if(this.data[o]=l.blue,this.data[o+1]=l.green,this.data[o+2]=l.red,this.data[o+3]=255,2*i+1>=this.width)break;l=this.palette[c],this.data[o+4]=l.blue,this.data[o+4+1]=l.green,this.data[o+4+2]=l.red,this.data[o+4+3]=255}t!==0&&(this.pos+=4-t)}},QF.prototype.bit8=function(){for(var e=this.width%4,t=this.height-1;t>=0;t--){for(var n=this.bottom_up?t:this.height-1-t,r=0;r<this.width;r++){var i=this.datav.getUint8(this.pos++,!0),a=n*this.width*4+4*r;if(i<this.palette.length){var o=this.palette[i];this.data[a]=o.red,this.data[a+1]=o.green,this.data[a+2]=o.blue,this.data[a+3]=255}else this.data[a]=255,this.data[a+1]=255,this.data[a+2]=255,this.data[a+3]=255}e!==0&&(this.pos+=4-e)}},QF.prototype.bit15=function(){for(var e=this.width%3,t=31,n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,i=0;i<this.width;i++){var a=this.datav.getUint16(this.pos,!0);this.pos+=2;var o=(a&t)/t*255|0,s=(a>>5&t)/t*255|0,c=(a>>10&t)/t*255|0,l=a>>15?255:0,u=r*this.width*4+4*i;this.data[u]=c,this.data[u+1]=s,this.data[u+2]=o,this.data[u+3]=l}this.pos+=e}},QF.prototype.bit16=function(){for(var e=this.width%3,t=31,n=63,r=this.height-1;r>=0;r--){for(var i=this.bottom_up?r:this.height-1-r,a=0;a<this.width;a++){var o=this.datav.getUint16(this.pos,!0);this.pos+=2;var s=(o&t)/t*255|0,c=(o>>5&n)/n*255|0,l=(o>>11)/t*255|0,u=i*this.width*4+4*a;this.data[u]=l,this.data[u+1]=c,this.data[u+2]=s,this.data[u+3]=255}this.pos+=e}},QF.prototype.bit24=function(){for(var e=this.height-1;e>=0;e--){for(var t=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=t*this.width*4+4*n;this.data[o]=a,this.data[o+1]=i,this.data[o+2]=r,this.data[o+3]=255}this.pos+=this.width%4}},QF.prototype.bit32=function(){for(var e=this.height-1;e>=0;e--)for(var t=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=this.datav.getUint8(this.pos++,!0),s=t*this.width*4+4*n;this.data[s]=a,this.data[s+1]=i,this.data[s+2]=r,this.data[s+3]=o}},QF.prototype.getData=function(){return this.data},function(e){e.processBMP=function(t,n,r,i){var a=new QF(t,!1),o=a.width,s=a.height,c={data:a.getData(),width:o,height:s},l=new ZF(100).encode(c,100);return e.processJPEG.call(this,l,n,r,i)}}(kP.API),$F.prototype.getData=function(){return this.data},function(e){e.processWEBP=function(t,n,r,i){var a=new $F(t),o=a.width,s=a.height,c={data:a.getData(),width:o,height:s},l=new ZF(100).encode(c,100);return e.processJPEG.call(this,l,n,r,i)}}(kP.API),kP.API.processRGBA=function(e,t,n){for(var r=e.data,i=r.length,a=new Uint8Array(i/4*3),o=new Uint8Array(i/4),s=0,c=0,l=0;l<i;l+=4){var u=r[l],d=r[l+1],f=r[l+2],p=r[l+3];a[s++]=u,a[s++]=d,a[s++]=f,o[c++]=p}var m=this.__addimage__.arrayBufferToBinaryString(a);return{alpha:this.__addimage__.arrayBufferToBinaryString(o),data:m,index:t,alias:n,colorSpace:`DeviceRGB`,bitsPerComponent:8,width:e.width,height:e.height}},kP.API.setLanguage=function(e){return this.internal.languageSettings===void 0&&(this.internal.languageSettings={},this.internal.languageSettings.isSubscribed=!1),{af:`Afrikaans`,sq:`Albanian`,ar:`Arabic (Standard)`,"ar-DZ":`Arabic (Algeria)`,"ar-BH":`Arabic (Bahrain)`,"ar-EG":`Arabic (Egypt)`,"ar-IQ":`Arabic (Iraq)`,"ar-JO":`Arabic (Jordan)`,"ar-KW":`Arabic (Kuwait)`,"ar-LB":`Arabic (Lebanon)`,"ar-LY":`Arabic (Libya)`,"ar-MA":`Arabic (Morocco)`,"ar-OM":`Arabic (Oman)`,"ar-QA":`Arabic (Qatar)`,"ar-SA":`Arabic (Saudi Arabia)`,"ar-SY":`Arabic (Syria)`,"ar-TN":`Arabic (Tunisia)`,"ar-AE":`Arabic (U.A.E.)`,"ar-YE":`Arabic (Yemen)`,an:`Aragonese`,hy:`Armenian`,as:`Assamese`,ast:`Asturian`,az:`Azerbaijani`,eu:`Basque`,be:`Belarusian`,bn:`Bengali`,bs:`Bosnian`,br:`Breton`,bg:`Bulgarian`,my:`Burmese`,ca:`Catalan`,ch:`Chamorro`,ce:`Chechen`,zh:`Chinese`,"zh-HK":`Chinese (Hong Kong)`,"zh-CN":`Chinese (PRC)`,"zh-SG":`Chinese (Singapore)`,"zh-TW":`Chinese (Taiwan)`,cv:`Chuvash`,co:`Corsican`,cr:`Cree`,hr:`Croatian`,cs:`Czech`,da:`Danish`,nl:`Dutch (Standard)`,"nl-BE":`Dutch (Belgian)`,en:`English`,"en-AU":`English (Australia)`,"en-BZ":`English (Belize)`,"en-CA":`English (Canada)`,"en-IE":`English (Ireland)`,"en-JM":`English (Jamaica)`,"en-NZ":`English (New Zealand)`,"en-PH":`English (Philippines)`,"en-ZA":`English (South Africa)`,"en-TT":`English (Trinidad & Tobago)`,"en-GB":`English (United Kingdom)`,"en-US":`English (United States)`,"en-ZW":`English (Zimbabwe)`,eo:`Esperanto`,et:`Estonian`,fo:`Faeroese`,fj:`Fijian`,fi:`Finnish`,fr:`French (Standard)`,"fr-BE":`French (Belgium)`,"fr-CA":`French (Canada)`,"fr-FR":`French (France)`,"fr-LU":`French (Luxembourg)`,"fr-MC":`French (Monaco)`,"fr-CH":`French (Switzerland)`,fy:`Frisian`,fur:`Friulian`,gd:`Gaelic (Scots)`,"gd-IE":`Gaelic (Irish)`,gl:`Galacian`,ka:`Georgian`,de:`German (Standard)`,"de-AT":`German (Austria)`,"de-DE":`German (Germany)`,"de-LI":`German (Liechtenstein)`,"de-LU":`German (Luxembourg)`,"de-CH":`German (Switzerland)`,el:`Greek`,gu:`Gujurati`,ht:`Haitian`,he:`Hebrew`,hi:`Hindi`,hu:`Hungarian`,is:`Icelandic`,id:`Indonesian`,iu:`Inuktitut`,ga:`Irish`,it:`Italian (Standard)`,"it-CH":`Italian (Switzerland)`,ja:`Japanese`,kn:`Kannada`,ks:`Kashmiri`,kk:`Kazakh`,km:`Khmer`,ky:`Kirghiz`,tlh:`Klingon`,ko:`Korean`,"ko-KP":`Korean (North Korea)`,"ko-KR":`Korean (South Korea)`,la:`Latin`,lv:`Latvian`,lt:`Lithuanian`,lb:`Luxembourgish`,mk:`North Macedonia`,ms:`Malay`,ml:`Malayalam`,mt:`Maltese`,mi:`Maori`,mr:`Marathi`,mo:`Moldavian`,nv:`Navajo`,ng:`Ndonga`,ne:`Nepali`,no:`Norwegian`,nb:`Norwegian (Bokmal)`,nn:`Norwegian (Nynorsk)`,oc:`Occitan`,or:`Oriya`,om:`Oromo`,fa:`Persian`,"fa-IR":`Persian/Iran`,pl:`Polish`,pt:`Portuguese`,"pt-BR":`Portuguese (Brazil)`,pa:`Punjabi`,"pa-IN":`Punjabi (India)`,"pa-PK":`Punjabi (Pakistan)`,qu:`Quechua`,rm:`Rhaeto-Romanic`,ro:`Romanian`,"ro-MO":`Romanian (Moldavia)`,ru:`Russian`,"ru-MO":`Russian (Moldavia)`,sz:`Sami (Lappish)`,sg:`Sango`,sa:`Sanskrit`,sc:`Sardinian`,sd:`Sindhi`,si:`Singhalese`,sr:`Serbian`,sk:`Slovak`,sl:`Slovenian`,so:`Somani`,sb:`Sorbian`,es:`Spanish`,"es-AR":`Spanish (Argentina)`,"es-BO":`Spanish (Bolivia)`,"es-CL":`Spanish (Chile)`,"es-CO":`Spanish (Colombia)`,"es-CR":`Spanish (Costa Rica)`,"es-DO":`Spanish (Dominican Republic)`,"es-EC":`Spanish (Ecuador)`,"es-SV":`Spanish (El Salvador)`,"es-GT":`Spanish (Guatemala)`,"es-HN":`Spanish (Honduras)`,"es-MX":`Spanish (Mexico)`,"es-NI":`Spanish (Nicaragua)`,"es-PA":`Spanish (Panama)`,"es-PY":`Spanish (Paraguay)`,"es-PE":`Spanish (Peru)`,"es-PR":`Spanish (Puerto Rico)`,"es-ES":`Spanish (Spain)`,"es-UY":`Spanish (Uruguay)`,"es-VE":`Spanish (Venezuela)`,sx:`Sutu`,sw:`Swahili`,sv:`Swedish`,"sv-FI":`Swedish (Finland)`,"sv-SV":`Swedish (Sweden)`,ta:`Tamil`,tt:`Tatar`,te:`Teluga`,th:`Thai`,tig:`Tigre`,ts:`Tsonga`,tn:`Tswana`,tr:`Turkish`,tk:`Turkmen`,uk:`Ukrainian`,hsb:`Upper Sorbian`,ur:`Urdu`,ve:`Venda`,vi:`Vietnamese`,vo:`Volapuk`,wa:`Walloon`,cy:`Welsh`,xh:`Xhosa`,ji:`Yiddish`,zu:`Zulu`}[e]!==void 0&&(this.internal.languageSettings.languageCode=e,!1===this.internal.languageSettings.isSubscribed&&(this.internal.events.subscribe(`putCatalog`,function(){this.internal.write(`/Lang (`+this.internal.languageSettings.languageCode+`)`)}),this.internal.languageSettings.isSubscribed=!0)),this},MF=kP.API,NF=MF.getCharWidthsArray=function(e,t){var n,r,i=(t||={}).font||this.internal.getFont(),a=t.fontSize||this.internal.getFontSize(),o=t.charSpace||this.internal.getCharSpace(),s=t.widths?t.widths:i.metadata.Unicode.widths,c=s.fof?s.fof:1,l=t.kerning?t.kerning:i.metadata.Unicode.kerning,u=l.fof?l.fof:1,d=!1!==t.doKerning,f=0,p=e.length,m=0,h=s[0]||c,g=[];for(n=0;n<p;n++)r=e.charCodeAt(n),typeof i.metadata.widthOfString==`function`?g.push((i.metadata.widthOfGlyph(i.metadata.characterToGlyph(r))+1e3/a*o||0)/1e3):(f=d&&hD(l[r])===`object`&&!isNaN(parseInt(l[r][m],10))?l[r][m]/u:0,g.push((s[r]||h)/c+f)),m=r;return g},PF=MF.getStringUnitWidth=function(e,t){var n=(t||={}).fontSize||this.internal.getFontSize(),r=t.font||this.internal.getFont(),i=t.charSpace||this.internal.getCharSpace();return MF.processArabic&&(e=MF.processArabic(e)),typeof r.metadata.widthOfString==`function`?r.metadata.widthOfString(e,n,i)/n:NF.apply(this,arguments).reduce(function(e,t){return e+t},0)},FF=function(e,t,n,r){for(var i=[],a=0,o=e.length,s=0;a!==o&&s+t[a]<n;)s+=t[a],a++;i.push(e.slice(0,a));var c=a;for(s=0;a!==o;)s+t[a]>r&&(i.push(e.slice(c,a)),s=0,c=a),s+=t[a],a++;return c!==a&&i.push(e.slice(c,a)),i},IF=function(e,t,n){n||={};var r,i,a,o,s,c,l,u=[],d=[u],f=n.textIndent||0,p=0,m=0,h=e.split(` `),g=NF.apply(this,[` `,n])[0];if(c=n.lineIndent===-1?h[0].length+2:n.lineIndent||0){var _=Array(c).join(` `),v=[];h.map(function(e){(e=e.split(/\s*\n/)).length>1?v=v.concat(e.map(function(e,t){return(t&&e.length?`
|
||
`:``)+e})):v.push(e[0])}),h=v,c=PF.apply(this,[_,n])}for(a=0,o=h.length;a<o;a++){var y=0;if(r=h[a],c&&r[0]==`
|
||
`&&(r=r.substr(1),y=1),f+p+(m=(i=NF.apply(this,[r,n])).reduce(function(e,t){return e+t},0))>t||y){if(m>t){for(s=FF.apply(this,[r,i,t-(f+p),t]),u.push(s.shift()),u=[s.pop()];s.length;)d.push([s.shift()]);m=i.slice(r.length-(u[0]?u[0].length:0)).reduce(function(e,t){return e+t},0)}else u=[r];d.push(u),f=m+c,p=g}else u.push(r),f+=p+m,p=g}return l=c?function(e,t){return(t?_:``)+e.join(` `)}:function(e){return e.join(` `)},d.map(l)},MF.splitTextToSize=function(e,t,n){var r,i=(n||={}).fontSize||this.internal.getFontSize(),a=function(e){if(e.widths&&e.kerning)return{widths:e.widths,kerning:e.kerning};var t=this.internal.getFont(e.fontName,e.fontStyle),n=`Unicode`;return t.metadata[n]?{widths:t.metadata[n].widths||{0:1},kerning:t.metadata[n].kerning||{}}:{font:t.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,n);r=Array.isArray(e)?e:String(e).split(/\r?\n/);var o=1*this.internal.scaleFactor*t/i;a.textIndent=n.textIndent?1*n.textIndent*this.internal.scaleFactor/i:0,a.lineIndent=n.lineIndent;var s,c,l=[];for(s=0,c=r.length;s<c;s++)l=l.concat(IF.apply(this,[r[s],o,a]));return l},function(e){e.__fontmetrics__=e.__fontmetrics__||{};for(var t=`0123456789abcdef`,n=`klmnopqrstuvwxyz`,r={},i={},a=0;a<16;a++)r[n[a]]=t[a],i[t[a]]=n[a];var o=function(e){return`0x`+parseInt(e,10).toString(16)},s=e.__fontmetrics__.compress=function(e){var t,n,r,a,c=[`{`];for(var l in e){if(t=e[l],isNaN(parseInt(l,10))?n=`'`+l+`'`:(l=parseInt(l,10),n=(n=o(l).slice(2)).slice(0,-1)+i[n.slice(-1)]),typeof t==`number`)t<0?(r=o(t).slice(3),a=`-`):(r=o(t).slice(2),a=``),r=a+r.slice(0,-1)+i[r.slice(-1)];else{if(hD(t)!==`object`)throw Error(`Don't know what to do with value type `+hD(t)+`.`);r=s(t)}c.push(n+r)}return c.push(`}`),c.join(``)},c=e.__fontmetrics__.uncompress=function(e){if(typeof e!=`string`)throw Error(`Invalid argument passed to uncompress.`);for(var t,n,i,a,o={},s=1,c=o,l=[],u=``,d=``,f=e.length-1,p=1;p<f;p+=1)(a=e[p])==`'`?t?(i=t.join(``),t=void 0):t=[]:t?t.push(a):a==`{`?(l.push([c,i]),c={},i=void 0):a==`}`?((n=l.pop())[0][n[1]]=c,i=void 0,c=n[0]):a==`-`?s=-1:i===void 0?r.hasOwnProperty(a)?(u+=r[a],i=parseInt(u,16)*s,s=1,u=``):u+=a:r.hasOwnProperty(a)?(d+=r[a],c[i]=parseInt(d,16)*s,s=1,i=void 0,d=``):d+=a;return o},l={codePages:[`WinAnsiEncoding`],WinAnsiEncoding:c(`{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}`)},u={Unicode:{Courier:l,"Courier-Bold":l,"Courier-BoldOblique":l,"Courier-Oblique":l,Helvetica:l,"Helvetica-Bold":l,"Helvetica-BoldOblique":l,"Helvetica-Oblique":l,"Times-Roman":l,"Times-Bold":l,"Times-BoldItalic":l,"Times-Italic":l}},d={Unicode:{"Courier-Oblique":c(`{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}`),"Times-BoldItalic":c(`{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}`),"Helvetica-Bold":c(`{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}`),Courier:c(`{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}`),"Courier-BoldOblique":c(`{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}`),"Times-Bold":c(`{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}`),Symbol:c(`{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}`),Helvetica:c(`{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}`),"Helvetica-BoldOblique":c(`{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}`),ZapfDingbats:c(`{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}`),"Courier-Bold":c(`{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}`),"Times-Italic":c(`{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}`),"Times-Roman":c(`{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}`),"Helvetica-Oblique":c(`{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}`)}};e.events.push([`addFont`,function(e){var t=e.font,n=d.Unicode[t.postScriptName];n&&(t.metadata.Unicode={},t.metadata.Unicode.widths=n.widths,t.metadata.Unicode.kerning=n.kerning);var r=u.Unicode[t.postScriptName];r&&(t.metadata.Unicode.encoding=r,t.encoding=r.codePages[0])}])}(kP.API),function(e){var t=function(e){for(var t=e.length,n=new Uint8Array(t),r=0;r<t;r++)n[r]=e.charCodeAt(r);return n};e.API.events.push([`addFont`,function(n){var r=void 0,i=n.font,a=n.instance;if(!i.isStandardFont){if(a===void 0)throw Error(`Font does not exist in vFS, import fonts or remove declaration doc.addFont('`+i.postScriptName+`').`);if(typeof(r=!1===a.existsFileInVFS(i.postScriptName)?a.loadFile(i.postScriptName):a.getFileFromVFS(i.postScriptName))!=`string`)throw Error(`Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('`+i.postScriptName+`').`);(function(n,r){r=/^\x00\x01\x00\x00/.test(r)?t(r):t(iP(r)),n.metadata=e.API.TTFFont.open(r),n.metadata.Unicode=n.metadata.Unicode||{encoding:{},kerning:{},widths:[]},n.metadata.glyIdsUsed=[0]})(i,r)}}])}(kP),kP.API.addSvgAsImage=function(e,t,n,r,i,a,o,s){if(isNaN(t)||isNaN(n))throw QN.error(`jsPDF.addSvgAsImage: Invalid coordinates`,arguments),Error(`Invalid coordinates passed to jsPDF.addSvgAsImage`);if(isNaN(r)||isNaN(i))throw QN.error(`jsPDF.addSvgAsImage: Invalid measurements`,arguments),Error(`Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage`);var c=document.createElement(`canvas`);c.width=r,c.height=i;var l=c.getContext(`2d`);l.fillStyle=`#fff`,l.fillRect(0,0,c.width,c.height);var u={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},d=this;return(XN.canvg?Promise.resolve(XN.canvg):Gb(()=>import(`./index.es-Dm4MvI1O.js`),[])).catch(function(e){return Promise.reject(Error(`Could not load canvg: `+e))}).then(function(e){return e.default?e.default:e}).then(function(t){return t.fromString(l,e,u)},function(){return Promise.reject(Error(`Could not load canvg.`))}).then(function(e){return e.render(u)}).then(function(){d.addImage(c.toDataURL(`image/jpeg`,1),t,n,r,i,o,s)})},kP.API.putTotalPages=function(e){var t,n=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(t=new RegExp(e,`g`),n=this.internal.getNumberOfPages()):(t=new RegExp(this.pdfEscape16(e,this.internal.getFont()),`g`),n=this.pdfEscape16(this.internal.getNumberOfPages()+``,this.internal.getFont()));for(var r=1;r<=this.internal.getNumberOfPages();r++)for(var i=0;i<this.internal.pages[r].length;i++)this.internal.pages[r][i]=this.internal.pages[r][i].replace(t,n);return this},kP.API.viewerPreferences=function(e,t){var n;e||={},t||=!1;var r,i,a,o={HideToolbar:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:`UseNone`,value:`UseNone`,type:`name`,explicitSet:!1,valueSet:[`UseNone`,`UseOutlines`,`UseThumbs`,`UseOC`],pdfVersion:1.3},Direction:{defaultValue:`L2R`,value:`L2R`,type:`name`,explicitSet:!1,valueSet:[`L2R`,`R2L`],pdfVersion:1.3},ViewArea:{defaultValue:`CropBox`,value:`CropBox`,type:`name`,explicitSet:!1,valueSet:[`MediaBox`,`CropBox`,`TrimBox`,`BleedBox`,`ArtBox`],pdfVersion:1.4},ViewClip:{defaultValue:`CropBox`,value:`CropBox`,type:`name`,explicitSet:!1,valueSet:[`MediaBox`,`CropBox`,`TrimBox`,`BleedBox`,`ArtBox`],pdfVersion:1.4},PrintArea:{defaultValue:`CropBox`,value:`CropBox`,type:`name`,explicitSet:!1,valueSet:[`MediaBox`,`CropBox`,`TrimBox`,`BleedBox`,`ArtBox`],pdfVersion:1.4},PrintClip:{defaultValue:`CropBox`,value:`CropBox`,type:`name`,explicitSet:!1,valueSet:[`MediaBox`,`CropBox`,`TrimBox`,`BleedBox`,`ArtBox`],pdfVersion:1.4},PrintScaling:{defaultValue:`AppDefault`,value:`AppDefault`,type:`name`,explicitSet:!1,valueSet:[`AppDefault`,`None`],pdfVersion:1.6},Duplex:{defaultValue:``,value:`none`,type:`name`,explicitSet:!1,valueSet:[`Simplex`,`DuplexFlipShortEdge`,`DuplexFlipLongEdge`,`none`],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:``,value:``,type:`array`,explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:`integer`,explicitSet:!1,valueSet:null,pdfVersion:1.7}},s=Object.keys(o),c=[],l=0,u=0,d=0;function f(e,t){var n,r=!1;for(n=0;n<e.length;n+=1)e[n]===t&&(r=!0);return r}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,e===`reset`||!0===t){var p=s.length;for(d=0;d<p;d+=1)n[s[d]].value=n[s[d]].defaultValue,n[s[d]].explicitSet=!1}if(hD(e)===`object`){for(i in e)if(a=e[i],f(s,i)&&a!==void 0){if(n[i].type===`boolean`&&typeof a==`boolean`)n[i].value=a;else if(n[i].type===`name`&&f(n[i].valueSet,a))n[i].value=a;else if(n[i].type===`integer`&&Number.isInteger(a))n[i].value=a;else if(n[i].type===`array`){for(l=0;l<a.length;l+=1)if(r=!0,a[l].length===1&&typeof a[l][0]==`number`)c.push(String(a[l]-1));else if(a[l].length>1){for(u=0;u<a[l].length;u+=1)typeof a[l][u]!=`number`&&(r=!1);!0===r&&c.push([a[l][0]-1,a[l][1]-1].join(` `))}n[i].value=`[`+c.join(` `)+`]`}else n[i].value=n[i].defaultValue;n[i].explicitSet=!0}}return!1===this.internal.viewerpreferences.isSubscribed&&(this.internal.events.subscribe(`putCatalog`,function(){var e,t=[];for(e in n)!0===n[e].explicitSet&&(n[e].type===`name`?t.push(`/`+e+` /`+n[e].value):t.push(`/`+e+` `+n[e].value));t.length!==0&&this.internal.write(`/ViewerPreferences
|
||
<<
|
||
`+t.join(`
|
||
`)+`
|
||
>>`)}),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=n,this},kP.API.addMetadata=function(e,t){return this.internal.__metadata__===void 0&&(this.internal.__metadata__={metadata:e,namespaceUri:t??`http://jspdf.default.namespaceuri/`,rawXml:typeof t==`boolean`&&t},this.internal.events.subscribe(`putCatalog`,tI),this.internal.events.subscribe(`postPutResources`,eI)),this},function(e){var t=e.API,n=t.pdfEscape16=function(e,t){for(var n,r=t.metadata.Unicode.widths,i=[``,`0`,`00`,`000`,`0000`],a=[``],o=0,s=e.length;o<s;++o){if(n=t.metadata.characterToGlyph(e.charCodeAt(o)),t.metadata.glyIdsUsed.push(n),t.metadata.toUnicode[n]=e.charCodeAt(o),r.indexOf(n)==-1&&(r.push(n),r.push([parseInt(t.metadata.widthOfGlyph(n),10)])),n==`0`)return a.join(``);n=n.toString(16),a.push(i[4-n.length],n)}return a.join(``)},r=function(e){var t,n,r,i,a,o,s;for(a=`/CIDInit /ProcSet findresource begin
|
||
12 dict begin
|
||
begincmap
|
||
/CIDSystemInfo <<
|
||
/Registry (Adobe)
|
||
/Ordering (UCS)
|
||
/Supplement 0
|
||
>> def
|
||
/CMapName /Adobe-Identity-UCS def
|
||
/CMapType 2 def
|
||
1 begincodespacerange
|
||
<0000><ffff>
|
||
endcodespacerange`,r=[],o=0,s=(n=Object.keys(e).sort(function(e,t){return e-t})).length;o<s;o++)t=n[o],r.length>=100&&(a+=`
|
||
`+r.length+` beginbfchar
|
||
`+r.join(`
|
||
`)+`
|
||
endbfchar`,r=[]),e[t]!==void 0&&e[t]!==null&&typeof e[t].toString==`function`&&(i=(`0000`+e[t].toString(16)).slice(-4),t=(`0000`+(+t).toString(16)).slice(-4),r.push(`<`+t+`><`+i+`>`));return r.length&&(a+=`
|
||
`+r.length+` beginbfchar
|
||
`+r.join(`
|
||
`)+`
|
||
endbfchar
|
||
`),a+`endcmap
|
||
CMapName currentdict /CMap defineresource pop
|
||
end
|
||
end`};t.events.push([`putFont`,function(t){(function(t){var n=t.font,i=t.out,a=t.newObject,o=t.putStream;if(n.metadata instanceof e.API.TTFFont&&n.encoding===`Identity-H`){for(var s=n.metadata.Unicode.widths,c=n.metadata.subset.encode(n.metadata.glyIdsUsed,1),l=``,u=0;u<c.length;u++)l+=String.fromCharCode(c[u]);var d=a();o({data:l,addLength1:!0,objectId:d}),i(`endobj`);var f=a();o({data:r(n.metadata.toUnicode),addLength1:!0,objectId:f}),i(`endobj`);var p=a();i(`<<`),i(`/Type /FontDescriptor`),i(`/FontName /`+CP(n.fontName)),i(`/FontFile2 `+d+` 0 R`),i(`/FontBBox `+e.API.PDFObject.convert(n.metadata.bbox)),i(`/Flags `+n.metadata.flags),i(`/StemV `+n.metadata.stemV),i(`/ItalicAngle `+n.metadata.italicAngle),i(`/Ascent `+n.metadata.ascender),i(`/Descent `+n.metadata.decender),i(`/CapHeight `+n.metadata.capHeight),i(`>>`),i(`endobj`);var m=a();i(`<<`),i(`/Type /Font`),i(`/BaseFont /`+CP(n.fontName)),i(`/FontDescriptor `+p+` 0 R`),i(`/W `+e.API.PDFObject.convert(s)),i(`/CIDToGIDMap /Identity`),i(`/DW 1000`),i(`/Subtype /CIDFontType2`),i(`/CIDSystemInfo`),i(`<<`),i(`/Supplement 0`),i(`/Registry (Adobe)`),i(`/Ordering (`+n.encoding+`)`),i(`>>`),i(`>>`),i(`endobj`),n.objectNumber=a(),i(`<<`),i(`/Type /Font`),i(`/Subtype /Type0`),i(`/ToUnicode `+f+` 0 R`),i(`/BaseFont /`+CP(n.fontName)),i(`/Encoding /`+n.encoding),i(`/DescendantFonts [`+m+` 0 R]`),i(`>>`),i(`endobj`),n.isAlreadyPutted=!0}})(t)}]),t.events.push([`putFont`,function(t){(function(t){var n=t.font,i=t.out,a=t.newObject,o=t.putStream;if(n.metadata instanceof e.API.TTFFont&&n.encoding===`WinAnsiEncoding`){for(var s=n.metadata.rawData,c=``,l=0;l<s.length;l++)c+=String.fromCharCode(s[l]);var u=a();o({data:c,addLength1:!0,objectId:u}),i(`endobj`);var d=a();o({data:r(n.metadata.toUnicode),addLength1:!0,objectId:d}),i(`endobj`);var f=a();i(`<<`),i(`/Descent `+n.metadata.decender),i(`/CapHeight `+n.metadata.capHeight),i(`/StemV `+n.metadata.stemV),i(`/Type /FontDescriptor`),i(`/FontFile2 `+u+` 0 R`),i(`/Flags 96`),i(`/FontBBox `+e.API.PDFObject.convert(n.metadata.bbox)),i(`/FontName /`+CP(n.fontName)),i(`/ItalicAngle `+n.metadata.italicAngle),i(`/Ascent `+n.metadata.ascender),i(`>>`),i(`endobj`),n.objectNumber=a();for(var p=0;p<n.metadata.hmtx.widths.length;p++)n.metadata.hmtx.widths[p]=parseInt(n.metadata.hmtx.widths[p]*(1e3/n.metadata.head.unitsPerEm));i(`<</Subtype/TrueType/Type/Font/ToUnicode `+d+` 0 R/BaseFont/`+CP(n.fontName)+`/FontDescriptor `+f+` 0 R/Encoding/`+n.encoding+` /FirstChar 29 /LastChar 255 /Widths `+e.API.PDFObject.convert(n.metadata.hmtx.widths)+`>>`),i(`endobj`),n.isAlreadyPutted=!0}})(t)}]);var i=function(e){var t,r=e.text||``,i=e.x,a=e.y,o=e.options||{},s=e.mutex||{},c=s.pdfEscape,l=s.activeFontKey,u=s.fonts,d=l,f=``,p=0,m=``,h=u[d].encoding;if(u[d].encoding!==`Identity-H`)return{text:r,x:i,y:a,options:o,mutex:s};for(m=r,d=l,Array.isArray(r)&&(m=r[0]),p=0;p<m.length;p+=1)u[d].metadata.hasOwnProperty(`cmap`)&&(t=u[d].metadata.cmap.unicode.codeMap[m[p].charCodeAt(0)]),t||m[p].charCodeAt(0)<256&&u[d].metadata.hasOwnProperty(`Unicode`)?f+=m[p]:f+=``;var g=``;return parseInt(d.slice(1))<14||h===`WinAnsiEncoding`?g=c(f,d).split(``).map(function(e){return e.charCodeAt(0).toString(16)}).join(``):h===`Identity-H`&&(g=n(f,u[d])),s.isHex=!0,{text:g,x:i,y:a,options:o,mutex:s}};t.events.push([`postProcessText`,function(e){var t=e.text||``,n=[],r={text:t,x:e.x,y:e.y,options:e.options,mutex:e.mutex};if(Array.isArray(t)){var a=0;for(a=0;a<t.length;a+=1)Array.isArray(t[a])&&t[a].length===3?n.push([i(Object.assign({},r,{text:t[a][0]})).text,t[a][1],t[a][2]]):n.push(i(Object.assign({},r,{text:t[a]})).text);e.text=n}else e.text=i(Object.assign({},r,{text:t})).text}])}(kP),function(e){var t=function(){return this.internal.vFS===void 0&&(this.internal.vFS={}),!0};e.existsFileInVFS=function(e){return t.call(this),this.internal.vFS[e]!==void 0},e.addFileToVFS=function(e,n){return t.call(this),this.internal.vFS[e]=n,this},e.getFileFromVFS=function(e){return t.call(this),this.internal.vFS[e]===void 0?null:this.internal.vFS[e]}}(kP.API),function(e){e.__bidiEngine__=e.prototype.__bidiEngine__=function(e){var n,r,i,a,o,s,c,l=t,u=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],d=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],f={L:0,R:1,EN:2,AN:3,N:4,B:5,S:6},p={0:0,5:1,6:2,7:3,32:4,251:5,254:6,255:7},m=`(.).(.<.>.<.[.].[.{.}.{.«.».«.‹.›.‹.⁅.⁆.⁅.⁽.⁾.⁽.₍.₎.₍.≤.≥.≤.〈.〉.〈.﹙.﹚.﹙.﹛.﹜.﹛.﹝.﹞.﹝.﹤.﹥.﹤`.split(`.`),h=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),g=!1,_=0;this.__bidiEngine__={};var v=function(e){var t=e.charCodeAt(),n=t>>8,r=p[n];return r===void 0?n===252||n===253?`AL`:h.test(n)?`L`:n===8?`R`:`N`:l[256*r+(255&t)]},y=function(e){for(var t,n=0;n<e.length;n++){if((t=v(e.charAt(n)))===`L`)return!1;if(t===`R`)return!0}return!1},b=function(e,t,o,s){var c,l,u,d,f=t[s];switch(f){case`L`:case`R`:case`LRE`:case`RLE`:case`LRO`:case`RLO`:case`PDF`:g=!1;break;case`N`:case`AN`:break;case`EN`:g&&(f=`AN`);break;case`AL`:g=!0,f=`R`;break;case`WS`:case`BN`:f=`N`;break;case`CS`:s<1||s+1>=t.length||(c=o[s-1])!==`EN`&&c!==`AN`||(l=t[s+1])!==`EN`&&l!==`AN`?f=`N`:g&&(l=`AN`),f=l===c?l:`N`;break;case`ES`:f=(c=s>0?o[s-1]:`B`)===`EN`&&s+1<t.length&&t[s+1]===`EN`?`EN`:`N`;break;case`ET`:if(s>0&&o[s-1]===`EN`){f=`EN`;break}if(g){f=`N`;break}for(u=s+1,d=t.length;u<d&&t[u]===`ET`;)u++;f=u<d&&t[u]===`EN`?`EN`:`N`;break;case`NSM`:if(i&&!a){for(d=t.length,u=s+1;u<d&&t[u]===`NSM`;)u++;if(u<d){var p=e[s],m=p>=1425&&p<=2303||p===64286;if(c=t[u],m&&(c===`R`||c===`AL`)){f=`R`;break}}}f=s<1||(c=t[s-1])===`B`?`N`:o[s-1];break;case`B`:g=!1,n=!0,f=_;break;case`S`:r=!0,f=`N`}return f},x=function(e,t,n){var r=e.split(``);return n&&S(r,n,{hiLevel:_}),r.reverse(),t&&t.reverse(),r.join(``)},S=function(e,t,i){var a,o,s,c,l,p=-1,m=e.length,h=0,y=[],x=_?d:u,S=[];for(g=!1,n=!1,r=!1,o=0;o<m;o++)S[o]=v(e[o]);for(s=0;s<m;s++){if(l=h,y[s]=b(e,S,y,s),a=240&(h=x[l][f[y[s]]]),h&=15,t[s]=c=x[h][5],a>0)if(a===16){for(o=p;o<s;o++)t[o]=1;p=-1}else p=-1;if(x[h][6])p===-1&&(p=s);else if(p>-1){for(o=p;o<s;o++)t[o]=c;p=-1}S[s]===`B`&&(t[s]=0),i.hiLevel|=c}r&&function(e,t,n){for(var r=0;r<n;r++)if(e[r]===`S`){t[r]=_;for(var i=r-1;i>=0&&e[i]===`WS`;i--)t[i]=_}}(S,t,m)},C=function(e,t,r,i,a){if(!(a.hiLevel<e)){if(e===1&&_===1&&!n)return t.reverse(),void(r&&r.reverse());for(var o,s,c,l,u=t.length,d=0;d<u;){if(i[d]>=e){for(c=d+1;c<u&&i[c]>=e;)c++;for(l=d,s=c-1;l<s;l++,s--)o=t[l],t[l]=t[s],t[s]=o,r&&(o=r[l],r[l]=r[s],r[s]=o);d=c}d++}}},w=function(e,t,n){var r=e.split(``),i={hiLevel:_};return n||=[],S(r,n,i),function(e,t,n){if(n.hiLevel!==0&&c)for(var r,i=0;i<e.length;i++)t[i]===1&&(r=m.indexOf(e[i]))>=0&&(e[i]=m[r+1])}(r,n,i),C(2,r,t,n,i),C(1,r,t,n,i),r.join(``)};return this.__bidiEngine__.doBidiReorder=function(e,t,n){if(function(e,t){if(t)for(var n=0;n<e.length;n++)t[n]=n;a===void 0&&(a=y(e)),s===void 0&&(s=y(e))}(e,t),i||!o||s)if(i&&o&&a^s)_=+!!a,e=x(e,t,n);else if(!i&&o&&s)_=+!!a,e=w(e,t,n),e=x(e,t);else if(!i||a||o||s){if(i&&!o&&a^s)e=x(e,t),a?(_=0,e=w(e,t,n)):(_=1,e=w(e,t,n),e=x(e,t));else if(i&&a&&!o&&s)_=1,e=w(e,t,n),e=x(e,t);else if(!i&&!o&&a^s){var r=c;a?(_=1,e=w(e,t,n),_=0,c=!1,e=w(e,t,n),c=r):(_=0,e=w(e,t,n),e=x(e,t),_=1,c=!1,e=w(e,t,n),c=r,e=x(e,t))}}else _=0,e=w(e,t,n);else _=+!!a,e=w(e,t,n);return e},this.__bidiEngine__.setOptions=function(e){e&&(i=e.isInputVisual,o=e.isOutputVisual,a=e.isInputRtl,s=e.isOutputRtl,c=e.isSymmetricSwapping)},this.__bidiEngine__.setOptions(e),this.__bidiEngine__};var t=`BN.BN.BN.BN.BN.BN.BN.BN.BN.S.B.S.WS.B.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.B.B.B.S.WS.N.N.ET.ET.ET.N.N.N.N.N.ES.CS.ES.CS.CS.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.CS.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.N.BN.BN.BN.BN.BN.BN.B.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.CS.N.ET.ET.ET.ET.N.N.N.N.L.N.N.BN.N.N.ET.ET.EN.EN.N.L.N.N.N.EN.L.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.L.L.L.L.L.L.L.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.L.N.N.N.N.N.ET.N.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.R.NSM.R.NSM.NSM.R.NSM.NSM.R.NSM.N.N.N.N.N.N.N.N.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.N.N.N.N.N.R.R.R.R.R.N.N.N.N.N.N.N.N.N.N.N.AN.AN.AN.AN.AN.AN.N.N.AL.ET.ET.AL.CS.AL.N.N.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AL.AL.N.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AN.AN.AN.AN.AN.AN.AN.AN.AN.AN.ET.AN.AN.AL.AL.AL.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AN.N.NSM.NSM.NSM.NSM.NSM.NSM.AL.AL.NSM.NSM.N.NSM.NSM.NSM.NSM.AL.AL.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.N.AL.AL.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.N.N.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AL.N.N.N.N.N.N.N.N.N.N.N.N.N.N.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.R.R.N.N.N.N.R.N.N.N.N.N.WS.WS.WS.WS.WS.WS.WS.WS.WS.WS.WS.BN.BN.BN.L.R.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.WS.B.LRE.RLE.PDF.LRO.RLO.CS.ET.ET.ET.ET.ET.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.CS.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.WS.BN.BN.BN.BN.BN.N.LRI.RLI.FSI.PDI.BN.BN.BN.BN.BN.BN.EN.L.N.N.EN.EN.EN.EN.EN.EN.ES.ES.N.N.N.L.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.ES.ES.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.L.L.L.L.L.L.L.N.N.N.N.N.N.N.N.N.N.N.N.L.L.L.L.L.N.N.N.N.N.R.NSM.R.R.R.R.R.R.R.R.R.R.ES.R.R.R.R.R.R.R.R.R.R.R.R.R.N.R.R.R.R.R.N.R.N.R.R.N.R.R.N.R.R.R.R.R.R.R.R.R.R.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.CS.N.CS.N.N.CS.N.N.N.N.N.N.N.N.N.ET.N.N.ES.ES.N.N.N.N.N.ET.ET.N.N.N.N.N.AL.AL.AL.AL.AL.N.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.N.N.BN.N.N.N.ET.ET.ET.N.N.N.N.N.ES.CS.ES.CS.CS.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.CS.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.N.N.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.L.L.L.L.L.L.N.N.L.L.L.L.L.L.N.N.L.L.L.L.L.L.N.N.L.L.L.N.N.N.ET.ET.N.N.N.ET.ET.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N`.split(`.`),n=new e.__bidiEngine__({isInputVisual:!0});e.API.events.push([`postProcessText`,function(e){var t=e.text;e.x,e.y;var r=e.options||{};e.mutex,r.lang;var i=[];if(r.isInputVisual=typeof r.isInputVisual!=`boolean`||r.isInputVisual,n.setOptions(r),Object.prototype.toString.call(t)===`[object Array]`){var a=0;for(i=[],a=0;a<t.length;a+=1)Object.prototype.toString.call(t[a])===`[object Array]`?i.push([n.doBidiReorder(t[a][0]),t[a][1],t[a][2]]):i.push([n.doBidiReorder(t[a])]);e.text=i}else e.text=n.doBidiReorder(t);n.setOptions({isInputVisual:!0})}])}(kP),kP.API.TTFFont=function(){function e(e){var t;if(this.rawData=e,t=this.contents=new rI(e),this.contents.pos=4,t.readString(4)===`ttcf`)throw Error(`TTCF not supported.`);t.pos=0,this.parse(),this.subset=new SI(this),this.registerTTF()}return e.open=function(t){return new e(t)},e.prototype.parse=function(){return this.directory=new iI(this.contents),this.head=new sI(this),this.name=new mI(this),this.cmap=new lI(this),this.toUnicode={},this.hhea=new uI(this),this.maxp=new hI(this),this.hmtx=new gI(this),this.post=new fI(this),this.os2=new dI(this),this.loca=new xI(this),this.glyf=new vI(this),this.ascender=this.os2.exists&&this.os2.ascender||this.hhea.ascender,this.decender=this.os2.exists&&this.os2.decender||this.hhea.decender,this.lineGap=this.os2.exists&&this.os2.lineGap||this.hhea.lineGap,this.bbox=[this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax]},e.prototype.registerTTF=function(){var e,t,n,r,i;if(this.scaleFactor=1e3/this.head.unitsPerEm,this.bbox=function(){var t,n,r,i;for(i=[],t=0,n=(r=this.bbox).length;t<n;t++)e=r[t],i.push(Math.round(e*this.scaleFactor));return i}.call(this),this.stemV=0,this.post.exists?(n=255&(r=this.post.italic_angle),32768&(t=r>>16)&&(t=-(1+(65535^t))),this.italicAngle=+(t+`.`+n)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=(i=this.familyClass)===1||i===2||i===3||i===4||i===5||i===7,this.isScript=this.familyClass===10,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),this.italicAngle!==0&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw Error(`No unicode cmap for font`)},e.prototype.characterToGlyph=function(e){return this.cmap.unicode?.codeMap[e]||0},e.prototype.widthOfGlyph=function(e){var t;return t=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(e).advance*t},e.prototype.widthOfString=function(e,t,n){var r,i,a,o;for(a=0,i=0,o=(e=``+e).length;0<=o?i<o:i>o;i=0<=o?++i:--i)r=e.charCodeAt(i),a+=this.widthOfGlyph(this.characterToGlyph(r))+1e3/t*n||0;return t/1e3*a},e.prototype.lineHeight=function(e,t){var n;return t??=!1,n=t?this.lineGap:0,(this.ascender+n-this.decender)/1e3*e},e}();var nI,rI=function(){function e(e){this.data=e??[],this.pos=0,this.length=this.data.length}return e.prototype.readByte=function(){return this.data[this.pos++]},e.prototype.writeByte=function(e){return this.data[this.pos++]=e},e.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},e.prototype.writeUInt32=function(e){return this.writeByte(e>>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e)},e.prototype.readInt32=function(){var e;return(e=this.readUInt32())>=2147483648?e-4294967296:e},e.prototype.writeInt32=function(e){return e<0&&(e+=4294967296),this.writeUInt32(e)},e.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},e.prototype.writeUInt16=function(e){return this.writeByte(e>>8&255),this.writeByte(255&e)},e.prototype.readInt16=function(){var e;return(e=this.readUInt16())>=32768?e-65536:e},e.prototype.writeInt16=function(e){return e<0&&(e+=65536),this.writeUInt16(e)},e.prototype.readString=function(e){var t,n;for(n=[],t=0;0<=e?t<e:t>e;t=0<=e?++t:--t)n[t]=String.fromCharCode(this.readByte());return n.join(``)},e.prototype.writeString=function(e){var t,n,r;for(r=[],t=0,n=e.length;0<=n?t<n:t>n;t=0<=n?++t:--t)r.push(this.writeByte(e.charCodeAt(t)));return r},e.prototype.readShort=function(){return this.readInt16()},e.prototype.writeShort=function(e){return this.writeInt16(e)},e.prototype.readLongLong=function(){var e,t,n,r,i,a,o,s;return e=this.readByte(),t=this.readByte(),n=this.readByte(),r=this.readByte(),i=this.readByte(),a=this.readByte(),o=this.readByte(),s=this.readByte(),128&e?-1*(72057594037927940*(255^e)+281474976710656*(255^t)+1099511627776*(255^n)+4294967296*(255^r)+16777216*(255^i)+65536*(255^a)+256*(255^o)+(255^s)+1):72057594037927940*e+281474976710656*t+1099511627776*n+4294967296*r+16777216*i+65536*a+256*o+s},e.prototype.writeLongLong=function(e){var t,n;return t=Math.floor(e/4294967296),n=4294967295&e,this.writeByte(t>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t),this.writeByte(n>>24&255),this.writeByte(n>>16&255),this.writeByte(n>>8&255),this.writeByte(255&n)},e.prototype.readInt=function(){return this.readInt32()},e.prototype.writeInt=function(e){return this.writeInt32(e)},e.prototype.read=function(e){var t,n;for(t=[],n=0;0<=e?n<e:n>e;n=0<=e?++n:--n)t.push(this.readByte());return t},e.prototype.write=function(e){var t,n,r,i;for(i=[],n=0,r=e.length;n<r;n++)t=e[n],i.push(this.writeByte(t));return i},e}(),iI=function(){var e;function t(e){var t,n,r;for(this.scalarType=e.readInt(),this.tableCount=e.readShort(),this.searchRange=e.readShort(),this.entrySelector=e.readShort(),this.rangeShift=e.readShort(),this.tables={},n=0,r=this.tableCount;0<=r?n<r:n>r;n=0<=r?++n:--n)t={tag:e.readString(4),checksum:e.readInt(),offset:e.readInt(),length:e.readInt()},this.tables[t.tag]=t}return t.prototype.encode=function(t){var n,r,i,a,o,s,c,l,u,d,f,p,m;for(m in f=Object.keys(t).length,s=Math.log(2),u=16*Math.floor(Math.log(f)/s),a=Math.floor(u/s),l=16*f-u,(r=new rI).writeInt(this.scalarType),r.writeShort(f),r.writeShort(u),r.writeShort(a),r.writeShort(l),i=16*f,c=r.pos+i,o=null,p=[],t)for(d=t[m],r.writeString(m),r.writeInt(e(d)),r.writeInt(c),r.writeInt(d.length),p=p.concat(d),m===`head`&&(o=c),c+=d.length;c%4;)p.push(0),c++;return r.write(p),n=2981146554-e(r.data),r.pos=o+8,r.writeUInt32(n),r.data},e=function(e){var t,n,r,i;for(e=_I.call(e);e.length%4;)e.push(0);for(r=new rI(e),n=0,t=0,i=e.length;t<i;t=t+=4)n+=r.readUInt32();return 4294967295&n},t}(),aI={}.hasOwnProperty,oI=function(e,t){for(var n in t)aI.call(t,n)&&(e[n]=t[n]);function r(){this.constructor=e}return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};nI=function(){function e(e){var t;this.file=e,t=this.file.directory.tables[this.tag],this.exists=!!t,t&&(this.offset=t.offset,this.length=t.length,this.parse(this.file.contents))}return e.prototype.parse=function(){},e.prototype.encode=function(){},e.prototype.raw=function(){return this.exists?(this.file.contents.pos=this.offset,this.file.contents.read(this.length)):null},e}();var sI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`head`,e.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.revision=e.readInt(),this.checkSumAdjustment=e.readInt(),this.magicNumber=e.readInt(),this.flags=e.readShort(),this.unitsPerEm=e.readShort(),this.created=e.readLongLong(),this.modified=e.readLongLong(),this.xMin=e.readShort(),this.yMin=e.readShort(),this.xMax=e.readShort(),this.yMax=e.readShort(),this.macStyle=e.readShort(),this.lowestRecPPEM=e.readShort(),this.fontDirectionHint=e.readShort(),this.indexToLocFormat=e.readShort(),this.glyphDataFormat=e.readShort()},e.prototype.encode=function(e){var t;return(t=new rI).writeInt(this.version),t.writeInt(this.revision),t.writeInt(this.checkSumAdjustment),t.writeInt(this.magicNumber),t.writeShort(this.flags),t.writeShort(this.unitsPerEm),t.writeLongLong(this.created),t.writeLongLong(this.modified),t.writeShort(this.xMin),t.writeShort(this.yMin),t.writeShort(this.xMax),t.writeShort(this.yMax),t.writeShort(this.macStyle),t.writeShort(this.lowestRecPPEM),t.writeShort(this.fontDirectionHint),t.writeShort(e),t.writeShort(this.glyphDataFormat),t.data},e}(),cI=function(){function e(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v;switch(this.platformID=e.readUInt16(),this.encodingID=e.readShort(),this.offset=t+e.readInt(),u=e.pos,e.pos=this.offset,this.format=e.readUInt16(),this.length=e.readUInt16(),this.language=e.readUInt16(),this.isUnicode=this.platformID===3&&this.encodingID===1&&this.format===4||this.platformID===0&&this.format===4,this.codeMap={},this.format){case 0:for(s=0;s<256;++s)this.codeMap[s]=e.readByte();break;case 4:for(f=e.readUInt16(),d=f/2,e.pos+=6,i=function(){var t,n;for(n=[],s=t=0;0<=d?t<d:t>d;s=0<=d?++t:--t)n.push(e.readUInt16());return n}(),e.pos+=2,m=function(){var t,n;for(n=[],s=t=0;0<=d?t<d:t>d;s=0<=d?++t:--t)n.push(e.readUInt16());return n}(),c=function(){var t,n;for(n=[],s=t=0;0<=d?t<d:t>d;s=0<=d?++t:--t)n.push(e.readUInt16());return n}(),l=function(){var t,n;for(n=[],s=t=0;0<=d?t<d:t>d;s=0<=d?++t:--t)n.push(e.readUInt16());return n}(),r=(this.length-e.pos+this.offset)/2,o=function(){var t,n;for(n=[],s=t=0;0<=r?t<r:t>r;s=0<=r?++t:--t)n.push(e.readUInt16());return n}(),s=g=0,v=i.length;g<v;s=++g)for(h=i[s],n=_=p=m[s];p<=h?_<=h:_>=h;n=p<=h?++_:--_)l[s]===0?a=n+c[s]:(a=o[l[s]/2+(n-p)-(d-s)]||0)!==0&&(a+=c[s]),this.codeMap[n]=65535&a}e.pos=u}return e.encode=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,ee,R,te,z,B,V,ne,re,ie,ae;switch(k=new rI,a=Object.keys(e).sort(function(e,t){return e-t}),t){case`macroman`:for(m=0,h=function(){var e=[];for(p=0;p<256;++p)e.push(0);return e}(),_={0:0},i={},A=0,P=a.length;A<P;A++)_[ne=e[r=a[A]]]??(_[ne]=++m),i[r]={old:e[r],new:_[e[r]]},h[r]=_[e[r]];return k.writeUInt16(1),k.writeUInt16(0),k.writeUInt32(12),k.writeUInt16(0),k.writeUInt16(262),k.writeUInt16(0),k.write(h),{charMap:i,subtable:k.data,maxGlyphID:m+1};case`unicode`:for(D=[],u=[],v=0,_={},n={},g=c=null,j=0,F=a.length;j<F;j++)_[b=e[r=a[j]]]??(_[b]=++v),n[r]={old:b,new:_[b]},o=_[b]-r,g!=null&&o===c||(g&&u.push(g),D.push(r),c=o),g=r;for(g&&u.push(g),u.push(65535),D.push(65535),T=2*(w=D.length),C=2*(Math.log(w)/Math.LN2)**2,d=Math.log(C/2)/Math.LN2,S=2*w-C,s=[],x=[],f=[],p=M=0,I=D.length;M<I;p=++M){if(E=D[p],l=u[p],E===65535){s.push(0),x.push(0);break}if(E-(O=n[E].new)>=32768)for(s.push(0),x.push(2*(f.length+w-p)),r=N=E;E<=l?N<=l:N>=l;r=E<=l?++N:--N)f.push(n[r].new);else s.push(O-E),x.push(0)}for(k.writeUInt16(3),k.writeUInt16(1),k.writeUInt32(12),k.writeUInt16(4),k.writeUInt16(16+8*w+2*f.length),k.writeUInt16(0),k.writeUInt16(T),k.writeUInt16(C),k.writeUInt16(d),k.writeUInt16(S),B=0,L=u.length;B<L;B++)r=u[B],k.writeUInt16(r);for(k.writeUInt16(0),V=0,ee=D.length;V<ee;V++)r=D[V],k.writeUInt16(r);for(re=0,R=s.length;re<R;re++)o=s[re],k.writeUInt16(o);for(ie=0,te=x.length;ie<te;ie++)y=x[ie],k.writeUInt16(y);for(ae=0,z=f.length;ae<z;ae++)m=f[ae],k.writeUInt16(m);return{charMap:n,subtable:k.data,maxGlyphID:v+1}}},e}(),lI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`cmap`,e.prototype.parse=function(e){var t,n,r;for(e.pos=this.offset,this.version=e.readUInt16(),r=e.readUInt16(),this.tables=[],this.unicode=null,n=0;0<=r?n<r:n>r;n=0<=r?++n:--n)t=new cI(e,this.offset),this.tables.push(t),t.isUnicode&&this.unicode==null&&(this.unicode=t);return!0},e.encode=function(e,t){var n,r;return t??=`macroman`,n=cI.encode(e,t),(r=new rI).writeUInt16(0),r.writeUInt16(1),n.table=r.data.concat(n.subtable),n},e}(),uI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`hhea`,e.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.ascender=e.readShort(),this.decender=e.readShort(),this.lineGap=e.readShort(),this.advanceWidthMax=e.readShort(),this.minLeftSideBearing=e.readShort(),this.minRightSideBearing=e.readShort(),this.xMaxExtent=e.readShort(),this.caretSlopeRise=e.readShort(),this.caretSlopeRun=e.readShort(),this.caretOffset=e.readShort(),e.pos+=8,this.metricDataFormat=e.readShort(),this.numberOfMetrics=e.readUInt16()},e}(),dI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`OS/2`,e.prototype.parse=function(e){if(e.pos=this.offset,this.version=e.readUInt16(),this.averageCharWidth=e.readShort(),this.weightClass=e.readUInt16(),this.widthClass=e.readUInt16(),this.type=e.readShort(),this.ySubscriptXSize=e.readShort(),this.ySubscriptYSize=e.readShort(),this.ySubscriptXOffset=e.readShort(),this.ySubscriptYOffset=e.readShort(),this.ySuperscriptXSize=e.readShort(),this.ySuperscriptYSize=e.readShort(),this.ySuperscriptXOffset=e.readShort(),this.ySuperscriptYOffset=e.readShort(),this.yStrikeoutSize=e.readShort(),this.yStrikeoutPosition=e.readShort(),this.familyClass=e.readShort(),this.panose=function(){var t,n;for(n=[],t=0;t<10;++t)n.push(e.readByte());return n}(),this.charRange=function(){var t,n;for(n=[],t=0;t<4;++t)n.push(e.readInt());return n}(),this.vendorID=e.readString(4),this.selection=e.readShort(),this.firstCharIndex=e.readShort(),this.lastCharIndex=e.readShort(),this.version>0&&(this.ascent=e.readShort(),this.descent=e.readShort(),this.lineGap=e.readShort(),this.winAscent=e.readShort(),this.winDescent=e.readShort(),this.codePageRange=function(){var t,n;for(n=[],t=0;t<2;t=++t)n.push(e.readInt());return n}(),this.version>1))return this.xHeight=e.readShort(),this.capHeight=e.readShort(),this.defaultChar=e.readShort(),this.breakChar=e.readShort(),this.maxContext=e.readShort()},e}(),fI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`post`,e.prototype.parse=function(e){var t,n,r;switch(e.pos=this.offset,this.format=e.readInt(),this.italicAngle=e.readInt(),this.underlinePosition=e.readShort(),this.underlineThickness=e.readShort(),this.isFixedPitch=e.readInt(),this.minMemType42=e.readInt(),this.maxMemType42=e.readInt(),this.minMemType1=e.readInt(),this.maxMemType1=e.readInt(),this.format){case 65536:case 196608:break;case 131072:var i;for(n=e.readUInt16(),this.glyphNameIndex=[],i=0;0<=n?i<n:i>n;i=0<=n?++i:--i)this.glyphNameIndex.push(e.readUInt16());for(this.names=[],r=[];e.pos<this.offset+this.length;)t=e.readByte(),r.push(this.names.push(e.readString(t)));return r;case 151552:return n=e.readUInt16(),this.offsets=e.read(n);case 262144:return this.map=function(){var t,n,r;for(r=[],i=t=0,n=this.file.maxp.numGlyphs;0<=n?t<n:t>n;i=0<=n?++t:--t)r.push(e.readUInt32());return r}.call(this)}},e}(),pI=function(e,t){this.raw=e,this.length=e.length,this.platformID=t.platformID,this.encodingID=t.encodingID,this.languageID=t.languageID},mI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`name`,e.prototype.parse=function(e){var t,n,r,i,a,o,s,c,l,u,d;for(e.pos=this.offset,e.readShort(),t=e.readShort(),o=e.readShort(),n=[],i=0;0<=t?i<t:i>t;i=0<=t?++i:--i)n.push({platformID:e.readShort(),encodingID:e.readShort(),languageID:e.readShort(),nameID:e.readShort(),length:e.readShort(),offset:this.offset+o+e.readShort()});for(s={},i=l=0,u=n.length;l<u;i=++l)r=n[i],e.pos=r.offset,c=e.readString(r.length),a=new pI(c,r),s[d=r.nameID]??(s[d]=[]),s[r.nameID].push(a);this.strings=s,this.copyright=s[0],this.fontFamily=s[1],this.fontSubfamily=s[2],this.uniqueSubfamily=s[3],this.fontName=s[4],this.version=s[5];try{this.postscriptName=s[6][0].raw.replace(/[\x00-\x19\x80-\xff]/g,``)}catch{this.postscriptName=s[4][0].raw.replace(/[\x00-\x19\x80-\xff]/g,``)}return this.trademark=s[7],this.manufacturer=s[8],this.designer=s[9],this.description=s[10],this.vendorUrl=s[11],this.designerUrl=s[12],this.license=s[13],this.licenseUrl=s[14],this.preferredFamily=s[15],this.preferredSubfamily=s[17],this.compatibleFull=s[18],this.sampleText=s[19]},e}(),hI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`maxp`,e.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.numGlyphs=e.readUInt16(),this.maxPoints=e.readUInt16(),this.maxContours=e.readUInt16(),this.maxCompositePoints=e.readUInt16(),this.maxComponentContours=e.readUInt16(),this.maxZones=e.readUInt16(),this.maxTwilightPoints=e.readUInt16(),this.maxStorage=e.readUInt16(),this.maxFunctionDefs=e.readUInt16(),this.maxInstructionDefs=e.readUInt16(),this.maxStackElements=e.readUInt16(),this.maxSizeOfInstructions=e.readUInt16(),this.maxComponentElements=e.readUInt16(),this.maxComponentDepth=e.readUInt16()},e}(),gI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`hmtx`,e.prototype.parse=function(e){var t,n,r,i,a,o,s;for(e.pos=this.offset,this.metrics=[],t=0,o=this.file.hhea.numberOfMetrics;0<=o?t<o:t>o;t=0<=o?++t:--t)this.metrics.push({advance:e.readUInt16(),lsb:e.readInt16()});for(r=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var n,i;for(i=[],t=n=0;0<=r?n<r:n>r;t=0<=r?++n:--n)i.push(e.readInt16());return i}(),this.widths=function(){var e,t,n,r;for(r=[],e=0,t=(n=this.metrics).length;e<t;e++)i=n[e],r.push(i.advance);return r}.call(this),n=this.widths[this.widths.length-1],s=[],t=a=0;0<=r?a<r:a>r;t=0<=r?++a:--a)s.push(this.widths.push(n));return s},e.prototype.forGlyph=function(e){return e in this.metrics?this.metrics[e]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[e-this.metrics.length]}},e}(),_I=[].slice,vI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`glyf`,e.prototype.parse=function(){return this.cache={}},e.prototype.glyphFor=function(e){var t,n,r,i,a,o,s,c,l,u;return e in this.cache?this.cache[e]:(i=this.file.loca,t=this.file.contents,n=i.indexOf(e),(r=i.lengthOf(e))===0?this.cache[e]=null:(t.pos=this.offset+n,a=(o=new rI(t.read(r))).readShort(),c=o.readShort(),u=o.readShort(),s=o.readShort(),l=o.readShort(),this.cache[e]=a===-1?new bI(o,c,u,s,l):new yI(o,a,c,u,s,l),this.cache[e]))},e.prototype.encode=function(e,t,n){var r,i,a,o,s;for(a=[],i=[],o=0,s=t.length;o<s;o++)r=e[t[o]],i.push(a.length),r&&(a=a.concat(r.encode(n)));return i.push(a.length),{table:a,offsets:i}},e}(),yI=function(){function e(e,t,n,r,i,a){this.raw=e,this.numberOfContours=t,this.xMin=n,this.yMin=r,this.xMax=i,this.yMax=a,this.compound=!1}return e.prototype.encode=function(){return this.raw.data},e}(),bI=function(){function e(e,t,n,r,i){var a,o;for(this.raw=e,this.xMin=t,this.yMin=n,this.xMax=r,this.yMax=i,this.compound=!0,this.glyphIDs=[],this.glyphOffsets=[],a=this.raw;o=a.readShort(),this.glyphOffsets.push(a.pos),this.glyphIDs.push(a.readUInt16()),32&o;)a.pos+=1&o?4:2,128&o?a.pos+=8:64&o?a.pos+=4:8&o&&(a.pos+=2)}return e.prototype.encode=function(){var e,t,n;for(t=new rI(_I.call(this.raw.data)),e=0,n=this.glyphIDs.length;e<n;++e)t.pos=this.glyphOffsets[e];return t.data},e}(),xI=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return oI(e,nI),e.prototype.tag=`loca`,e.prototype.parse=function(e){var t,n;return e.pos=this.offset,t=this.file.head.indexToLocFormat,this.offsets=t===0?function(){var t,r;for(r=[],n=0,t=this.length;n<t;n+=2)r.push(2*e.readUInt16());return r}.call(this):function(){var t,r;for(r=[],n=0,t=this.length;n<t;n+=4)r.push(e.readUInt32());return r}.call(this)},e.prototype.indexOf=function(e){return this.offsets[e]},e.prototype.lengthOf=function(e){return this.offsets[e+1]-this.offsets[e]},e.prototype.encode=function(e,t){for(var n=new Uint32Array(this.offsets.length),r=0,i=0,a=0;a<n.length;++a)if(n[a]=r,i<t.length&&t[i]==a){++i,n[a]=r;var o=this.offsets[a],s=this.offsets[a+1]-o;s>0&&(r+=s)}for(var c=Array(4*n.length),l=0;l<n.length;++l)c[4*l+3]=255&n[l],c[4*l+2]=(65280&n[l])>>8,c[4*l+1]=(16711680&n[l])>>16,c[4*l]=(4278190080&n[l])>>24;return c},e}(),SI=function(){function e(e){this.font=e,this.subset={},this.unicodes={},this.next=33}return e.prototype.generateCmap=function(){var e,t,n,r,i;for(t in r=this.font.cmap.tables[0].codeMap,e={},i=this.subset)n=i[t],e[t]=r[n];return e},e.prototype.glyphsFor=function(e){var t,n,r,i,a,o,s;for(r={},a=0,o=e.length;a<o;a++)r[i=e[a]]=this.font.glyf.glyphFor(i);for(i in t=[],r)(n=r[i])!=null&&n.compound&&t.push.apply(t,n.glyphIDs);if(t.length>0)for(i in s=this.glyphsFor(t))n=s[i],r[i]=n;return r},e.prototype.encode=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;for(r in n=lI.encode(this.generateCmap(),`unicode`),a=this.glyphsFor(e),f={0:0},g=n.charMap)f[(s=g[r]).old]=s.new;for(p in d=n.maxGlyphID,a)p in f||(f[p]=d++);return l=function(e){var t,n;for(t in n={},e)n[e[t]]=t;return n}(f),u=Object.keys(l).sort(function(e,t){return e-t}),m=function(){var e,t,n;for(n=[],e=0,t=u.length;e<t;e++)o=u[e],n.push(l[o]);return n}(),i=this.font.glyf.encode(a,m,f),c=this.font.loca.encode(i.offsets,m),h={cmap:this.font.cmap.raw(),glyf:i.table,loca:c,hmtx:this.font.hmtx.raw(),hhea:this.font.hhea.raw(),maxp:this.font.maxp.raw(),post:this.font.post.raw(),name:this.font.name.raw(),head:this.font.head.encode(t)},this.font.os2.exists&&(h[`OS/2`]=this.font.os2.raw()),this.font.directory.encode(h)},e}();kP.API.PDFObject=function(){var e;function t(){}return e=function(e,t){return(Array(t+1).join(`0`)+e).slice(-t)},t.convert=function(n){var r,i,a,o;if(Array.isArray(n))return`[`+function(){var e,i,a;for(a=[],e=0,i=n.length;e<i;e++)r=n[e],a.push(t.convert(r));return a}().join(` `)+`]`;if(typeof n==`string`)return`/`+n;if(n?.isString)return`(`+n+`)`;if(n instanceof Date)return`(D:`+e(n.getUTCFullYear(),4)+e(n.getUTCMonth(),2)+e(n.getUTCDate(),2)+e(n.getUTCHours(),2)+e(n.getUTCMinutes(),2)+e(n.getUTCSeconds(),2)+`Z)`;if({}.toString.call(n)===`[object Object]`){for(i in a=[`<<`],n)o=n[i],a.push(`/`+i+` `+t.convert(o));return a.push(`>>`),a.join(`
|
||
`)}return``+n},t}();function CI(e,t,n,r,i){r||={};var a=1.15,o=i.internal.scaleFactor,s=i.internal.getFontSize()/o,c=s*(i.getLineHeightFactor?i.getLineHeightFactor():a),l=/\r\n|\r|\n/g,u=``,d=1;if((r.valign===`middle`||r.valign===`bottom`||r.halign===`center`||r.halign===`right`)&&(u=typeof e==`string`?e.split(l):e,d=u.length||1),n+=s*(2-a),r.valign===`middle`?n-=d/2*c:r.valign===`bottom`&&(n-=d*c),r.halign===`center`||r.halign===`right`){var f=s;if(r.halign===`center`&&(f*=.5),u&&d>=1){for(var p=0;p<u.length;p++)i.text(u[p],t-i.getStringUnitWidth(u[p])*f,n),n+=c;return i}t-=i.getStringUnitWidth(e)*f}return r.halign===`justify`?i.text(e,t,n,{maxWidth:r.maxWidth||100,align:`justify`}):i.text(e,t,n),i}var wI={},TI=function(){function e(e){this.jsPDFDocument=e,this.userStyles={textColor:e.getTextColor?this.jsPDFDocument.getTextColor():0,fontSize:e.internal.getFontSize(),fontStyle:e.internal.getFont().fontStyle,font:e.internal.getFont().fontName,lineWidth:e.getLineWidth?this.jsPDFDocument.getLineWidth():0,lineColor:e.getDrawColor?this.jsPDFDocument.getDrawColor():0}}return e.setDefaults=function(e,t){t===void 0&&(t=null),t?t.__autoTableDocumentDefaults=e:wI=e},e.unifyColor=function(e){return Array.isArray(e)?e:typeof e==`number`?[e,e,e]:typeof e==`string`?[e]:null},e.prototype.applyStyles=function(t,n){var r,i,a;n===void 0&&(n=!1),t.fontStyle&&this.jsPDFDocument.setFontStyle&&this.jsPDFDocument.setFontStyle(t.fontStyle);var o=this.jsPDFDocument.internal.getFont(),s=o.fontStyle,c=o.fontName;if(t.font&&(c=t.font),t.fontStyle){s=t.fontStyle;var l=this.getFontList()[c];l&&l.indexOf(s)===-1&&this.jsPDFDocument.setFontStyle&&(this.jsPDFDocument.setFontStyle(l[0]),s=l[0])}if(this.jsPDFDocument.setFont(c,s),t.fontSize&&this.jsPDFDocument.setFontSize(t.fontSize),!n){var u=e.unifyColor(t.fillColor);u&&(r=this.jsPDFDocument).setFillColor.apply(r,u),u=e.unifyColor(t.textColor),u&&(i=this.jsPDFDocument).setTextColor.apply(i,u),u=e.unifyColor(t.lineColor),u&&(a=this.jsPDFDocument).setDrawColor.apply(a,u),typeof t.lineWidth==`number`&&this.jsPDFDocument.setLineWidth(t.lineWidth)}},e.prototype.splitTextToSize=function(e,t,n){return this.jsPDFDocument.splitTextToSize(e,t,n)},e.prototype.rect=function(e,t,n,r,i){return this.jsPDFDocument.rect(e,t,n,r,i)},e.prototype.getLastAutoTable=function(){return this.jsPDFDocument.lastAutoTable||null},e.prototype.getTextWidth=function(e){return this.jsPDFDocument.getTextWidth(e)},e.prototype.getDocument=function(){return this.jsPDFDocument},e.prototype.setPage=function(e){this.jsPDFDocument.setPage(e)},e.prototype.addPage=function(){return this.jsPDFDocument.addPage()},e.prototype.getFontList=function(){return this.jsPDFDocument.getFontList()},e.prototype.getGlobalOptions=function(){return wI||{}},e.prototype.getDocumentOptions=function(){return this.jsPDFDocument.__autoTableDocumentDefaults||{}},e.prototype.pageSize=function(){var e=this.jsPDFDocument.internal.pageSize;return e.width??(e={width:e.getWidth(),height:e.getHeight()}),e},e.prototype.scaleFactor=function(){return this.jsPDFDocument.internal.scaleFactor},e.prototype.getLineHeightFactor=function(){var e=this.jsPDFDocument;return e.getLineHeightFactor?e.getLineHeightFactor():1.15},e.prototype.getLineHeight=function(e){return e/this.scaleFactor()*this.getLineHeightFactor()},e.prototype.pageNumber=function(){var e=this.jsPDFDocument.internal.getCurrentPageInfo();return e?e.pageNumber:this.jsPDFDocument.internal.getNumberOfPages()},e}(),EI=function(e,t){return EI=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},EI(e,t)};function DI(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);EI(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var OI=function(e){DI(t,e);function t(t){var n=e.call(this)||this;return n._element=t,n}return t}(Array);function kI(e){return{font:`helvetica`,fontStyle:`normal`,overflow:`linebreak`,fillColor:!1,textColor:20,halign:`left`,valign:`top`,fontSize:10,cellPadding:5/e,lineColor:200,lineWidth:0,cellWidth:`auto`,minCellHeight:0,minCellWidth:0}}function AI(e){return{striped:{table:{fillColor:255,textColor:80,fontStyle:`normal`},head:{textColor:255,fillColor:[41,128,185],fontStyle:`bold`},body:{},foot:{textColor:255,fillColor:[41,128,185],fontStyle:`bold`},alternateRow:{fillColor:245}},grid:{table:{fillColor:255,textColor:80,fontStyle:`normal`,lineWidth:.1},head:{textColor:255,fillColor:[26,188,156],fontStyle:`bold`,lineWidth:0},body:{},foot:{textColor:255,fillColor:[26,188,156],fontStyle:`bold`,lineWidth:0},alternateRow:{}},plain:{head:{fontStyle:`bold`},foot:{fontStyle:`bold`}}}[e]}function jI(e,t,n){return n.applyStyles(t,!0),(Array.isArray(e)?e:[e]).map(function(e){return n.getTextWidth(e)}).reduce(function(e,t){return Math.max(e,t)},0)}function MI(e,t,n,r){var i=t.settings.tableLineWidth,a=t.settings.tableLineColor;e.applyStyles({lineWidth:i,lineColor:a});var o=NI(i,!1);o&&e.rect(n.x,n.y,t.getWidth(e.pageSize().width),r.y-n.y,o)}function NI(e,t){var n=e>0,r=t||t===0;return n&&r?`DF`:n?`S`:r?`F`:null}function PI(e,t){if(e||=t,Array.isArray(e)){if(e.length>=4)return{top:e[0],right:e[1],bottom:e[2],left:e[3]};if(e.length===3)return{top:e[0],right:e[1],bottom:e[2],left:e[1]};if(e.length===2)return{top:e[0],right:e[1],bottom:e[0],left:e[1]};e=e.length===1?e[0]:t}return typeof e==`object`?(typeof e.vertical==`number`&&(e.top=e.vertical,e.bottom=e.vertical),typeof e.horizontal==`number`&&(e.right=e.horizontal,e.left=e.horizontal),{left:e.left??t,top:e.top??t,right:e.right??t,bottom:e.bottom??t}):(typeof e!=`number`&&(e=t),{top:e,right:e,bottom:e,left:e})}function FI(e,t){var n=PI(t.settings.margin,0);return e.pageSize().width-(n.left+n.right)}function II(e,t,n,r,i){var a={},o=96/72,s=RI(t,function(e){return i.getComputedStyle(e).backgroundColor});s!=null&&(a.fillColor=s);var c=RI(t,function(e){return i.getComputedStyle(e).color});c!=null&&(a.textColor=c);var l=BI(r,n);l&&(a.cellPadding=l);var u=`borderTopColor`,d=o*n,f=r.borderTopWidth;if(r.borderBottomWidth===f&&r.borderRightWidth===f&&r.borderLeftWidth===f){var p=(parseFloat(f)||0)/d;p&&(a.lineWidth=p)}else a.lineWidth={top:(parseFloat(r.borderTopWidth)||0)/d,right:(parseFloat(r.borderRightWidth)||0)/d,bottom:(parseFloat(r.borderBottomWidth)||0)/d,left:(parseFloat(r.borderLeftWidth)||0)/d},a.lineWidth.top||(a.lineWidth.right?u=`borderRightColor`:a.lineWidth.bottom?u=`borderBottomColor`:a.lineWidth.left&&(u=`borderLeftColor`));var m=RI(t,function(e){return i.getComputedStyle(e)[u]});m!=null&&(a.lineColor=m);var h=[`left`,`right`,`center`,`justify`];h.indexOf(r.textAlign)!==-1&&(a.halign=r.textAlign),h=[`middle`,`bottom`,`top`],h.indexOf(r.verticalAlign)!==-1&&(a.valign=r.verticalAlign);var g=parseInt(r.fontSize||``);isNaN(g)||(a.fontSize=g/o);var _=LI(r);_&&(a.fontStyle=_);var v=(r.fontFamily||``).toLowerCase();return e.indexOf(v)!==-1&&(a.font=v),a}function LI(e){var t=``;return(e.fontWeight===`bold`||e.fontWeight===`bolder`||parseInt(e.fontWeight)>=700)&&(t=`bold`),(e.fontStyle===`italic`||e.fontStyle===`oblique`)&&(t+=`italic`),t}function RI(e,t){var n=zI(e,t);if(!n)return null;var r=n.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d*))?\)$/);if(!r||!Array.isArray(r))return null;var i=[parseInt(r[1]),parseInt(r[2]),parseInt(r[3])];return parseInt(r[4])===0||isNaN(i[0])||isNaN(i[1])||isNaN(i[2])?null:i}function zI(e,t){var n=t(e);return n===`rgba(0, 0, 0, 0)`||n===`transparent`||n===`initial`||n===`inherit`?e.parentElement==null?null:zI(e.parentElement,t):n}function BI(e,t){var n=[e.paddingTop,e.paddingRight,e.paddingBottom,e.paddingLeft],r=96/(72/t),i=(parseInt(e.lineHeight)-parseInt(e.fontSize))/t/2,a=PI(n.map(function(e){return parseInt(e||`0`)/r}),0);return i>a.top&&(a.top=i),i>a.bottom&&(a.bottom=i),a}function VI(e,t,n,r,i){r===void 0&&(r=!1),i===void 0&&(i=!1);var a=typeof t==`string`?n.document.querySelector(t):t,o=Object.keys(e.getFontList()),s=e.scaleFactor(),c=[],l=[],u=[];if(!a)return console.error(`Html table could not be found with input: `,t),{head:c,body:l,foot:u};for(var d=0;d<a.rows.length;d++){var f=a.rows[d],p=(f?.parentElement?.tagName)?.toLowerCase(),m=HI(o,s,n,f,r,i);m&&(p===`thead`?c.push(m):p===`tfoot`?u.push(m):l.push(m))}return{head:c,body:l,foot:u}}function HI(e,t,n,r,i,a){for(var o=new OI(r),s=0;s<r.cells.length;s++){var c=r.cells[s],l=n.getComputedStyle(c);if(i||l.display!==`none`){var u=void 0;a&&(u=II(e,c,t,l,n)),o.push({rowSpan:c.rowSpan,colSpan:c.colSpan,styles:u,_element:c,content:UI(c)})}}var d=n.getComputedStyle(r);if(o.length>0&&(i||d.display!==`none`))return o}function UI(e){var t=e.cloneNode(!0);return t.innerHTML=t.innerHTML.replace(/\n/g,``).replace(/ +/g,` `),t.innerHTML=t.innerHTML.split(/<br.*?>/).map(function(e){return e.trim()}).join(`
|
||
`),t.innerText||t.textContent||``}function WI(e,t,n){for(var r=0,i=[e,t,n];r<i.length;r++){var a=i[r];a&&typeof a!=`object`&&console.error(`The options parameter should be of type object, is: `+typeof a),a.startY&&typeof a.startY!=`number`&&(console.error(`Invalid value for startY option`,a.startY),delete a.startY)}}function GI(e,t,n,r,i){if(e==null)throw TypeError(`Cannot convert undefined or null to object`);for(var a=Object(e),o=1;o<arguments.length;o++){var s=arguments[o];if(s!=null)for(var c in s)Object.prototype.hasOwnProperty.call(s,c)&&(a[c]=s[c])}return a}function KI(e,t){var n=new TI(e),r=n.getDocumentOptions(),i=n.getGlobalOptions();WI(i,r,t);var a=GI({},i,r,t),o;typeof window<`u`&&(o=window);var s=qI(i,r,t),c=JI(i,r,t),l=YI(n,a),u=ZI(n,a,o);return{id:t.tableId,content:u,hooks:c,styles:s,settings:l}}function qI(e,t,n){for(var r={styles:{},headStyles:{},bodyStyles:{},footStyles:{},alternateRowStyles:{},columnStyles:{}},i=function(i){if(i===`columnStyles`){var a=e[i],o=t[i],s=n[i];r.columnStyles=GI({},a,o,s)}else{var c=[e,t,n].map(function(e){return e[i]||{}});r[i]=GI({},c[0],c[1],c[2])}},a=0,o=Object.keys(r);a<o.length;a++){var s=o[a];i(s)}return r}function JI(e,t,n){for(var r=[e,t,n],i={didParseCell:[],willDrawCell:[],didDrawCell:[],willDrawPage:[],didDrawPage:[]},a=0,o=r;a<o.length;a++){var s=o[a];s.didParseCell&&i.didParseCell.push(s.didParseCell),s.willDrawCell&&i.willDrawCell.push(s.willDrawCell),s.didDrawCell&&i.didDrawCell.push(s.didDrawCell),s.willDrawPage&&i.willDrawPage.push(s.willDrawPage),s.didDrawPage&&i.didDrawPage.push(s.didDrawPage)}return i}function YI(e,t){var n=PI(t.margin,40/e.scaleFactor()),r=XI(e,t.startY)??n.top,i=t.showFoot===!0?`everyPage`:t.showFoot===!1?`never`:t.showFoot??`everyPage`,a=t.showHead===!0?`everyPage`:t.showHead===!1?`never`:t.showHead??`everyPage`,o=t.useCss??!1,s=t.theme||(o?`plain`:`striped`),c=!!t.horizontalPageBreak,l=t.horizontalPageBreakRepeat??null;return{includeHiddenHtml:t.includeHiddenHtml??!1,useCss:o,theme:s,startY:r,margin:n,pageBreak:t.pageBreak??`auto`,rowPageBreak:t.rowPageBreak??`auto`,tableWidth:t.tableWidth??`auto`,showHead:a,showFoot:i,tableLineWidth:t.tableLineWidth??0,tableLineColor:t.tableLineColor??200,horizontalPageBreak:c,horizontalPageBreakRepeat:l,horizontalPageBreakBehaviour:t.horizontalPageBreakBehaviour??`afterAllRows`}}function XI(e,t){var n=e.getLastAutoTable(),r=e.scaleFactor(),i=e.pageNumber(),a=!1;return n&&n.startPageNumber&&(a=n.startPageNumber+n.pageNumber-1===i),typeof t==`number`?t:(t==null||t===!1)&&a&&n?.finalY!=null?n.finalY+20/r:null}function ZI(e,t,n){var r=t.head||[],i=t.body||[],a=t.foot||[];if(t.html){var o=t.includeHiddenHtml;if(n){var s=VI(e,t.html,n,o,t.useCss)||{};r=s.head||r,i=s.body||r,a=s.foot||r}else console.error(`Cannot parse html in non browser environment`)}return{columns:t.columns||QI(r,i,a),head:r,body:i,foot:a}}function QI(e,t,n){var r=e[0]||t[0]||n[0]||[],i=[];return Object.keys(r).filter(function(e){return e!==`_element`}).forEach(function(e){var t=1,n=Array.isArray(r)?r[parseInt(e)]:r[e];typeof n==`object`&&!Array.isArray(n)&&(t=n?.colSpan||1);for(var a=0;a<t;a++){var o=void 0;o=Array.isArray(r)?i.length:e+(a>0?`_${a}`:``);var s={dataKey:o};i.push(s)}}),i}var $I=function(){function e(e,t,n){this.table=t,this.pageNumber=t.pageNumber,this.settings=t.settings,this.cursor=n,this.doc=e.getDocument()}return e}(),eL=function(e){DI(t,e);function t(t,n,r,i,a,o){var s=e.call(this,t,n,o)||this;return s.cell=r,s.row=i,s.column=a,s.section=i.section,s}return t}($I),tL=function(){function e(e,t){this.pageNumber=1,this.id=e.id,this.settings=e.settings,this.styles=e.styles,this.hooks=e.hooks,this.columns=t.columns,this.head=t.head,this.body=t.body,this.foot=t.foot}return e.prototype.getHeadHeight=function(e){return this.head.reduce(function(t,n){return t+n.getMaxCellHeight(e)},0)},e.prototype.getFootHeight=function(e){return this.foot.reduce(function(t,n){return t+n.getMaxCellHeight(e)},0)},e.prototype.allRows=function(){return this.head.concat(this.body).concat(this.foot)},e.prototype.callCellHooks=function(e,t,n,r,i,a){for(var o=0,s=t;o<s.length;o++){var c=s[o],l=c(new eL(e,this,n,r,i,a))===!1;if(n.text=Array.isArray(n.text)?n.text:[n.text],l)return!1}return!0},e.prototype.callEndPageHooks=function(e,t){e.applyStyles(e.userStyles);for(var n=0,r=this.hooks.didDrawPage;n<r.length;n++){var i=r[n];i(new $I(e,this,t))}},e.prototype.callWillDrawPageHooks=function(e,t){for(var n=0,r=this.hooks.willDrawPage;n<r.length;n++){var i=r[n];i(new $I(e,this,t))}},e.prototype.getWidth=function(e){if(typeof this.settings.tableWidth==`number`)return this.settings.tableWidth;if(this.settings.tableWidth===`wrap`)return this.columns.reduce(function(e,t){return e+t.wrappedWidth},0);var t=this.settings.margin;return e-t.left-t.right},e}(),nL=function(){function e(e,t,n,r,i){i===void 0&&(i=!1),this.height=0,this.raw=e,e instanceof OI&&(this.raw=e._element,this.element=e._element),this.index=t,this.section=n,this.cells=r,this.spansMultiplePages=i}return e.prototype.getMaxCellHeight=function(e){var t=this;return e.reduce(function(e,n){return Math.max(e,t.cells[n.index]?.height||0)},0)},e.prototype.hasRowSpan=function(e){var t=this;return e.filter(function(e){var n=t.cells[e.index];return n?n.rowSpan>1:!1}).length>0},e.prototype.canEntireRowFit=function(e,t){return this.getMaxCellHeight(t)<=e},e.prototype.getMinimumRowHeight=function(e,t){var n=this;return e.reduce(function(e,r){var i=n.cells[r.index];if(!i)return 0;var a=t.getLineHeight(i.styles.fontSize),o=i.padding(`vertical`)+a;return o>e?o:e},0)},e}(),rL=function(){function e(e,t,n){this.contentHeight=0,this.contentWidth=0,this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.height=0,this.x=0,this.y=0,this.styles=t,this.section=n,this.raw=e;var r=e;typeof e==`object`&&e&&!Array.isArray(e)?(this.rowSpan=e.rowSpan||1,this.colSpan=e.colSpan||1,r=e.content??e,e._element&&(this.raw=e._element)):(this.rowSpan=1,this.colSpan=1);var i=r==null?``:``+r,a=/\r\n|\r|\n/g;this.text=i.split(a)}return e.prototype.getTextPos=function(){var e;if(this.styles.valign===`top`)e=this.y+this.padding(`top`);else if(this.styles.valign===`bottom`)e=this.y+this.height-this.padding(`bottom`);else{var t=this.height-this.padding(`vertical`);e=this.y+t/2+this.padding(`top`)}var n;if(this.styles.halign===`right`)n=this.x+this.width-this.padding(`right`);else if(this.styles.halign===`center`){var r=this.width-this.padding(`horizontal`);n=this.x+r/2+this.padding(`left`)}else n=this.x+this.padding(`left`);return{x:n,y:e}},e.prototype.getContentHeight=function(e,t){t===void 0&&(t=1.15);var n=(Array.isArray(this.text)?this.text.length:1)*(this.styles.fontSize/e*t)+this.padding(`vertical`);return Math.max(n,this.styles.minCellHeight)},e.prototype.padding=function(e){var t=PI(this.styles.cellPadding,0);return e===`vertical`?t.top+t.bottom:e===`horizontal`?t.left+t.right:t[e]},e}(),iL=function(){function e(e,t,n){this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.dataKey=e,this.raw=t,this.index=n}return e.prototype.getMaxCustomCellWidth=function(e){for(var t=0,n=0,r=e.allRows();n<r.length;n++){var i=r[n].cells[this.index];i&&typeof i.styles.cellWidth==`number`&&(t=Math.max(t,i.styles.cellWidth))}return t},e}();function aL(e,t){oL(e,t);var n=[],r=0;t.columns.forEach(function(e){var i=e.getMaxCustomCellWidth(t);i?e.width=i:(e.width=e.wrappedWidth,n.push(e)),r+=e.width});var i=t.getWidth(e.pageSize().width)-r;i&&=sL(n,i,function(e){return Math.max(e.minReadableWidth,e.minWidth)}),i&&=sL(n,i,function(e){return e.minWidth}),i=Math.abs(i),!t.settings.horizontalPageBreak&&i>.1/e.scaleFactor()&&(i=i<1?i:Math.round(i),console.log(`Of the table content, ${i} units width could not fit page`)),lL(t),uL(t,e),cL(t)}function oL(e,t){var n=e.scaleFactor(),r=t.settings.horizontalPageBreak,i=FI(e,t);t.allRows().forEach(function(a){for(var o=0,s=t.columns;o<s.length;o++){var c=s[o],l=a.cells[c.index];if(l){var u=t.hooks.didParseCell;t.callCellHooks(e,u,l,a,c,null);var d=l.padding(`horizontal`);if(l.contentWidth=jI(l.text,l.styles,e)+d,l.minReadableWidth=jI(l.text.join(` `).split(/[^\S\u00A0]+/),l.styles,e)+l.padding(`horizontal`),typeof l.styles.cellWidth==`number`)l.minWidth=l.styles.cellWidth,l.wrappedWidth=l.styles.cellWidth;else if(l.styles.cellWidth===`wrap`||r===!0)l.contentWidth>i?(l.minWidth=i,l.wrappedWidth=i):(l.minWidth=l.contentWidth,l.wrappedWidth=l.contentWidth);else{var f=10/n;l.minWidth=l.styles.minCellWidth||f,l.wrappedWidth=l.contentWidth,l.minWidth>l.wrappedWidth&&(l.wrappedWidth=l.minWidth)}}}}),t.allRows().forEach(function(e){for(var n=0,r=t.columns;n<r.length;n++){var i=r[n],a=e.cells[i.index];if(a&&a.colSpan===1)i.wrappedWidth=Math.max(i.wrappedWidth,a.wrappedWidth),i.minWidth=Math.max(i.minWidth,a.minWidth),i.minReadableWidth=Math.max(i.minReadableWidth,a.minReadableWidth);else{var o=t.styles.columnStyles[i.dataKey]||t.styles.columnStyles[i.index]||{},s=o.cellWidth||o.minCellWidth;s&&typeof s==`number`&&(i.minWidth=s,i.wrappedWidth=s)}a&&(a.colSpan>1&&!i.minWidth&&(i.minWidth=a.minWidth),a.colSpan>1&&!i.wrappedWidth&&(i.wrappedWidth=a.minWidth))}})}function sL(e,t,n){for(var r=t,i=e.reduce(function(e,t){return e+t.wrappedWidth},0),a=0;a<e.length;a++){var o=e[a],s=r*(o.wrappedWidth/i),c=o.width+s,l=n(o),u=c<l?l:c;t-=u-o.width,o.width=u}if(t=Math.round(t*1e10)/1e10,t){var d=e.filter(function(e){return t<0?e.width>n(e):!0});d.length&&(t=sL(d,t,n))}return t}function cL(e){for(var t={},n=1,r=e.allRows(),i=0;i<r.length;i++)for(var a=r[i],o=0,s=e.columns;o<s.length;o++){var c=s[o],l=t[c.index];if(n>1)n--,delete a.cells[c.index];else if(l)l.cell.height+=a.height,n=l.cell.colSpan,delete a.cells[c.index],l.left--,l.left<=1&&delete t[c.index];else{var u=a.cells[c.index];if(!u)continue;if(u.height=a.height,u.rowSpan>1){var d=r.length-i,f=u.rowSpan>d?d:u.rowSpan;t[c.index]={cell:u,left:f,row:a}}}}}function lL(e){for(var t=e.allRows(),n=0;n<t.length;n++)for(var r=t[n],i=null,a=0,o=0,s=0;s<e.columns.length;s++){var c=e.columns[s];if(--o,o>1&&e.columns[s+1])a+=c.width,delete r.cells[c.index];else if(i){var l=i;delete r.cells[c.index],i=null,l.width=c.width+a}else{var l=r.cells[c.index];if(!l)continue;if(o=l.colSpan,a=0,l.colSpan>1){i=l,a+=c.width;continue}l.width=c.width+a}}}function uL(e,t){for(var n={count:0,height:0},r=0,i=e.allRows();r<i.length;r++){for(var a=i[r],o=0,s=e.columns;o<s.length;o++){var c=s[o],l=a.cells[c.index];if(l){t.applyStyles(l.styles,!0);var u=l.width-l.padding(`horizontal`);if(l.styles.overflow===`linebreak`)l.text=t.splitTextToSize(l.text,u+1/t.scaleFactor(),{fontSize:l.styles.fontSize});else if(l.styles.overflow===`ellipsize`)l.text=dL(l.text,u,l.styles,t,`...`);else if(l.styles.overflow===`hidden`)l.text=dL(l.text,u,l.styles,t,``);else if(typeof l.styles.overflow==`function`){var d=l.styles.overflow(l.text,u);typeof d==`string`?l.text=[d]:l.text=d}l.contentHeight=l.getContentHeight(t.scaleFactor(),t.getLineHeightFactor());var f=l.contentHeight/l.rowSpan;l.rowSpan>1&&n.count*n.height<f*l.rowSpan?n={height:f,count:l.rowSpan}:n&&n.count>0&&n.height>f&&(f=n.height),f>a.height&&(a.height=f)}}n.count--}}function dL(e,t,n,r,i){return e.map(function(e){return fL(e,t,n,r,i)})}function fL(e,t,n,r,i){var a=1e4*r.scaleFactor();if(t=Math.ceil(t*a)/a,t>=jI(e,n,r))return e;for(;t<jI(e+i,n,r)&&!(e.length<=1);)e=e.substring(0,e.length-1);return e.trim()+i}function pL(e,t){var n=new TI(e),r=new tL(t,mL(t,n.scaleFactor()));return aL(n,r),n.applyStyles(n.userStyles),r}function mL(e,t){var n=e.content,r=vL(n.columns);if(n.head.length===0){var i=gL(r,`head`);i&&n.head.push(i)}if(n.foot.length===0){var i=gL(r,`foot`);i&&n.foot.push(i)}var a=e.settings.theme,o=e.styles;return{columns:r,head:hL(`head`,n.head,r,o,a,t),body:hL(`body`,n.body,r,o,a,t),foot:hL(`foot`,n.foot,r,o,a,t)}}function hL(e,t,n,r,i,a){var o={};return t.map(function(t,s){for(var c=0,l={},u=0,d=0,f=0,p=n;f<p.length;f++){var m=p[f];if(o[m.index]==null||o[m.index].left===0)if(d===0){var h=void 0;h=Array.isArray(t)?t[m.index-u-c]:t[m.dataKey];var g={};typeof h==`object`&&!Array.isArray(h)&&(g=h?.styles||{});var _=yL(e,m,s,i,r,a,g),v=new rL(h,_,e);l[m.dataKey]=v,l[m.index]=v,d=v.colSpan-1,o[m.index]={left:v.rowSpan-1,times:d}}else d--,u++;else o[m.index].left--,d=o[m.index].times,c++}return new nL(t,s,e,l)})}function gL(e,t){var n={};return e.forEach(function(e){if(e.raw!=null){var r=_L(t,e.raw);r!=null&&(n[e.dataKey]=r)}}),Object.keys(n).length>0?n:null}function _L(e,t){if(e===`head`){if(typeof t==`object`)return t.header||null;if(typeof t==`string`||typeof t==`number`)return t}else if(e===`foot`&&typeof t==`object`)return t.footer;return null}function vL(e){return e.map(function(e,t){return new iL(typeof e==`object`?e.dataKey??t:t,e,t)})}function yL(e,t,n,r,i,a,o){var s=AI(r),c;e===`head`?c=i.headStyles:e===`body`?c=i.bodyStyles:e===`foot`&&(c=i.footStyles);var l=GI({},s.table,s[e],i.styles,c),u=i.columnStyles[t.dataKey]||i.columnStyles[t.index]||{},d=e===`body`?u:{},f=e===`body`&&n%2==0?GI({},s.alternateRow,i.alternateRowStyles):{};return GI(GI({},kI(a),l,f,d),o)}function bL(e,t,n){n===void 0&&(n={});var r=FI(e,t),i=new Map,a=[],o=[],s=[];Array.isArray(t.settings.horizontalPageBreakRepeat)?s=t.settings.horizontalPageBreakRepeat:(typeof t.settings.horizontalPageBreakRepeat==`string`||typeof t.settings.horizontalPageBreakRepeat==`number`)&&(s=[t.settings.horizontalPageBreakRepeat]),s.forEach(function(e){var n=t.columns.find(function(t){return t.dataKey===e||t.index===e});n&&!i.has(n.index)&&(i.set(n.index,!0),a.push(n.index),o.push(t.columns[n.index]),r-=n.wrappedWidth)});for(var c=!0,l=n?.start??0;l<t.columns.length;){if(i.has(l)){l++;continue}var u=t.columns[l].wrappedWidth;if(c||r>=u)c=!1,a.push(l),o.push(t.columns[l]),r-=u;else break;l++}return{colIndexes:a,columns:o,lastIndex:l-1}}function xL(e,t){for(var n=[],r=0;r<t.columns.length;r++){var i=bL(e,t,{start:r});i.columns.length&&(n.push(i),r=i.lastIndex)}return n}function SL(e,t){var n=t.settings,r=n.startY,i=n.margin,a={x:i.left,y:r},o=t.getHeadHeight(t.columns)+t.getFootHeight(t.columns),s=r+i.bottom+o;if(n.pageBreak===`avoid`){var c=t.body.reduce(function(e,t){return e+t.height},0);s+=c}var l=new TI(e);(n.pageBreak===`always`||n.startY!=null&&s>l.pageSize().height)&&(LL(l),a.y=i.top),t.callWillDrawPageHooks(l,a);var u=GI({},a);t.startPageNumber=l.pageNumber(),n.horizontalPageBreak?CL(l,t,u,a):(l.applyStyles(l.userStyles),(n.showHead===`firstPage`||n.showHead===`everyPage`)&&t.head.forEach(function(e){return ML(l,t,e,a,t.columns)}),l.applyStyles(l.userStyles),t.body.forEach(function(e,n){jL(l,t,e,n===t.body.length-1,u,a,t.columns)}),l.applyStyles(l.userStyles),(n.showFoot===`lastPage`||n.showFoot===`everyPage`)&&t.foot.forEach(function(e){return ML(l,t,e,a,t.columns)})),MI(l,t,u,a),t.callEndPageHooks(l,a),t.finalY=a.y,e.lastAutoTable=t,l.applyStyles(l.userStyles)}function CL(e,t,n,r){var i=xL(e,t);if(t.settings.horizontalPageBreakBehaviour===`afterAllRows`)i.forEach(function(i,a){e.applyStyles(e.userStyles),a>0?IL(e,t,n,r,i.columns,!0):wL(e,t,r,i.columns),TL(e,t,n,r,i.columns),DL(e,t,r,i.columns)});else for(var a=-1,o=i[0],s=function(){var s=a;if(o){e.applyStyles(e.userStyles);var c=o.columns;a>=0?IL(e,t,n,r,c,!0):wL(e,t,r,c),s=EL(e,t,a+1,r,c),DL(e,t,r,c)}var l=s-a;i.slice(1).forEach(function(i){e.applyStyles(e.userStyles),IL(e,t,n,r,i.columns,!0),EL(e,t,a+1,r,i.columns,l),DL(e,t,r,i.columns)}),a=s};a<t.body.length-1;)s()}function wL(e,t,n,r){var i=t.settings;e.applyStyles(e.userStyles),(i.showHead===`firstPage`||i.showHead===`everyPage`)&&t.head.forEach(function(i){return ML(e,t,i,n,r)})}function TL(e,t,n,r,i){e.applyStyles(e.userStyles),t.body.forEach(function(a,o){jL(e,t,a,o===t.body.length-1,n,r,i)})}function EL(e,t,n,r,i,a){e.applyStyles(e.userStyles),a??=t.body.length;for(var o=Math.min(n+a,t.body.length),s=-1,c=t.body.slice(n,o),l=0;l<c.length;l++){var u=c[l],d=FL(e,t,n+l===t.body.length-1,r);if(u.canEntireRowFit(d,i))ML(e,t,u,r,i),s=n+l;else break}return s}function DL(e,t,n,r){var i=t.settings;e.applyStyles(e.userStyles),(i.showFoot===`lastPage`||i.showFoot===`everyPage`)&&t.foot.forEach(function(i){return ML(e,t,i,n,r)})}function OL(e,t,n){var r=n.getLineHeight(e.styles.fontSize),i=e.padding(`vertical`),a=Math.floor((t-i)/r);return Math.max(0,a)}function kL(e,t,n,r){var i={};e.spansMultiplePages=!0,e.height=0;for(var a=0,o=0,s=n.columns;o<s.length;o++){var c=s[o],l=e.cells[c.index];if(l){Array.isArray(l.text)||(l.text=[l.text]);var u=new rL(l.raw,l.styles,l.section);u=GI(u,l),u.text=[];var d=OL(l,t,r);l.text.length>d&&(u.text=l.text.splice(d,l.text.length));var f=r.scaleFactor(),p=r.getLineHeightFactor();l.contentHeight=l.getContentHeight(f,p),l.contentHeight>=t&&(l.contentHeight=t,u.styles.minCellHeight-=t),l.contentHeight>e.height&&(e.height=l.contentHeight),u.contentHeight=u.getContentHeight(f,p),u.contentHeight>a&&(a=u.contentHeight),i[c.index]=u}}var m=new nL(e.raw,-1,e.section,i,!0);m.height=a;for(var h=0,g=n.columns;h<g.length;h++){var c=g[h],u=m.cells[c.index];u&&(u.height=m.height);var l=e.cells[c.index];l&&(l.height=e.height)}return m}function AL(e,t,n,r){var i=e.pageSize().height,a=r.settings.margin,o=i-(a.top+a.bottom);t.section===`body`&&(o-=r.getHeadHeight(r.columns)+r.getFootHeight(r.columns));var s=t.getMinimumRowHeight(r.columns,e),c=s<n;if(s>o)return console.log(`Will not be able to print row ${t.index} correctly since it's minimum height is larger than page height`),!0;if(!c)return!1;var l=t.hasRowSpan(r.columns);return t.getMaxCellHeight(r.columns)>o?(l&&console.log(`The content of row ${t.index} will not be drawn correctly since drawing rows with a height larger than the page height and has cells with rowspans is not supported.`),!0):!(l||r.settings.rowPageBreak===`avoid`)}function jL(e,t,n,r,i,a,o){var s=FL(e,t,r,a);if(n.canEntireRowFit(s,o))ML(e,t,n,a,o);else if(AL(e,n,s,t)){var c=kL(n,s,t,e);ML(e,t,n,a,o),IL(e,t,i,a,o),jL(e,t,c,r,i,a,o)}else IL(e,t,i,a,o),jL(e,t,n,r,i,a,o)}function ML(e,t,n,r,i){r.x=t.settings.margin.left;for(var a=0,o=i;a<o.length;a++){var s=o[a],c=n.cells[s.index];if(!c){r.x+=s.width;continue}if(e.applyStyles(c.styles),c.x=r.x,c.y=r.y,t.callCellHooks(e,t.hooks.willDrawCell,c,n,s,r)===!1){r.x+=s.width;continue}NL(e,c,r);var l=c.getTextPos();CI(c.text,l.x,l.y,{halign:c.styles.halign,valign:c.styles.valign,maxWidth:Math.ceil(c.width-c.padding(`left`)-c.padding(`right`))},e.getDocument()),t.callCellHooks(e,t.hooks.didDrawCell,c,n,s,r),r.x+=s.width}r.y+=n.height}function NL(e,t,n){var r=t.styles;if(e.getDocument().setFillColor(e.getDocument().getFillColor()),typeof r.lineWidth==`number`){var i=NI(r.lineWidth,r.fillColor);i&&e.rect(t.x,n.y,t.width,t.height,i)}else typeof r.lineWidth==`object`&&(r.fillColor&&e.rect(t.x,n.y,t.width,t.height,`F`),PL(e,t,n,r.lineWidth))}function PL(e,t,n,r){var i,a,o,s;r.top&&(i=n.x,a=n.y,o=n.x+t.width,s=n.y,r.right&&(o+=.5*r.right),r.left&&(i-=.5*r.left),c(r.top,i,a,o,s)),r.bottom&&(i=n.x,a=n.y+t.height,o=n.x+t.width,s=n.y+t.height,r.right&&(o+=.5*r.right),r.left&&(i-=.5*r.left),c(r.bottom,i,a,o,s)),r.left&&(i=n.x,a=n.y,o=n.x,s=n.y+t.height,r.top&&(a-=.5*r.top),r.bottom&&(s+=.5*r.bottom),c(r.left,i,a,o,s)),r.right&&(i=n.x+t.width,a=n.y,o=n.x+t.width,s=n.y+t.height,r.top&&(a-=.5*r.top),r.bottom&&(s+=.5*r.bottom),c(r.right,i,a,o,s));function c(t,n,r,i,a){e.getDocument().setLineWidth(t),e.getDocument().line(n,r,i,a,`S`)}}function FL(e,t,n,r){var i=t.settings.margin.bottom,a=t.settings.showFoot;return(a===`everyPage`||a===`lastPage`&&n)&&(i+=t.getFootHeight(t.columns)),e.pageSize().height-r.y-i}function IL(e,t,n,r,i,a){i===void 0&&(i=[]),a===void 0&&(a=!1),e.applyStyles(e.userStyles),t.settings.showFoot===`everyPage`&&!a&&t.foot.forEach(function(n){return ML(e,t,n,r,i)}),t.callEndPageHooks(e,r);var o=t.settings.margin;MI(e,t,n,r),LL(e),t.pageNumber++,r.x=o.left,r.y=o.top,n.y=o.top,t.callWillDrawPageHooks(e,r),t.settings.showHead===`everyPage`&&(t.head.forEach(function(n){return ML(e,t,n,r,i)}),e.applyStyles(e.userStyles))}function LL(e){var t=e.pageNumber();return e.setPage(t+1),e.pageNumber()===t?(e.addPage(),!0):!1}function RL(e){e.API.autoTable=function(){var e=[...arguments][0],t=KI(this,e),n=pL(this,t);return SL(this,n),this},e.API.lastAutoTable=!1,e.API.autoTableText=function(e,t,n,r){CI(e,t,n,r,this)},e.API.autoTableSetDefaults=function(e){return TI.setDefaults(e,this),this},e.autoTableSetDefaults=function(e,t){TI.setDefaults(e,t)},e.API.autoTableHtmlToJson=function(e,t){if(t===void 0&&(t=!1),typeof window>`u`)return console.error(`Cannot run autoTableHtmlToJson in non browser environment`),null;var n=VI(new TI(this),e,window,t,!1),r=n.head,i=n.body;return{columns:r[0]?.map(function(e){return e.content})||[],rows:i,data:i}}}function zL(e,t){SL(e,pL(e,KI(e,t)))}try{if(typeof window<`u`&&window){var BL=window,VL=BL.jsPDF||BL.jspdf?.jsPDF;VL&&RL(VL)}}catch(e){console.error(`Could not apply autoTable plugin`,e)}function HL(e,t){let n=new kP({orientation:`portrait`,unit:`mm`,format:`a4`}),r=n.internal.pageSize.getWidth();n.setFillColor(15,23,42),n.rect(0,0,r,40,`F`),n.setTextColor(255,255,255),n.setFont(`helvetica`,`bold`),n.setFontSize(18),n.text(`HYDRO BUILDER`,15,18),n.setFont(`helvetica`,`normal`),n.setFontSize(10),n.setTextColor(148,163,184),n.text(`BILL OF MATERIALS`,15,24),n.setTextColor(255,255,255),n.setFont(`helvetica`,`bold`),n.setFontSize(11);let i=t.length>30?t.substring(0,27)+`...`:t;n.text(i,r-15,18,{align:`right`}),n.setFont(`helvetica`,`normal`),n.setFontSize(9),n.setTextColor(148,163,184),n.text(`Date: ${new Date().toLocaleDateString()}`,r-15,24,{align:`right`});let a=50;if(n.setFillColor(248,250,252),n.setDrawColor(226,232,240),n.rect(15,a,r-30,22,`FD`),n.setFont(`helvetica`,`normal`),n.setFontSize(8),n.setTextColor(100,116,139),n.text(`TOTAL ESTIMATED COST`,23,a+7),n.text(`PART COUNT`,80,a+7),n.text(`LINE ITEMS`,130,a+7),n.setFont(`helvetica`,`bold`),n.setFontSize(12),n.setTextColor(14,116,144),n.text(oD(e.totalCost),23,a+15),n.setTextColor(15,23,42),n.text(`${e.partCount} parts`,80,a+15),n.text(`${e.lines.length} items`,130,a+15),e.cutLists.length>0){let t=e.cutLists.reduce((e,t)=>e+t.sticksToBuy,0);n.setFont(`helvetica`,`normal`),n.setFontSize(8),n.setTextColor(100,116,139),n.text(`PVC STICKS (10 FT)`,165,a+7),n.setFont(`helvetica`,`bold`),n.setFontSize(12),n.setTextColor(15,23,42),n.text(`${t} sticks`,165,a+15)}a+=32,n.setFont(`helvetica`,`bold`),n.setFontSize(11),n.setTextColor(15,23,42),n.text(`Line Items`,15,a),a+=4;let o=[`Category`,`Description`,`Spec`,`Qty`,`Unit`,`Unit Cost`,`Total`],s=e.lines.map(e=>[e.category,e.description,e.spec??``,e.qty,e.unit,oD(e.unitCost),oD(e.totalCost)+(e.estimated?` (est.)`:``)]);if(zL(n,{startY:a,head:[o],body:s,margin:{left:15,right:15},theme:`grid`,styles:{fontSize:8,cellPadding:2,font:`helvetica`},headStyles:{fillColor:[39,39,42],textColor:[255,255,255],fontStyle:`bold`},columnStyles:{0:{cellWidth:25},1:{cellWidth:50},2:{cellWidth:40},3:{cellWidth:12,halign:`center`},4:{cellWidth:15,halign:`center`},5:{cellWidth:18,halign:`right`},6:{cellWidth:20,halign:`right`}}}),a=n.lastAutoTable.finalY+10,e.cutLists.length>0){a>n.internal.pageSize.getHeight()-40&&(n.addPage(),a=20),n.setFont(`helvetica`,`bold`),n.setFontSize(11),n.setTextColor(15,23,42),n.text(`PVC Cut Lists (10 ft / 120 in sticks)`,15,a),a+=4;let t=[`Diameter`,`Stick`,`Cuts (in)`,`Used`,`Leftover`],r=[];for(let t of e.cutLists)for(let e of t.sticks){let n=e.cuts.map(e=>aD(e)).join(`, `);r.push([iD(t.diameterIn),`Stick ${e.index}`,n,aD(e.usedIn),aD(e.leftoverIn)])}zL(n,{startY:a,head:[t],body:r,margin:{left:15,right:15},theme:`grid`,styles:{fontSize:8,cellPadding:2,font:`helvetica`},headStyles:{fillColor:[71,85,105],textColor:[255,255,255],fontStyle:`bold`},columnStyles:{0:{cellWidth:25},1:{cellWidth:25},2:{cellWidth:90},3:{cellWidth:20,halign:`right`},4:{cellWidth:20,halign:`right`}}}),a=n.lastAutoTable.finalY+10}a>n.internal.pageSize.getHeight()-50&&(n.addPage(),a=20),n.setFont(`helvetica`,`bold`),n.setFontSize(11),n.setTextColor(15,23,42),n.text(`Category Subtotals`,15,a),a+=4;let c=[`Category`,`Subtotal`],l=e.categories.map(e=>[e.name,oD(e.subtotal)]);l.push([`Grand Total (Estimated)`,oD(e.totalCost)]),zL(n,{startY:a,head:[c],body:l,margin:{left:15,right:r-100},theme:`grid`,styles:{fontSize:8,cellPadding:2.5,font:`helvetica`},headStyles:{fillColor:[15,23,42],textColor:[255,255,255],fontStyle:`bold`},columnStyles:{0:{cellWidth:50},1:{cellWidth:35,halign:`right`,fontStyle:`bold`}},didParseCell:e=>{e.row.index===l.length-1&&(e.cell.styles.fillColor=[241,245,249],e.cell.styles.fontStyle=`bold`,e.column.index===1&&(e.cell.styles.textColor=[14,116,144]))}});let u=t.replace(/[^a-z0-9-_ ]/gi,``).trim()||`hydro-system`;n.save(`${u}-bom.pdf`)}var UL={POSITION:[`byte`,`byte normalized`,`unsigned byte`,`unsigned byte normalized`,`short`,`short normalized`,`unsigned short`,`unsigned short normalized`],NORMAL:[`byte normalized`,`short normalized`],TANGENT:[`byte normalized`,`short normalized`],TEXCOORD:[`byte`,`byte normalized`,`unsigned byte`,`short`,`short normalized`,`unsigned short`]},WL=class{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new dR(e)}),this.register(function(e){return new fR(e)}),this.register(function(e){return new gR(e)}),this.register(function(e){return new _R(e)}),this.register(function(e){return new vR(e)}),this.register(function(e){return new yR(e)}),this.register(function(e){return new pR(e)}),this.register(function(e){return new mR(e)}),this.register(function(e){return new hR(e)}),this.register(function(e){return new bR(e)}),this.register(function(e){return new xR(e)}),this.register(function(e){return new SR(e)}),this.register(function(e){return new CR(e)}),this.register(function(e){return new wR(e)})}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}setTextureUtils(e){return this.textureUtils=e,this}parse(e,t,n,r){let i=new uR,a=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)a.push(this.pluginCallbacks[e](i));i.setPlugins(a),i.setTextureUtils(this.textureUtils),i.writeAsync(e,t,r).catch(n)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,r,i,t)})}},GL={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},KL=`KHR_mesh_quantization`,qL={};qL[D]=GL.NEAREST,qL[O]=GL.NEAREST_MIPMAP_NEAREST,qL[A]=GL.NEAREST_MIPMAP_LINEAR,qL[M]=GL.LINEAR,qL[N]=GL.LINEAR_MIPMAP_NEAREST,qL[F]=GL.LINEAR_MIPMAP_LINEAR,qL[T]=GL.CLAMP_TO_EDGE,qL[w]=GL.REPEAT,qL[E]=GL.MIRRORED_REPEAT;var JL={scale:`scale`,position:`translation`,quaternion:`rotation`,morphTargetInfluences:`weights`},YL=new Y,XL=12,ZL=1179937895,QL=2,$L=8,eR=1313821514,tR=5130562;function nR(e,t){return e.length===t.length&&e.every(function(e,n){return e===t[n]})}function rR(e){return new TextEncoder().encode(e).buffer}function iR(e){return nR(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function aR(e,t,n){let r={min:Array(e.itemSize).fill(1/0),max:Array(e.itemSize).fill(-1/0)};for(let i=t;i<t+n;i++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[i*e.itemSize+t]:(t===0?n=e.getX(i):t===1?n=e.getY(i):t===2?n=e.getZ(i):t===3&&(n=e.getW(i)),e.normalized===!0&&(n=jn.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function oR(e){return Math.ceil(e/4)*4}function sR(e,t=0){let n=oR(e.byteLength);if(n!==e.byteLength){let r=new Uint8Array(n);if(r.set(new Uint8Array(e)),t!==0)for(let i=e.byteLength;i<n;i++)r[i]=t;return r.buffer}return e}function cR(){return typeof document>`u`&&typeof OffscreenCanvas<`u`?new OffscreenCanvas(1,1):document.createElement(`canvas`)}function lR(e,t){if(typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas){let n;return t===`image/jpeg`?n=.92:t===`image/webp`&&(n=.8),e.convertToBlob({type:t,quality:n})}else return new Promise(n=>e.toBlob(n,t))}var uR=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:`2.0`,generator:`THREE.GLTFExporter r184`}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this,i=r.buffers,a=r.json;n=r.options;let o=r.extensionsUsed,s=r.extensionsRequired,c=new Blob(i,{type:`application/octet-stream`}),l=Object.keys(o),u=Object.keys(s);if(l.length>0&&(a.extensionsUsed=l),u.length>0&&(a.extensionsRequired=u),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=c.size),n.binary===!0){let e=new FileReader;e.readAsArrayBuffer(c),e.onloadend=function(){let n=sR(e.result),r=new DataView(new ArrayBuffer($L));r.setUint32(0,n.byteLength,!0),r.setUint32(4,tR,!0);let i=sR(rR(JSON.stringify(a)),32),o=new DataView(new ArrayBuffer($L));o.setUint32(0,i.byteLength,!0),o.setUint32(4,eR,!0);let s=new ArrayBuffer(XL),c=new DataView(s);c.setUint32(0,ZL,!0),c.setUint32(4,QL,!0);let l=XL+o.byteLength+i.byteLength+r.byteLength+n.byteLength;c.setUint32(8,l,!0);let u=new Blob([s,o,i,r,n],{type:`application/octet-stream`}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(a.buffers&&a.buffers.length>0){let e=new FileReader;e.readAsDataURL(c),e.onloadend=function(){let n=e.result;a.buffers[0].uri=n,t(a)}}else t(a)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn(`THREE.GLTFExporter: userData of '`+e.name+`' won't be serialized because of JSON.stringify error - `+t.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new q;for(let n=0,r=e.count;n<r;n++)if(Math.abs(t.fromBufferAttribute(e,n).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new q;for(let e=0,t=n.count;e<t;e++)r.fromBufferAttribute(n,e),r.x===0&&r.y===0&&r.z===0?r.setX(1):r.normalize(),n.setXYZ(e,r.x,r.y,r.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1,r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,t){if(e===t)return e;function n(e){return e.colorSpace===`srgb`?function(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}:function(e){return e}}e instanceof ds&&(e=await this.decompressTextureAsync(e)),t instanceof ds&&(t=await this.decompressTextureAsync(t));let r=e?e.image:null,i=t?t.image:null,a=Math.max(r?r.width:0,i?i.width:0),o=Math.max(r?r.height:0,i?i.height:0),s=cR();s.width=a,s.height=o;let c=s.getContext(`2d`,{willReadFrequently:!0});c.fillStyle=`#00ffff`,c.fillRect(0,0,a,o);let l=c.getImageData(0,0,a,o);if(r){c.drawImage(r,0,0,a,o);let t=n(e),i=c.getImageData(0,0,a,o).data;for(let e=2;e<i.length;e+=4)l.data[e]=t(i[e]/256)*256}if(i){c.drawImage(i,0,0,a,o);let e=n(t),r=c.getImageData(0,0,a,o).data;for(let t=1;t<r.length;t+=4)l.data[t]=e(r[t]/256)*256}c.putImageData(l,0,0);let u=(e||t).clone();return u.source=new Kn(s),u.colorSpace=``,u.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn(`THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.`),console.warn(`THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.`),u}async decompressTextureAsync(e,t=1/0){if(this.textureUtils===null)throw Error(`THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.`);return await this.textureUtils.decompress(e,t)}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||=[{byteLength:0}],n.push(e),0}processBufferView(e,t,n,r,i){let a=this.json;a.bufferViews||=[];let o;switch(t){case GL.BYTE:case GL.UNSIGNED_BYTE:o=1;break;case GL.SHORT:case GL.UNSIGNED_SHORT:o=2;break;default:o=4}let s=e.itemSize*o;i===GL.ARRAY_BUFFER&&(s=Math.ceil(s/4)*4);let c=oR(r*s),l=new DataView(new ArrayBuffer(c)),u=0;for(let i=n;i<n+r;i++){for(let n=0;n<e.itemSize;n++){let r;e.itemSize>4?r=e.array[i*e.itemSize+n]:(n===0?r=e.getX(i):n===1?r=e.getY(i):n===2?r=e.getZ(i):n===3&&(r=e.getW(i)),e.normalized===!0&&(r=jn.normalize(r,e.array))),t===GL.FLOAT?l.setFloat32(u,r,!0):t===GL.INT?l.setInt32(u,r,!0):t===GL.UNSIGNED_INT?l.setUint32(u,r,!0):t===GL.SHORT?l.setInt16(u,r,!0):t===GL.UNSIGNED_SHORT?l.setUint16(u,r,!0):t===GL.BYTE?l.setInt8(u,r):t===GL.UNSIGNED_BYTE&&l.setUint8(u,r),u+=o}u%s!==0&&(u+=s-u%s)}let d={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:c};return i!==void 0&&(d.target=i),i===GL.ARRAY_BUFFER&&(d.byteStride=s),this.byteOffset+=c,a.bufferViews.push(d),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||=[],new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=sR(i.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let i=this.json,a={1:`SCALAR`,2:`VEC2`,3:`VEC3`,4:`VEC4`,9:`MAT3`,16:`MAT4`},o;if(e.array.constructor===Float32Array)o=GL.FLOAT;else if(e.array.constructor===Int32Array)o=GL.INT;else if(e.array.constructor===Uint32Array)o=GL.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=GL.SHORT;else if(e.array.constructor===Uint16Array)o=GL.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=GL.BYTE;else if(e.array.constructor===Uint8Array)o=GL.UNSIGNED_BYTE;else throw Error(`THREE.GLTFExporter: Unsupported bufferAttribute component type: `+e.array.constructor.name);if(n===void 0&&(n=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;let s=aR(e,n,r),c;t!==void 0&&(c=e===t.index?GL.ELEMENT_ARRAY_BUFFER:GL.ARRAY_BUFFER);let l=this.processBufferView(e,o,n,r,c),u={bufferView:l.id,byteOffset:l.byteOffset,componentType:o,count:r,max:s.max,min:s.min,type:a[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||=[],i.accessors.push(u)-1}processImage(e,t,n,r=`image/png`){if(e!==null){let i=this,a=i.cache,o=i.json,s=i.options,c=i.pending;a.images.has(e)||a.images.set(e,{});let l=a.images.get(e),u=r+`:flipY/`+n.toString();if(l[u]!==void 0)return l[u];o.images||=[];let d={mimeType:r},f=cR();f.width=Math.min(e.width,s.maxTextureSize),f.height=Math.min(e.height,s.maxTextureSize);let p=f.getContext(`2d`,{willReadFrequently:!0});if(n===!0&&(p.translate(0,f.height),p.scale(1,-1)),e.data!==void 0){t!==1023&&console.error(`GLTFExporter: Only RGBAFormat is supported.`,t),(e.width>s.maxTextureSize||e.height>s.maxTextureSize)&&console.warn(`GLTFExporter: Image size is bigger than maxTextureSize`,e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)p.drawImage(e,0,0,f.width,f.height);else throw Error(`THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.`);s.binary===!0?c.push(lR(f,r).then(e=>i.processBufferViewImage(e)).then(e=>{d.bufferView=e})):d.uri=Wn.getDataURL(f,r);let m=o.images.push(d)-1;return l[u]=m,m}else throw Error(`THREE.GLTFExporter: No valid image data found. Unable to process texture.`)}processSampler(e){let t=this.json;t.samplers||=[];let n={magFilter:qL[e.magFilter],minFilter:qL[e.minFilter],wrapS:qL[e.wrapS],wrapT:qL[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);r.textures||=[],e instanceof ds&&(e=await this.decompressTextureAsync(e,t.maxTextureSize));let i=e.userData.mimeType,a=this.processImage(e.image,e.format,e.flipY,i),o={sampler:this.processSampler(e)};i===`image/webp`?(o.extensions=o.extensions||{},o.extensions.EXT_texture_webp={source:a},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):o.source=a,e.name&&(o.name=e.name),await this._invokeAllAsync(async function(t){t.writeTexture&&await t.writeTexture(e,o)});let s=r.textures.push(o)-1;return n.textures.set(e,s),s}async processMaterialAsync(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn(`GLTFExporter: THREE.ShaderMaterial not supported.`),null;n.materials||=[];let r={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn(`GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.`);let i=e.color.toArray().concat([e.opacity]);if(nR(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=0,r.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),r.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode=`BLEND`:e.alphaTest>0&&(r.alphaMode=`MASK`,r.alphaCutoff=e.alphaTest),e.side===2&&(r.doubleSided=!0),e.name!==``&&(r.name=e.name),this.serializeUserData(e,r),await this._invokeAllAsync(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,r)});let a=n.materials.push(r)-1;return t.materials.set(e,a),a}async processMeshAsync(e){let t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)r.push(e.material[t].uuid);else r.push(e.material.uuid);let i=r.join(`:`);if(t.meshes.has(i))return t.meshes.get(i);let a=e.geometry,o;o=e.isLineSegments?GL.LINES:e.isLineLoop?GL.LINE_LOOP:e.isLine?GL.LINE_STRIP:e.isPoints?GL.POINTS:e.material.wireframe?GL.LINES:GL.TRIANGLES;let s={},c={},l=[],u=[],d={uv:`TEXCOORD_0`,uv1:`TEXCOORD_1`,uv2:`TEXCOORD_2`,uv3:`TEXCOORD_3`,color:`COLOR_0`,skinWeight:`WEIGHTS_0`,skinIndex:`JOINTS_0`},f=a.getAttribute(`normal`);f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn(`THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.`),a.setAttribute(`normal`,this.createNormalizedNormalAttribute(f)));let p=null;for(let e in a.attributes){if(e.slice(0,5)===`morph`)continue;let n=a.attributes[e];if(e=d[e]||e.toUpperCase(),!/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)&&!e.startsWith(`_`)&&(e=`_`+e),t.attributes.has(this.getUID(n))){c[e]=t.attributes.get(this.getUID(n));continue}p=null;let r=n.array;e===`JOINTS_0`&&!(r instanceof Uint16Array)&&!(r instanceof Uint8Array)?(console.warn(`GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.`),p=WL.Utils.toTypedBufferAttribute(n,Uint16Array)):(r instanceof Uint32Array||r instanceof Int32Array)&&!e.startsWith(`_`)&&(console.warn(`GLTFExporter: Attribute "${e}" converted to type FLOAT.`),p=WL.Utils.toTypedBufferAttribute(n,Float32Array));let i=this.processAccessor(p||n,a);i!==null&&(e.startsWith(`_`)||this.detectMeshQuantization(e,n),c[e]=i,t.attributes.set(this.getUID(n),i))}if(f!==void 0&&a.setAttribute(`normal`,f),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let n=[],r=[],i={};if(e.morphTargetDictionary!==void 0)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let o=0;o<e.morphTargetInfluences.length;++o){let s={},c=!1;for(let e in a.morphAttributes){if(e!==`position`&&e!==`normal`){c||=(console.warn(`GLTFExporter: Only POSITION and NORMAL morph are supported.`),!0);continue}let n=a.morphAttributes[e][o],r=e.toUpperCase(),i=a.attributes[e];if(t.attributes.has(this.getUID(n,!0))){s[r]=t.attributes.get(this.getUID(n,!0));continue}let l=n.clone();if(!a.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let t=0;t<n.itemSize;t++)t===0&&l.setX(e,n.getX(e)-i.getX(e)),t===1&&l.setY(e,n.getY(e)-i.getY(e)),t===2&&l.setZ(e,n.getZ(e)-i.getZ(e)),t===3&&l.setW(e,n.getW(e)-i.getW(e));s[r]=this.processAccessor(l,a),t.attributes.set(this.getUID(i,!0),s[r])}u.push(s),n.push(e.morphTargetInfluences[o]),e.morphTargetDictionary!==void 0&&r.push(i[o])}s.weights=n,r.length>0&&(s.extras={},s.extras.targetNames=r)}let m=Array.isArray(e.material);if(m&&a.groups.length===0)return null;let h=!1;if(m&&a.index===null){let e=[];for(let t=0,n=a.attributes.position.count;t<n;t++)e[t]=t;a.setIndex(e),h=!0}let g=m?e.material:[e.material],_=m?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=_.length;e<n;e++){let n={mode:o,attributes:c};if(this.serializeUserData(a,n),u.length>0&&(n.targets=u),a.index!==null){let r=this.getUID(a.index);(_[e].start!==void 0||_[e].count!==void 0)&&(r+=`:`+_[e].start+`:`+_[e].count),t.attributes.has(r)?n.indices=t.attributes.get(r):(n.indices=this.processAccessor(a.index,a,_[e].start,_[e].count),t.attributes.set(r,n.indices)),n.indices===null&&delete n.indices}let r=await this.processMaterialAsync(g[_[e].materialIndex]);r!==null&&(n.material=r),l.push(n)}h===!0&&a.setIndex(null),s.primitives=l,n.meshes||=[],await this._invokeAllAsync(function(t){t.writeMesh&&t.writeMesh(e,s)});let v=n.meshes.push(s)-1;return t.meshes.set(i,v),v}detectMeshQuantization(e,t){if(this.extensionsUsed[KL])return;let n;switch(t.array.constructor){case Int8Array:n=`byte`;break;case Uint8Array:n=`unsigned byte`;break;case Int16Array:n=`short`;break;case Uint16Array:n=`unsigned short`;break;default:return}t.normalized&&(n+=` normalized`);let r=e.split(`_`,1)[0];UL[r]&&UL[r].includes(n)&&(this.extensionsUsed[KL]=!0,this.extensionsRequired[KL]=!0)}processCamera(e){let t=this.json;t.cameras||=[];let n=e.isOrthographicCamera,r={type:n?`orthographic`:`perspective`};return n?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:jn.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==``&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||=[],e=WL.Utils.mergeMorphTargetTracks(e.clone(),t);let i=e.tracks,a=[],o=[];for(let e=0;e<i.length;++e){let n=i[e],s=Fd.parseTrackName(n.name),c=Fd.findNode(t,s.nodeName),l=JL[s.propertyName];if(s.objectName===`bones`&&(c=c.isSkinnedMesh===!0?c.skeleton.getBoneByName(s.objectIndex):void 0),!c||!l){console.warn(`THREE.GLTFExporter: Could not export animation track "%s".`,n.name);continue}let u=n.values.length/n.times.length;l===JL.morphTargetInfluences&&(u/=c.morphTargetInfluences.length);let d;n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(d=`CUBICSPLINE`,u/=3):d=n.getInterpolation()===2300?`STEP`:`LINEAR`,o.push({input:this.processAccessor(new Ti(n.times,1)),output:this.processAccessor(new Ti(n.values,u)),interpolation:d}),a.push({sampler:o.length-1,target:{node:r.get(c),path:l}})}let s={name:e.name||`clip_`+n.animations.length,samplers:o,channels:a};return this.serializeUserData(e,s),n.animations.push(s),n.animations.length-1}processSkin(e){let t=this.json,n=this.nodeMap,r=t.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;let a=e.skeleton.bones[0];if(a===void 0)return null;let o=[],s=new Float32Array(i.bones.length*16),c=new J;for(let t=0;t<i.bones.length;++t)o.push(n.get(i.bones[t])),c.copy(i.boneInverses[t]),c.multiply(e.bindMatrix).toArray(s,t*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new Ti(s,16)),joints:o,skeleton:n.get(a)}),r.skin=t.skins.length-1}async processNodeAsync(e){let t=this.json,n=this.options,r=this.nodeMap;if(t.nodes||=[],e.pivot!==null)return await this._processNodeWithPivotAsync(e);let i={};if(n.trs){let t=e.quaternion.toArray(),n=e.position.toArray(),r=e.scale.toArray();nR(t,[0,0,0,1])||(i.rotation=t),nR(n,[0,0,0])||(i.translation=n),nR(r,[1,1,1])||(i.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),iR(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==``&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let t=await this.processMeshAsync(e);t!==null&&(i.mesh=t)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let a=t.nodes.push(i)-1;if(r.set(e,a),e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(i);e!==null&&t.push(e)}}t.length>0&&(i.children=t)}return await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,i)}),a}async _processNodeWithPivotAsync(e){let t=this.json,n=this.options,r=this.nodeMap,i=e.pivot,a={},o=e.quaternion.toArray(),s=[e.position.x+i.x,e.position.y+i.y,e.position.z+i.z],c=e.scale.toArray();nR(o,[0,0,0,1])||(a.rotation=o),nR(s,[0,0,0])||(a.translation=s),nR(c,[1,1,1])||(a.scale=c),a.extras={pivot:i.toArray()},e.name!==``&&(a.name=String(e.name)),this.serializeUserData(e,a);let l=t.nodes.push(a)-1;r.set(e,l);let u={},d=[-i.x,-i.y,-i.z];if(nR(d,[0,0,0])||(u.translation=d),e.isMesh||e.isLine||e.isPoints){let t=await this.processMeshAsync(e);t!==null&&(u.mesh=t)}else e.isCamera&&(u.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let f=[t.nodes.push(u)-1];if(e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(i);e!==null&&t.push(e)}}t.length>0&&(u.children=t)}return a.children=f,await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,a)}),l}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==``&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(r);e!==null&&i.push(e)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new Vr;t.name=`AuxScene`;for(let n=0;n<e.length;n++)t.children.push(e[n]);await this.processSceneAsync(t)}async processInputAsync(e){let t=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(t){t.beforeParse&&t.beforeParse(e)});let n=[];for(let t=0;t<e.length;t++)e[t]instanceof Vr?await this.processSceneAsync(e[t]):n.push(e[t]);n.length>0&&await this.processObjectsAsync(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);await this._invokeAllAsync(function(t){t.afterParse&&t.afterParse(e)})}async _invokeAllAsync(e){for(let t=0,n=this.plugins.length;t<n;t++)await e(this.plugins[t])}},dR=class{constructor(e){this.writer=e,this.name=`KHR_lights_punctual`}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn(`THREE.GLTFExporter: Only directional, point, and spot lights are supported.`,e);return}let n=this.writer,r=n.json,i=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type=`directional`:e.isPointLight?(a.type=`point`,e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type=`spot`,e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(1-e.penumbra)*e.angle,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn(`THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.`),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn(`THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.`),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}},fR=class{constructor(e){this.writer=e,this.name=`KHR_materials_unlit`}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},pR=class{constructor(e){this.writer=e,this.name=`KHR_materials_clearcoat`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(t.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},mR=class{constructor(e){this.writer=e,this.name=`KHR_materials_dispersion`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let n=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},hR=class{constructor(e){this.writer=e,this.name=`KHR_materials_iridescence`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},gR=class{constructor(e){this.writer=e,this.name=`KHR_materials_transmission`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},_R=class{constructor(e){this.writer=e,this.name=`KHR_materials_volume`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},vR=class{constructor(e){this.writer=e,this.name=`KHR_materials_ior`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},yR=class{constructor(e){this.writer=e,this.name=`KHR_materials_specular`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(YL)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},bR=class{constructor(e){this.writer=e,this.name=`KHR_materials_sheen`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},xR=class{constructor(e){this.writer=e,this.name=`KHR_materials_anisotropy`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},SR=class{constructor(e){this.writer=e,this.name=`KHR_materials_emissive_strength`}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},CR=class{constructor(e){this.writer=e,this.name=`EXT_materials_bump`}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.bumpMap){let t={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(t,e.bumpMap),i.bumpTexture=t}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},wR=class{constructor(e){this.writer=e,this.name=`EXT_mesh_gpu_instancing`}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,r=e,i=new Float32Array(r.count*3),a=new Float32Array(r.count*4),o=new Float32Array(r.count*3),s=new J,c=new q,l=new Mn,u=new q;for(let e=0;e<r.count;e++)r.getMatrixAt(e,s),s.decompose(c,l,u),c.toArray(i,e*3),l.toArray(a,e*4),u.toArray(o,e*3);let d={TRANSLATION:n.processAccessor(new Ti(i,3)),ROTATION:n.processAccessor(new Ti(a,4)),SCALE:n.processAccessor(new Ti(o,3))};r.instanceColor&&(d._COLOR_0=n.processAccessor(r.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:d},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};WL.Utils={insertKeyframe:function(e,t){let n=.001,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+r),o=e.createInterpolant(new e.ValueBufferType(r)),s;if(e.times.length===0){i[0]=t;for(let e=0;e<r;e++)a[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;i[0]=t,i.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),s=i.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<n)return c;if(e.times[c]<t&&e.times[c+1]>t){i.set(e.times.slice(0,c+1),0),i[c+1]=t,i.set(e.times.slice(c+1),c+2),a.set(e.values.slice(0,(c+1)*r),0),a.set(o.evaluate(t),(c+1)*r),a.set(e.values.slice((c+1)*r),(c+2)*r),s=c+1;break}}return e.times=i,e.values=a,s},mergeMorphTargetTracks:function(e,t){let n=[],r={},i=e.tracks;for(let e=0;e<i.length;++e){let a=i[e],o=Fd.parseTrackName(a.name),s=Fd.findNode(t,o.nodeName);if(o.propertyName!==`morphTargetInfluences`||o.propertyIndex===void 0){n.push(a);continue}if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw Error(`THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.`);console.warn(`THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.`),a=a.clone(),a.setInterpolation(nt)}let c=s.morphTargetInfluences.length,l=s.morphTargetDictionary[o.propertyIndex];if(l===void 0)throw Error(`THREE.GLTFExporter: Morph target name not found: `+o.propertyIndex);let u;if(r[s.uuid]===void 0){u=a.clone();let e=new u.ValueBufferType(c*u.times.length);for(let t=0;t<u.times.length;t++)e[t*c+l]=u.values[t];u.name=(o.nodeName||``)+`.morphTargetInfluences`,u.values=e,r[s.uuid]=u,n.push(u);continue}let d=a.createInterpolant(new a.ValueBufferType(1));u=r[s.uuid];for(let e=0;e<u.times.length;e++)u.values[e*c+l]=d.evaluate(u.times[e]);for(let e=0;e<a.times.length;e++){let t=this.insertKeyframe(u,a.times[e]);u.values[t*c+l]=a.values[e]}}return e.tracks=n,e},toTypedBufferAttribute:function(e,t){let n=new Ti(new t(e.count*e.itemSize),e.itemSize,!1);if(!e.normalized&&!e.isInterleavedBufferAttribute)return n.array.set(e.array),n;for(let t=0,r=e.count;t<r;t++)for(let r=0;r<e.itemSize;r++)n.setComponent(t,r,e.getComponent(t,r));return n}};var TR=class{parse(e){let t=``,n=0,r=0,i=0,a=new q,o=new Y,s=new q,c=new K,l=[];function u(e){let o=0,u=0,d=0,f=e.geometry,p=new Fn,m=f.getAttribute(`position`),h=f.getAttribute(`normal`),g=f.getAttribute(`uv`),_=f.getIndex();if(t+=`o `+e.name+`
|
||
`,e.material&&e.material.name&&(t+=`usemtl `+e.material.name+`
|
||
`),m!==void 0)for(let n=0,r=m.count;n<r;n++,o++)a.fromBufferAttribute(m,n),a.applyMatrix4(e.matrixWorld),t+=`v `+a.x+` `+a.y+` `+a.z+`
|
||
`;if(g!==void 0)for(let e=0,n=g.count;e<n;e++,d++)c.fromBufferAttribute(g,e),t+=`vt `+c.x+` `+c.y+`
|
||
`;if(h!==void 0){p.getNormalMatrix(e.matrixWorld);for(let e=0,n=h.count;e<n;e++,u++)s.fromBufferAttribute(h,e),s.applyMatrix3(p).normalize(),t+=`vn `+s.x+` `+s.y+` `+s.z+`
|
||
`}if(_!==null)for(let e=0,a=_.count;e<a;e+=3){for(let t=0;t<3;t++){let a=_.getX(e+t)+1;l[t]=n+a+(h||g?`/`+(g?r+a:``)+(h?`/`+(i+a):``):``)}t+=`f `+l.join(` `)+`
|
||
`}else for(let e=0,a=m.count;e<a;e+=3){for(let t=0;t<3;t++){let a=e+t+1;l[t]=n+a+(h||g?`/`+(g?r+a:``)+(h?`/`+(i+a):``):``)}t+=`f `+l.join(` `)+`
|
||
`}n+=o,r+=d,i+=u}function d(e){let r=0,i=e.geometry,o=e.type,s=i.getAttribute(`position`);if(t+=`o `+e.name+`
|
||
`,s!==void 0)for(let n=0,i=s.count;n<i;n++,r++)a.fromBufferAttribute(s,n),a.applyMatrix4(e.matrixWorld),t+=`v `+a.x+` `+a.y+` `+a.z+`
|
||
`;if(o===`Line`){t+=`l `;for(let e=1,r=s.count;e<=r;e++)t+=n+e+` `;t+=`
|
||
`}if(o===`LineSegments`)for(let e=1,r=e+1,i=s.count;e<i;e+=2,r=e+1)t+=`l `+(n+e)+` `+(n+r)+`
|
||
`;n+=r}function f(e){let r=0,i=e.geometry,s=i.getAttribute(`position`),c=i.getAttribute(`color`);if(t+=`o `+e.name+`
|
||
`,s!==void 0){for(let n=0,i=s.count;n<i;n++,r++)a.fromBufferAttribute(s,n),a.applyMatrix4(e.matrixWorld),t+=`v `+a.x+` `+a.y+` `+a.z,c!==void 0&&(o.fromBufferAttribute(c,n),Bn.workingToColorSpace(o,mt),t+=` `+o.r+` `+o.g+` `+o.b),t+=`
|
||
`;t+=`p `;for(let e=1,r=s.count;e<=r;e++)t+=n+e+` `;t+=`
|
||
`}n+=r}return e.traverse(function(e){e.isMesh===!0&&u(e),e.isLine===!0&&d(e),e.isPoints===!0&&f(e)}),t}};function ER(e){let t=new jr;return t.name=`ExportedParts`,e.traverse(e=>{if(e.name===`part-body-mesh`){let n=e.clone(!0),r=[];n.traverse(e=>{e instanceof La&&!e.castShadow&&r.push(e)});for(let e of r)e.parent?.remove(e);e.updateWorldMatrix(!0,!1),n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),n.updateMatrix(),n.applyMatrix4(e.matrixWorld),t.add(n)}}),t}function DR(e,t,n){let r=new Blob([e],{type:t}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function OR(e,t){let n=ER(e);new WL().parse(n,e=>{DR(typeof e==`string`?e:JSON.stringify(e,null,2),`application/json`,`${t.replace(/\s+/g,`_`)||`hydro_system`}.gltf`)},e=>{console.error(`Failed to export glTF:`,e)},{binary:!1})}function kR(e,t){let n=ER(e);DR(new TR().parse(n),`text/plain`,`${t.replace(/\s+/g,`_`)||`hydro_system`}.obj`)}function AR({onClose:e}){let t=Q(e=>e.parts),n=Q(e=>e.activeRoomId),r=Q(e=>e.projectName),i=Q(e=>e.scene),a=(0,v.useMemo)(()=>Object.values(t).filter(e=>e.roomId===n),[t,n]),o=(0,v.useMemo)(()=>WE(a),[a]),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(null);(0,v.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t),l.current&&clearTimeout(l.current)}},[e]);let u=async()=>{try{await navigator.clipboard.writeText(pD(o)),c(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>c(!1),1500)}catch{}},d=()=>{let e=window.open(``,`_blank`,`width=720,height=900`);if(!e)return;let t=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);e.document.write(`<!doctype html><title>${t(r)} — Bill of Materials</title><pre style="font: 12px/1.5 ui-monospace, Menlo, monospace; padding: 24px;">`+t(pD(o))+`</pre>`),e.document.close(),e.focus(),e.print()},f=(0,v.useMemo)(()=>{let e=new Map;for(let t of o.lines){let n=e.get(t.category);n?n.push(t):e.set(t.category,[t])}return[...e.entries()]},[o]),p=e=>o.categories.find(t=>t.name===e)?.subtotal??0;return(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex justify-end`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-[2px]`,onClick:e,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`relative flex h-full w-full max-w-xl flex-col border-l border-zinc-800 bg-zinc-950 shadow-2xl`,children:[(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-zinc-800 px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-bold tracking-wide text-zinc-100`,children:`Bill of Materials`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-zinc-500`,children:r})]}),(0,Z.jsx)(`button`,{onClick:e,title:`Close (Esc)`,className:`rounded-md px-2 py-1 text-sm text-zinc-400 transition hover:bg-zinc-800 hover:text-zinc-100`,children:`✕`})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-end justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`text-2xl font-bold text-sky-400 tabular-nums`,children:[oD(o.totalCost),(0,Z.jsx)(`span`,{className:`ml-1.5 text-xs font-medium text-zinc-500`,children:`est. total`})]}),(0,Z.jsxs)(`div`,{className:`text-[11px] text-zinc-500 tabular-nums`,children:[o.partCount,` parts · `,o.lines.length,` line items`,o.cutLists.length>0&&` · ${o.cutLists.reduce((e,t)=>e+t.sticksToBuy,0)} PVC sticks`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 justify-end`,children:[(0,Z.jsx)(MR,{onClick:()=>mD(o,r),title:`Download as CSV`,children:`Export CSV`}),(0,Z.jsx)(MR,{onClick:()=>HL(o,r),title:`Download as PDF`,children:`Export PDF`}),(0,Z.jsx)(MR,{onClick:u,title:`Copy shopping list to clipboard`,children:s?`Copied`:`Copy as text`}),(0,Z.jsx)(MR,{onClick:d,title:`Print shopping list`,children:`Print`}),(0,Z.jsx)(MR,{onClick:()=>i&&OR(i,`${r}.gltf`),title:i?`Export 3D layout as glTF`:`Scene loading...`,disabled:!i,children:`Export glTF`}),(0,Z.jsx)(MR,{onClick:()=>i&&kR(i,`${r}.obj`),title:i?`Export 3D layout as OBJ`:`Scene loading...`,disabled:!i,children:`Export OBJ`})]})]})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:o.partCount===0?(0,Z.jsx)(`p`,{className:`py-10 text-center text-xs text-zinc-600`,children:`Nothing here yet — place some parts in the scene to build a shopping list.`}):(0,Z.jsxs)(Z.Fragment,{children:[f.map(([e,t])=>(0,Z.jsxs)(`section`,{className:`mb-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:e}),(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold text-zinc-400 tabular-nums`,children:oD(p(e))})]}),(0,Z.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-zinc-800`,children:t.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-3 py-2 ${t%2==1?`bg-zinc-900/40`:`bg-zinc-900/10`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`text-xs font-medium text-zinc-200`,children:[e.description,e.qty>1||e.unit===`stick`?(0,Z.jsxs)(`span`,{className:`ml-1.5 text-zinc-500`,children:[`×`,e.qty]}):null,e.estimated&&(0,Z.jsx)(`span`,{className:`ml-1.5 rounded bg-amber-950/80 px-1 py-px text-[9px] font-semibold text-amber-400 ring-1 ring-amber-900`,children:`est.`})]}),e.spec&&(0,Z.jsx)(`div`,{className:`mt-0.5 text-[10px] text-zinc-500`,children:e.spec})]}),(0,Z.jsxs)(`div`,{className:`shrink-0 text-right`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-zinc-200 tabular-nums`,children:oD(e.totalCost)}),e.qty>1&&(0,Z.jsxs)(`div`,{className:`text-[10px] text-zinc-500 tabular-nums`,children:[oD(e.unitCost),` / `,e.unit]})]})]},e.key))})]},e)),o.cutLists.length>0&&(0,Z.jsxs)(`section`,{className:`mb-5`,children:[(0,Z.jsx)(`h3`,{className:`mb-1.5 text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:`Cut list — 10 ft sticks`}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.cutLists.map(e=>(0,Z.jsx)(jR,{list:e},e.diameterIn))})]})]})}),(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-zinc-800 px-5 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,Z.jsx)(`span`,{className:`text-zinc-500`,children:`Prices are rough US retail estimates, not quotes.`}),(0,Z.jsx)(`span`,{className:`font-bold text-zinc-100 tabular-nums`,children:oD(o.totalCost)})]})})]})]})}function jR({list:e}){let[t,n]=(0,v.useState)(!1);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-zinc-800 bg-zinc-900/30`,children:[(0,Z.jsxs)(`button`,{onClick:()=>n(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-left transition hover:bg-zinc-800/50`,children:[(0,Z.jsxs)(`span`,{className:`text-xs font-semibold text-zinc-200`,children:[iD(e.diameterIn),` PVC`,(0,Z.jsxs)(`span`,{className:`ml-2 font-normal text-zinc-500`,children:[`buy `,e.sticksToBuy,` stick`,e.sticksToBuy===1?``:`s`,` · `,e.cuts.length,` `,`cuts · `,aD(e.totalLeftoverIn),` scrap`]})]}),(0,Z.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:t?`Hide`:`Show`})]}),t&&(0,Z.jsxs)(`div`,{className:`border-t border-zinc-800 px-3 py-2`,children:[e.sticks.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-2 py-0.5`,children:[(0,Z.jsxs)(`span`,{className:`w-14 shrink-0 text-[10px] font-semibold text-zinc-500`,children:[`Stick `,e.index]}),(0,Z.jsxs)(`span`,{className:`text-[11px] text-zinc-300 tabular-nums`,children:[e.cuts.map(e=>aD(e)).join(`, `),(0,Z.jsxs)(`span`,{className:`ml-1.5 text-zinc-500`,children:[`— `,aD(e.leftoverIn),` left`]})]})]},e.index)),e.spliceCount>0&&(0,Z.jsxs)(`p`,{className:`mt-1 text-[10px] text-amber-400/90`,children:[e.spliceCount,` coupling`,e.spliceCount===1?``:`s`,` needed to splice runs longer than 10 ft.`]})]})]})}function MR({children:e,onClick:t,title:n,disabled:r}){return(0,Z.jsx)(`button`,{onClick:t,title:n,disabled:r,className:`rounded-md px-2.5 py-1.5 text-xs font-medium transition ${r?`bg-zinc-800 text-zinc-500 ring-1 ring-zinc-700 cursor-not-allowed opacity-50`:`bg-sky-500/15 text-sky-300 ring-1 ring-sky-700 hover:bg-sky-500/25`}`,children:e})}var NR=(e,t=1)=>Number(e.toFixed(t)).toString(),PR=.8;function FR(e,t){let n=e.partsMap[t];if(!n)return 0;let r=e.graph.connectorsByPart.get(t)??[],i=r.find(e=>e.connectorId===`out`)??r[r.length-1];if(!i)return 0;let a=n.position[1],o=[i.partId],s=new Set([t]);for(;o.length>0;){let t=o.shift();if(s.has(t))continue;s.add(t);let n=e.partsMap[t];n&&(a=Math.max(a,n.position[1]));let r=e.graph.neighbors.get(t);if(r)for(let e of r)s.has(e)||o.push(e)}return Math.max(0,a-n.position[1])}function IR(e){let t=[];for(let n of e.sim?.pumps??[]){let r=e.partsMap[n?.pumpId??``];if(!r||uS(r))continue;let i=n.maxHeadFt??0,a=FR(e,r.id);if(i<=0)continue;let o=a/i;if(o<=.8)continue;let s=lS(r),c=`Choose a higher-head pump or lower the highest point by ${NR(Math.max(.1,a-PR*i))} ft`;o>=1?t.push({id:`pump-head:${r.id}`,severity:`error`,title:`Pump cannot reach the highest point`,detail:`${s} must lift water ${NR(a)} ft but its max head is ${NR(i)} ft — it delivers no flow.`,partIds:[r.id],fix:c}):t.push({id:`pump-head:${r.id}`,severity:`warning`,title:`Pump near its limit (${Math.round(o*100)}%), keep \u226520% margin`,detail:`${s} is lifting ${NR(a)} ft of ${NR(i)} ft max head, so flow is heavily reduced and the pump will wear quickly.`,partIds:[r.id],fix:c})}return t}function LR(e,t,n){let r=[];for(let{a:t,b:i}of e.graph.joints)t.key===n&&r.push(i.partId),i.key===n&&r.push(t.partId);let i=new Set([t,...r]),a=[...r];for(;a.length;){let t=a.shift();if(e.partsMap[t]?.type===`reservoir`)return!0;for(let n of e.graph.neighbors.get(t)??[])i.has(n)||(i.add(n),a.push(n))}return!1}function RR(e){let t=[];for(let n of e.parts){if(n.type!==`pump`)continue;let r=lS(n);if(uS(n)){t.push({id:`pump-dead:${n.id}`,severity:`error`,title:`Pump is switched off`,detail:`${r} is powered off, so it delivers no flow.`,partIds:[n.id],fix:`Turn the pump on (power toggle in the inspector).`});continue}let i=e.graph.connectorsByPart.get(n.id)??[],a=i.find(e=>e.connectorId===`in`)??i[0],o=i.find(e=>e.connectorId===`out`)??i[i.length-1],s=o&&e.graph.joinedKeys.has(o.key),c=a&&e.graph.joinedKeys.has(a.key),l=e.sim?.pumps?.find(e=>e?.pumpId===n.id);if(l&&(l.gph??0)>0&&s&&c)continue;let u=FR(e,n.id);if(l&&(l.maxHeadFt??0)>0&&u>=(l.maxHeadFt??0))continue;let d,f;a&&!e.graph.joinedKeys.has(a.key)?(d=`${r}'s inlet is not connected to anything — there is no water source.`,f=`Connect the pump inlet to a reservoir.`):a&&!LR(e,n.id,a.key)?(d=`${r}'s inlet line never reaches a reservoir — there is no water source.`,f=`Route the inlet line back to a reservoir.`):o&&!e.graph.joinedKeys.has(o.key)?(d=`${r}'s outlet is not connected to anything — water has nowhere to go.`,f=`Connect the pump outlet to your plumbing.`):(d=e.sim?.warnings?.find(e=>e?.partId===n.id&&e?.level!==`info`)?.message??`${r} delivers no flow.`,f=`Check for closed valves and verify the line reaches an outlet.`),t.push({id:`pump-dead:${n.id}`,severity:`error`,title:`Pump delivers no flow`,detail:d,partIds:[n.id],fix:f})}return t}function zR(e,t){return e.type===`reducer`||e.type===`reducingElbow`?t===`a`?e.params.diameterA??1.5:e.params.diameterB??1:e.type===`reducingTee`?t===`c`||t===`branch`?e.params.diameterB??1:e.params.diameterA??1.5:e.params.diameter??1}function BR(e){let t=[],n=new Set;for(let{a:r,b:i}of e.graph.joints){let a=e.partsMap[r.partId],o=e.partsMap[i.partId];if(!a||!o)continue;let s=zR(a,r.connectorId),c=zR(o,i.connectorId);if(Math.abs(s-c)<.01)continue;let l=[r.partId,i.partId].sort().join(`:`);if(n.has(l))continue;n.add(l);let u=lS(a),d=lS(o);t.push({id:`diameter-mismatch:${l}`,severity:`warning`,title:`Mismatched pipe diameters at a joint`,detail:`${u} (${NR(s,2)} in) is joined to ${d} (${NR(c,2)} in) — the abrupt size change causes turbulence and pressure loss.`,partIds:[r.partId,i.partId],fix:`Add a reducer or match diameters (${u} is ${NR(s,2)} in, ${d} is ${NR(c,2)} in)`})}return t}function VR(e){let t=e.sim?.flows??{},n=new Set(Object.keys(t).filter(e=>(t[e]??0)>0));if(!n.size)return[];let r=[];for(let t of e.parts){let i=e.graph.connectorsByPart.get(t.id)??[];if(!i.length||t.type===`pump`||dS(t))continue;let a=i.filter(t=>e.graph.joinedKeys.has(t.key)).length;if(a===0||a===i.length)continue;let o=[t.id],s=null,c=t.id,l=null;for(let t=0;t<e.parts.length;t++){let t=[...e.graph.neighbors.get(c)??[]].filter(e=>e!==s&&!o.includes(e));if(t.length!==1)break;let n=t[0],r=e.partsMap[n],i=(e.graph.neighbors.get(n)?.size??0)>=3;if(!r||r.type===`pump`||dS(r)||i){l=n;break}o.push(n),s=c,c=n}(l!==null&&n.has(l)||o.some(e=>n.has(e)))&&(o.some(t=>dS(e.partsMap[t]))||r.push({id:`dead-leg:${t.id}`,severity:`warning`,title:`Dead leg — stagnant water`,detail:`${lS(t)} ends a flowing branch with no reservoir, emitter, drain or grow part — water will sit stagnant (or leak) here.`,partIds:o,fix:`Cap with an emitter/drain or remove`}))}return r}function HR(e){let t=[];for(let n of e.parts){if(n.type!==`pipe`)continue;let r=e.graph.connectorsByPart.get(n.id)??[];if(r.length<2)continue;let[i,a]=[r[0].pos,r[r.length-1].pos];if(Math.abs(i[1]-a[1])>.3)continue;let o=(i[1]+a[1])/2;if(o<=1.5)continue;let s=n.params?.length??Math.hypot(a[0]-i[0],a[2]-i[2]);if(s<=4)continue;let c=t=>e.parts.some(r=>{if(r.id===n.id)return!1;let i=fS(r,e.graph.connectorsByPart.get(r.id)??[]),a=.3;return t[0]>=i.min[0]-a&&t[0]<=i.max[0]+a&&t[2]>=i.min[2]-a&&t[2]<=i.max[2]+a&&i.max[1]>=t[1]-.6&&i.min[1]<=t[1]-.6});c(i)||c(a)||t.push({id:`unsupported-span:${n.id}`,severity:`info`,title:`Unsupported span ${NR(s)} ft`,detail:`${lS(n)} runs ${NR(s)} ft at ${NR(o)} ft height with nothing beneath either end — it will sag over time.`,partIds:[n.id],fix:`Add a lattice/structure support`})}return t}function UR(e){let t=e.sim?.flows??{},n=[];for(let r of e.sim?.pumps??[]){if((r?.gph??0)<=0)continue;let i=r.pumpId,a=e.graph.nodeOfConnector.get(`${i}:out`),o=a?e.graph.nodes.get(a):void 0;if(!o)continue;let s=o.pos[1],c=0,l=i,u=s,d=new Set([`P:${i}`,o.id]),f=[{id:o.id,pathMax:s,highPart:i}];for(;f.length;){let{id:n,pathMax:r,highPart:a}=f.pop(),o=e.graph.nodes.get(n);if(o)for(let n of o.edges){if(d.has(n.to)||(t[n.partId]??0)<=0&&n.partId!==i)continue;d.add(n.to);let o=e.graph.nodes.get(n.to);if(!o)continue;let p=r,m=a;o.pos[1]>p&&(p=o.pos[1],m=n.partId);let h=p-o.pos[1];p>s+.5&&h>c&&(c=h,l=m,u=p),f.push({id:n.to,pathMax:p,highPart:m})}}c>=2&&n.push({id:`siphon:${i}`,severity:`info`,title:`Possible siphon on shutdown`,detail:`Flow from ${lS(e.partsMap[i])} climbs to ${NR(u)} ft and then descends ${NR(c)} ft — when the pump stops, gravity can keep siphoning water through the line.`,partIds:[l],fix:`Add an air gap or check valve at the high point`})}return n}function WR(e){let t=[];for(let n of e.parts){if(!(n.type===`drain`||typeof n.params?.capacityGph==`number`))continue;let r=n.params?.capacityGph??250,i=e.sim?.drains?.find?.(e=>e?.partId===n.id)?.inflowGph??e.sim?.flows?.[n.id]??0;if(i<=r+.5)continue;let a=Math.ceil(i/25)*25;t.push({id:`drain-capacity:${n.id}`,severity:`error`,title:`Undersized drain — will overflow`,detail:`${lS(n)} receives ${Math.round(i)} GPH but is rated for ${Math.round(r)} GPH — the excess will back up and flood.`,partIds:[n.id],fix:`Upsize drain to \u2265 ${a} GPH capacity`})}return t}function GR(e){let t=[];for(let n of e.sim?.netPots??[]){if(!n?.overflowing)continue;let r=e.partsMap[n.partId];if(!r)continue;let i=e.partsMap[n.sourcePartId];t.push({id:`net-pot-spill:${n.partId}`,severity:`error`,title:`Net pot will overflow from backed-up plumbing`,detail:`${lS(r)} sits above ${lS(i)}. Water is rising to ${NR(n.waterHeightFt)} ft while the pot rim is ${NR(n.rimHeightFt)} ft, so nutrient solution will spill out of the top.`,partIds:i?[n.partId,i.id]:[n.partId],fix:`Add a drain/outlet, lower water level, or move the net pot off the flooded line.`})}return t}function KR(e){let t=[];for(let n of e.parts){let r=e.graph.connectorsByPart.get(n.id)??[];r.length&&(r.some(t=>e.graph.joinedKeys.has(t.key))||t.push({id:`orphan:${n.id}`,severity:`info`,title:`Not connected to anything`,detail:`${lS(n)} has no connections — it is not part of any water circuit.`,partIds:[n.id],fix:`Drag it onto a matching connector, or delete it if unused.`}))}return t}function qR(e){let t=[];for(let n of e.parts){if(n.type!==`valve`||n.params?.open!==0)continue;let r=e.graph.componentOf.get(n.id);r!==void 0&&[...e.graph.components[r]].some(t=>{let n=e.partsMap[t];return n?.type===`pump`&&!uS(n)})&&t.push({id:`closed-valve:${n.id}`,severity:`info`,title:`Closed valve blocking a flowing line`,detail:`${lS(n)} is fully closed — everything beyond it gets no water.`,partIds:[n.id],fix:`Open the valve, or remove it if the branch is unused.`})}return t}function JR(e){let t=[];for(let n of e.roomMetrics){let r=e.partsMap[n.roomId],i=(r?.params.width??0)*(r?.params.depth??0);if(!n.sealed&&n.co2TankCount>0&&t.push({id:`room-co2-open:${n.roomId}`,severity:`warning`,title:`CO2 enrichment wasted in open-air room`,detail:`${n.label} is marked open air but has ${n.co2TankCount} CO2 tank${n.co2TankCount===1?``:`s`} — outside air exchange will purge enrichment before plants can use it.`,partIds:[n.roomId],fix:`Seal the room or remove CO2 hardware.`}),n.sealed&&n.airChangesPerMinute>1&&t.push({id:`room-sealed-exhaust:${n.roomId}`,severity:`warning`,title:`Sealed room exhausting too aggressively`,detail:`${n.label} is marked sealed but exhausts ${n.airChangesPerMinute.toFixed(2)} room volumes per minute — that behaves more like an open-air room and dumps conditioned CO2-rich air.`,partIds:[n.roomId],fix:`Reduce exhaust CFM or switch the room to open air.`}),!n.sealed&&n.airChangesPerMinute<.5&&t.push({id:`room-vent-low:${n.roomId}`,severity:`info`,title:`Low air exchange for open-air room`,detail:`${n.label} exchanges only ${n.airChangesPerMinute.toFixed(2)} room volumes per minute — heat and humidity can linger unless intake/exhaust is stronger.`,partIds:[n.roomId],fix:`Increase exhaust capacity or reduce room volume.`}),n.sealed&&n.co2TankCount===0&&n.lightWatts>=600&&t.push({id:`room-co2-missing:${n.roomId}`,severity:`info`,title:`High-light sealed room without CO2`,detail:`${n.label} is sealed and carries ${Math.round(n.lightWatts)} W of lighting but no CO2 source — the room can be enriched, but currently cannot take advantage of the sealed configuration.`,partIds:[n.roomId],fix:`Add a CO2 tank or switch to open-air ventilation.`}),i>0&&n.lightWatts>0){let e=n.lightWatts/i;e<25?t.push({id:`room-light-low:${n.roomId}`,severity:`info`,title:`Low lighting density`,detail:`${n.label} provides ${e.toFixed(1)} W/ft2 across ${i.toFixed(1)} ft2 — useful for propagation or low-light crops, but light-hungry plants will underperform.`,partIds:[n.roomId],fix:`Add more fixture wattage or reduce active canopy area.`}):e>55&&t.push({id:`room-light-high:${n.roomId}`,severity:`warning`,title:`Very high lighting density`,detail:`${n.label} is carrying ${e.toFixed(1)} W/ft2 — that is intense enough to demand strong cooling, CO2 strategy, and careful canopy distance management.`,partIds:[n.roomId],fix:`Raise fixtures, reduce wattage, or tighten environmental control.`})}n.lightWatts>0&&(n.roomDLI<10?t.push({id:`room-dli-low:${n.roomId}`,severity:`warning`,title:`Daily Light Integral (DLI) is too low`,detail:`${n.label} active DLI is ${n.roomDLI.toFixed(1)} — DLI < 10 is insufficient for healthy growth and will cause the crop to stretch.`,partIds:[n.roomId],fix:`Increase grow lights wattage, increase photoperiod (hours on), or decrease room/canopy area.`}):n.roomDLI>45&&t.push({id:`room-dli-high:${n.roomId}`,severity:`warning`,title:`Daily Light Integral (DLI) is too high`,detail:`${n.label} active DLI is ${n.roomDLI.toFixed(1)} — DLI > 45 risks phototoxic bleaching and leaf tissue damage.`,partIds:[n.roomId],fix:`Reduce grow lights wattage, decrease photoperiod (hours on), or raise the fixtures.`})),n.sealed&&n.lightWatts>400&&n.roomCo2===150&&t.push({id:`room-co2-starved:${n.roomId}`,severity:`warning`,title:`Sealed room CO₂ starvation risk`,detail:`${n.label} is sealed and runs high-wattage lighting (${n.lightWatts.toFixed(0)} W > 400 W), but CO₂ levels drop to 150 PPM due to lack of a CO₂ tank.`,partIds:[n.roomId],fix:`Add a CO₂ tank or switch to open-air ventilation.`});let a=Q.getState().growthStage??`vegetative`,o=.8,s=1.6;a===`seedling`?(o=.4,s=.8):a===`vegetative`?(o=.8,s=1.2):a===`flowering`&&(o=1.2,s=1.6),n.roomVPD<o?t.push({id:`room-vpd-low:${n.roomId}`,severity:`warning`,title:`Vapor Pressure Deficit (VPD) is too low`,detail:`${n.label} VPD is ${n.roomVPD.toFixed(2)} kPa, which is below the optimal range of ${o}-${s} kPa for the ${a} stage. Low VPD slows transpiration and can cause nutrient deficiencies.`,partIds:[n.roomId],fix:`Raise the temperature, lower relative humidity, or increase exhaust ventilation.`}):n.roomVPD>s&&t.push({id:`room-vpd-high:${n.roomId}`,severity:`warning`,title:`Vapor Pressure Deficit (VPD) is too high`,detail:`${n.label} VPD is ${n.roomVPD.toFixed(2)} kPa, which is above the optimal range of ${o}-${s} kPa for the ${a} stage. High VPD causes excessive transpiration, leading to plant stress and wilting.`,partIds:[n.roomId],fix:`Lower the temperature, increase relative humidity, or reduce lighting intensity.`})}return t}var YR=[{id:`pump-head`,description:`Pumps should keep ≥20% head margin below their max head.`,run:IR},{id:`pump-dead`,description:`Pumps that are off, starved of source water, or dead-ended.`,run:RR},{id:`diameter-mismatch`,description:`Joined connectors whose parts have different pipe diameters.`,run:BR},{id:`dead-leg`,description:`Flowing branches that terminate with no exit part (stagnation).`,run:VR},{id:`unsupported-span`,description:`Long elevated horizontal pipes with nothing beneath their ends.`,run:HR},{id:`siphon`,description:`Flow paths that climb then descend ≥2 ft (siphon on shutdown).`,run:UR},{id:`drain-capacity`,description:`Drains receiving more flow than their rated capacity.`,run:WR},{id:`net-pot-spill`,description:`Net pots positioned over backed-up wet lines that will spill from the rim.`,run:GR},{id:`orphan`,description:`Flow-capable parts with no connections at all.`,run:KR},{id:`closed-valve`,description:`Fully closed valves on an otherwise powered circuit.`,run:qR},{id:`room-environment`,description:`Grow-room ventilation, sealed/open-air behavior, CO2 use, and light density.`,run:JR},{id:`reservoir-chemistry`,description:`Reservoir temperature, pH, and EC/nutrient concentration values.`,run:XR},{id:`part-overlap`,description:`Parts that are overlapping or morphing into one another.`,run:ZR}];function XR(e){let t=[],n=e.parts.filter(e=>e.type===`reservoir`);for(let r of n){let n=nC(r,e.partsMap),i=e.sim?.reservoirRuntime?.[r.id];i?.empty?t.push({id:`res-empty:${r.id}`,severity:`error`,title:`Reservoir runs dry under current load`,detail:`${r.label||`Reservoir #${r.id}`} is fully depleted by the current pump/drain demand, so downstream flow stops entirely.`,partIds:[r.id],fix:`Increase reservoir volume, reduce draw rate, or close the loop with return flow.`}):i&&i.minutesRemaining!==null&&i.minutesRemaining<30&&t.push({id:`res-runtime-low:${r.id}`,severity:`warning`,title:`Reservoir runtime is too short`,detail:`${r.label||`Reservoir #${r.id}`} has only ${i.minutesRemaining.toFixed(1)} minutes of water left at the current net draw of ${i.netOutflowGph.toFixed(1)} GPH.`,partIds:[r.id],fix:`Increase source volume, reduce pump flow, or return more water to this reservoir.`}),n.tempF>73&&t.push({id:`res-temp-high:${r.id}`,severity:`warning`,title:`Reservoir water temperature too high`,detail:`${r.label||`Reservoir #${r.id}`} water temperature is ${n.tempF.toFixed(1)}°F — water above 73°F holds significantly less dissolved oxygen and increases Pythium (root rot) risks.`,partIds:[r.id],fix:`Add a water chiller, reduce room ambient temperature, or turn off unneeded inline pumps.`}),n.ph<5.5?t.push({id:`res-ph-low:${r.id}`,severity:`warning`,title:`Water pH is too low (acidic)`,detail:`${r.label||`Reservoir #${r.id}`} pH is ${n.ph.toFixed(1)} — pH below 5.5 locks out Calcium, Magnesium, and Phosphorus, starving the plant.`,partIds:[r.id],fix:`Add pH Up (potassium hydroxide) or dilute with fresh water to raise pH to 5.8 - 6.2.`}):n.ph>6.5&&t.push({id:`res-ph-high:${r.id}`,severity:`warning`,title:`Water pH is too high (alkaline)`,detail:`${r.label||`Reservoir #${r.id}`} pH is ${n.ph.toFixed(1)} — pH above 6.5 locks out Iron, Manganese, Boron, and Zinc, causing leaf chlorosis.`,partIds:[r.id],fix:`Add pH Down (phosphoric/citric acid) to lower pH to 5.8 - 6.2.`});let a=Q.getState().growthStage,o=1,s=1.6,c=`Add more concentrated nutrient solution (part A/B) to raise EC to 1.0 - 1.6 mS/cm.`,l=`Dilute the reservoir with fresh water to reduce nutrient concentration (EC).`;a===`seedling`?(o=.4,s=.8,c=`Add dilute nutrient solution to raise EC to 0.4 - 0.8 mS/cm for seedlings.`,l=`Dilute the reservoir with fresh water to lower EC to 0.4 - 0.8 mS/cm for seedlings.`):a===`flowering`&&(o=1.5,s=2.2,c=`Add bloom nutrients to raise EC to 1.5 - 2.2 mS/cm for flowering.`,l=`Dilute the reservoir with fresh water to lower EC to 1.5 - 2.2 mS/cm for flowering.`),n.ec<o?t.push({id:`res-ec-low:${r.id}`,severity:`info`,title:`Low nutrient concentration (EC)`,detail:`${r.label||`Reservoir #${r.id}`} EC is ${n.ec.toFixed(1)} mS/cm — very low nutrient levels will limit growth rate and lead to deficiencies in the ${a} stage.`,partIds:[r.id],fix:c}):n.ec>s&&t.push({id:`res-ec-high:${r.id}`,severity:`warning`,title:`High nutrient concentration (EC)`,detail:`${r.label||`Reservoir #${r.id}`} EC is ${n.ec.toFixed(1)} mS/cm — EC above ${s.toFixed(1)} risks nutrient burn or root dehydration in the ${a} stage.`,partIds:[r.id],fix:l})}return t}function ZR(e){let t=[],n=new Set;for(let r=0;r<e.parts.length;r++){let i=e.parts[r];for(let a=r+1;a<e.parts.length;a++){let r=e.parts[a],o=rS(i.position,r.position);if(o<.15){let e=[i.id,r.id].sort().join(`:`);if(n.has(e))continue;n.add(e),t.push({id:`part-overlap:${e}`,severity:`warning`,title:`Overlapping parts (clipping)`,detail:`${lS(i)} and ${lS(r)} are occupying the same space and morphing into each other.`,partIds:[i.id,r.id],fix:`Delete the duplicate part or move them apart`})}else if(i.type===`pipe`&&r.type===`pipe`){let e=i.rotation[1],a=r.rotation[1],s=Math.abs(Math.atan2(Math.sin(e-a),Math.cos(e-a)));if(s<.05||Math.abs(s-Math.PI)<.05){let a=Math.cos(e),s=-Math.sin(e),c=r.position[0]-i.position[0],l=r.position[1]-i.position[1],u=r.position[2]-i.position[2],d=c*a+u*s,f=c-d*a,p=u-d*s;if(Math.hypot(f,l,p)<.12){let e=((i.params.length??2)+(r.params.length??2))/2-.05;if(o<e-.2){let a=[i.id,r.id].sort().join(`:`);if(n.has(a))continue;n.add(a),t.push({id:`part-overlap:${a}`,severity:`warning`,title:`Collinear pipes overlapping`,detail:`${lS(i)} and ${lS(r)} are collinear but overlapping by ${(e-o).toFixed(1)} ft, causing them to morph together.`,partIds:[i.id,r.id],fix:`Adjust their positions or delete one`})}}}}}}return t}var QR={error:0,warning:1,info:2};function $R(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e.id,e])):e,r=Object.values(n),i=t;if(!i)try{i=JS(n)}catch{i=void 0}let a={partsMap:n,parts:r,sim:i,graph:mS(r),roomMetrics:KT(n)},o=[];for(let e of YR)try{o.push(...e.run(a))}catch(t){console.warn(`[design-check] rule "${e.id}" failed:`,t)}return o.sort((e,t)=>QR[e.severity]-QR[t.severity])}var ez=[`error`,`warning`,`info`],tz={error:{heading:`Errors`,noun:[`error`,`errors`],card:`border-rose-900/60 bg-rose-950/40`,dot:`bg-rose-500`,text:`text-rose-300`},warning:{heading:`Warnings`,noun:[`warning`,`warnings`],card:`border-amber-900/60 bg-amber-950/30`,dot:`bg-amber-400`,text:`text-amber-300`},info:{heading:`Tips`,noun:[`tip`,`tips`],card:`border-sky-900/60 bg-sky-950/30`,dot:`bg-sky-400`,text:`text-sky-300`}};function nz(e){let t=[];for(let n of ez){let r=e.filter(e=>e.severity===n).length;r>0&&t.push(`${r} ${tz[n].noun[r===1?0:1]}`)}return t.join(` · `)}function rz({finding:e,onSelectPart:t,onApplyFix:n}){let r=tz[e.severity],i=e.id.startsWith(`dead-leg:`)||e.id.startsWith(`diameter-mismatch:`)||e.id.startsWith(`pump-dead:`);return(0,Z.jsx)(`div`,{className:`rounded-lg border px-3 py-2.5 ${r.card}`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`span`,{className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${r.dot}`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-semibold leading-snug ${r.text}`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-snug text-zinc-400`,children:e.detail}),e.fix&&(0,Z.jsxs)(`p`,{className:`mt-1.5 rounded-md bg-zinc-900/80 px-2 py-1 text-[11px] leading-snug text-zinc-300`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-sky-400`,children:`Fix: `}),e.fix]}),e.partIds.length>0&&t&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[e.partIds.map((n,r)=>(0,Z.jsxs)(`button`,{onClick:()=>t(n),className:`rounded-md border border-zinc-700 bg-zinc-900 px-2 py-0.5 text-[10px] font-semibold text-sky-400 hover:border-sky-700 hover:bg-zinc-800`,children:[`Show part`,e.partIds.length>1?` ${r+1}`:``]},n)),i&&n&&(0,Z.jsx)(`button`,{onClick:()=>n(e),className:`rounded-md border border-emerald-700 bg-emerald-950 px-2 py-0.5 text-[10px] font-semibold text-emerald-300 hover:border-emerald-500 hover:bg-emerald-900`,children:`Apply fix`})]})]})]})})}function iz({findings:e,onSelectPart:t,onApplyFix:n,onClose:r}){let i=e.length===0;return(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:r}),(0,Z.jsxs)(`aside`,{className:`relative flex h-full w-[26rem] max-w-full flex-col border-l border-zinc-800 bg-zinc-950 shadow-2xl`,children:[(0,Z.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-zinc-800 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-bold tracking-wide text-zinc-100`,children:`Design Check`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-[11px] text-zinc-500`,children:i?`All rules passed`:nz(e)})]}),(0,Z.jsx)(`button`,{onClick:r,"aria-label":`Close design check`,className:`rounded-md border border-zinc-800 bg-zinc-900 px-2 py-1 text-xs font-semibold text-zinc-400 hover:border-zinc-600 hover:text-zinc-200`,children:`Close`})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-3`,children:i?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-center`,children:[(0,Z.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-emerald-950 ring-1 ring-emerald-800`,children:(0,Z.jsx)(`svg`,{viewBox:`0 0 20 20`,className:`h-6 w-6 text-emerald-400`,fill:`none`,children:(0,Z.jsx)(`path`,{d:`M4 10.5l4 4 8-9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-emerald-400`,children:`Build validated — no issues`}),(0,Z.jsx)(`p`,{className:`max-w-[16rem] text-[11px] text-zinc-500`,children:`Every design rule passed. Press Play to watch the water run.`})]}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:ez.map(r=>{let i=e.filter(e=>e.severity===r);if(!i.length)return null;let a=tz[r];return(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] font-bold tracking-wider text-zinc-500 uppercase`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${a.dot}`}),a.heading,(0,Z.jsx)(`span`,{className:`font-mono text-zinc-600`,children:i.length})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:i.map(e=>(0,Z.jsx)(rz,{finding:e,onSelectPart:t,onApplyFix:n},e.id))})]},r)})})})]})]})}var az=[`#38bdf8`,`#3d7bfa`,`#34d399`,`#3b7a57`,`#fbbf24`,`#f97316`,`#e0564f`,`#a78bfa`],oz=e=>{let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return az[Math.abs(t)%az.length]};function sz(){let{user:e}=wE(),t=Q(e=>e.parts),n=Q(e=>e.projectName),[r,i]=(0,v.useState)({}),a=(0,v.useRef)(null),o=(0,v.useRef)(t),s=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{if(!e)return;let t=window.location.protocol===`https:`?`wss:`:`ws:`,r=window.location.port===`5173`?`3000`:window.location.port,c=`${t}//${window.location.hostname}${r?`:${r}`:``}`,l=new WebSocket(c);return a.current=l,l.onopen=()=>{let t=oz(e.email);l.send(JSON.stringify({type:`join`,projectRoom:n,userId:e.id,userName:e.email,color:t,activeRoomId:Q.getState().activeRoomId}))},l.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`mutation`?(s.current=!0,o.current=t.parts,Q.getState().syncParts(t.parts)):t.type===`cursor`?i(e=>({...e,[t.userId]:{position:t.position,userName:t.userName,color:t.color,activeRoomId:t.activeRoomId}})):t.type===`leave`&&i(e=>{let n={...e};return delete n[t.userId],n})}catch(e){console.error(`Error handling WebSocket message:`,e)}},l.onclose=()=>{console.log(`Collaboration WebSocket disconnected`)},l.onerror=e=>{console.error(`Collaboration WebSocket error:`,e)},()=>{l.close(),a.current=null}},[e,n]),(0,v.useEffect)(()=>{if(s.current){s.current=!1,o.current=t;return}if(t!==o.current){o.current=t;let e=a.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`mutation`,parts:t}))}},[t]),(0,v.useEffect)(()=>{let e=0,t=t=>{let n=Date.now();if(n-e<50)return;e=n;let r=t.detail,i=a.current;i&&i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:`cursor`,position:[r.x,r.y,r.z],activeRoomId:Q.getState().activeRoomId}))};return window.addEventListener(`collab:cursor`,t),()=>{window.removeEventListener(`collab:cursor`,t)}},[]),{remoteCursors:r}}var cz=()=>{let{login:e,signup:t,error:n,clearError:r}=wE(),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null);return(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-zinc-950 overflow-y-auto px-4 py-8`,children:[(0,Z.jsx)(`div`,{className:`absolute top-0 left-0 right-0 bottom-0 bg-[radial-gradient(circle_at_30%_20%,rgba(14,165,233,0.1),transparent_40%)] pointer-events-none`}),(0,Z.jsxs)(`div`,{className:`w-full max-w-5xl grid grid-cols-1 lg:grid-cols-12 gap-8 lg:gap-12 items-center relative z-10 my-auto`,children:[(0,Z.jsxs)(`div`,{className:`lg:col-span-7 flex flex-col text-left space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`grid h-8 w-8 place-items-center rounded-lg bg-gradient-to-br from-sky-400 to-blue-600 text-sm font-black text-white shadow-md shadow-sky-500/10`,children:`H`}),(0,Z.jsx)(`span`,{className:`text-sm font-bold tracking-wider text-sky-400 uppercase`,children:`Hydro Builder`})]}),(0,Z.jsxs)(`h1`,{className:`text-3xl sm:text-4xl lg:text-5xl font-black text-white leading-tight tracking-tight`,children:[`Stop Guessing. `,(0,Z.jsx)(`br`,{className:`hidden sm:inline`}),(0,Z.jsx)(`span`,{className:`bg-gradient-to-r from-sky-400 to-blue-500 bg-clip-text text-transparent`,children:`Precision-Plumb`}),` Your Grow.`]}),(0,Z.jsx)(`p`,{className:`text-sm sm:text-base text-zinc-400 max-w-xl leading-relaxed`,children:`Eliminate design errors, head-loss issues, and unnecessary trips to the hardware store. Design, simulate, and size your entire water system in full interactive 3D.`}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-5 pt-2`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-base`,children:`💧`}),(0,Z.jsx)(`h3`,{className:`text-sm font-bold text-zinc-200`,children:`Real-Time Fluid Simulation`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-zinc-400 leading-relaxed pl-6`,children:`Instant calculations for GPH flow rates, water velocities (ft/s), and system pressures.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-base`,children:`📋`}),(0,Z.jsx)(`h3`,{className:`text-sm font-bold text-zinc-200`,children:`BOM & Cut List Generator`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-zinc-400 leading-relaxed pl-6`,children:`One-click material summaries of every fitting, adapter, and pipe length. Your design is your shopping list.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-base`,children:`📐`}),(0,Z.jsx)(`h3`,{className:`text-sm font-bold text-zinc-200`,children:`Auto-Snapping & Route Tools`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-zinc-400 leading-relaxed pl-6`,children:`Automatic elbow insertions, grid snaps, and open-ended pipe caps. Plumb runs in seconds.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-base`,children:`🔍`}),(0,Z.jsx)(`h3`,{className:`text-sm font-bold text-zinc-200`,children:`Pro Design Check Diagnostics`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-zinc-400 leading-relaxed pl-6`,children:`Automated error checks for dead-legs, backwards slopes, and diameter size mismatches.`})]})]}),(0,Z.jsxs)(`div`,{className:`border border-zinc-800 bg-zinc-900/30 rounded-xl p-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 max-w-xl`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-bold text-sky-400 uppercase tracking-widest block`,children:`Pricing model`}),(0,Z.jsx)(`span`,{className:`text-sm font-bold text-zinc-200`,children:`1 free workspace forever`})]}),(0,Z.jsx)(`div`,{className:`hidden sm:block h-6 w-px bg-zinc-800`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-bold text-emerald-400 uppercase tracking-widest block`,children:`Unlimited building`}),(0,Z.jsx)(`span`,{className:`text-sm font-bold text-zinc-200`,children:`Only $5 per additional build slot`})]})]})]}),(0,Z.jsx)(`div`,{className:`lg:col-span-5 w-full flex justify-center`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-md overflow-hidden rounded-2xl border border-zinc-850 bg-zinc-900/80 p-8 shadow-2xl backdrop-blur-md`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,Z.jsx)(`h2`,{className:`text-xl font-bold text-zinc-100`,children:i?`Create your free account`:`Welcome Back`}),(0,Z.jsx)(`p`,{className:`text-xs text-zinc-400 mt-1`,children:i?`Get instant access to your free build slot`:`Sign in to access your designs`})]}),(f||n)&&(0,Z.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/10 p-3 text-xs text-red-400`,children:f||n}),(0,Z.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),!o||!c){p(`Please fill in all fields`);return}d(!0),p(null),r();try{i?await t(o,c):await e(o,c)}catch(e){p(e instanceof Error?e.message:`Authentication failed`)}finally{d(!1)}},className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-semibold text-zinc-400 mb-1`,htmlFor:`email`,children:`Email Address`}),(0,Z.jsx)(`input`,{id:`email`,type:`email`,autoComplete:`email`,value:o,onChange:e=>s(e.target.value),className:`w-full rounded-lg border border-zinc-800 bg-zinc-950 px-3.5 py-2.5 text-sm text-zinc-200 outline-none transition focus:border-sky-500 focus:bg-zinc-950`,placeholder:`you@example.com`,required:!0})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-semibold text-zinc-400 mb-1`,htmlFor:`password`,children:`Password`}),(0,Z.jsx)(`input`,{id:`password`,type:`password`,autoComplete:i?`new-password`:`current-password`,value:c,onChange:e=>l(e.target.value),className:`w-full rounded-lg border border-zinc-800 bg-zinc-950 px-3.5 py-2.5 text-sm text-zinc-200 outline-none transition focus:border-sky-500 focus:bg-zinc-950`,placeholder:`••••••••`,required:!0})]}),(0,Z.jsx)(`button`,{type:`submit`,disabled:u,className:`w-full rounded-lg bg-gradient-to-r from-sky-500 to-blue-600 py-3 text-sm font-semibold text-white transition hover:from-sky-400 hover:to-blue-500 disabled:opacity-50 flex items-center justify-center gap-2 cursor-pointer shadow-lg shadow-sky-500/10`,children:u?(0,Z.jsx)(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`}):i?`Sign Up & Build`:`Sign In`})]}),(0,Z.jsx)(`div`,{className:`mt-5 text-center`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{a(!i),p(null),r()},className:`text-xs font-medium text-sky-400 hover:text-sky-300 transition`,children:i?`Already have an account? Sign In`:`Don't have an account? Sign Up`})})]})})]})]})};function lz(e,t){let{user:n}=wE(),r=n&&n.purchased_slots>0;(0,v.useEffect)(()=>{if(t)return;let n=r?yE(e):null;n&&n.parts.length>0?Q.getState().loadParts(n.parts,n.name):Q.getState().loadParts(dT(),`Demo: pump loop`)},[e,t,r])}function uz(e,t){let{user:n}=wE(),r=n&&n.purchased_slots>0,i=EE(e=>e.setStatus);(0,v.useEffect)(()=>{if(t)return;if(!r){i(`unsaved`);return}let n,a=!1,o=Q.subscribe((t,r)=>{t.parts!==r.parts&&(a=!0,i(`unsaved`));let o=t.draggingId!==null||t.gizmoDragging,s=(r.draggingId!==null||r.gizmoDragging)&&!o,c=t.parts!==r.parts&&!o;a&&(s||c)?(clearTimeout(n),i(`saving`),n=setTimeout(()=>{vE(Q.getState().projectName,Object.values(Q.getState().parts),e),a=!1,i(`saved`)},600)):o&&(clearTimeout(n),n=void 0)});return()=>{o(),clearTimeout(n)}},[e,t,r,i])}function dz(){(0,v.useEffect)(()=>{let e=e=>{let t=e.target;if(/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))return;let n=Q.getState(),r=e.metaKey||e.ctrlKey;if(r&&e.key.toLowerCase()===`z`){e.preventDefault(),e.shiftKey?n.redo():n.undo();return}if(r&&e.key.toLowerCase()===`y`){e.preventDefault(),n.redo();return}if(r&&e.key.toLowerCase()===`a`){e.preventDefault(),n.selectAll();return}if(r&&e.key.toLowerCase()===`c`){let t=n.selectedIds.map(e=>n.parts[e]).filter(Boolean);t.length>0&&(e.preventDefault(),navigator.clipboard.writeText(JSON.stringify({app:`hydro-builder-clip`,parts:t})),bS(`Copied ${t.length} parts`,`info`));return}if(r&&e.key.toLowerCase()===`v`){e.preventDefault(),navigator.clipboard.readText().then(e=>{try{let t=JSON.parse(e);t&&t.app===`hydro-builder-clip`&&Array.isArray(t.parts)&&bS(`Pasted ${n.pasteParts(t.parts).length} parts`,`success`)}catch{bS(`Clipboard does not contain valid hydro parts`,`error`)}}).catch(()=>{bS(`Could not read clipboard`,`error`)});return}if(r)return;let i=iT(e.key);if(i){e.preventDefault(),n.tool!==`select`&&n.setTool(`select`),n.setPlacingType(n.placingType===i?null:i);return}switch(e.key){case` `:e.preventDefault(),n.toggleSimRunning();break;case`Escape`:n.colorPopover?n.closeColorPopover():(n.setTool(`select`),n.setSelected(null));break;case`Delete`:case`Backspace`:n.removeParts(n.selectedIds);break;case`r`:case`R`:n.rotateParts(n.selectedIds,1,(e.shiftKey?-1:1)*(Math.PI/2));break;case`d`:case`D`:e.preventDefault(),n.duplicateParts(n.selectedIds);break;case`q`:case`Q`:n.translateParts(n.selectedIds,[0,-n.gridSize,0],`nudge`);break;case`e`:case`E`:n.translateParts(n.selectedIds,[0,n.gridSize,0],`nudge`);break}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function fz(){let{user:e,loading:t}=wE(),n=e?.email;lz(n,t),uz(n,t),dz();let{remoteCursors:r}=sz(),i=Q(e=>e.placingType),a=Q(e=>e.tool),o=Q(e=>e.selectedIds.length),s=Q(e=>e.viewMode),c=Q(e=>e.renderMode),l=Q(e=>e.parts),u=Q(e=>e.activeRoomId),d=YS(),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=(0,v.useMemo)(()=>Object.values(l).filter(e=>e.roomId===u),[l,u]);return t?(0,Z.jsxs)(`div`,{className:`flex h-screen flex-col items-center justify-center bg-zinc-950 text-zinc-100`,children:[(0,Z.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-sky-500 border-t-transparent mb-4`}),(0,Z.jsx)(`span`,{className:`text-sm font-semibold tracking-wider text-zinc-400`,children:`Hydro Builder initializing...`})]}):e?(0,Z.jsxs)(`div`,{className:`flex h-screen flex-col bg-zinc-950 text-zinc-100 select-none`,children:[(0,Z.jsx)(OE,{onOpenBom:()=>p(!0),onCheckBuild:()=>{h($R(g,d))}}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Z.jsx)(HT,{}),(0,Z.jsxs)(`main`,{className:`relative min-w-0 flex-1`,onDragOver:e=>e.preventDefault(),onDrop:e=>{let t=e.dataTransfer.getData(`application/x-hydro-part`);if(!t)return;e.preventDefault();let n=jw(e.clientX,e.clientY);if(!n)return;let r=Q.getState(),i=e=>r.snapToGrid?NS(e,r.gridSize):e,a=[`pipe`,`elbow`,`tee`,`valve`,`emitter`].includes(t)?.25:0;r.addPart(t,[i(n[0]),a,i(n[2])])},children:[(0,Z.jsx)(nT,{remoteCursors:r}),(i||a===`measure`||a===`pipeRun`)&&(0,Z.jsx)(`div`,{className:`pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-full border border-sky-800 bg-sky-950/90 px-4 py-1.5 text-xs font-medium text-sky-200 shadow-lg`,children:i?`Click to place · Shift-click to stamp copies · 1-9 switches parts · Esc to cancel`:a===`pipeRun`?`Pipe Run: click points · Shift-click to keep routing · Esc to exit`:`Measure: click two points · Esc to exit`}),!i&&a!==`measure`&&o>0&&(0,Z.jsx)(`div`,{className:`pointer-events-none absolute bottom-3 left-1/2 -translate-x-1/2 rounded-full border border-zinc-800 bg-zinc-950/85 px-4 py-1.5 text-[11px] font-medium text-zinc-400 shadow-lg backdrop-blur`,children:o>1?`${o} parts — drag moves all · ⌥drag clones · ⇧click adds/removes · ⌘click color · D duplicate · ⌫ delete`:`Drag body or gizmo to move · double-click plumbing to grab the whole run · selected pipes show stretch handles · drag a connector dot to snap${s===`orbit`?` · ⇧drag for vertical`:``} · ${c===`xray`?`X-Ray shows internals`:c===`water`?`Water mode isolates flow`:`Builder mode keeps solids primary`} · ⌥drag clones · ⌘click color · R rotate`}),(0,Z.jsx)(YT,{})]}),(0,Z.jsx)(QT,{})]}),(0,Z.jsx)(NE,{}),f&&(0,Z.jsx)(AR,{onClose:()=>p(!1)}),m&&(0,Z.jsx)(iz,{findings:m,onSelectPart:e=>{let t=Q.getState();if(t.setSelected(e),e){let n=t.parts[e];n&&t.setFocusTarget(n.position)}},onApplyFix:e=>{let t=Q.getState();if(e.id.startsWith(`dead-leg:`))t.fixDeadLeg(e.partIds);else if(e.id.startsWith(`diameter-mismatch:`))t.fixDiameterMismatch(e.partIds);else if(e.id.startsWith(`pump-dead:`)){let n=e.partIds[0];if(n){let e=t.parts[n];e&&(e.params.on===0||e.params.enabled===0)?t.updatePart(n,{params:{...e.params,on:1,enabled:1}}):t.fixPumpDeadEnd(n)}}else if(e.id.startsWith(`pump-head:`)){let n=e.partIds[0];if(n){let e=t.parts[n];if(e){let r=Math.ceil((e.params.maxHeadFt||8)*1.5);t.updatePart(n,{params:{...e.params,maxHeadFt:Math.min(30,r)}})}}}else if(e.id.startsWith(`unsupported-span:`)){let n=e.partIds[0];if(n){let e=t.parts[n];if(e){let n=e.position[1],r=Math.max(.5,n-.1),i=t.addPart(`lattice`,[e.position[0],r/2,e.position[2]],{snap:!1}),a=Q.getState().parts[i];a&&t.updatePart(i,{params:{...a.params,height:r}})}}}else if(e.id.startsWith(`drain-capacity:`)){let n=e.partIds[0];if(n){let e=t.parts[n];if(e){let r=d.drains?.find(e=>e?.partId===n)?.inflowGph??d.flows?.[n]??0,i=Math.ceil(r/25)*25;t.updatePart(n,{params:{...e.params,capacityGph:Math.min(2e3,i)}})}}}else if(e.id.startsWith(`res-temp-high:`)){let e=Object.values(t.parts).filter(e=>e.type===`waterChiller`);for(let n of e)t.updatePart(n.id,{params:{...n.params,on:1,targetTemp:68}})}else if(e.id.startsWith(`res-ph-low:`)||e.id.startsWith(`res-ph-high:`)){let n=e.partIds[0];if(n){let e=t.parts[n];e&&t.updatePart(n,{params:{...e.params,ph:6}})}}else if(e.id.startsWith(`res-ec-low:`)||e.id.startsWith(`res-ec-high:`)){let n=e.partIds[0];if(n){let e=t.parts[n];e&&t.updatePart(n,{params:{...e.params,ec:1.2}})}}else if(e.id.startsWith(`room-co2-open:`)||e.id.startsWith(`room-co2-missing:`)||e.id.startsWith(`room-co2-starved:`)){let n=e.partIds[0];if(n){let r=t.parts[n];if(r){let i=e.id.startsWith(`room-co2-open:`);t.updatePart(n,{params:{...r.params,sealed:+!!i}})}}}else if(e.id.startsWith(`room-sealed-exhaust:`)){let n=e.partIds[0];if(n){let e=t.parts[n];e&&t.updatePart(n,{params:{...e.params,sealed:0}})}}else if(e.id.startsWith(`room-vent-low:`)){let e=Object.values(t.parts).filter(e=>e.type===`inlineFan`);for(let n of e)t.updatePart(n.id,{params:{...n.params,cfm:600}})}else if(e.id.startsWith(`room-light-low:`)){let e=Object.values(t.parts).filter(e=>e.type===`growLight`);for(let n of e)t.updatePart(n.id,{params:{...n.params,watts:Math.min(1e3,(n.params.watts??650)+150)}})}else if(e.id.startsWith(`room-light-high:`)){let e=Object.values(t.parts).filter(e=>e.type===`growLight`);for(let n of e)t.updatePart(n.id,{params:{...n.params,watts:Math.max(100,(n.params.watts??650)-200)}})}else if(e.id.startsWith(`room-dli-low:`)){let e=Object.values(t.parts).filter(e=>e.type===`growLight`);for(let n of e)t.updatePart(n.id,{params:{...n.params,photoperiod:Math.min(24,(n.params.photoperiod??18)+4)}})}else if(e.id.startsWith(`room-dli-high:`)){let e=Object.values(t.parts).filter(e=>e.type===`growLight`);for(let n of e)t.updatePart(n.id,{params:{...n.params,photoperiod:Math.max(0,(n.params.photoperiod??18)-6)}})}else if(e.id.startsWith(`room-vpd-low:`)){let e=Object.values(t.parts).filter(e=>e.type===`growLight`);for(let n of e)t.updatePart(n.id,{params:{...n.params,watts:Math.min(1e3,(n.params.watts??650)+150)}})}else if(e.id.startsWith(`room-vpd-high:`)){let e=Object.values(t.parts).filter(e=>e.type===`growLight`);for(let n of e)t.updatePart(n.id,{params:{...n.params,watts:Math.max(100,(n.params.watts??650)-150)}})}else if(e.id.startsWith(`closed-valve:`)){let n=e.partIds[0];if(n){let e=t.parts[n];e&&t.updatePart(n,{params:{...e.params,open:100}})}}else if(e.id.startsWith(`part-overlap:`)){let n=e.partIds;n.length>=2&&t.removeParts([n[1]])}else e.id.startsWith(`orphan:`)&&t.removeParts(e.partIds);setTimeout(()=>{h($R(Object.values(Q.getState().parts),d))},50)},onClose:()=>h(null)}),(0,Z.jsx)(SS,{})]}):(0,Z.jsx)(cz,{})}function pz(){return(0,Z.jsx)(CE,{children:(0,Z.jsx)(fz,{})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(v.StrictMode,{children:(0,Z.jsx)(pz,{})}));export{o as n,l as r,hD as t}; |