diff --git a/api/developer.js b/api/developer.js new file mode 100644 index 0000000..4c81f63 --- /dev/null +++ b/api/developer.js @@ -0,0 +1,46 @@ +/** + * Vercel Serverless Function — serves a single developer's full data from Cosmos DB + * + * Endpoint: /api/developer?id= + */ +import { CosmosClient } from '@azure/cosmos'; + +const COSMOS_ENDPOINT = process.env.COSMOS_ENDPOINT; +const COSMOS_KEY = process.env.COSMOS_KEY; +const DATABASE = 'devglobe'; +const CONTAINER = 'developers'; + +export default async function handler(req, res) { + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Methods', 'GET'); + res.setHeader('Cache-Control', 's-maxage=3600, stale-while-revalidate=600'); + res.setHeader('Content-Type', 'application/json'); + + const { id } = req.query; + if (!id) { + return res.status(400).json({ error: 'Query parameter "id" is required' }); + } + + if (!COSMOS_ENDPOINT || !COSMOS_KEY) { + return res.status(500).json({ error: 'Cosmos DB credentials not configured' }); + } + + try { + const client = new CosmosClient({ endpoint: COSMOS_ENDPOINT, key: COSMOS_KEY }); + const container = client.database(DATABASE).container(CONTAINER); + + const { resources } = await container.items.query({ + query: 'SELECT c.id, c.login, c.name, c.avatarUrl, c.bio, c.location, c.lat, c.lng, c.followers, c.totalStars, c.totalForks, c.totalCommits, c.topLanguage, c.languages, c.publicRepos, c.topRepos, c.soReputation, c.soAnswers, c.soAcceptRate, c.soBadges, c.soUserId FROM c WHERE c.id = @id', + parameters: [{ name: '@id', value: id }] + }).fetchAll(); + + if (resources.length === 0) { + return res.status(404).json({ error: 'Developer not found' }); + } + + res.status(200).json(resources[0]); + } catch (err) { + console.error('Cosmos DB error:', err.message); + res.status(500).json({ error: 'Failed to fetch developer data' }); + } +} diff --git a/api/developers.js b/api/developers.js index 8537fec..8aa8dd8 100644 --- a/api/developers.js +++ b/api/developers.js @@ -27,8 +27,10 @@ export default async function handler(req, res) { const client = new CosmosClient({ endpoint: COSMOS_ENDPOINT, key: COSMOS_KEY }); const container = client.database(DATABASE).container(CONTAINER); + // Slim projection — only fields needed for globe rendering, leaderboard, and scoring + // Detail panel fetches full doc on demand via /api/developer?id=... const { resources } = await container.items - .query('SELECT * FROM c') + .query('SELECT c.id, c.login, c.name, c.avatarUrl, c.location, c.lat, c.lng, c.followers, c.totalStars, c.totalForks, c.totalCommits, c.topLanguage, c.soReputation, c.soAnswers, c.soAcceptRate, c.soBadges FROM c') .fetchAll(); res.status(200).json(resources); diff --git a/api/search.js b/api/search.js index e630b85..d4f297c 100644 --- a/api/search.js +++ b/api/search.js @@ -67,60 +67,68 @@ export default async function handler(req, res) { results = resources; } else if (mode === 'text') { + const searchTerm = q.toLowerCase(); const { resources } = await container.items.query({ query: ` SELECT TOP ${limit} c.id, c.login, c.name, c.avatarUrl, c.location, c.lat, c.lng, c.topLanguage, c.score, c.totalStars, c.followers, c.soReputation FROM c - WHERE FullTextContains(c.login, @q) - OR FullTextContains(c.name, @q) - OR FullTextContains(c.location, @q) - OR FullTextContains(c.bio, @q) - OR FullTextContains(c.topLanguage, @q) - ORDER BY RANK FullTextScore(c.login, [@q]) + - FullTextScore(c.name, [@q]) + - FullTextScore(c.location, [@q]) + - FullTextScore(c.bio, [@q]) + - FullTextScore(c.topLanguage, [@q]) + WHERE CONTAINS(LOWER(c.login), @q) + OR CONTAINS(LOWER(c.name), @q) + OR CONTAINS(LOWER(c.location), @q) + OR CONTAINS(LOWER(c.bio), @q) + OR CONTAINS(LOWER(c.topLanguage), @q) + ORDER BY c.score DESC `, - parameters: [{ name: '@q', value: q }] + parameters: [{ name: '@q', value: searchTerm }] }).fetchAll(); results = resources; } else { - // Hybrid: RRF fusion of vector + full-text + // Hybrid: client-side RRF fusion of vector + text results if (!OPENAI_ENDPOINT || !OPENAI_KEY) { return res.status(500).json({ error: 'OpenAI not configured for hybrid search' }); } + const searchTerm = q.toLowerCase(); const embedding = await getEmbedding(q); - const { resources } = await container.items.query({ - query: ` - SELECT TOP ${limit} - c.id, c.login, c.name, c.avatarUrl, c.location, c.lat, c.lng, - c.topLanguage, c.score, c.totalStars, c.followers, c.soReputation - FROM c - WHERE FullTextContains(c.login, @q) - OR FullTextContains(c.name, @q) - OR FullTextContains(c.location, @q) - OR FullTextContains(c.bio, @q) - OR FullTextContains(c.topLanguage, @q) - OR VectorDistance(c.embedding, @embedding) > 0.7 - ORDER BY RANK RRF( - FullTextScore(c.login, [@q]) + - FullTextScore(c.name, [@q]) + - FullTextScore(c.location, [@q]) + - FullTextScore(c.bio, [@q]) + - FullTextScore(c.topLanguage, [@q]), - VectorDistance(c.embedding, @embedding) - ) - `, - parameters: [ - { name: '@q', value: q }, - { name: '@embedding', value: embedding } - ] - }).fetchAll(); - results = resources; + + // Run vector and text searches in parallel + const [vectorRes, textRes] = await Promise.all([ + container.items.query({ + query: ` + SELECT TOP ${limit} + c.id, c.login, c.name, c.avatarUrl, c.location, c.lat, c.lng, + c.topLanguage, c.score, c.totalStars, c.followers, c.soReputation + FROM c + ORDER BY VectorDistance(c.embedding, @embedding) + `, + parameters: [{ name: '@embedding', value: embedding }] + }).fetchAll(), + container.items.query({ + query: ` + SELECT TOP ${limit} + c.id, c.login, c.name, c.avatarUrl, c.location, c.lat, c.lng, + c.topLanguage, c.score, c.totalStars, c.followers, c.soReputation + FROM c + WHERE CONTAINS(LOWER(c.login), @q) + OR CONTAINS(LOWER(c.name), @q) + OR CONTAINS(LOWER(c.location), @q) + OR CONTAINS(LOWER(c.bio), @q) + OR CONTAINS(LOWER(c.topLanguage), @q) + ORDER BY c.score DESC + `, + parameters: [{ name: '@q', value: searchTerm }] + }).fetchAll() + ]); + + // RRF fusion + const k = 60; + const rrf = new Map(); + const allMap = new Map(); + vectorRes.resources.forEach((r, i) => { rrf.set(r.login, (rrf.get(r.login) || 0) + 1 / (k + i + 1)); allMap.set(r.login, r); }); + textRes.resources.forEach((r, i) => { rrf.set(r.login, (rrf.get(r.login) || 0) + 1 / (k + i + 1)); allMap.set(r.login, r); }); + results = [...rrf.entries()].sort((a, b) => b[1] - a[1]).slice(0, limit).map(([login]) => allMap.get(login)); } res.json({ query: q, mode, count: results.length, results }); diff --git a/dist/assets/index-BNP1Oj68.js b/dist/assets/index-BNP1Oj68.js new file mode 100644 index 0000000..f2fced5 --- /dev/null +++ b/dist/assets/index-BNP1Oj68.js @@ -0,0 +1,5274 @@ +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;li[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{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(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()-Tt&&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||125o?(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{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(1ie||(e.current=re[ie],re[ie]=null,ie--)}function se(e,t){ie++,re[ie]=e.current,e.current=t}var ce=ae(null),le=ae(null),ue=ae(null),de=ae(null);function fe(e,t){switch(se(ue,t),se(le,e),se(ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Qd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Qd(t),e=$d(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}oe(ce),se(ce,e)}function pe(){oe(ce),oe(le),oe(ue)}function me(e){e.memoizedState!==null&&se(de,e);var t=ce.current,n=$d(t,e.type);t!==n&&(se(le,e),se(ce,n))}function he(e){le.current===e&&(oe(ce),oe(le)),de.current===e&&(oe(de),lp._currentValue=ne)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ye=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ve(n):``}function xe(e,t){switch(e.tag){case 26:case 27:case 5:return ve(e.type);case 16:return ve(`Lazy`);case 13:return e.child!==t&&t!==null?ve(`Suspense Fallback`):ve(`Suspense`);case 19:return ve(`SuspenseList`);case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return ve(`Activity`);default:return``}}function Se(e){try{var t=``,n=null;do t+=xe(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var I=Object.prototype.hasOwnProperty,Ce=t.unstable_scheduleCallback,we=t.unstable_cancelCallback,Te=t.unstable_shouldYield,Ee=t.unstable_requestPaint,De=t.unstable_now,Oe=t.unstable_getCurrentPriorityLevel,ke=t.unstable_ImmediatePriority,Ae=t.unstable_UserBlockingPriority,je=t.unstable_NormalPriority,Me=t.unstable_LowPriority,Ne=t.unstable_IdlePriority,Pe=t.log,Fe=t.unstable_setDisableYieldValue,Ie=null,Le=null;function Re(e){if(typeof Pe==`function`&&Fe(e),Le&&typeof Le.setStrictMode==`function`)try{Le.setStrictMode(Ie,e)}catch{}}var ze=Math.clz32?Math.clz32:L,Be=Math.log,Ve=Math.LN2;function L(e){return e>>>=0,e===0?32:31-(Be(e)/Ve|0)|0}var He=256,Ue=262144,We=4194304;function Ge(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 Ke(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=Ge(n))):i=Ge(o):i=Ge(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ge(n))):i=Ge(o)):i=Ge(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 qe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Je(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 Ye(){var e=We;return We<<=1,!(We&62914560)&&(We=4194304),e}function Xe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ze(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Qe(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`u`||window.document===void 0||window.document.createElement===void 0),ln=!1;if(cn)try{var un={};Object.defineProperty(un,"passive",{get:function(){ln=!0}}),window.addEventListener(`test`,un,un),window.removeEventListener(`test`,un,un)}catch{ln=!1}var dn=null,fn=null,pn=null;function mn(){if(pn)return pn;var e,t=fn,n=t.length,r,i=`value`in dn?dn.value:dn.textContent,a=i.length;for(e=0;e=Wn),qn=` `,Jn=!1;function Yn(e,t){switch(e){case`keyup`:return Hn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Xn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Zn=!1;function Qn(e,t){switch(e){case`compositionend`:return Xn(t);case`keypress`:return t.which===32?(Jn=!0,qn):null;case`textInput`:return e=t.data,e===qn&&Jn?null:e;default:return null}}function $n(e,t){if(Zn)return e===`compositionend`||!Un&&Yn(e,t)?(e=mn(),pn=fn=dn=null,Zn=!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)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=br(n)}}function Sr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Sr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Cr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Lt(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=Lt(e.document)}return t}function wr(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 Tr=cn&&`documentMode`in document&&11>=document.documentMode,Er=null,Dr=null,Or=null,kr=!1;function Ar(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;kr||Er==null||Er!==Lt(r)||(r=Er,`selectionStart`in r&&wr(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}),Or&&yr(Or,r)||(Or=r,r=Id(Dr,`onSelect`),0>=o,i-=o,Si=1<<32-ze(t)+i|n<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),ji&&wi(i,h),l;if(d===null){for(;hg?(_=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),ji&&wi(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 ji&&wi(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)}),ji&&wi(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&&Ta(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ma(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=li(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ci(o.type,o.key,o.props,null,e.mode,c),Ma(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=fi(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=Ta(o),b(e,r,o,c)}if(ee(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,ja(o),c);if(o.$$typeof===C)return b(e,r,$i(e,o),c);Na(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=ui(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Aa=0;var i=b(e,t,n,r);return ka=null,i}catch(t){if(t===ya||t===xa)throw t;var a=ii(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Fa=Pa(!0),Ia=Pa(!1),La=!1;function Ra(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function za(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 Ba(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Va(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Hl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ti(e),ei(e,null,n),t}return Zr(e,r,t,n),ti(e)}function Ha(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,et(e,n)}}function Ua(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 Wa=!1;function Ga(){if(Wa){var e=ua;if(e!==null)throw e}}function Ka(e,t,n,r){Wa=!1;var i=e.updateQueue;La=!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?(Gl&f)===f:(r&f)===f){f!==0&&f===la&&(Wa=!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:La=!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),$l|=o,e.lanes=o,e.memoizedState=d}}function qa(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ja(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=F.T,s={};F.T=s,Fs(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ps(e,t,pa(c,r),xu(e)):Ps(e,t,r,xu(e))}catch(n){Ps(e,t,{then:function(){},status:`rejected`,reason:n},xu())}finally{te.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.T=o}}function ws(){}function Ts(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Es(e).queue;Cs(e,a,t,ne,n===null?ws:function(){return Ds(e),n(r)})}function Es(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Io,lastRenderedState:ne},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Io,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ds(e){var t=Es(e);t.next===null&&(t=e.alternate.memoizedState),Ps(e,t.next.queue,{},xu())}function Os(){return Qi(lp)}function ks(){return jo().memoizedState}function As(){return jo().memoizedState}function js(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=xu();e=Ba(n);var r=Va(t,e,n);r!==null&&(Cu(r,t,n),Ha(r,t,n)),t={cache:aa()},e.payload=t;return}t=t.return}}function Ms(e,t,n){var r=xu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Is(e)?Ls(t,n):(n=Qr(e,t,n,r),n!==null&&(Cu(n,e,r),Rs(n,t,r)))}function Ns(e,t,n){Ps(e,t,n,xu())}function Ps(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Is(e))Ls(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,vr(s,o))return Zr(e,t,i,0),Ul===null&&Xr(),!1}catch{}if(n=Qr(e,t,i,r),n!==null)return Cu(n,e,r),Rs(n,t,r),!0}return!1}function Fs(e,t,n,r){if(r={lane:2,revertLane:bd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Is(e)){if(t)throw Error(i(479))}else t=Qr(e,n,r,2),t!==null&&Cu(t,e,2)}function Is(e){var t=e.alternate;return e===uo||t!==null&&t===uo}function Ls(e,t){ho=mo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Rs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,et(e,n)}}var zs={readContext:Qi,use:Po,useCallback:xo,useContext:xo,useEffect:xo,useImperativeHandle:xo,useLayoutEffect:xo,useInsertionEffect:xo,useMemo:xo,useReducer:xo,useRef:xo,useState:xo,useDebugValue:xo,useDeferredValue:xo,useTransition:xo,useSyncExternalStore:xo,useId:xo,useHostTransitionStatus:xo,useFormState:xo,useActionState:xo,useOptimistic:xo,useMemoCache:xo,useCacheRefresh:xo};zs.useEffectEvent=xo;var Bs={readContext:Qi,use:Po,useCallback:function(e,t){return Ao().memoizedState=[e,t===void 0?null:t],e},useContext:Qi,useEffect:us,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),cs(4194308,4,gs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return cs(4194308,4,e,t)},useInsertionEffect:function(e,t){cs(4,2,e,t)},useMemo:function(e,t){var n=Ao();t=t===void 0?null:t;var r=e();if(go){Re(!0);try{e()}finally{Re(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Ao();if(n!==void 0){var i=n(t);if(go){Re(!0);try{n(t)}finally{Re(!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=Ms.bind(null,uo,e),[r.memoizedState,e]},useRef:function(e){var t=Ao();return e={current:e},t.memoizedState=e},useState:function(e){e=Ko(e);var t=e.queue,n=Ns.bind(null,uo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:vs,useDeferredValue:function(e,t){return xs(Ao(),e,t)},useTransition:function(){var e=Ko(!1);return e=Cs.bind(null,uo,e.queue,!0,!1),Ao().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=uo,a=Ao();if(ji){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ul===null)throw Error(i(349));Gl&127||Vo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,us(Uo.bind(null,r,o,e),[e]),r.flags|=2048,os(9,{destroy:void 0},Ho.bind(null,r,o,n,t),null),n},useId:function(){var e=Ao(),t=Ul.identifierPrefix;if(ji){var n=Ci,r=Si;n=(r&~(1<<32-ze(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=_o++,0<\/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[st]=t,o[ct]=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(Gd(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&&Pc(t)}}return zc(t),Fc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Pc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ue.current,Ri(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ki,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[st]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Hd(e.nodeValue,n)),e||Fi(t,!0)}else e=Zd(e).createTextNode(r),e[st]=t,t.stateNode=e}return zc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ri(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[st]=t}else zi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;zc(t),e=!1}else n=Bi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(oo(t),t):(oo(t),null);if(t.flags&128)throw Error(i(558))}return zc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ri(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[st]=t}else zi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;zc(t),a=!1}else a=Bi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(oo(t),t):(oo(t),null)}return oo(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),Lc(t,t.updateQueue),zc(t),null);case 4:return pe(),e===null&&Md(t.stateNode.containerInfo),zc(t),null;case 10:return Ki(t.type),zc(t),null;case 19:if(oe(so),r=t.memoizedState,r===null)return zc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Rc(r,!1);else{if(Ql!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=co(e),o!==null){for(t.flags|=128,Rc(r,!1),e=o.updateQueue,t.updateQueue=e,Lc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)si(n,e),n=n.sibling;return se(so,so.current&1|2),ji&&wi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&De()>lu&&(t.flags|=128,a=!0,Rc(r,!1),t.lanes=4194304)}else{if(!a)if(e=co(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Lc(t,e),Rc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!ji)return zc(t),null}else 2*De()-r.renderingStartTime>lu&&n!==536870912&&(t.flags|=128,a=!0,Rc(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?(zc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=De(),e.sibling=null,n=so.current,se(so,a?n&1|2:n&1),ji&&wi(t,r.treeForkCount),e);case 22:case 23:return oo(t),$a(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(zc(t),t.subtreeFlags&6&&(t.flags|=8192)):zc(t),n=t.updateQueue,n!==null&&Lc(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&&oe(ha),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ki(ia),zc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Vc(e,t){switch(Di(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ki(ia),pe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return he(t),null;case 31:if(t.memoizedState!==null){if(oo(t),t.alternate===null)throw Error(i(340));zi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(oo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));zi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(so),null;case 4:return pe(),null;case 10:return Ki(t.type),null;case 22:case 23:return oo(t),$a(),e!==null&&oe(ha),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ki(ia),null;case 25:return null;default:return null}}function Hc(e,t){switch(Di(t),t.tag){case 3:Ki(ia),pe();break;case 26:case 27:case 5:he(t);break;case 4:pe();break;case 31:t.memoizedState!==null&&oo(t);break;case 13:oo(t);break;case 19:oe(so);break;case 10:Ki(t.type);break;case 22:case 23:oo(t),$a(),e!==null&&oe(ha);break;case 24:Ki(ia)}}function Uc(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){$u(t,t.return,e)}}function Wc(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){$u(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){$u(t,t.return,e)}}function Gc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ja(t,n)}catch(t){$u(e,e.return,t)}}}function Kc(e,t,n){n.props=qs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){$u(e,t,n)}}function qc(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){$u(e,t,n)}}function Jc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){$u(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){$u(e,t,n)}else n.current=null}function Yc(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){$u(e,e.return,t)}}function Xc(e,t,n){try{var r=e.stateNode;Kd(r,e.type,n,t),r[ct]=t}catch(t){$u(e,e.return,t)}}function Zc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&lf(e.type)||e.tag===4}function Qc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Zc(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&&lf(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 $c(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=en));else if(r!==4&&(r===27&&lf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for($c(e,t,n),e=e.sibling;e!==null;)$c(e,t,n),e=e.sibling}function el(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&&lf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(el(e,t,n),e=e.sibling;e!==null;)el(e,t,n),e=e.sibling}function tl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Gd(t,r,n),t[st]=e,t[ct]=n}catch(t){$u(e,e.return,t)}}var nl=!1,rl=!1,il=!1,al=typeof WeakSet==`function`?WeakSet:Set,ol=null;function sl(e,t){if(e=e.containerInfo,Yd=vp,e=Cr(e),wr(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(Xd={focusedElem:e,selectionRange:n},vp=!1,ol=t;ol!==null;)if(t=ol,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,ol=e;else for(;ol!==null;){switch(t=ol,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 title`))),Gd(o,r,n),o[st]=e,bt(o),r=o;break a;case`link`:var s=Qf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=xr(s,h),v=xr(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;sn?32:n,F.T=null,n=_u,_u=null;var o=pu,s=hu;if(fu=0,mu=pu=null,hu=0,Hl&6)throw Error(i(331));var c=Hl;if(Hl|=4,Ll(o.current),kl(o,o.current,s,n),Hl=c,pd(0,!1),Le&&typeof Le.onPostCommitFiberRoot==`function`)try{Le.onPostCommitFiberRoot(Ie,o)}catch{}return!0}finally{te.p=a,F.T=r,Yu(e,t)}}function Qu(e,t,n){t=mi(n,t),t=$s(e.stateNode,t,2),e=Va(e,t,2),e!==null&&(Ze(e,2),fd(e))}function $u(e,t,n){if(e.tag===3)Qu(e,e,n);else for(;t!==null;){if(t.tag===3){Qu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(du===null||!du.has(r))){e=mi(n,e),n=ec(2),r=Va(t,n,2),r!==null&&(tc(n,r,t,e),Ze(r,2),fd(r));break}}t=t.return}}function ed(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Vl;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)||(Xl=!0,i.add(n),e=td.bind(null,e,t,n),t.then(e,e))}function td(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ul===e&&(Gl&n)===n&&(Ql===4||Ql===3&&(Gl&62914560)===Gl&&300>De()-su?!(Hl&2)&&Au(e,0):tu|=n,ru===Gl&&(ru=0)),fd(e)}function nd(e,t){t===0&&(t=Ye()),e=$r(e,t),e!==null&&(Ze(e,t),fd(e))}function rd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),nd(e,n)}function id(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),nd(e,n)}function ad(e,t){return Ce(e,t)}var od=null,sd=null,cd=!1,ld=!1,ud=!1,dd=0;function fd(e){e!==sd&&e.next===null&&(sd===null?od=sd=e:sd=sd.next=e),ld=!0,cd||(cd=!0,yd())}function pd(e,t){if(!ud&&ld){ud=!0;do for(var n=!1,r=od;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-ze(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,vd(r,a))}else a=Gl,a=Ke(r,r===Ul?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||qe(r,a)||(n=!0,vd(r,a));r=r.next}while(n);ud=!1}}function md(){hd()}function hd(){ld=cd=!1;var e=0;dd!==0&&nf()&&(e=dd);for(var t=De(),n=null,r=od;r!==null;){var i=r.next,a=gd(r,t);a===0?(r.next=null,n===null?od=i:n.next=i,i===null&&(sd=n)):(n=r,(e!==0||a&3)&&(ld=!0)),r=i}fu!==0&&fu!==5||pd(e,!1),dd!==0&&(dd=0)}function gd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&qd(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function Mf(e,t,n){var r=jf;if(r&&typeof t==`string`&&t){var i=zt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Ef.has(i)||(Ef.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Gd(t,`link`,e),bt(t),r.head.appendChild(t)))}}function Nf(e){Of.D(e),Mf(`dns-prefetch`,e,null)}function Pf(e,t){Of.C(e,t),Mf(`preconnect`,e,t)}function Ff(e,t,n){Of.L(e,t,n);var r=jf;if(r&&e&&t){var i=`link[rel="preload"][as="`+zt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+zt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+zt(n.imageSizes)+`"]`)):i+=`[href="`+zt(e)+`"]`;var a=i;switch(t){case`style`:a=Vf(e);break;case`script`:a=Gf(e)}Tf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Tf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Hf(a))||t===`script`&&r.querySelector(Kf(a))||(t=r.createElement(`link`),Gd(t,`link`,e),bt(t),r.head.appendChild(t)))}}function If(e,t){Of.m(e,t);var n=jf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+zt(r)+`"][href="`+zt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Gf(e)}if(!Tf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),Tf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Kf(a)))return}r=n.createElement(`link`),Gd(r,`link`,e),bt(r),n.head.appendChild(r)}}}function Lf(e,t,n){Of.S(e,t,n);var r=jf;if(r&&e){var i=yt(r).hoistableStyles,a=Vf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Hf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Tf.get(a))&&Yf(e,n);var c=o=r.createElement(`link`);bt(c),Gd(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,Jf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Rf(e,t){Of.X(e,t);var n=jf;if(n&&e){var r=yt(n).hoistableScripts,i=Gf(e),a=r.get(i);a||(a=n.querySelector(Kf(i)),a||(e=m({src:e,async:!0},t),(t=Tf.get(i))&&Xf(e,t),a=n.createElement(`script`),bt(a),Gd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function zf(e,t){Of.M(e,t);var n=jf;if(n&&e){var r=yt(n).hoistableScripts,i=Gf(e),a=r.get(i);a||(a=n.querySelector(Kf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=Tf.get(i))&&Xf(e,t),a=n.createElement(`script`),bt(a),Gd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Bf(e,t,n,r){var a=(a=ue.current)?Df(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=Vf(n.href),n=yt(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=Vf(n.href);var o=yt(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(Hf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),Tf.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},Tf.set(e,n),o||Wf(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=Gf(n),n=yt(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 Vf(e){return`href="`+zt(e)+`"`}function Hf(e){return`link[rel="stylesheet"][`+e+`]`}function Uf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Wf(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}),Gd(t,`link`,n),bt(t),e.head.appendChild(t))}function Gf(e){return`[src="`+zt(e)+`"]`}function Kf(e){return`script[async]`+e}function qf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+zt(n.href)+`"]`);if(r)return t.instance=r,bt(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`),bt(r),Gd(r,`style`,a),Jf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Vf(n.href);var o=e.querySelector(Hf(a));if(o)return t.state.loading|=4,t.instance=o,bt(o),o;r=Uf(n),(a=Tf.get(a))&&Yf(r,a),o=(e.ownerDocument||e).createElement(`link`),bt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Gd(o,`link`,r),t.state.loading|=4,Jf(o,n.precedence,e),t.instance=o;case`script`:return o=Gf(n.src),(a=e.querySelector(Kf(o)))?(t.instance=a,bt(a),a):(r=n,(a=Tf.get(o))&&(r=m({},n),Xf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),bt(a),Gd(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,Jf(r,n.precedence,e));return t.instance}function Jf(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 title`):null)}function ep(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 tp(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function np(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=Vf(r.href),a=t.querySelector(Hf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ap.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,bt(a);return}a=t.ownerDocument||t,r=Uf(r),(i=Tf.get(i))&&Yf(r,i),a=a.createElement(`link`),bt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Gd(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=ap.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var rp=0;function ip(e,t){return e.stylesheets&&e.count===0&&sp(e,e.stylesheets),0rp?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function ap(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)sp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var op=null;function sp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,op=new Map,t.forEach(cp,e),op=null,ap.call(e))}function cp(e,t){if(!(t.state.loading&4)){var n=op.get(e);if(n)var r=n.get(null);else{n=new Map,op.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{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=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})),y=o(((e,t)=>{t.exports=v()})),b=l(_(),1),x=l(d(),1),S=y();function C(){return(0,S.jsxs)(`header`,{className:`header`,children:[(0,S.jsxs)(`div`,{className:`header__brand`,children:[(0,S.jsx)(`span`,{className:`header__icon`,children:`🌐`}),(0,S.jsx)(`h1`,{className:`header__title`,children:`DevGlobe`}),(0,S.jsx)(`span`,{className:`header__subtitle`,children:`Visualizing the World's Top Open-Source Contributors`})]}),(0,S.jsxs)(`div`,{className:`header__actions`,children:[(0,S.jsxs)(`a`,{href:`https://github.com/sajeetharan/devglobe`,target:`_blank`,rel:`noreferrer`,className:`btn btn--star`,children:[(0,S.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`currentColor`,children:(0,S.jsx)(`path`,{d:`M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.75.75 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25z`})}),`Star on GitHub`]}),(0,S.jsxs)(`a`,{href:`https://github.com/sponsors/sajeetharan`,target:`_blank`,rel:`noreferrer`,className:`btn btn--sponsor`,children:[(0,S.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`currentColor`,children:(0,S.jsx)(`path`,{d:`m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002z`})}),`Sponsor`]})]})]})}var w={stars:.25,commits:.25,repoReach:.2,soReputation:.15,soEngagement:.1,community:.05};function T(e,t){return e<=0||t<=0?0:Math.log(1+e)/Math.log(1+t)}function E(e,t){return t<=0?0:Math.min(e/t,1)}function D(e,t){let n={stars:T(e.totalStars||0,t.stars),commits:T(e.totalCommits||0,t.commits),repoReach:T((e.totalForks||0)+(e.totalWatchers||0),t.repoReach),soReputation:T(e.soReputation||0,t.soReputation),soEngagement:E((e.soAcceptRate||0)/100*(e.soAnswers||0),t.soEngagement),community:T((e.followers||0)+(e.soBadges||0),t.community)},r=0;for(let[e,t]of Object.entries(w))r+=n[e]*t;return{total:Math.round(r*100),dimensions:n}}function O(e){let t={stars:Math.max(...e.map(e=>e.totalStars||0)),commits:Math.max(...e.map(e=>e.totalCommits||0)),repoReach:Math.max(...e.map(e=>(e.totalForks||0)+(e.totalWatchers||0))),soReputation:Math.max(...e.map(e=>e.soReputation||0)),soEngagement:Math.max(...e.map(e=>(e.soAcceptRate||0)/100*(e.soAnswers||0))),community:Math.max(...e.map(e=>(e.followers||0)+(e.soBadges||0)))};return e.map(e=>{let{total:n,dimensions:r}=D(e,t);return{...e,score:n,scoreDimensions:r}}).sort((e,t)=>t.score-e.score)}function k(e){let t=e.stars+e.commits+e.repoReach,n=e.soReputation+e.soEngagement;return t>n*3?`#2ea44f`:n>t*1.5?`#f48024`:`#3b82f6`}var A=[{query:`open source contributors in San Francisco`,label:`SF contributors`},{query:`Python developer working on AI and deep learning`,label:`AI & deep learning`},{query:`full stack JavaScript developer`,label:`full stack JS dev`},{query:`Linux kernel and systems programming in C`,label:`Linux kernel devs`}];function j({developers:e,onResults:t,onReset:n}){let[r,i]=(0,x.useState)(``),[a,o]=(0,x.useState)(`hybrid`),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(null),d=(0,x.useRef)(null),f=(0,x.useRef)(null),p=(0,x.useRef)(null),m=(0,x.useCallback)(async(r,i)=>{if(!r.trim()){n(),u(null);return}if(i===`text`){let n=r.toLowerCase(),i=e.filter(e=>e.login&&e.login.toLowerCase().includes(n)||e.name&&e.name.toLowerCase().includes(n)||e.location&&e.location.toLowerCase().includes(n));t(i),u(i.length);return}f.current&&f.current.abort();let a=new AbortController;f.current=a,c(!0);try{let e=await(await fetch(`/api/search?q=${encodeURIComponent(r)}&mode=${i}&top=20`,{signal:a.signal})).json();if(!a.signal.aborted){let n=e.results||[];t(n),u(n.length)}}catch(e){e.name!==`AbortError`&&console.error(`Search failed:`,e)}finally{a.signal.aborted||c(!1)}},[e,t,n]),h=e=>{let t=e.target.value;i(t),clearTimeout(p.current),p.current=setTimeout(()=>m(t,a),400)},g=e=>{e.key===`Enter`&&(clearTimeout(p.current),m(r,a)),e.key===`Escape`&&y()},_=e=>{let t=e.target.value;o(t),r.trim()&&m(r,t)},v=e=>{i(e),m(e,a),d.current?.focus()},y=()=>{i(``),u(null),n(),d.current?.focus()};return(0,S.jsxs)(`div`,{className:`search-bar`,id:`search-bar`,children:[(0,S.jsxs)(`div`,{className:`search-bar__inner`,children:[s?(0,S.jsx)(`div`,{className:`search-bar__spinner`}):(0,S.jsx)(`svg`,{className:`search-bar__icon`,viewBox:`0 0 20 20`,fill:`currentColor`,width:`18`,height:`18`,children:(0,S.jsx)(`path`,{fillRule:`evenodd`,d:`M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z`,clipRule:`evenodd`})}),(0,S.jsx)(`input`,{ref:d,type:`text`,placeholder:`Search developers, languages, or locations...`,autoComplete:`off`,value:r,onChange:h,onKeyDown:g}),r&&(0,S.jsx)(`button`,{className:`search-bar__clear`,onClick:y,title:`Clear search (Esc)`,children:(0,S.jsx)(`svg`,{viewBox:`0 0 20 20`,fill:`currentColor`,width:`16`,height:`16`,children:(0,S.jsx)(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z`,clipRule:`evenodd`})})}),(0,S.jsxs)(`select`,{value:a,onChange:_,title:`Search mode`,children:[(0,S.jsx)(`option`,{value:`text`,children:`Text`}),(0,S.jsx)(`option`,{value:`vector`,children:`Vector (AI)`}),(0,S.jsx)(`option`,{value:`hybrid`,children:`Hybrid`})]})]}),l!==null&&r&&(0,S.jsx)(`div`,{className:`search-bar__results`,children:l===0?`No results found`:`${l} developer${l===1?``:`s`} found`}),(0,S.jsxs)(`div`,{className:`search-bar__samples${r?` hidden`:``}`,children:[(0,S.jsx)(`span`,{children:`Try:`}),A.map(e=>(0,S.jsx)(`button`,{onClick:()=>v(e.query),children:e.label},e.label))]})]})}function M(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 N(e,t,n){return t=ce(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P(e,t){return te(e)||M(e,t)||re(e,t)||oe()}function ee(e){return F(e)||ne(e)||re(e)||ae()}function F(e){if(Array.isArray(e))return ie(e)}function te(e){if(Array.isArray(e))return e}function ne(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function re(e,t){if(e){if(typeof e==`string`)return ie(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ie(e,t)}}function ie(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);ne,methodNames:r=[],initPropNames:i=[]}={}){return(0,x.forwardRef)((a,o)=>{let s=(0,x.useRef)(),c=(0,x.useMemo)(()=>e(Object.fromEntries(i.filter(e=>a.hasOwnProperty(e)).map(e=>[e,a[e]]))),[]);de(()=>{c(n(s.current))},x.useLayoutEffect),de(()=>c._destructor instanceof Function?c._destructor:void 0);let l=(0,x.useCallback)((e,...t)=>c[e]instanceof Function?c[e](...t):void 0,[c]),u=(0,x.useRef)({});return Object.keys(le(a,[...r,...i])).filter(e=>u.current[e]!==a[e]).forEach(e=>l(e,a[e])),u.current=a,(0,x.useImperativeHandle)(o,()=>Object.fromEntries(r.map(e=>[e,(...t)=>l(e,...t)])),[l]),x.createElement(t,{ref:s})})}function de(e,t=x.useEffect){let n=(0,x.useRef)(),r=(0,x.useRef)(!1),i=(0,x.useRef)(!1),[a,o]=(0,x.useState)(0);r.current&&(i.current=!0),t(()=>(r.current||=(n.current=e(),!0),o(e=>e+1),()=>{i.current&&=(n.current&&n.current(),n.current=void 0,r.current=!1,!1)}),[])}var fe={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},pe={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},me=1e3,he=1001,ge=1002,_e=1003,ve=1004,ye=1005,be=1006,xe=1007,Se=1008,I=1008,Ce=1009,we=1010,Te=1011,Ee=1012,De=1013,Oe=1014,ke=1015,Ae=1016,je=1017,Me=1018,Ne=1020,Pe=35902,Fe=35899,Ie=1021,Le=1022,Re=1023,ze=1026,Be=1027,Ve=1028,L=1029,He=1030,Ue=1031,We=1032,Ge=1033,Ke=33776,qe=33777,Je=33778,Ye=33779,Xe=35840,Ze=35841,Qe=35842,$e=35843,et=36196,tt=37492,nt=37496,rt=37488,it=37489,at=37490,ot=37491,st=37808,ct=37809,lt=37810,ut=37811,dt=37812,ft=37813,pt=37814,mt=37815,ht=37816,gt=37817,_t=37818,vt=37819,yt=37820,bt=37821,xt=36492,St=36494,Ct=36495,wt=36283,Tt=36284,Et=36285,Dt=36286,Ot=2300,kt=2301,At=2302,jt=2303,Mt=2400,Nt=2401,Pt=2402,Ft=3200,It=`srgb`,Lt=`srgb-linear`,Rt=`linear`,zt=`srgb`,Bt=7680,Vt=7681,Ht=7682,Ut=7683,Wt=34055,Gt=34056,Kt=5386,qt=35044,Jt=35048,Yt=2e3,Xt=2001,Zt={COMPUTE:`compute`,RENDER:`render`},Qt={TEXTURE_COMPARE:`depthTextureCompare`};function $t(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function en(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function tn(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function nn(){let e=tn(`canvas`);return e.style.display=`block`,e}var rn={};function an(...e){let t=`THREE.`+e.shift();console.log(t,...e)}function on(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 R(...e){e=on(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function z(...e){e=on(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function sn(...e){let t=e.join(` `);t in rn||(rn[t]=!0,R(...e))}function cn(){return typeof self<`u`&&self.scheduler!==void 0&&self.scheduler.yield!==void 0?self.scheduler.yield():new Promise(e=>{requestAnimationFrame(e)})}function ln(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 un={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},dn=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&&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>8&255]+fn[e>>16&255]+fn[e>>24&255]+`-`+fn[t&255]+fn[t>>8&255]+`-`+fn[t>>16&15|64]+fn[t>>24&255]+`-`+fn[n&63|128]+fn[n>>8&255]+`-`+fn[n>>16&255]+fn[n>>24&255]+fn[r&255]+fn[r>>8&255]+fn[r>>16&255]+fn[r>>24&255]).toLowerCase()}function _n(e,t,n){return Math.max(t,Math.min(n,e))}function vn(e,t){return(e%t+t)%t}function yn(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function bn(e,t,n){return e===t?0:(n-e)/(t-e)}function xn(e,t,n){return(1-n)*e+n*t}function Sn(e,t,n,r){return xn(e,t,1-Math.exp(-n*r))}function Cn(e,t=1){return t-Math.abs(vn(e,t*2)-t)}function wn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Tn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function En(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Dn(e,t){return e+Math.random()*(t-e)}function On(e){return e*(.5-Math.random())}function kn(e){e!==void 0&&(pn=e);let t=pn+=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 An(e){return e*mn}function jn(e){return e*hn}function Mn(e){return(e&e-1)==0&&e!==0}function Nn(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Pn(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Fn(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:R(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function In(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(`THREE.MathUtils: Invalid component type.`)}}function Ln(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(`THREE.MathUtils: Invalid component type.`)}}var Rn={DEG2RAD:mn,RAD2DEG:hn,generateUUID:gn,clamp:_n,euclideanModulo:vn,mapLinear:yn,inverseLerp:bn,lerp:xn,damp:Sn,pingpong:Cn,smoothstep:wn,smootherstep:Tn,randInt:En,randFloat:Dn,randFloatSpread:On,seededRandom:kn,degToRad:An,radToDeg:jn,isPowerOfTwo:Mn,ceilPowerOfTwo:Nn,floorPowerOfTwo:Pn,setQuaternionFromProperEuler:Fn,normalize:Ln,denormalize:In},B=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(`THREE.Vector2: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`THREE.Vector2: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,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=_n(this.x,e.x,t.x),this.y=_n(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=_n(this.x,e,t),this.y=_n(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(_n(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(_n(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}},zn=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:R(`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(_n(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}},V=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(`THREE.Vector3: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`THREE.Vector3: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,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(Vn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Vn.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=_n(this.x,e.x,t.x),this.y=_n(this.y,e.y,t.y),this.z=_n(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=_n(this.x,e,t),this.y=_n(this.y,e,t),this.z=_n(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(_n(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 Bn.copy(this).projectOnVector(e),this.sub(Bn)}reflect(e){return this.sub(Bn.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(_n(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}},Bn=new V,Vn=new zn,Hn=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 sn(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(Un.makeScale(e,t)),this}rotate(e){return sn(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(Un.makeRotation(-e)),this}translate(e,t){return sn(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(Un.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)}},Un=new Hn,Wn=new Hn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Gn=new Hn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Kn(){let e={enabled:!0,workingColorSpace:Lt,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Jn(e.r),e.g=Jn(e.g),e.b=Jn(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=Yn(e.r),e.g=Yn(e.g),e.b=Yn(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===``?Rt: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 sn(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return sn(`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({[Lt]:{primaries:t,whitePoint:r,transfer:Rt,toXYZ:Wn,fromXYZ:Gn,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:It},outputColorSpaceConfig:{drawingBufferColorSpace:It}},[It]:{primaries:t,whitePoint:r,transfer:zt,toXYZ:Wn,fromXYZ:Gn,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:It}}}),e}var qn=Kn();function Jn(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Yn(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Xn,Zn=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{Xn===void 0&&(Xn=tn(`canvas`)),Xn.width=e.width,Xn.height=e.height;let t=Xn.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Xn}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=tn(`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;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(nr).x}get height(){return this.source.getSize(nr).y}get depth(){return this.source.getSize(nr).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){R(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){R(`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 me:e.x-=Math.floor(e.x);break;case he:e.x=e.x<0?0:1;break;case ge: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 me:e.y-=Math.floor(e.y);break;case he:e.y=e.y<0?0:1;break;case ge: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++}};rr.DEFAULT_IMAGE=null,rr.DEFAULT_MAPPING=300,rr.DEFAULT_ANISOTROPY=1;var ir=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(`THREE.Vector4: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`THREE.Vector4: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?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)s&&e>_?e_?s1);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>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(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;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(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.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(Lr)))}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 Ir;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},zr={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},Br={h:0,s:0,l:0},Vr={h:0,s:0,l:0};function Hr(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 Ur=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=It){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,qn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=qn.workingColorSpace){return this.r=e,this.g=t,this.b=n,qn.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=qn.workingColorSpace){if(e=vn(e,1),t=_n(t,0,1),n=_n(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=Hr(i,r,e+1/3),this.g=Hr(i,r,e),this.b=Hr(i,r,e-1/3)}return qn.colorSpaceToWorking(this,r),this}setStyle(e,t=It){function n(t){t!==void 0&&parseFloat(t)<1&&R(`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:R(`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);R(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=It){let n=zr[e.toLowerCase()];return n===void 0?R(`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=Jn(e.r),this.g=Jn(e.g),this.b=Jn(e.b),this}copyLinearToSRGB(e){return this.r=Yn(e.r),this.g=Yn(e.g),this.b=Yn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=It){return qn.workingToColorSpace(Wr.copy(this),e),Math.round(_n(Wr.r*255,0,255))*65536+Math.round(_n(Wr.g*255,0,255))*256+Math.round(_n(Wr.b*255,0,255))}getHexString(e=It){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qn.workingColorSpace){qn.workingToColorSpace(Wr.copy(this),t);let n=Wr.r,r=Wr.g,i=Wr.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+(r0&&(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}},Kr=new V,qr=new V,Jr=new V,Yr=new V,Xr=new V,Zr=new V,Qr=new V,$r=new V,ei=new V,ti=new V,ni=new ir,ri=new ir,ii=new ir,ai=class e{constructor(e=new V,t=new V,n=new V){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Kr.subVectors(e,t),r.cross(Kr);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){Kr.subVectors(r,t),qr.subVectors(n,t),Jr.subVectors(e,t);let a=Kr.dot(Kr),o=Kr.dot(qr),s=Kr.dot(Jr),c=qr.dot(qr),l=qr.dot(Jr),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,Yr)!==null&&Yr.x>=0&&Yr.y>=0&&Yr.x+Yr.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Yr)===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,Yr.x),s.addScaledVector(a,Yr.y),s.addScaledVector(o,Yr.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return ni.setScalar(0),ri.setScalar(0),ii.setScalar(0),ni.fromBufferAttribute(e,t),ri.fromBufferAttribute(e,n),ii.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ni,i.x),a.addScaledVector(ri,i.y),a.addScaledVector(ii,i.z),a}static isFrontFacing(e,t,n,r){return Kr.subVectors(n,t),qr.subVectors(e,t),Kr.cross(qr).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 Kr.subVectors(this.c,this.b),qr.subVectors(this.a,this.b),Kr.cross(qr).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;Xr.subVectors(r,n),Zr.subVectors(i,n),$r.subVectors(e,n);let s=Xr.dot($r),c=Zr.dot($r);if(s<=0&&c<=0)return t.copy(n);ei.subVectors(e,r);let l=Xr.dot(ei),u=Zr.dot(ei);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(Xr,a);ti.subVectors(e,i);let f=Xr.dot(ti),p=Zr.dot(ti);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(Zr,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Qr.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Qr,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Xr,a).addScaledVector(Zr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},oi=class{constructor(e=new V(1/0,1/0,1/0),t=new V(-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=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,ci),ci.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(gi),_i.subVectors(this.max,gi),ui.subVectors(e.a,gi),di.subVectors(e.b,gi),fi.subVectors(e.c,gi),pi.subVectors(di,ui),mi.subVectors(fi,di),hi.subVectors(ui,fi);let t=[0,-pi.z,pi.y,0,-mi.z,mi.y,0,-hi.z,hi.y,pi.z,0,-pi.x,mi.z,0,-mi.x,hi.z,0,-hi.x,-pi.y,pi.x,0,-mi.y,mi.x,0,-hi.y,hi.x,0];return!bi(t,ui,di,fi,_i)||(t=[1,0,0,0,1,0,0,0,1],!bi(t,ui,di,fi,_i))?!1:(vi.crossVectors(pi,mi),t=[vi.x,vi.y,vi.z],bi(t,ui,di,fi,_i))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ci).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ci).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:(si[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),si[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),si[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),si[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),si[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),si[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),si[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),si[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(si),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}},si=[new V,new V,new V,new V,new V,new V,new V,new V],ci=new V,li=new oi,ui=new V,di=new V,fi=new V,pi=new V,mi=new V,hi=new V,gi=new V,_i=new V,vi=new V,yi=new V;function bi(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){yi.fromArray(e,a);let o=i.x*Math.abs(yi.x)+i.y*Math.abs(yi.y)+i.z*Math.abs(yi.z),s=t.dot(yi),c=n.dot(yi),l=r.dot(yi);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var xi=Si();function Si(){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 Ci(e){Math.abs(e)>65504&&R(`DataUtils.toHalfFloat(): Value out of range.`),e=_n(e,-65504,65504),xi.floatView[0]=e;let t=xi.uint32View[0],n=t>>23&511;return xi.baseTable[n]+((t&8388607)>>xi.shiftTable[n])}function wi(e){let t=e>>10;return xi.uint32View[0]=xi.mantissaTable[xi.offsetTable[t]+(e&1023)]+xi.exponentTable[t],xi.floatView[0]}var Ti=new V,Ei=new B,Di=0,Oi=class extends dn{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:Di++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=qt,this.updateRanges=[],this.gpuType=ke,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;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=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;Pi.subVectors(e,this.center);let t=Pi.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Pi,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):(Fi.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Pi.copy(e.center).add(Fi)),this.expandByPoint(Pi.copy(e.center).sub(Fi))),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}},Li=0,Ri=new lr,zi=new Fr,Bi=new V,Vi=new oi,Hi=new oi,Ui=new V,Wi=class e extends dn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Li++}),this.uuid=gn(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new($t(e)?Ai:ki)(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 Hn().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._transformed=!0,this}applyQuaternion(e){return Ri.makeRotationFromQuaternion(e),this.applyMatrix4(Ri),this}rotateX(e){return Ri.makeRotationX(e),this.applyMatrix4(Ri),this}rotateY(e){return Ri.makeRotationY(e),this.applyMatrix4(Ri),this}rotateZ(e){return Ri.makeRotationZ(e),this.applyMatrix4(Ri),this}translate(e,t,n){return Ri.makeTranslation(e,t,n),this.applyMatrix4(Ri),this}scale(e,t,n){return Ri.makeScale(e,t,n),this.applyMatrix4(Ri),this}lookAt(e){return zi.lookAt(e),zi.updateMatrix(),this.applyMatrix4(zi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Bi).negate(),this.translate(Bi.x,Bi.y,Bi.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&R(`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 oi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){z(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!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;t0&&(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;e0!=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){R(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){R(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||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}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ur().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors==`number`?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new B().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new B().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;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++}},Xi=class extends Yi{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new Ur(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}},Zi=new V,Qi=new V,$i=new V,ea=new V,ta=new V,na=new V,ra=new V,ia=class{constructor(e=new V,t=new V(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,Zi)),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=Zi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Zi.copy(this.origin).addScaledVector(this.direction,t),Zi.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Qi.copy(e).add(t).multiplyScalar(.5),$i.copy(t).sub(e).normalize(),ea.copy(this.origin).sub(Qi);let i=e.distanceTo(t)*.5,a=-this.direction.dot($i),o=ea.dot(this.direction),s=-ea.dot($i),c=ea.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(Qi).addScaledVector($i,d),f}intersectSphere(e,t){Zi.subVectors(e.center,this.origin);let n=Zi.dot(this.direction),r=Zi.dot(Zi)-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=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=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Zi)!==null}intersectTriangle(e,t,n,r,i){ta.subVectors(t,e),na.subVectors(n,e),ra.crossVectors(ta,na);let a=this.direction.dot(ra),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ea.subVectors(this.origin,e);let s=o*this.direction.dot(na.crossVectors(ea,na));if(s<0)return null;let c=o*this.direction.dot(ta.cross(ea));if(c<0||s+c>a)return null;let l=-o*ea.dot(ra);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)}},aa=class extends Yi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Ur(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 vr,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}},oa=new lr,sa=new ia,ca=new Ii,la=new V,ua=new V,da=new V,fa=new V,pa=new V,ma=new V,ha=new V,ga=new V,_a=class extends Fr{constructor(e=new Wi,t=new aa){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(e.far-e.near)**2))&&(oa.copy(i).invert(),sa.copy(e.ray).applyMatrix4(oa),!(n.boundingBox!==null&&sa.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,sa)))}_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;in.far?null:{distance:l,point:ga.clone(),object:e}}function ya(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,ua),e.getVertexPosition(c,da),e.getVertexPosition(l,fa);let u=va(e,t,n,r,ua,da,fa,ha);if(u){let e=new V;ai.getBarycoord(ha,ua,da,fa,e),i&&(u.uv=ai.getInterpolatedAttribute(i,s,c,l,e,new B)),a&&(u.uv1=ai.getInterpolatedAttribute(a,s,c,l,e,new B)),o&&(u.normal=ai.getInterpolatedAttribute(o,s,c,l,e,new V),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new V,materialIndex:0};ai.getNormal(ua,da,fa,t.normal),u.face=t,u.barycoord=e}return u}var ba=class extends rr{constructor(e=null,t=1,n=1,r,i,a,o,s,c=_e,l=_e,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}},xa=class extends Oi{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}},Sa=new V,Ca=new V,wa=new Hn,Ta=class{constructor(e=new V(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=Sa.subVectors(n,t).cross(Ca.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(Sa),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||wa.getNormalMatrix(e),r=this.coplanarPoint(Sa).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)}},Ea=new Ii,Da=new B(.5,.5),Oa=new V,ka=class{constructor(e=new Ta,t=new Ta,n=new Ta,r=new Ta,i=new Ta,a=new Ta){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=Yt,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(),Ea.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ea.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ea)}intersectsSprite(e){return Ea.center.set(0,0,0),Ea.radius=.7071067811865476+Da.distanceTo(e.center),Ea.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ea)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,Oa.y=r.normal.y>0?e.max.y:e.min.y,Oa.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Oa)<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)}},Aa=new lr,ja=class e{constructor(){this.coordinateSystem=Yt,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;Ra.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(Ra);if(!(ct.far))return{distance:c,point:za.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Ha=new V,Ua=new V,Wa=class extends Ba{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;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Qa=class extends rr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=_e,this.minFilter=_e,this.generateMipmaps=!1,this.needsUpdate=!0}},$a=class extends rr{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}},eo=class extends rr{constructor(e,t,n=Oe,r,i,a,o=_e,s=_e,c,l=ze,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.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 $n(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}},to=class extends eo{constructor(e,t=Oe,n=301,r,i,a=_e,o=_e,s,c=ze){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}},no=class extends rr{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},ro=class e extends Wi{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 Mi(c,3)),this.setAttribute(`normal`,new Mi(l,3)),this.setAttribute(`uv`,new Mi(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 V;for(let a=0;a0?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;e0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Mi(u,3)),this.setAttribute(`normal`,new Mi(d,3)),this.setAttribute(`uv`,new Mi(f,2));function _(){let a=new V,_=new V,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;n0||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 B,m=new V,_=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;e0)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 B:new V);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 V,r=[],i=[],a=[],o=new V,s=new lr;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new V)}i[0]=new V,a[0]=new V;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(_n(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(_n(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}},so=class extends oo{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 B){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}},co=class extends so{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function lo(){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 uo=new V,fo=new V,po=new lo,mo=new lo,ho=new lo,go=class extends oo{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 V){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]:(fo.subVectors(r[0],r[1]).add(r[0]),c=fo);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(_o(o,s.x,c.x,l.x,u.x),_o(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){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;n1&&!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;t0){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}},Lo=class extends Io{constructor(e){super(e),this.uuid=gn(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Vo(a,o,n,s,c,l,0),o}function zo(e,t,n,r,i){let a;if(i===gs(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=ps(i/r|0,e[i],e[i+1],a);return a&&as(a,a.next)&&(ms(a),a=a.next),a}function Bo(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(as(n,n.next)||is(n.prev,n,n.next)===0)){if(ms(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function Vo(e,t,n,r,i,a,o){if(!e)return;!o&&a&&Zo(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?Uo(e,r,i,a):Ho(e)){t.push(c.i,e.i,l.i),ms(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=Wo(Bo(e),t),Vo(e,t,n,r,i,a,2)):o===2&&Go(e,t,n,r,i,a):Vo(Bo(e),t,n,r,i,a,1);break}}}function Ho(e){let t=e.prev,n=e,r=e.next;if(is(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&&ns(i,s,a,c,o,l,m.x,m.y)&&is(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Uo(e,t,n,r){let i=e.prev,a=e,o=e.next;if(is(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),_=$o(p,m,t,n,r),v=$o(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&&ns(s,u,c,d,l,f,y.x,y.y)&&is(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&&ns(s,u,c,d,l,f,b.x,b.y)&&is(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&&ns(s,u,c,d,l,f,y.x,y.y)&&is(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&&ns(s,u,c,d,l,f,b.x,b.y)&&is(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Wo(e,t){let n=e;do{let r=n.prev,i=n.next.next;!as(r,i)&&os(r,n,n.next,i)&&us(r,i)&&us(i,r)&&(t.push(r.i,n.i,i.i),ms(n),ms(n.next),n=e=i),n=n.next}while(n!==e);return Bo(n)}function Go(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&rs(o,e)){let s=fs(o,e);o=Bo(o,o.next),s=Bo(s,s.next),Vo(o,t,n,r,i,a,0),Vo(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Ko(e,t,n,r){let i=[];for(let n=0,a=t.length;n=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.x&&n.x>=c&&r!==n.x&&ts(io.x||n.x===o.x&&Xo(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Xo(e,t){return is(e.prev,e,t.prev)<0&&is(t.next,e,e.next)<0}function Zo(e,t,n,r){let i=e;do i.z===0&&(i.z=$o(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,Qo(i)}function Qo(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;e0||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 $o(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 es(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function ns(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&ts(e,t,n,r,i,a,o,s)}function rs(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!ls(e,t)&&(us(e,t)&&us(t,e)&&ds(e,t)&&(is(e.prev,e,t.prev)||is(e,t.prev,t))||as(e,t)&&is(e.prev,e,e.next)>0&&is(t.prev,t,t.next)>0)}function is(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function as(e,t){return e.x===t.x&&e.y===t.y}function os(e,t,n,r){let i=cs(is(e,t,n)),a=cs(is(e,t,r)),o=cs(is(n,r,e)),s=cs(is(n,r,t));return!!(i!==a&&o!==s||i===0&&ss(e,n,t)||a===0&&ss(e,r,t)||o===0&&ss(n,e,r)||s===0&&ss(n,t,r))}function ss(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 cs(e){return e>0?1:e<0?-1:0}function ls(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&&os(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function us(e,t){return is(e.prev,e,e.next)<0?is(e,t,e.next)>=0&&is(e,e.prev,t)>=0:is(e,t,e.prev)<0||is(e,e.next,t)<0}function ds(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 fs(e,t){let n=hs(e.i,e.x,e.y),r=hs(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 ps(e,t,n,r){let i=hs(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 ms(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 hs(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function gs(e,t,n,r){let i=0;for(let a=t,o=n-r;a2&&e[t-1].equals(e[0])&&e.pop()}function bs(e,t){for(let n=0;n2**-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 B(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 B(r/a,i/a)}let j=[];for(let e=0,t=D.length,n=t-1,r=e+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=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e0)&&f.push(t,i,c),(e!==n-1||s0&&(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}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case`t`:this.uniforms[n].value=t[r.value]||null;break;case`c`:this.uniforms[n].value=new Ur().setHex(r.value);break;case`v2`:this.uniforms[n].value=new B().fromArray(r.value);break;case`v3`:this.uniforms[n].value=new V().fromArray(r.value);break;case`v4`:this.uniforms[n].value=new ir().fromArray(r.value);break;case`m3`:this.uniforms[n].value=new Hn().fromArray(r.value);break;case`m4`:this.uniforms[n].value=new lr().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let t in e.extensions)this.extensions[t]=e.extensions[t];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},zs=class extends Rs{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Bs=class extends Yi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new Ur(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 Ur(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new B(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 vr,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}},Vs=class extends Bs{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 B(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return _n(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 Ur(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 Ur(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ur(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}},Hs=class extends Yi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new Ur(16777215),this.specular=new Ur(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ur(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vr,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}},Us=class extends Yi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new Ur(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ur(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new B(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}},Ws=class extends Yi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new B(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}},Gs=class extends Yi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new Ur(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ur(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vr,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}},Ks=class extends Yi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=Ft,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}},qs=class extends Yi{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}},Js=class extends Yi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new Ur(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new B(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}},Ys=class extends Ma{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 Xs(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var Zs=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=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--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&&(z(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(z(`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)){z(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){z(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&en(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){z(`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()===At,i=e.length-1,a=1;for(let o=1;o0){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}};nc.prototype.ValueTypeName=``,nc.prototype.TimeBufferType=Float32Array,nc.prototype.ValueBufferType=Float32Array,nc.prototype.DefaultInterpolation=kt;var rc=class extends nc{constructor(e,t,n){super(e,t,n)}};rc.prototype.ValueTypeName=`bool`,rc.prototype.ValueBufferType=Array,rc.prototype.DefaultInterpolation=Ot,rc.prototype.InterpolantFactoryMethodLinear=void 0,rc.prototype.InterpolantFactoryMethodSmooth=void 0;var ic=class extends nc{constructor(e,t,n,r){super(e,t,n,r)}};ic.prototype.ValueTypeName=`color`;var ac=class extends nc{constructor(e,t,n,r){super(e,t,n,r)}};ac.prototype.ValueTypeName=`number`;var oc=class extends Zs{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)zn.slerpFlat(i,0,a,c-o,a,c,s);return i}},sc=class extends nc{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new oc(this.times,this.values,this.getValueSize(),e)}};sc.prototype.ValueTypeName=`quaternion`,sc.prototype.InterpolantFactoryMethodSmooth=void 0;var cc=class extends nc{constructor(e,t,n){super(e,t,n)}};cc.prototype.ValueTypeName=`string`,cc.prototype.ValueBufferType=Array,cc.prototype.DefaultInterpolation=Ot,cc.prototype.InterpolantFactoryMethodLinear=void 0,cc.prototype.InterpolantFactoryMethodSmooth=void 0;var lc=class extends nc{constructor(e,t,n,r){super(e,t,n,r)}};lc.prototype.ValueTypeName=`vector`;var uc={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(dc(e)||(this.files[e]=t))},get:function(e){if(this.enabled!==!1&&!dc(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function dc(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch{return!1}}var fc=new 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 e=e.normalize(`NFC`),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=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,ml).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)}},gl=new V,_l=new V,vl=new V,yl=new V,bl=new V,xl=new V,Sl=new V,Cl=class{constructor(e=new V,t=new V){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){gl.subVectors(e,this.start),_l.subVectors(this.end,this.start);let n=_l.dot(_l);if(n===0)return 0;let r=_l.dot(gl)/n;return t&&(r=_n(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=xl,n=Sl){let r=1e-8*1e-8,i,a,o=this.start,s=e.start,c=this.end,l=e.end;vl.subVectors(c,o),yl.subVectors(l,s),bl.subVectors(o,s);let u=vl.dot(vl),d=yl.dot(yl),f=yl.dot(bl);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=_n(a,0,1);else{let e=vl.dot(bl);if(d<=r)a=0,i=_n(-e/u,0,1);else{let t=vl.dot(yl),n=u*d-t*t;i=n===0?0:_n((t*f-e*d)/n,0,1),a=(t*i+f)/d,a<0?(a=0,i=_n(-e/u,0,1)):a>1&&(a=1,i=_n((t-e)/u,0,1))}}return t.copy(o).addScaledVector(vl,i),n.copy(s).addScaledVector(yl,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)}},wl=class{constructor(){this.type=`ShapePath`,this.color=new Ur,this.subPaths=[],this.currentPath=null,this.userData={}}moveTo(e,t){return this.currentPath=new Io,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(){function e(e,t){let n=!1,r=t.length;for(let i=0,a=r-1;ie.y!=o.y>e.y&&e.x<(o.x-r.x)*(e.y-r.y)/(o.y-r.y)+r.x&&(n=!n)}return n}function t(t,n){let r=n.getCenter(new B);if(e(r,t))return r;let i=r.y,a=[],o=t.length;for(let e=0;ei!=r.y>i){let e=n.x+(i-n.y)*(r.x-n.x)/(r.y-n.y);a.push(e)}}return a.length>1&&(a.sort((e,t)=>e-t),r.x=(a[0]+a[1])/2),r}let n=this.userData.style&&this.userData.style.fillRule||`nonzero`;n!==`nonzero`&&n!==`evenodd`&&(R(`Fill-rule "`+n+`" is not supported, falling back to "nonzero".`),n=`nonzero`);let r=n===`nonzero`?(e=>e!==0):(e=>(e&1)!=0),i=[];for(let e of this.subPaths){let n=e.getPoints();if(n.length<3)continue;let r=vs.area(n);if(r===0)continue;let a=new hl;for(let e=0;et.absArea-e.absArea);for(let t=0;t=0;r--){let t=i[r];if(t.boundingBox.containsBox(n.boundingBox)&&e(n.interiorPoint,t.points)){n.container=t.exclude?t.container:t,a=t.winding,n.winding+=a;break}}r(n.winding)===r(a)&&(n.exclude=!0)}for(let e of i)e.exclude||(e.role=e.container===null||e.container.role===`hole`?`outer`:`hole`);let a=[],o=new Map;for(let e of i){if(e.exclude||e.role!==`outer`)continue;let t=new Lo;t.curves=e.subPath.curves,a.push(t),o.set(e,t)}for(let e of i){if(e.exclude||e.role!==`hole`)continue;let t=o.get(e.container);if(!t)continue;let n=new Io;n.curves=e.subPath.curves,t.holes.push(n)}return a}},Tl=class extends dn{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){R(`Controls: connect() now requires an element.`);return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function El(e,t,n,r){let i=Dl(r);switch(n){case Ie:return e*t;case Ve:return e*t/i.components*i.byteLength;case L:return e*t/i.components*i.byteLength;case He:return e*t*2/i.components*i.byteLength;case Ue:return e*t*2/i.components*i.byteLength;case Le:return e*t*3/i.components*i.byteLength;case Re:return e*t*4/i.components*i.byteLength;case Ge:return e*t*4/i.components*i.byteLength;case Ke:case qe:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Je:case Ye:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Ze:case $e:return Math.max(e,16)*Math.max(t,8)/4;case Xe:case Qe:return Math.max(e,8)*Math.max(t,8)/2;case et:case tt:case rt:case it:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case nt:case at:case ot:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case st:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case ct:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case lt:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case ut:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case dt:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case ft:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case pt:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case mt:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case ht:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case gt:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case _t:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case vt:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case yt:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case bt:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case xt:case St:case Ct:return Math.ceil(e/4)*Math.ceil(t/4)*16;case wt:case Tt:return Math.ceil(e/4)*Math.ceil(t/4)*8;case Et:case Dt:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function Dl(e){switch(e){case Ce:case we:return{byteLength:1,components:1};case Ee:case Te:case Ae:return{byteLength:2,components:1};case je:case Me:return{byteLength:2,components:4};case Oe:case De:case ke:return{byteLength:4,components:1};case Pe:case Fe:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`185`}})),typeof window<`u`&&(window.__THREE__?R(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`185`);function Ol(){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 kl(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 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 ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,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; +#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 = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,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 = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,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 = transformNormalByInverseViewMatrix( 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 = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,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 = transformNormalByInverseViewMatrix( 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 + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,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 ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #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 = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,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 = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,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 + #include +}`,backgroundCube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +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 + #include +}`,cube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,cube_frag:`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,depth_vert:`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,depth_frag:`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #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 +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,distance_frag:`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,equirect_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,equirect_frag:`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,linedashed_vert:`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,linedashed_frag:`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,meshbasic_vert:`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,meshbasic_frag:`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,meshlambert_vert:`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshlambert_frag:`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshmatcap_vert:`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,meshmatcap_frag:`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,meshnormal_vert:`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,meshnormal_frag:`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshphong_frag:`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshphysical_vert:`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,meshphysical_frag:`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + 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 + #include + #include + #include + #include + #include +}`,meshtoon_vert:`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,meshtoon_frag:`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,points_vert:`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,points_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,shadow_vert:`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,shadow_frag:`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,sprite_vert:`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,sprite_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`},jl={common:{diffuse:{value:new Ur(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Hn},alphaMap:{value:null},alphaMapTransform:{value:new Hn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Hn}},envmap:{envMap:{value:null},envMapRotation:{value:new Hn},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Hn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Hn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Hn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Hn},normalScale:{value:new B(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Hn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Hn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Hn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Hn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ur(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 V},probesMax:{value:new V},probesResolution:{value:new V}},points:{diffuse:{value:new Ur(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Hn},alphaTest:{value:0},uvTransform:{value:new Hn}},sprite:{diffuse:{value:new Ur(16777215)},opacity:{value:1},center:{value:new B(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Hn},alphaMap:{value:null},alphaMapTransform:{value:new Hn},alphaTest:{value:0}}},Ml={basic:{uniforms:js([jl.common,jl.specularmap,jl.envmap,jl.aomap,jl.lightmap,jl.fog]),vertexShader:Al.meshbasic_vert,fragmentShader:Al.meshbasic_frag},lambert:{uniforms:js([jl.common,jl.specularmap,jl.envmap,jl.aomap,jl.lightmap,jl.emissivemap,jl.bumpmap,jl.normalmap,jl.displacementmap,jl.fog,jl.lights,{emissive:{value:new Ur(0)},envMapIntensity:{value:1}}]),vertexShader:Al.meshlambert_vert,fragmentShader:Al.meshlambert_frag},phong:{uniforms:js([jl.common,jl.specularmap,jl.envmap,jl.aomap,jl.lightmap,jl.emissivemap,jl.bumpmap,jl.normalmap,jl.displacementmap,jl.fog,jl.lights,{emissive:{value:new Ur(0)},specular:{value:new Ur(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Al.meshphong_vert,fragmentShader:Al.meshphong_frag},standard:{uniforms:js([jl.common,jl.envmap,jl.aomap,jl.lightmap,jl.emissivemap,jl.bumpmap,jl.normalmap,jl.displacementmap,jl.roughnessmap,jl.metalnessmap,jl.fog,jl.lights,{emissive:{value:new Ur(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Al.meshphysical_vert,fragmentShader:Al.meshphysical_frag},toon:{uniforms:js([jl.common,jl.aomap,jl.lightmap,jl.emissivemap,jl.bumpmap,jl.normalmap,jl.displacementmap,jl.gradientmap,jl.fog,jl.lights,{emissive:{value:new Ur(0)}}]),vertexShader:Al.meshtoon_vert,fragmentShader:Al.meshtoon_frag},matcap:{uniforms:js([jl.common,jl.bumpmap,jl.normalmap,jl.displacementmap,jl.fog,{matcap:{value:null}}]),vertexShader:Al.meshmatcap_vert,fragmentShader:Al.meshmatcap_frag},points:{uniforms:js([jl.points,jl.fog]),vertexShader:Al.points_vert,fragmentShader:Al.points_frag},dashed:{uniforms:js([jl.common,jl.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Al.linedashed_vert,fragmentShader:Al.linedashed_frag},depth:{uniforms:js([jl.common,jl.displacementmap]),vertexShader:Al.depth_vert,fragmentShader:Al.depth_frag},normal:{uniforms:js([jl.common,jl.bumpmap,jl.normalmap,jl.displacementmap,{opacity:{value:1}}]),vertexShader:Al.meshnormal_vert,fragmentShader:Al.meshnormal_frag},sprite:{uniforms:js([jl.sprite,jl.fog]),vertexShader:Al.sprite_vert,fragmentShader:Al.sprite_frag},background:{uniforms:{uvTransform:{value:new Hn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Al.background_vert,fragmentShader:Al.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Hn}},vertexShader:Al.backgroundCube_vert,fragmentShader:Al.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Al.cube_vert,fragmentShader:Al.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Al.equirect_vert,fragmentShader:Al.equirect_frag},distance:{uniforms:js([jl.common,jl.displacementmap,{referencePosition:{value:new V},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Al.distance_vert,fragmentShader:Al.distance_frag},shadow:{uniforms:js([jl.lights,jl.fog,{color:{value:new Ur(0)},opacity:{value:1}}]),vertexShader:Al.shadow_vert,fragmentShader:Al.shadow_frag}};Ml.physical={uniforms:js([Ml.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Hn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Hn},clearcoatNormalScale:{value:new B(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Hn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Hn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Hn},sheen:{value:0},sheenColor:{value:new Ur(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Hn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Hn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Hn},transmissionSamplerSize:{value:new B},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Hn},attenuationDistance:{value:0},attenuationColor:{value:new Ur(0)},specularColor:{value:new Ur(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Hn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Hn},anisotropyVector:{value:new B},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Hn}}]),vertexShader:Al.meshphysical_vert,fragmentShader:Al.meshphysical_frag};var Nl={r:0,b:0,g:0},Pl=new lr,Fl=new Hn;Fl.set(-1,0,0,0,1,0,0,0,1);function Il(e,t,n,r,i,a){let o=new Ur(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 _a(new ro(1,1,1),new Rs({name:`BackgroundCubeMaterial`,uniforms:As(Ml.backgroundCube.uniforms),vertexShader:Ml.backgroundCube.vertexShader,fragmentShader:Ml.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(Pl.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Fl),l.material.toneMapped=qn.getTransfer(i.colorSpace)!==zt,(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 _a(new ws(2,2),new Rs({name:`BackgroundMaterial`,uniforms:As(Ml.background.uniforms),vertexShader:Ml.background.vertexShader,fragmentShader:Ml.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=qn.getTransfer(i.colorSpace)!==zt,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(Nl,Ps(e)),n.buffers.color.setClear(Nl.r,Nl.g,Nl.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 Ll(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=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=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;e0&&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&&(R(`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&&R(`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 Bl(e){let t=this,n=null,r=0,i=!1,a=!1,o=new Ta,s=new Hn,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.length0&&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=au(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=iu(),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;e2?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=au()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=iu());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;tu(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Gl)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-Vl?n-d+Vl:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,tu(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,Gl),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,tu(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,Gl)}_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`&&z(`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*Ul-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):Ul;m>Ul&&R(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ul}`);let h=[],g=0;for(let e=0;e_-Vl?r-_+Vl:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Gl)}};function $l(e){let t=[],n=[],r=[],i=e,a=e-Vl+1+Hl.length;for(let o=0;oe-Vl?s=Hl[o-e+Vl-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 Wi;h.setAttribute(`position`,new Oi(f,3)),h.setAttribute(`uv`,new Oi(p,2)),h.setAttribute(`faceIndex`,new Oi(m,1)),r.push(new _a(h,null)),i>Vl&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function eu(e,t,n){let r=new or(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function tu(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function nu(e,t,n){return new Rs({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:Wl,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:ou(),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 + + #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 ru(e,t,n){let r=new Float32Array(Ul),i=new V(0,1,0);return new Rs({name:`SphericalGaussianBlur`,defines:{n:Ul,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:ou(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function iu(){return new Rs({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:ou(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function au(){return new Rs({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ou(),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 ou(){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 su=class extends or{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 $a(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 + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new ro(5,5,5),i=new Rs({name:`CubemapFromEquirect`,uniforms:As(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new _a(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=be),new Gc(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 cu(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 su(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 Ql(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 Ql(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 lu(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&&sn(`WebGLRenderer: `+e+` extension not supported.`),t}}}function uu(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=65535?Ai:ki)(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.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new sr(h,p,m,u);g.type=ke,g.needsUpdate=!0;let _=f*4;for(let t=0;t + #include + + 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}),u=new _a(c,l),d=new Fc(-1,1,1,-1,0,1),f=null,p=null,m=!1,h,g=null,_=[],v=!1;this.setSize=function(e,t){o.setSize(e,t),s.setSize(e,t);for(let n=0;n<_.length;n++){let r=_[n];r.setSize&&r.setSize(e,t)}},this.setEffects=function(e){_=e,v=_.length>0&&_[0].isRenderPass===!0;let t=o.width,n=o.height;for(let e=0;e<_.length;e++){let r=_[e];r.setSize&&r.setSize(t,n)}},this.begin=function(e,t){if(m||e.toneMapping===0&&_.length===0)return!1;if(g=t,t!==null){let e=t.width,n=t.height;(o.width!==e||o.height!==n)&&this.setSize(e,n)}return v===!1&&e.setRenderTarget(o),h=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(e,t){e.toneMapping=h,m=!0;let n=o,r=s;for(let i=0;i<_.length;i++){let a=_[i];if(a.enabled!==!1&&(a.render(e,r,n,t),a.needsSwap!==!1)){let e=n;n=r,r=e}}if(f!==e.outputColorSpace||p!==e.toneMapping){f=e.outputColorSpace,p=e.toneMapping,l.defines={},qn.getTransfer(f)===`srgb`&&(l.defines.SRGB_TRANSFER=``);let t=hu[p];t&&(l.defines[t]=``),l.needsUpdate=!0}l.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(g),e.render(u,d),g=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.depthTexture&&o.depthTexture.dispose(),o.dispose(),s.dispose(),c.dispose(),l.dispose()}}var _u=new rr,vu=new eo(1,1),yu=new sr,bu=new cr,xu=new $a,Su=[],Cu=[],wu=new Float32Array(16),Tu=new Float32Array(9),Eu=new Float32Array(4);function Du(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=Su[i];if(a===void 0&&(a=new Float32Array(i),Su[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 Ou(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(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 wd(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var Td=37297,Ed=0;function Dd(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`:` `} ${i}: ${n[e]}`)}return r.join(` +`)}var Od=new Hn;function kd(e){qn._getMatrix(Od,qn.workingColorSpace,e);let t=`mat3( ${Od.elements.map(e=>e.toFixed(4))} )`;switch(qn.getTransfer(e)){case Rt:return[t,`LinearTransferOETF`];case zt:return[t,`sRGBTransferOETF`];default:return R(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function Ad(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+` + +`+Dd(e.getShaderSource(t),r)}else return i}function jd(e,t){let n=kd(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` +`)}var Md={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function Nd(e,t){let n=Md[t];return n===void 0?(R(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var Pd=new V;function Fd(){return qn.getLuminanceCoefficients(Pd),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${Pd.x.toFixed(4)}, ${Pd.y.toFixed(4)}, ${Pd.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` +`)}function Id(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(zd).join(` +`)}function Ld(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` +`)}function Rd(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Ud(e){return e.replace(Hd,Gd)}var Wd=new Map;function Gd(e,t){let n=Al[t];if(n===void 0){let e=Wd.get(t);if(e!==void 0)n=Al[e],R(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`THREE.WebGLProgram: Can not resolve #include <`+t+`>`)}return Ud(n)}var Kd=/#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 qd(e){return e.replace(Kd,Jd)}function Jd(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` +`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(zd).join(` +`),_.length>0&&(_+=` +`)):(g=[Yd(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(zd).join(` +`),_=[Yd(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?``:Al.tonemapping_pars_fragment,n.toneMapping===0?``:Nd(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,Al.colorspace_pars_fragment,jd(`linearToOutputTexel`,n.outputColorSpace),Fd(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(zd).join(` +`)),o=Ud(o),o=Bd(o,n),o=Vd(o,n),s=Ud(s),s=Bd(s,n),s=Vd(s,n),o=qd(o),s=qd(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=wd(i,i.VERTEX_SHADER,y),S=wd(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.hasPositionAttribute===!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=Ad(i,x,`vertex`),n=Ad(i,S,`fragment`);z(`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):R(`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 Cd(i,h),T=Rd(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,Td)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Ed++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var sf=0,cf=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.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}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}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 lf(e),t.set(e,n)),n}},lf=class{constructor(e){this.id=sf++,this.code=e,this.usedTimes=0}};function uf(e){return e===1030||e===37490||e===36285}function df(e,t,n,r,i,a){let o=new yr,s=new cf,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&&R(`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=Ml[C];D=e.vertexShader,O=e.fragmentShader}else{D=i.vertexShader,O=i.fragmentShader;let e=s.getVertexShaderStage(i),t=s.getFragmentShaderStage(i);s.update(i,e,t),k=e.id,A=t.id}let j=e.getRenderTarget(),M=e.state.buffers.depth.getReversed(),N=h.isInstancedMesh===!0,P=h.isBatchedMesh===!0,ee=!!i.map,F=!!i.matcap,te=!!x,ne=!!i.aoMap,re=!!i.lightMap,ie=!!i.bumpMap&&i.wireframe===!1,ae=!!i.normalMap,oe=!!i.displacementMap,se=!!i.emissiveMap,ce=!!i.metalnessMap,le=!!i.roughnessMap,ue=i.anisotropy>0,de=i.clearcoat>0,fe=i.dispersion>0,pe=i.iridescence>0,me=i.sheen>0,he=i.transmission>0,ge=ue&&!!i.anisotropyMap,_e=de&&!!i.clearcoatMap,ve=de&&!!i.clearcoatNormalMap,ye=de&&!!i.clearcoatRoughnessMap,be=pe&&!!i.iridescenceMap,xe=pe&&!!i.iridescenceThicknessMap,Se=me&&!!i.sheenColorMap,I=me&&!!i.sheenRoughnessMap,Ce=!!i.specularMap,we=!!i.specularColorMap,Te=!!i.specularIntensityMap,Ee=he&&!!i.transmissionMap,De=he&&!!i.thicknessMap,Oe=!!i.gradientMap,ke=!!i.alphaMap,Ae=i.alphaTest>0,je=!!i.alphaHash,Me=!!i.extensions,Ne=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(Ne=e.toneMapping);let Pe={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:qn.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:ee,matcap:F,envMap:te,envMapMode:te&&x.mapping,envMapCubeUVHeight:S,aoMap:ne,lightMap:re,bumpMap:ie,normalMap:ae,displacementMap:oe,emissiveMap:se,normalMapObjectSpace:ae&&i.normalMapType===1,normalMapTangentSpace:ae&&i.normalMapType===0,packedNormalMap:ae&&i.normalMapType===0&&uf(i.normalMap.format),metalnessMap:ce,roughnessMap:le,anisotropy:ue,anisotropyMap:ge,clearcoat:de,clearcoatMap:_e,clearcoatNormalMap:ve,clearcoatRoughnessMap:ye,dispersion:fe,iridescence:pe,iridescenceMap:be,iridescenceThicknessMap:xe,sheen:me,sheenColorMap:Se,sheenRoughnessMap:I,specularMap:Ce,specularColorMap:we,specularIntensityMap:Te,transmission:he,transmissionMap:Ee,thicknessMap:De,gradientMap:Oe,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:ke,alphaTest:Ae,alphaHash:je,combine:i.combine,mapUv:ee&&m(i.map.channel),aoMapUv:ne&&m(i.aoMap.channel),lightMapUv:re&&m(i.lightMap.channel),bumpMapUv:ie&&m(i.bumpMap.channel),normalMapUv:ae&&m(i.normalMap.channel),displacementMapUv:oe&&m(i.displacementMap.channel),emissiveMapUv:se&&m(i.emissiveMap.channel),metalnessMapUv:ce&&m(i.metalnessMap.channel),roughnessMapUv:le&&m(i.roughnessMap.channel),anisotropyMapUv:ge&&m(i.anisotropyMap.channel),clearcoatMapUv:_e&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:ve&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ye&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:be&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:xe&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:Se&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:I&&m(i.sheenRoughnessMap.channel),specularMapUv:Ce&&m(i.specularMap.channel),specularColorMapUv:we&&m(i.specularColorMap.channel),specularIntensityMapUv:Te&&m(i.specularIntensityMap.channel),transmissionMapUv:Ee&&m(i.transmissionMap.channel),thicknessMapUv:De&&m(i.thicknessMap.channel),alphaMapUv:ke&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(ae||ue),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&&(ee||ke),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&ae===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:M,skinning:h.isSkinnedMesh===!0,hasPositionAttribute:v.attributes.position!==void 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:Ne,decodeVideoTexture:ee&&i.map.isVideoTexture===!0&&qn.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:se&&i.emissiveMap.isVideoTexture===!0&&qn.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:Me&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(Me&&i.extensions.multiDraw===!0||P)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Pe.vertexUv1s=c.has(1),Pe.vertexUv2s=c.has(2),Pe.vertexUv3s=c.has(3),c.clear(),Pe}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),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=Ml[t];n=Fs.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new of(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 ff(){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 pf(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 mf(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 hf(){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,a){n.length>1&&n.sort(e||pf),r.length>1&&r.sort(t||mf),i.length>1&&i.sort(t||mf),a&&(n.reverse(),r.reverse(),i.reverse())}function d(){for(let n=t,r=e.length;n=r.length?(i=new hf,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function _f(){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 V,color:new Ur};break;case`SpotLight`:n={position:new V,direction:new V,color:new Ur,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new V,color:new Ur,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new V,skyColor:new Ur,groundColor:new Ur};break;case`RectAreaLight`:n={color:new Ur,position:new V,halfWidth:new V,halfHeight:new V};break}return e[t.id]=n,n}}}function vf(){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 B};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var yf=0;function bf(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function xf(e){let t=new _f,n=vf(),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 V);let i=new V,a=new lr,o=new lr;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(bf);for(let e=0,y=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=jl.LTC_FLOAT_1,r.rectAreaLTC2=jl.LTC_FLOAT_2):(r.rectAreaLTC1=jl.LTC_HALF_1,r.rectAreaLTC2=jl.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=yf++)}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=i.length?(a=new Sf(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var wf=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Tf=`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 ); +}`,Ef=[new V(1,0,0),new V(-1,0,0),new V(0,1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1)],Df=[new V(0,-1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1),new V(0,-1,0),new V(0,-1,0)],Of=new lr,kf=new V,Af=new V;function jf(e,t,n){let r=new ka,i=new B,a=new B,o=new ir,s=new Ks,c=new qs,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new Rs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:wf,fragmentShader:Tf}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Wi;m.setAttribute(`position`,new Oi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new _a(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&&(R(`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;cu||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){R(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new or(i.x,i.y,{format:He,type:Ae,minFilter:be,magFilter:be,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new eo(i.x,i.y,ke),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=ze,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=_e,d.map.depthTexture.magFilter=_e}else l.isPointLight?(d.map=new su(i.x),d.map.depthTexture=new to(i.x,Oe)):(d.map=new or(i.x,i.y),d.map.depthTexture=new eo(i.x,i.y,Oe)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=ze,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=be,d.map.depthTexture.magFilter=be):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=_e,d.map.depthTexture.magFilter=_e);d.camera.updateProjectionMatrix()}let g=d.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t0||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=2):(P=parseFloat(/^WebGL (\d)/.exec(ee)[1]),N=P>=1);let F=null,te={},ne=e.getParameter(e.SCISSOR_BOX),re=e.getParameter(e.VIEWPORT),ie=new ir().fromArray(ne),ae=new ir().fromArray(re);function oe(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`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new B,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):tn(`canvas`)}function g(e,t,n){let r=1,i=Ne(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),R(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&R(`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];R(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||R(`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?Rt:qn.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,R(`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),T(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function w(e){let t=e.target;t.removeEventListener(`dispose`,w),D(t)}function T(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&&E(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function E(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 D(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=i.maxTextures&&R(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),O+=1,e}function N(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 P(t,i){let a=r.get(t);if(t.isVideoTexture&&je(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)R(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)R(`WebGLRenderer: Texture marked for update but image is incomplete`);else{le(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 ee(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){le(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 F(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){le(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function te(t,i){let a=r.get(t);if(t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version){ue(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let ne={[me]:e.REPEAT,[he]:e.CLAMP_TO_EDGE,[ge]:e.MIRRORED_REPEAT},re={[_e]:e.NEAREST,[ve]:e.NEAREST_MIPMAP_NEAREST,[ye]:e.NEAREST_MIPMAP_LINEAR,[be]:e.LINEAR,[xe]:e.LINEAR_MIPMAP_NEAREST,[Se]:e.LINEAR_MIPMAP_LINEAR},ie={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 ae(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)&&R(`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,ne[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,ne[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,ne[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,re[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,re[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,ie[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 oe(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=N(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&&E(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function se(e,t,n){return Math.floor(Math.floor(e/n)/t)}function ce(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;e0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let t=El(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 R(`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;t0){let i=El(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>=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}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,r=e.RGBA,i=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,r,i,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=Ne(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t0&&D++;let t=Ne(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>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),Ae(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,ke(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 fe(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;Ae(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,ke(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,ke(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{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++)pe(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?pe(i.__webglFramebuffer[0],t,0):pe(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(),fe(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(),fe(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 Ce(t,n,i){let a=r.get(t);n!==void 0&&de(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&I(t)}function we(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,w);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;n0){s.__webglFramebuffer=[];for(let t=0;t0&&Ae(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(Ae(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;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function je(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function Me(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(qn.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&R(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):z(`WebGLTextures: Unsupported texture color space:`,n)),t}function Ne(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=M,this.resetTextureUnits=k,this.getTextureUnits=A,this.setTextureUnits=j,this.setTexture2D=P,this.setTexture2DArray=ee,this.setTexture3D=F,this.setTextureCube=te,this.rebindTextures=Ce,this.setupRenderTarget=we,this.updateRenderTargetMipmap=Te,this.updateMultisampleRenderTarget=Oe,this.setupDepthRenderbuffer=I,this.setupFrameBufferTexture=de,this.useMultisampledRTT=Ae,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function Pf(e,t){function n(n,r=``){let i,a=qn.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 Ff=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,If=` +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; + + } + +}`,Lf=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new no(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 Rs({vertexShader:Ff,fragmentShader:If,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new _a(new ws(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Rf=class extends dn{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 Lf,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new B,C=null,w=new Ac;w.viewport=new ir;let T=new Ac;T.viewport=new ir;let E=[w,T],D=new Kc,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 Rr,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Rr,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Rr,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=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=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 V,P=new V;function ee(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 F(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;F(D,i);for(let e=0;e0&&(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(zf.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(Bf),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 Hf(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&&(g(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,v));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;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function _(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?R(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):R(`WebGLRenderer: Unsupported uniform value type.`,e),t}function v(t){let n=t.target;n.removeEventListener(`dispose`,v);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function y(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:y}}var Uf=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]),Wf=null;function Gf(){return Wf===null&&(Wf=new ba(Uf,16,16,He,Ae),Wf.name=`DFG_LUT`,Wf.minFilter=be,Wf.magFilter=be,Wf.wrapS=he,Wf.wrapT=he,Wf.generateMipmaps=!1,Wf.needsUpdate=!0),Wf}var Kf=class{constructor(e={}){let{canvas:t=nn(),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=Ce}=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([Ge,Ue,L]),g=new Set([Ce,Oe,Ee,Ne,je,Me]),_=new Uint32Array(4),v=new Int32Array(4),y=new V,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,O=null,k=null,A=null;this._outputColorSpace=It;let j=0,M=0,N=null,P=-1,ee=null,F=new ir,te=new ir,ne=null,re=new Ur(0),ie=0,ae=t.width,oe=t.height,se=1,ce=null,le=null,ue=new ir(0,0,ae,oe),de=new ir(0,0,ae,oe),fe=!1,pe=new ka,me=!1,he=!1,ge=new lr,_e=new V,ve=new ir,ye={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},be=!1;function xe(){return N===null?se:1}let I=n;function we(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 r185`),t.addEventListener(`webglcontextlost`,it,!1),t.addEventListener(`webglcontextrestored`,at,!1),t.addEventListener(`webglcontextcreationerror`,ot,!1),I===null){let t=`webgl2`;if(I=we(t,e),I===null)throw we(t)?Error(`THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.`):Error(`THREE.WebGLRenderer: Error creating WebGL context.`)}}catch(e){throw z(`WebGLRenderer: `+e.message),e}let Te,De,ke,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,We,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt;function nt(){Te=new lu(I),Te.init(),$e=new Pf(I,Te),De=new zl(I,Te,e,$e),ke=new Mf(I,Te),De.reversedDepthBuffer&&d&&ke.buffers.depth.setReversed(!0),O=I.createFramebuffer(),k=I.createFramebuffer(),A=I.createFramebuffer(),Pe=new fu(I),Fe=new ff,Ie=new Nf(I,Te,ke,Fe,De,$e,Pe),Le=new cu(T),Re=new kl(I),et=new Ll(I,Re),ze=new uu(I,Re,Pe,et),Be=new mu(I,ze,Re,et,Pe),Xe=new pu(I,De,Ie),qe=new Bl(Fe),Ve=new df(T,Le,Te,De,et,qe),He=new Vf(T,Fe),We=new gf,Ke=new Cf(Te),Ye=new Il(T,Le,ke,Be,p,s),Je=new jf(T,Be,De),tt=new Hf(I,Pe,De,ke),Ze=new Rl(I,Te,Pe),Qe=new du(I,Te,Pe),Pe.programs=Ve.programs,T.capabilities=De,T.extensions=Te,T.properties=Fe,T.renderLists=We,T.shadowMap=Je,T.state=ke,T.info=Pe}nt(),m!==1009&&(w=new gu(m,t.width,t.height,o,r,i));let rt=new Rf(T,I);this.xr=rt,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){let e=Te.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=Te.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(e){e!==void 0&&(se=e,this.setSize(ae,oe,!1))},this.getSize=function(e){return e.set(ae,oe)},this.setSize=function(e,n,r=!0){if(rt.isPresenting){R(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ae=e,oe=n,t.width=Math.floor(e*se),t.height=Math.floor(n*se),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(ae*se,oe*se).floor()},this.setDrawingBufferSize=function(e,n,r){ae=e,oe=n,se=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){z(`WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t{function n(){if(r.forEach(function(e){Fe.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}Te.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let dt=null;function ft(e){dt&&dt(e)}function pt(){ht.stop()}function mt(){ht.start()}let ht=new Ol;ht.setAnimationLoop(ft),typeof self<`u`&&ht.setContext(self),this.setAnimationLoop=function(e){dt=e,rt.setAnimationLoop(e),e===null?ht.stop():ht.start()},rt.addEventListener(`sessionstart`,pt),rt.addEventListener(`sessionend`,mt),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){z(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=rt.enabled===!0&&rt.isPresenting===!0,r=w!==null&&(N===null||n)&&w.begin(T,N);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),rt.enabled===!0&&rt.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(rt.cameraAutoUpdate===!0&&rt.updateCamera(t),t=rt.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,N),x=Ke.get(e,C.length),x.init(t),x.state.textureUnits=Ie.getTextureUnits(),C.push(x),ge.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),pe.setFromProjectionMatrix(ge,Yt,t.reversedDepth),he=this.localClippingEnabled,me=qe.init(this.clippingPlanes,he),b=We.get(e,S.length),b.init(),S.push(b),rt.enabled===!0&&rt.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&>(e,t,-1/0,T.sortObjects)}gt(e,t,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(ce,le,t.reversedDepth),be=rt.enabled===!1||rt.isPresenting===!1||rt.hasDepthSensing()===!1,be&&Ye.addToRenderList(b,e),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),me===!0&&qe.beginShadows();let i=x.state.shadowsArray;if(Je.render(i,e,t),me===!0&&qe.endShadows(),(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;t0&&vt(n,r,e,t),be&&Ye.render(e),_t(b,e,t)}N!==null&&M===0&&(Ie.updateMultisampleRenderTarget(N),Ie.updateRenderTargetMipmap(N)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),et.resetDefaultState(),P=-1,ee=null,C.pop(),C.length>0?(x=C[C.length-1],Ie.setTextureUnits(x.state.textureUnits),me===!0&&qe.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function gt(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||pe.intersectsSprite(e)){r&&ve.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ge);let t=Be.update(e),i=e.material;i.visible&&b.push(e,t,i,n,ve.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||pe.intersectsObject(e))){let t=Be.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),ve.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ve.copy(e.boundingSphere.center)),ve.applyMatrix4(e.matrixWorld).applyMatrix4(ge)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&yt(i,t,n),a.length>0&&yt(a,t,n),o.length>0&&yt(o,t,n),ke.buffers.depth.setTest(!0),ke.buffers.depth.setMask(!0),ke.buffers.color.setMask(!0),ke.setPolygonOffset(!1)}function vt(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=Te.has(`EXT_color_buffer_half_float`)||Te.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new or(1,1,{generateMipmaps:!0,type:e?Ae:Ce,minFilter:Se,samples:Math.max(4,De.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qn.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||F;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(re),ie=T.getClearAlpha(),ie<1&&T.setClearColor(16777215,.5),T.clear(),be&&Ye.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),me===!0&&qe.setGlobalState(T.clippingPlanes,r),yt(e,n,r),Ie.updateMultisampleRenderTarget(a),Ie.updateRenderTargetMipmap(a),Te.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function St(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Cd.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function Ct(e,t){let n=Fe.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 wt(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;t0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=Fe.get(r),y=x.state.lights;if(me===!0&&(he===!0||e!==ee)){let t=e===ee&&r.id===P;qe.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!==qe.numPlanes||v.numIntersection!==qe.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=xt(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(ke.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==P&&(P=r.id,w=!0),v.needsLights){let e=wt(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||ee!==e){ke.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(I,`projectionMatrix`,e.projectionMatrix),O.setValue(I,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(I,_e.setFromMatrixPosition(e.matrixWorld)),De.logarithmicDepthBuffer&&O.setValue(I,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(I,`isOrthographic`,e.isOrthographicCamera===!0),ee!==e&&(ee=e,w=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&O.setValue(I,`directionalShadowMap`,y.state.directionalShadowMap,Ie),y.state.spotShadowMap.length>0&&O.setValue(I,`spotShadowMap`,y.state.spotShadowMap,Ie),y.state.pointShadowMap.length>0&&O.setValue(I,`pointShadowMap`,y.state.pointShadowMap,Ie)),i.isSkinnedMesh){O.setOptional(I,i,`bindMatrix`),O.setOptional(I,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(I,`boneTexture`,e.boneTexture,Ie))}i.isBatchedMesh&&(O.setOptional(I,i,`batchingTexture`),O.setValue(I,`batchingTexture`,i._matricesTexture,Ie),O.setOptional(I,i,`batchingIdTexture`),O.setValue(I,`batchingIdTexture`,i._indirectTexture,Ie),O.setOptional(I,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(I,`batchingColorTexture`,i._colorsTexture,Ie));let A=n.morphAttributes;if((A.position!==void 0||A.normal!==void 0||A.color!==void 0)&&Xe.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(I,`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=Gf()),w){if(O.setValue(I,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&Et(k,E),a&&r.fog===!0&&He.refreshFogUniforms(k,a),He.refreshMaterialUniforms(k,r,se,oe,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)}Cd.upload(I,St(v),k,Ie)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Cd.upload(I,St(v),k,Ie),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(I,`center`,i.center),O.setValue(I,`modelViewMatrix`,i.modelViewMatrix),O.setValue(I,`normalMatrix`,i.normalMatrix),O.setValue(I,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&Ie.useMultisampledRTT(e)===!1?Fe.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,F.copy(e.viewport),te.copy(e.scissor),ne=e.scissorTest}else F.copy(ue).multiplyScalar(se).floor(),te.copy(de).multiplyScalar(se).floor(),ne=fe;if(n!==0&&(r=O),ke.bindFramebuffer(I.FRAMEBUFFER,r)&&ke.drawBuffers(e,r),ke.viewport(F),ke.scissor(te),ke.setScissorTest(ne),i){let r=Fe.get(e.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&I.readBuffer(I.COLOR_ATTACHMENT0+s),!De.textureFormatReadable(c)){z(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!De.textureTypeReadable(l)){z(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&I.readPixels(t,n,r,i,$e.convert(c),$e.convert(l),a)}finally{let e=N===null?null:Fe.get(N).__webglFramebuffer;ke.bindFramebuffer(I.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=Fe.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){ke.bindFramebuffer(I.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+s),!De.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!De.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,d),I.bufferData(I.PIXEL_PACK_BUFFER,a.byteLength,I.STREAM_READ),I.readPixels(t,n,r,i,$e.convert(l),$e.convert(u),0);let f=N===null?null:Fe.get(N).__webglFramebuffer;ke.bindFramebuffer(I.FRAMEBUFFER,f);let p=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await ln(I,p,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,d),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,a),I.deleteBuffer(d),I.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;Ie.setTexture2D(e,0),I.copyTexSubImage2D(I.TEXTURE_2D,n,0,0,o,s,i,a),ke.unbindTexture()},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=$e.convert(t.format),_=$e.convert(t.type),v;t.isData3DTexture?(Ie.setTexture3D(t,0),v=I.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Ie.setTexture2DArray(t,0),v=I.TEXTURE_2D_ARRAY):(Ie.setTexture2D(t,0),v=I.TEXTURE_2D),ke.activeTexture(I.TEXTURE0),ke.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,t.flipY),ke.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),ke.pixelStorei(I.UNPACK_ALIGNMENT,t.unpackAlignment);let y=ke.getParameter(I.UNPACK_ROW_LENGTH),b=ke.getParameter(I.UNPACK_IMAGE_HEIGHT),x=ke.getParameter(I.UNPACK_SKIP_PIXELS),S=ke.getParameter(I.UNPACK_SKIP_ROWS),C=ke.getParameter(I.UNPACK_SKIP_IMAGES);ke.pixelStorei(I.UNPACK_ROW_LENGTH,h.width),ke.pixelStorei(I.UNPACK_IMAGE_HEIGHT,h.height),ke.pixelStorei(I.UNPACK_SKIP_PIXELS,l),ke.pixelStorei(I.UNPACK_SKIP_ROWS,u),ke.pixelStorei(I.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=Fe.get(e),r=Fe.get(t),h=Fe.get(n.__renderTarget),g=Fe.get(r.__renderTarget);ke.bindFramebuffer(I.READ_FRAMEBUFFER,h.__webglFramebuffer),ke.bindFramebuffer(I.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n=-1&&Jf.z<=1&&e.layers.test(r.layers)===!0,l=e.element;l.style.display=c===!0?``:`none`,c===!0&&(e.onBeforeRender(t,n,r),l.style.transform=`translate(`+-100*e.center.x+`%,`+-100*e.center.y+`%)translate(`+(Jf.x*i+i)+`px,`+(-Jf.y*a+a)+`px)`,l.parentNode!==s&&s.appendChild(l),e.onAfterRender(t,n,r));let d={distanceToCameraSquared:u(r,e)};o.objects.set(e,d)}for(let t=0,i=e.children.length;t=t||n<0||d&&r>=a}function _(){var e=ip();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(ip())}function x(){var e=ip(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}function Pp(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1e4?1e4:e,{In:function(t){return t**+e},Out:function(t){return 1-(1-t)**e},InOut:function(t){return t<.5?(t*2)**e/2:(1-(2-t*2)**e)/2+.5}}}}),Gp=function(){return performance.now()},Kp=function(){function e(){var e=[...arguments];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(){for(var e,t=[],n=0;n0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?a(e[n],e[n-1],n-r):a(e[i],e[i+1>n?n:i+1],r-i)},Bezier:function(e,t){for(var n=0,r=e.length-1,i=Math.pow,a=qp.Utils.Bernstein,o=0;o<=r;o++)n+=i(1-t,r-o)*i(t,o)*e[o]*a(r,o);return n},CatmullRom:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=qp.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(i=Math.floor(r=n*(1+t))),a(e[(i-1+n)%n],e[i],e[(i+1)%n],e[(i+2)%n],r-i)):t<0?e[0]-(a(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[n]-(a(e[n],e[n],e[n-1],e[n-1],r-n)-e[n]):a(e[i?i-1:0],e[i],e[n1;r--)n*=r;return e[t]=n,n}})(),CatmullRom:function(e,t,n,r,i){var a=(n-e)*.5,o=(r-t)*.5,s=i*i,c=i*s;return(2*t-2*n+a+o)*c+(-3*t+3*n-2*a-o)*s+a*i+t}}},Jp=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),Yp=new Kp,Xp=function(){function e(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Wp.Linear.None,this._interpolationFunction=qp.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Jp.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t==`object`?(this._group=t,t.add(this)):t===!0&&(this._group=Yp,Yp.add(this))}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.getDuration=function(){return this._duration},e.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw Error(`Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.`);return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},e.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},e.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},e.prototype.start=function(e,t){if(e===void 0&&(e=Gp()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed)for(var n in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var i in this._valuesEnd)r[i]=this._valuesEnd[i];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},e.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},e.prototype._setupProperties=function(e,t,n,r,i){for(var a in n){var o=e[a],s=Array.isArray(o),c=s?`array`:typeof o,l=!s&&Array.isArray(n[a]);if(!(c===`undefined`||c===`function`)){if(l){var u=n[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;fs)return 1;var e=a-Math.trunc(a/o)*o,t=Math.min(e/r._duration,1);return t===0&&a===r._duration?1:t}(),l=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),this._duration===0||a>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);for(i in isFinite(this._repeat)&&(this._repeat-=u),this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[i]==`string`&&(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,f=this._chainedTweens.length;d=(m=(c+d)/2))?c=m:d=m,(x=n>=(h=(l+f)/2))?l=h:f=h,(S=r>=(g=(u+p)/2))?u=g:p=g,a=o,!(o=o[C=S<<2|x<<1|b]))return a[C]=s,e;if(_=+e._x.call(null,o.data),v=+e._y.call(null,o.data),y=+e._z.call(null,o.data),t===_&&n===v&&r===y)return s.next=o,a?a[C]=s:e._root=s,e;do a=a?a[C]=Array(8):e._root=Array(8),(b=t>=(m=(c+d)/2))?c=m:d=m,(x=n>=(h=(l+f)/2))?l=h:f=h,(S=r>=(g=(u+p)/2))?u=g:p=g;while((C=S<<2|x<<1|b)==(w=(y>=g)<<2|(v>=h)<<1|_>=m));return a[w]=o,a[C]=s,e}function em(e){Array.isArray(e)||(e=Array.from(e));let t=e.length,n=new Float64Array(t),r=new Float64Array(t),i=new Float64Array(t),a=1/0,o=1/0,s=1/0,c=-1/0,l=-1/0,u=-1/0;for(let d=0,f,p,m,h;dc&&(c=p),ml&&(l=m),hu&&(u=h));if(a>c||o>l||s>u)return this;this.cover(a,o,s).cover(c,l,u);for(let a=0;ae||e>=o||i>t||t>=s||a>n||n>=c;)switch(f=(nm||(l=y.y0)>h||(u=y.z0)>g||(d=y.x1)=C)<<2|(t>=S)<<1|e>=x)&&(y=_[_.length-1],_[_.length-1]=_[_.length-1-b],_[_.length-1-b]=y)}else{var w=e-+this._x.call(null,v.data),T=t-+this._y.call(null,v.data),E=n-+this._z.call(null,v.data),D=w*w+T*T+E*E;if(DMath.sqrt((e-r)**2+(t-i)**2+(n-a)**2);function sm(e,t,n,r){let i=[],a=e-r,o=t-r,s=n-r,c=e+r,l=t+r,u=n+r;return this.visit((d,f,p,m,h,g,_)=>{if(!d.length)do{let a=d.data;om(e,t,n,this._x(a),this._y(a),this._z(a))<=r&&i.push(a)}while(d=d.next);return f>c||p>l||m>u||h=(h=(o+l)/2))?o=h:l=h,(y=p>=(g=(s+u)/2))?s=g:u=g,(b=m>=(_=(c+d)/2))?c=_:d=_,t=n,!(n=n[x=b<<2|y<<1|v]))return this;if(!n.length)break;(t[x+1&7]||t[x+2&7]||t[x+3&7]||t[x+4&7]||t[x+5&7]||t[x+6&7]||t[x+7&7])&&(r=t,S=x)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[x]=a:delete t[x],(n=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&n===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[S]=n:this._root=n),this):(this._root=a,this)}function lm(e){for(var t=0,n=e.length;tt?1:e>=t?0:NaN}function tee(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function wm(e){let t,n,r;e.length===2?(t=e===Cm||e===tee?e:Tm,n=e,r=e):(t=Cm,n=(t,n)=>Cm(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i>>1;n(e[t],r)<0?i=t+1:a=t}while(i>>1;n(e[t],r)<=0?i=t+1:a=t}while(in&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function Tm(){return 0}function Em(e){return e===null?NaN:+e}var Dm=wm(Cm),Om=Dm.right;Dm.left,wm(Em).center;function km(e,t){let n,r;if(t===void 0)for(let t of e)t!=null&&(n===void 0?t>=t&&(n=r=t):(n>t&&(n=t),r=a&&(n=r=a):(n>a&&(n=a),r0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,i=r-(a-n),!i););t>0&&(i<0&&e[t-1]<0||i>0&&e[t-1]>0)&&(r=i*2,n=a+r,r==n-a&&(a=n))}return a}},jm=Math.sqrt(50),Mm=Math.sqrt(10),Nm=Math.sqrt(2);function Pm(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=jm?10:a>=Mm?5:a>=Nm?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/lt&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*lt&&--c),c0))return[];if(e===t)return[e];let r=t=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n=i)&&(n=i)}return n}function zm(e,t){let n=0,r=0;if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(++n,r+=t);else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(a=+a)>=a&&(++n,r+=a)}if(n)return r/n}function*Bm(e){for(let t of e)yield*t}function Vm(e){return Array.from(Bm(e))}function Hm(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ph(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ph(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=eh.exec(e))?new gh(t[1],t[2],t[3],1):(t=th.exec(e))?new gh(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=nh.exec(e))?ph(t[1],t[2],t[3],t[4]):(t=rh.exec(e))?ph(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ih.exec(e))?Ch(t[1],t[2]/100,t[3]/100,1):(t=ah.exec(e))?Ch(t[1],t[2]/100,t[3]/100,t[4]):oh.hasOwnProperty(e)?fh(oh[e]):e===`transparent`?new gh(NaN,NaN,NaN,0):null}function fh(e){return new gh(e>>16&255,e>>8&255,e&255,1)}function ph(e,t,n,r){return r<=0&&(e=t=n=NaN),new gh(e,t,n,r)}function mh(e){return e instanceof qm||(e=dh(e)),e?(e=e.rgb(),new gh(e.r,e.g,e.b,e.opacity)):new gh}function hh(e,t,n,r){return arguments.length===1?mh(e):new gh(e,t,n,r??1)}function gh(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Gm(gh,hh,Km(qm,{brighter(e){return e=e==null?Ym:Ym**+e,new gh(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Jm:Jm**+e,new gh(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new gh(xh(this.r),xh(this.g),xh(this.b),bh(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:_h,formatHex:_h,formatHex8:vh,formatRgb:yh,toString:yh}));function _h(){return`#${Sh(this.r)}${Sh(this.g)}${Sh(this.b)}`}function vh(){return`#${Sh(this.r)}${Sh(this.g)}${Sh(this.b)}${Sh((isNaN(this.opacity)?1:this.opacity)*255)}`}function yh(){let e=bh(this.opacity);return`${e===1?`rgb(`:`rgba(`}${xh(this.r)}, ${xh(this.g)}, ${xh(this.b)}${e===1?`)`:`, ${e})`}`}function bh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function xh(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Sh(e){return e=xh(e),(e<16?`0`:``)+e.toString(16)}function Ch(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Eh(e,t,n,r)}function wh(e){if(e instanceof Eh)return new Eh(e.h,e.s,e.l,e.opacity);if(e instanceof qm||(e=dh(e)),!e)return new Eh;if(e instanceof Eh)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new Eh(o,s,c,e.opacity)}function Th(e,t,n,r){return arguments.length===1?wh(e):new Eh(e,t,n,r??1)}function Eh(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Gm(Eh,Th,Km(qm,{brighter(e){return e=e==null?Ym:Ym**+e,new Eh(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jm:Jm**+e,new Eh(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new gh(kh(e>=240?e-240:e+120,i,r),kh(e,i,r),kh(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Eh(Dh(this.h),Oh(this.s),Oh(this.l),bh(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=bh(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Dh(this.h)}, ${Oh(this.s)*100}%, ${Oh(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Dh(e){return e=(e||0)%360,e<0?e+360:e}function Oh(e){return Math.max(0,Math.min(1,e||0))}function kh(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Ah=e=>()=>e;function jh(e,t){return function(n){return e+n*t}}function Mh(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Nh(e){return(e=+e)==1?Ph:function(t,n){return n-t?Mh(t,n,e):Ah(isNaN(t)?n:t)}}function Ph(e,t){var n=t-e;return n?jh(e,n):Ah(isNaN(e)?t:e)}var Fh=(function e(t){var n=Nh(t);function r(e,t){var r=n((e=hh(e)).r,(t=hh(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Ph(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Ih(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Vh(r,i)})),n=Wh.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Vh(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Vh(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Vh(e,n)},{i:s-2,x:Vh(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++tt&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function ree(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i2?iee:ree,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),Vh))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,og),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=Yh,u()},d.clamp=function(e){return arguments.length?(o=e?!0:cg,u()):o!==cg},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function fg(){return dg()(cg,cg)}function pg(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function mg(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function hg(e){return e=mg(Math.abs(e)),e?e[1]:NaN}function aee(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function gg(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var _g=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function vg(e){if(!(t=_g.exec(e)))throw Error(`invalid format: `+e);var t;return new yg({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}vg.prototype=yg.prototype;function yg(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}yg.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function bg(e){out:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var xg;function Sg(e,t){var n=mg(e,t);if(!n)return xg=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(xg=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+mg(e,Math.max(0,t+a-1))[0]}function Cg(e,t){var n=mg(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var wg={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:pg,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Cg(e*100,t),r:Cg,s:Sg,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Tg(e){return e}var Eg=Array.prototype.map,Dg=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function Og(e){var t=e.grouping===void 0||e.thousands===void 0?Tg:aee(Eg.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?Tg:gg(Eg.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=vg(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):wg[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=wg[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=bg(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&xg!==void 0?Dg[8+xg/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++op||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(hg(t)/3)))*3,r=10**-n,i=l((e=vg(e),e.type=`f`,e),{suffix:Dg[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var kg,Ag,jg;oee({thousands:`,`,grouping:[3],currency:[`$`,``]});function oee(e){return kg=Og(e),Ag=kg.format,jg=kg.formatPrefix,kg}function see(e){return Math.max(0,-hg(Math.abs(e)))}function Mg(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(hg(t)/3)))*3-hg(Math.abs(e)))}function Ng(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,hg(t)-hg(e))+1}function Pg(e,t,n,r){var i=Lm(e,t,n),a;switch(r=vg(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=Mg(i,o))&&(r.precision=a),jg(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Ng(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=see(i))&&(r.precision=a-(r.type===`%`)*2);break}return Ag(r)}function Fg(e){var t=e.domain;return e.ticks=function(e){var n=t();return Fm(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Pg(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s0;){if(l=Im(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Ig(){var e=fg();return e.copy=function(){return ug(e,Ig())},Wm.apply(e,arguments),Fg(e)}function Lg(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[Om(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return Lg().domain([e,t]).range(i).unknown(a)},Wm.apply(Fg(o),arguments)}var Rg=1e-6,zg=Math.PI,Bg=zg/2,Vg=zg/4,Hg=zg*2,Ug=180/zg,Wg=zg/180,Gg=Math.abs,Kg=Math.atan,qg=Math.atan2,Jg=Math.cos,Yg=Math.ceil,Xg=Math.exp,Zg=Math.hypot,Qg=Math.log,$g=Math.sin,e_=Math.sign||function(e){return e>0?1:e<0?-1:0},t_=Math.sqrt,n_=Math.tan;function r_(e){return e>1?0:e<-1?zg:Math.acos(e)}function i_(e){return e>1?Bg:e<-1?-Bg:Math.asin(e)}function a_(e){return(e=$g(e/2))*e}function o_(){}function s_(e,t){e&&l_.hasOwnProperty(e.type)&&l_[e.type](e,t)}var c_={Feature:function(e,t){s_(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r=0?1:-1,i=r*n,a=Jg(t),o=$g(t),s=y_*o,c=v_*a+s*Jg(i),l=s*r*$g(i);p_.add(qg(l,c)),__=e,v_=a,y_=o}function T_(e){return[qg(e[1],e[0]),i_(e[2])]}function E_(e){var t=e[0],n=e[1],r=Jg(n);return[r*Jg(t),r*$g(t),$g(n)]}function D_(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function O_(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function k_(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function A_(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function j_(e){var t=t_(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var M_,N_,P_,F_,I_,L_,R_,z_,B_,V_,H_,U_={point:W_,lineStart:K_,lineEnd:q_,polygonStart:function(){U_.point=J_,U_.lineStart=cee,U_.lineEnd=Y_,B_=new Am,b_.polygonStart()},polygonEnd:function(){b_.polygonEnd(),U_.point=W_,U_.lineStart=K_,U_.lineEnd=q_,p_<0?(M_=-(P_=180),N_=-(F_=90)):B_>1e-6?F_=90:B_<-1e-6&&(N_=-90),H_[0]=M_,H_[1]=P_},sphere:function(){M_=-(P_=180),N_=-(F_=90)}};function W_(e,t){V_.push(H_=[M_=e,P_=e]),tF_&&(F_=t)}function G_(e,t){var n=E_([e*Wg,t*Wg]);if(z_){var r=O_(z_,n),i=O_([r[1],-r[0],0],r);j_(i),i=T_(i);var a=e-I_,o=a>0?1:-1,s=i[0]*Ug*o,c,l=Gg(a)>180;l^(o*I_F_&&(F_=c)):(s=(s+360)%360-180,l^(o*I_F_&&(F_=t))),l?eX_(M_,P_)&&(P_=e):X_(e,P_)>X_(M_,P_)&&(M_=e):P_>=M_?(eP_&&(P_=e)):e>I_?X_(M_,e)>X_(M_,P_)&&(P_=e):X_(e,P_)>X_(M_,P_)&&(M_=e)}else V_.push(H_=[M_=e,P_=e]);tF_&&(F_=t),z_=n,I_=e}function K_(){U_.point=G_}function q_(){H_[0]=M_,H_[1]=P_,U_.point=W_,z_=null}function J_(e,t){if(z_){var n=e-I_;B_.add(Gg(n)>180?n+(n>0?360:-360):n)}else L_=e,R_=t;b_.point(e,t),G_(e,t)}function cee(){b_.lineStart()}function Y_(){J_(L_,R_),b_.lineEnd(),Gg(B_)>1e-6&&(M_=-(P_=180)),H_[0]=M_,H_[1]=P_,z_=null}function X_(e,t){return(t-=e)<0?t+360:t}function Z_(e,t){return e[0]-t[0]}function Q_(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tX_(r[0],r[1])&&(r[1]=i[1]),X_(i[0],r[1])>X_(r[0],r[1])&&(r[0]=i[0])):a.push(r=i);for(o=-1/0,n=a.length-1,t=0,r=a[n];t<=n;r=i,++t)i=a[t],(s=X_(r[1],i[0]))>o&&(o=s,M_=i[0],P_=r[1])}return V_=H_=null,M_===1/0||N_===1/0?[[NaN,NaN],[NaN,NaN]]:[[M_,N_],[P_,F_]]}var ev,tv,nv,rv,iv,av,ov,sv,cv,lv,uv,dv,fv,pv,mv,hv,gv={sphere:o_,point:_v,lineStart:yv,lineEnd:Sv,polygonStart:function(){gv.lineStart=Cv,gv.lineEnd=wv},polygonEnd:function(){gv.lineStart=yv,gv.lineEnd=Sv}};function _v(e,t){e*=Wg,t*=Wg;var n=Jg(t);vv(n*Jg(e),n*$g(e),$g(t))}function vv(e,t,n){++ev,nv+=(e-nv)/ev,rv+=(t-rv)/ev,iv+=(n-iv)/ev}function yv(){gv.point=bv}function bv(e,t){e*=Wg,t*=Wg;var n=Jg(t);pv=n*Jg(e),mv=n*$g(e),hv=$g(t),gv.point=xv,vv(pv,mv,hv)}function xv(e,t){e*=Wg,t*=Wg;var n=Jg(t),r=n*Jg(e),i=n*$g(e),a=$g(t),o=qg(t_((o=mv*a-hv*i)*o+(o=hv*r-pv*a)*o+(o=pv*i-mv*r)*o),pv*r+mv*i+hv*a);tv+=o,av+=o*(pv+(pv=r)),ov+=o*(mv+(mv=i)),sv+=o*(hv+(hv=a)),vv(pv,mv,hv)}function Sv(){gv.point=_v}function Cv(){gv.point=Tv}function wv(){Ev(dv,fv),gv.point=_v}function Tv(e,t){dv=e,fv=t,e*=Wg,t*=Wg,gv.point=Ev;var n=Jg(t);pv=n*Jg(e),mv=n*$g(e),hv=$g(t),vv(pv,mv,hv)}function Ev(e,t){e*=Wg,t*=Wg;var n=Jg(t),r=n*Jg(e),i=n*$g(e),a=$g(t),o=mv*a-hv*i,s=hv*r-pv*a,c=pv*i-mv*r,l=Zg(o,s,c),u=i_(l),d=l&&-u/l;cv.add(d*o),lv.add(d*s),uv.add(d*c),tv+=u,av+=u*(pv+(pv=r)),ov+=u*(mv+(mv=i)),sv+=u*(hv+(hv=a)),vv(pv,mv,hv)}function Dv(e){ev=tv=nv=rv=iv=av=ov=sv=0,cv=new Am,lv=new Am,uv=new Am,f_(e,gv);var t=+cv,n=+lv,r=+uv,i=Zg(t,n,r);return i<1e-12&&(t=av,n=ov,r=sv,tv<1e-6&&(t=nv,n=rv,r=iv),i=Zg(t,n,r),i<1e-12)?[NaN,NaN]:[qg(n,t)*Ug,i_(r/i)*Ug]}function Ov(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return n=t.invert(n,r),n&&e.invert(n[0],n[1])}),n}function kv(e,t){return Gg(e)>zg&&(e-=Math.round(e/Hg)*Hg),[e,t]}kv.invert=kv;function Av(e,t,n){return(e%=Hg)?t||n?Ov(Mv(e),Nv(t,n)):Mv(e):t||n?Nv(t,n):kv}function jv(e){return function(t,n){return t+=e,Gg(t)>zg&&(t-=Math.round(t/Hg)*Hg),[t,n]}}function Mv(e){var t=jv(e);return t.invert=jv(-e),t}function Nv(e,t){var n=Jg(e),r=$g(e),i=Jg(t),a=$g(t);function o(e,t){var o=Jg(t),s=Jg(e)*o,c=$g(e)*o,l=$g(t),u=l*n+s*r;return[qg(c*i-u*a,s*n-l*r),i_(u*i+c*a)]}return o.invert=function(e,t){var o=Jg(t),s=Jg(e)*o,c=$g(e)*o,l=$g(t),u=l*i-c*a;return[qg(c*i+l*a,s*n+u*r),i_(u*n-s*r)]},o}function Pv(e){e=Av(e[0]*Wg,e[1]*Wg,e.length>2?e[2]*Wg:0);function t(t){return t=e(t[0]*Wg,t[1]*Wg),t[0]*=Ug,t[1]*=Ug,t}return t.invert=function(t){return t=e.invert(t[0]*Wg,t[1]*Wg),t[0]*=Ug,t[1]*=Ug,t},t}function Fv(e,t,n,r,i,a){if(n){var o=Jg(t),s=$g(t),c=r*n;i==null?(i=t+r*Hg,a=t-c/2):(i=Iv(o,i),a=Iv(o,a),(r>0?ia)&&(i+=r*Hg));for(var l,u=i;r>0?u>a:u1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Rv(e,t){return Gg(e[0]-t[0])<1e-6&&Gg(e[1]-t[1])<1e-6}function zv(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Bv(e,t,n,r,i){var a=[],o=[],s,c;if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,n=e[0],r=e[t],c;if(Rv(n,r)){if(!n[2]&&!r[2]){for(i.lineStart(),s=0;s=0;--s)i.point((d=u[s])[0],d[1]);else r(f.x,f.p.x,-1,i);f=f.p}f=f.o,u=f.z,p=!p}while(!f.v);i.lineEnd()}}}function Vv(e){if(t=e.length){for(var t,n=0,r=e[0],i;++n=0?1:-1,E=T*w,D=E>zg,O=g*S;if(c.add(qg(O*T*$g(E),_*C+O*Jg(E))),o+=D?w+T*Hg:w,D^m>=n^b>=n){var k=O_(E_(p),E_(y));j_(k);var A=O_(a,k);j_(A);var j=(D^w>=0?-1:1)*i_(A[2]);(r>j||r===j&&(k[0]||k[1]))&&(s+=D^w>=0?1:-1)}}return(o<-1e-6||o<1e-6&&c<-1e-12)^s&1}function Wv(e,t,n,r){return function(i){var a=t(i),o=Lv(),s=t(o),c=!1,l,u,d,f={point:p,lineStart:h,lineEnd:g,polygonStart:function(){f.point=_,f.lineStart=v,f.lineEnd=y,u=[],l=[]},polygonEnd:function(){f.point=p,f.lineStart=h,f.lineEnd=g,u=Vm(u);var e=Uv(l,r);u.length?(c||=(i.polygonStart(),!0),Bv(u,Kv,e,n,i)):e&&(c||=(i.polygonStart(),!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&=(i.polygonEnd(),!1),u=l=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function p(t,n){e(t,n)&&i.point(t,n)}function m(e,t){a.point(e,t)}function h(){f.point=m,a.lineStart()}function g(){f.point=p,a.lineEnd()}function _(e,t){d.push([e,t]),s.point(e,t)}function v(){s.lineStart(),d=[]}function y(){_(d[0][0],d[0][1]),s.lineEnd();var e=s.clean(),t=o.result(),n,r=t.length,a,f,p;if(d.pop(),l.push(d),d=null,r){if(e&1){if(f=t[0],(a=f.length-1)>0){for(c||=(i.polygonStart(),!0),i.lineStart(),n=0;n1&&e&2&&t.push(t.pop().concat(t.shift())),u.push(t.filter(Gv))}}return f}}function Gv(e){return e.length>1}function Kv(e,t){return((e=e.x)[0]<0?e[1]-Bg-Rg:Bg-e[1])-((t=t.x)[0]<0?t[1]-Bg-Rg:Bg-t[1])}var qv=Wv(function(){return!0},lee,dee,[-zg,-Bg]);function lee(e){var t=NaN,n=NaN,r=NaN,i;return{lineStart:function(){e.lineStart(),i=1},point:function(a,o){var s=a>0?zg:-zg,c=Gg(a-t);Gg(c-zg)<1e-6?(e.point(t,n=(n+o)/2>0?Bg:-Bg),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),e.point(a,n),i=0):r!==s&&c>=zg&&(Gg(t-r)<1e-6&&(t-=r*Rg),Gg(a-s)<1e-6&&(a-=s*Rg),n=uee(t,n,a,o),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),i=0),e.point(t=a,n=o),r=s},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-i}}}function uee(e,t,n,r){var i,a,o=$g(e-n);return Gg(o)>1e-6?Kg(($g(t)*(a=Jg(r))*$g(n)-$g(r)*(i=Jg(t))*$g(e))/(i*a*o)):(t+r)/2}function dee(e,t,n,r){var i;if(e==null)i=n*Bg,r.point(-zg,i),r.point(0,i),r.point(zg,i),r.point(zg,0),r.point(zg,-i),r.point(0,-i),r.point(-zg,-i),r.point(-zg,0),r.point(-zg,i);else if(Gg(e[0]-t[0])>1e-6){var a=e[0]0,i=Gg(t)>Rg;function a(t,r,i,a){Fv(a,e,n,i,t,r)}function o(e,n){return Jg(e)*Jg(n)>t}function s(e){var t,n,a,s,u;return{lineStart:function(){s=a=!1,u=1},point:function(d,f){var p=[d,f],m,h=o(d,f),g=r?h?0:l(d,f):h?l(d+(d<0?zg:-zg),f):0;if(!t&&(s=a=h)&&e.lineStart(),h!==a&&(m=c(t,p),(!m||Rv(t,m)||Rv(p,m))&&(p[2]=1)),h!==a)u=0,h?(e.lineStart(),m=c(p,t),e.point(m[0],m[1])):(m=c(t,p),e.point(m[0],m[1],2),e.lineEnd()),t=m;else if(i&&t&&r^h){var _;!(g&n)&&(_=c(p,t,!0))&&(u=0,r?(e.lineStart(),e.point(_[0][0],_[0][1]),e.point(_[1][0],_[1][1]),e.lineEnd()):(e.point(_[1][0],_[1][1]),e.lineEnd(),e.lineStart(),e.point(_[0][0],_[0][1],3)))}h&&(!t||!Rv(t,p))&&e.point(p[0],p[1]),t=p,a=h,n=g},lineEnd:function(){a&&e.lineEnd(),t=null},clean:function(){return u|(s&&a)<<1}}}function c(e,n,r){var i=E_(e),a=E_(n),o=[1,0,0],s=O_(i,a),c=D_(s,s),l=s[0],u=c-l*l;if(!u)return!r&&e;var d=t*c/u,f=-t*l/u,p=O_(o,s),m=A_(o,d);k_(m,A_(s,f));var h=p,g=D_(m,h),_=D_(h,h),v=g*g-_*(D_(m,m)-1);if(!(v<0)){var y=t_(v),b=A_(h,(-g-y)/_);if(k_(b,m),b=T_(b),!r)return b;var x=e[0],S=n[0],C=e[1],w=n[1],T;S0^b[1]<(Gg(b[0]-x)<1e-6?C:w):C<=b[1]&&b[1]<=w:E>zg^(x<=b[0]&&b[0]<=S)){var k=A_(h,(-g+y)/_);return k_(k,m),[b,T_(k)]}}}function l(t,n){var i=r?e:zg-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return Wv(o,s,a,r?[0,-e]:[-zg,e-zg])}function Jv(e,t,n,r,i,a){var o=e[0],s=e[1],c=t[0],l=t[1],u=0,d=1,f=c-o,p=l-s,m=n-o;if(!(!f&&m>0)){if(m/=f,f<0){if(m0){if(m>d)return;m>u&&(u=m)}if(m=i-o,!(!f&&m<0)){if(m/=f,f<0){if(m>d)return;m>u&&(u=m)}else if(f>0){if(m0)){if(m/=p,p<0){if(m0){if(m>d)return;m>u&&(u=m)}if(m=a-s,!(!p&&m<0)){if(m/=p,p<0){if(m>d)return;m>u&&(u=m)}else if(p>0){if(m0&&(e[0]=o+u*f,e[1]=s+u*p),d<1&&(t[0]=o+d*f,t[1]=s+d*p),!0}}}}}var Yv=1e9,Xv=-Yv;function Zv(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var u=0,d=0;if(i==null||(u=o(i,s))!==(d=o(a,s))||c(i,a)<0^s>0)do l.point(u===0||u===3?e:n,u>1?r:t);while((u=(u+s+4)%4)!==d);else l.point(a[0],a[1])}function o(r,i){return Gg(r[0]-e)<1e-6?i>0?0:3:Gg(r[0]-n)<1e-6?i>0?2:1:Gg(r[1]-t)<1e-6?+(i>0):i>0?3:2}function s(e,t){return c(e.x,t.x)}function c(e,t){var n=o(e,1),r=o(t,1);return n===r?n===0?t[1]-e[1]:n===1?e[0]-t[0]:n===2?e[1]-t[1]:t[0]-e[0]:n-r}return function(o){var c=o,l=Lv(),u,d,f,p,m,h,g,_,v,y,b,x={point:S,lineStart:E,lineEnd:D,polygonStart:w,polygonEnd:T};function S(e,t){i(e,t)&&c.point(e,t)}function C(){for(var t=0,n=0,i=d.length;nr&&(f-l)*(r-u)>(p-u)*(e-l)&&++t:p<=r&&(f-l)*(r-u)<(p-u)*(e-l)&&--t;return t}function w(){c=l,u=[],d=[],b=!0}function T(){var e=C(),t=b&&e,n=(u=Vm(u)).length;(t||n)&&(o.polygonStart(),t&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),n&&Bv(u,s,e,a,o),o.polygonEnd()),c=o,u=d=f=null}function E(){x.point=O,d&&d.push(f=[]),y=!0,v=!1,g=_=NaN}function D(){u&&(O(p,m),h&&v&&l.rejoin(),u.push(l.result())),x.point=S,v&&c.lineEnd()}function O(a,o){var s=i(a,o);if(d&&f.push([a,o]),y)p=a,m=o,h=s,y=!1,s&&(c.lineStart(),c.point(a,o));else if(s&&v)c.point(a,o);else{var l=[g=Math.max(Xv,Math.min(Yv,g)),_=Math.max(Xv,Math.min(Yv,_))],u=[a=Math.max(Xv,Math.min(Yv,a)),o=Math.max(Xv,Math.min(Yv,o))];Jv(l,u,e,t,n,r)?(v||(c.lineStart(),c.point(l[0],l[1])),c.point(u[0],u[1]),s||c.lineEnd(),b=!1):s&&(c.lineStart(),c.point(a,o),b=!1)}g=a,_=o,v=s}return x}}var Qv,$v,ey,ty,ny={sphere:o_,point:o_,lineStart:ry,lineEnd:o_,polygonStart:o_,polygonEnd:o_};function ry(){ny.point=ay,ny.lineEnd=iy}function iy(){ny.point=ny.lineEnd=o_}function ay(e,t){e*=Wg,t*=Wg,$v=e,ey=$g(t),ty=Jg(t),ny.point=oy}function oy(e,t){e*=Wg,t*=Wg;var n=$g(t),r=Jg(t),i=Gg(e-$v),a=Jg(i),o=r*$g(i),s=ty*n-ey*r*a,c=ey*n+ty*r*a;Qv.add(qg(t_(o*o+s*s),c)),$v=e,ey=n,ty=r}function sy(e){return Qv=new Am,f_(e,ny),+Qv}var cy=[null,null],ly={type:`LineString`,coordinates:cy};function uy(e,t){return cy[0]=e,cy[1]=t,sy(ly)}var dy={Feature:function(e,t){return py(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r0&&(i=uy(e[a],e[a-1]),i>0&&n<=i&&r<=i&&(n+r-i)*(1-((n-r)/i)**2)<1e-12*i))return!0;n=r}return!1}function gy(e,t){return!!Uv(e.map(_y),vy(t))}function _y(e){return e=e.map(vy),e.pop(),e}function vy(e){return[e[0]*Wg,e[1]*Wg]}function yy(e,t){return(e&&dy.hasOwnProperty(e.type)?dy[e.type]:py)(e,t)}function by(e,t,n){var r=Hm(e,t-Rg,n).concat(t);return function(e){return r.map(function(t){return[e,t]})}}function xy(e,t,n){var r=Hm(e,t-Rg,n).concat(t);return function(e){return r.map(function(t){return[t,e]})}}function Sy(){var e,t,n,r,i,a,o,s,c=10,l=c,u=90,d=360,f,p,m,h,g=2.5;function _(){return{type:`MultiLineString`,coordinates:v()}}function v(){return Hm(Yg(r/u)*u,n,u).map(m).concat(Hm(Yg(s/d)*d,o,d).map(h)).concat(Hm(Yg(t/c)*c,e,c).filter(function(e){return Gg(e%u)>Rg}).map(f)).concat(Hm(Yg(a/l)*l,i,l).filter(function(e){return Gg(e%d)>Rg}).map(p))}return _.lines=function(){return v().map(function(e){return{type:`LineString`,coordinates:e}})},_.outline=function(){return{type:`Polygon`,coordinates:[m(r).concat(h(o).slice(1),m(n).reverse().slice(1),h(s).reverse().slice(1))]}},_.extent=function(e){return arguments.length?_.extentMajor(e).extentMinor(e):_.extentMinor()},_.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),_.precision(g)):[[r,s],[n,o]]},_.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),_.precision(g)):[[t,a],[e,i]]},_.step=function(e){return arguments.length?_.stepMajor(e).stepMinor(e):_.stepMinor()},_.stepMajor=function(e){return arguments.length?(u=+e[0],d=+e[1],_):[u,d]},_.stepMinor=function(e){return arguments.length?(c=+e[0],l=+e[1],_):[c,l]},_.precision=function(c){return arguments.length?(g=+c,f=by(a,i,90),p=xy(t,e,g),m=by(s,o,90),h=xy(r,n,g),_):g},_.extentMajor([[-180,-90+Rg],[180,90-Rg]]).extentMinor([[-180,-80-Rg],[180,80+Rg]])}function Cy(){return Sy()()}function wy(e,t){var n=e[0]*Wg,r=e[1]*Wg,i=t[0]*Wg,a=t[1]*Wg,o=Jg(r),s=$g(r),c=Jg(a),l=$g(a),u=o*Jg(n),d=o*$g(n),f=c*Jg(i),p=c*$g(i),m=2*i_(t_(a_(a-r)+o*c*a_(i-n))),h=$g(m),g=m?function(e){var t=$g(e*=m)/h,n=$g(m-e)/h,r=n*u+t*f,i=n*d+t*p,a=n*s+t*l;return[qg(i,r)*Ug,qg(a,t_(r*r+i*i))*Ug]}:function(){return[n*Ug,r*Ug]};return g.distance=m,g}var Ty=e=>e,Ey=1/0,Dy=Ey,Oy=-Ey,ky=Oy,Ay={point:jy,lineStart:o_,lineEnd:o_,polygonStart:o_,polygonEnd:o_,result:function(){var e=[[Ey,Dy],[Oy,ky]];return Oy=ky=-(Dy=Ey=1/0),e}};function jy(e,t){eOy&&(Oy=e),tky&&(ky=t)}function My(e){return function(t){var n=new Ny;for(var r in e)n[r]=e[r];return n.stream=t,n}}function Ny(){}Ny.prototype={constructor:Ny,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function Py(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),f_(n,e.stream(Ay)),t(Ay.result()),r!=null&&e.clipExtent(r),e}function Fy(e,t,n){return Py(e,function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])},n)}function Iy(e,t,n){return Fy(e,[[0,0],t],n)}function Ly(e,t,n){return Py(e,function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])},n)}function Ry(e,t,n){return Py(e,function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])},n)}var zy=16,By=Jg(30*Wg);function Vy(e,t){return+t?Uy(e,t):Hy(e)}function Hy(e){return My({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function Uy(e,t){function n(r,i,a,o,s,c,l,u,d,f,p,m,h,g){var _=l-r,v=u-i,y=_*_+v*v;if(y>4*t&&h--){var b=o+f,x=s+p,S=c+m,C=t_(b*b+x*x+S*S),w=i_(S/=C),T=Gg(Gg(S)-1)<1e-6||Gg(a-d)<1e-6?(a+d)/2:qg(x,b),E=e(T,w),D=E[0],O=E[1],k=D-r,A=O-i,j=v*k-_*A;(j*j/y>t||Gg((_*k+v*A)/y-.5)>.3||o*f+s*p+c*m2?e[2]%360*Wg:0,k()):[s*Ug,c*Ug,l*Ug]},D.angle=function(e){return arguments.length?(d=e%360*Wg,k()):d*Ug},D.reflectX=function(e){return arguments.length?(f=e?-1:1,k()):f<0},D.reflectY=function(e){return arguments.length?(p=e?-1:1,k()):p<0},D.precision=function(e){return arguments.length?(S=Vy(C,x=e*e),A()):t_(x)},D.fitExtent=function(e,t){return Fy(D,e,t)},D.fitSize=function(e,t){return Iy(D,e,t)},D.fitWidth=function(e,t){return Ly(D,e,t)},D.fitHeight=function(e,t){return Ry(D,e,t)};function k(){var e=qy(n,0,0,f,p,d).apply(null,t(a,o)),m=qy(n,r-e[0],i-e[1],f,p,d);return u=Av(s,c,l),C=Ov(t,m),w=Ov(u,C),S=Vy(C,x),A()}function A(){return T=E=null,D}return function(){return t=e.apply(this,arguments),D.invert=t.invert&&O,k()}}function Xy(e){return function(t,n){var r=t_(t*t+n*n),i=e(r),a=$g(i),o=Jg(i);return[qg(t*a,r*o),i_(r&&n*a/r)]}}function Zy(e,t){return[e,Qg(n_((Bg+t)/2))]}Zy.invert=function(e,t){return[e,2*Kg(Xg(t))-Bg]};function Qy(e,t){var n=Jg(t),r=1+Jg(e)*n;return[n*$g(e)/r,$g(t)/r]}Qy.invert=Xy(function(e){return 2*Kg(e)});function $y(){return Jy(Qy).scale(250).clipAngle(142)}function eb(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=Ig().domain([1,0]).range([t,n]).clamp(!0),i=Ig().domain([Fb(t),Fb(n)]).range([1,0]).clamp(!0),a=function(e){return i(Fb(r(e)))},o=e.array,s=0,c=o.length;s2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=[],s=2**e,c=360/s,l=180/s,u=i===void 0?s-1:i,d=a===void 0?s-1:a,f=n,p=Math.min(s-1,u);f<=p;f++)for(var m=r,h=Math.min(s-1,d);m<=h;m++){var g=m,_=l;t&&(g=m===0?m:Ib(m/s)*s,_=((m+1===s?m+1:Ib((m+1)/s)*s)-g)*180/s);var v=-180+(f+.5)*c,y=90-(g*180/s+_/2),b=_;o.push({x:f,y:m,lng:v,lat:y,latLen:b})}return o},Bb=6,Vb=7,Hb=3,Ub=90,Wb=new WeakMap,Gb=new WeakMap,Kb=new WeakMap,qb=new WeakMap,Jb=new WeakMap,Yb=new WeakMap,Xb=new WeakMap,Zb=new WeakMap,Qb=new WeakSet,$b=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=r.tileUrl,a=r.minLevel,o=a===void 0?0:a,s=r.maxLevel,c=s===void 0?17:s,l=r.mercatorProjection,u=l===void 0||l;return sb(this,t),n=ab(this,t),db(n,Qb),lb(n,Wb,void 0),lb(n,Gb,void 0),lb(n,Kb,void 0),lb(n,qb,void 0),lb(n,Jb,{}),lb(n,Yb,void 0),lb(n,Xb,void 0),lb(n,Zb,void 0),mb(n,`minLevel`,void 0),mb(n,`maxLevel`,void 0),mb(n,`thresholds`,Tb(Array(30)).map(function(e,t){return 8/2**t})),mb(n,`curvatureResolution`,5),mb(n,`tileMargin`,0),mb(n,`clearTiles`,function(){Object.values(cb(Jb,n)).forEach(function(e){e.forEach(function(e){e.obj&&(n.remove(e.obj),Ab(e.obj),delete e.obj)})}),ub(Jb,n,{})}),ub(Wb,n,e),n.tileUrl=i,ub(Gb,n,u),n.minLevel=o,n.maxLevel=c,n.level=0,n.add(ub(Zb,n,new _a(new Ts(cb(Wb,n)*.99,180,90),new aa({color:0})))),cb(Zb,n).visible=!1,cb(Zb,n).material.polygonOffset=!0,cb(Zb,n).material.polygonOffsetUnits=3,cb(Zb,n).material.polygonOffsetFactor=1,n}return gb(t,e),pb(t,[{key:`tileUrl`,get:function(){return cb(Kb,this)},set:function(e){ub(Kb,this,e),this.updatePov(cb(Xb,this))}},{key:`level`,get:function(){return cb(qb,this)},set:function(e){var t,n=this;cb(Jb,this)[e]||rb(Qb,this,ex).call(this,e);var r=cb(qb,this);if(ub(qb,this,e),!(e===r||r===void 0)){if(cb(Zb,this).visible=e>0,cb(Jb,this)[e].forEach(function(e){return e.obj&&(e.obj.material.depthWrite=!0)}),re)for(var i=e+1;i<=r;i++)cb(Jb,this)[i]&&cb(Jb,this)[i].forEach(function(e){e.obj&&(n.remove(e.obj),Ab(e.obj),delete e.obj)});rb(Qb,this,tx).call(this)}}},{key:`updatePov`,value:function(e){var t=this;if(!(!e||!(e instanceof Ec))){ub(Xb,this,e);var n;if(ub(Yb,this,function(r){if(!r.hullPnts){var i=360/2**t.level,a=r.lng,o=r.lat,s=r.latLen,c=a-i/2,l=a+i/2,u=o-s/2,d=o+s/2;r.hullPnts=[[o,a],[u,c],[d,c],[u,l],[d,l]].map(function(e){var n=wb(e,2),r=n[0],i=n[1];return jb(r,i,cb(Wb,t))}).map(function(e){var t=e.x,n=e.y,r=e.z;return new V(t,n,r)})}return n||(n=new ka,e.updateMatrix(),e.updateMatrixWorld(),n.setFromProjectionMatrix(new lr().multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse))),r.hullPnts.some(function(e){return n.containsPoint(e.clone().applyMatrix4(t.matrixWorld))})}),this.tileUrl){var r=(e.position.clone().distanceTo(this.getWorldPosition(new V))-cb(Wb,this))/cb(Wb,this),i=this.thresholds.findIndex(function(e){return e&&e<=r});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,i<0?this.thresholds.length:i)),rb(Qb,this,tx).call(this)}}}}])}(Ir);function ex(e){var t=this;if(e>Vb){cb(Jb,this)[e]=[];return}var n=cb(Jb,this)[e]=zb(e,cb(Gb,this));n.forEach(function(e){return e.centroid=jb(e.lat,e.lng,cb(Wb,t))}),n.octree=ym().x(function(e){return e.centroid.x}).y(function(e){return e.centroid.y}).z(function(e){return e.centroid.z}).addAll(n)}function tx(){var e=this;if(!(!this.tileUrl||this.level===void 0||!cb(Jb,this).hasOwnProperty(this.level))&&!(!cb(Yb,this)&&this.level>Bb)){var t=cb(Jb,this)[this.level];if(cb(Xb,this)){var n=this.worldToLocal(cb(Xb,this).position.clone());if(t.octree){var r,i=this.worldToLocal(cb(Xb,this).position.clone()),a=(i.length()-cb(Wb,this))*Hb;t=(r=t.octree).findAllWithinRadius.apply(r,Tb(i).concat([a]))}else{var o=Mb(n),s=(o.r/cb(Wb,this)-1)*Ub,c=s/Math.cos(Nb(o.lat)),l=[o.lng-c,o.lng+c],u=[o.lat+s,o.lat-s],d=wb(Rb(this.level,cb(Gb,this),l[0],u[0]),2),f=d[0],p=d[1],m=wb(Rb(this.level,cb(Gb,this),l[1],u[1]),2),h=m[0],g=m[1];!t.record&&(t.record={});var _=t.record;if(!_.hasOwnProperty(`${Math.round((f+h)/2)}_${Math.round((p+g)/2)}`))t=zb(this.level,cb(Gb,this),f,p,h,g).map(function(e){var n=`${e.x}_${e.y}`;return _.hasOwnProperty(n)?_[n]:(_[n]=e,t.push(e),e)});else{for(var v=[],y=f;y<=h;y++)for(var b=p;b<=g;b++){var x=`${y}_${b}`;_.hasOwnProperty(x)||(_[x]=zb(this.level,cb(Gb,this),y,b,y,b)[0],t.push(_[x])),v.push(_[x])}t=v}}}t.filter(function(e){return!e.obj}).filter(cb(Yb,this)||function(){return!0}).forEach(function(t){var n=t.x,r=t.y,i=t.lng,a=t.lat,o=t.latLen,s=360/2**e.level;if(!t.obj){var c=s*(1-e.tileMargin),l=o*(1-e.tileMargin),u=Nb(i),d=Nb(-a),f=new _a(new Ts(cb(Wb,e),Math.ceil(c/e.curvatureResolution),Math.ceil(l/e.curvatureResolution),Nb(90-c/2)+u,Nb(c),Nb(90-l/2)+d,Nb(l)),new Gs);if(cb(Gb,e)){var p=wb([a+o/2,a-o/2].map(function(e){return .5-e/180}),2),m=p[0],h=p[1];Lb(f.geometry.attributes.uv,m,h)}t.obj=f}t.loading||(t.loading=!0,new gc().load(e.tileUrl(n,r,e.level),function(n){var r=t.obj;r&&(n.colorSpace=It,r.material.map=n,r.material.color=null,r.material.needsUpdate=!0,e.add(r)),t.loading=!1}))})}}var nx=new Set,rx=!1;function ix(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length;nx.size&&nx.clear();let a=ax(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s=0,c=0,l=0;if(r&&(a=px(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return sx(a,o,s,c,l),o}function ax(e,t,n,r,i){let a=null;if(i===Zx(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=Jx(i/r|0,e[i],e[i+1],a);return a&&Vx(a,a.next)&&(Yx(a),a=a.next),a}function ox(e,t=e){let n=t===e,r=e,i;do i=!1,r!==r.next&&(nx.size===0||!nx.has(r))&&(Vx(r,r.next)||Bx(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),rx=!0,Yx(r),r=r.prev,i=!0):(n||r!==t)&&(r=r.next,i=!n);while(i||r!==t);return t}function sx(e,t,n,r,i){i&&Nx(e,n,r,i);let a=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,c=e.next;if(Bx(s,e,c)<0&&(i?lx(e,n,r,i):cx(e))){t.push(s.i,e.i,c.i),Yx(e),e=c,a=c;continue}if(e=c,e===a){if(rx=!1,e=ox(e),rx){a=e;continue}if(!o){e=ux(e,t),a=e,o=!0;continue}dx(e,t,n,r,i);break}}}function cx(e){let t=e.prev,n=e,r=e.next,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&&!(i===m.x&&s===m.y)&&Rx(i,s,a,c,o,l,m.x,m.y)&&Bx(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function lx(e,t,n,r){let i=e.prev,a=e,o=e.next,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),_=Ix(p,m,t,n,r),v=Ix(h,g,t,n,r),y=e.prevZ;for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==o&&!(s===y.x&&u===y.y)&&Rx(s,u,c,d,l,f,y.x,y.y)&&Bx(y.prev,y,y.next)>=0)return!1;y=y.prevZ}let b=e.nextZ;for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==o&&!(s===b.x&&u===b.y)&&Rx(s,u,c,d,l,f,b.x,b.y)&&Bx(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ux(e,t){let n=e,r=!1;do{let i=n.prev,a=n.next.next;Hx(i,n,n.next,a,!1)&&Gx(i,a)&&Gx(a,i)&&(t.push(i.i,n.i,a.i),Yx(n),Yx(n.next),n=e=a,r=!0),n=n.next}while(n!==e);return r?ox(n):n}function dx(e,t,n,r,i){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&zx(a,e)){let o=qx(a,e);a=ox(a,a.next),o=ox(o,o.next),sx(a,t,n,r,i),sx(o,t,n,r,i);return}e=e.next}a=a.next}while(a!==e)}var fx=!1;function px(e,t,n,r){let i=[];for(let n=0,a=t.length;na&&(a=n.x),n.yo&&(o=n.y),t.xa&&(a=t.x),t.yo&&(o=t.y),n=t}while(++s_x[n+2]&&(_x[n+2]=t.x),t.y>_x[n+3]&&(_x[n+3]=t.y)}function wx(e){let t=bx[e];for(;t.prev.next!==t;)t=t.next;return bx[e]=t,t}function Tx(e){let t=yx[e];for(;t.prev.next!==t;)t=t.next;return yx[e]=t,t}function Ex(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Vx(e,n))return n;for(let t=0,s=0;t_x[s+3]||_x[s]>r||_x[s+2]<=a)continue;let c=wx(t);n=Tx(t);do{if(n.prev.next===n){if(Vx(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.xr||_x[f+3]u)continue;let p=wx(t);n=Tx(t);do{if(n.prev.next===n&&r>=n.x&&n.x>=s&&r!==n.x&&Rx(ir)&&(to.x||n.x===o.x&&Dx(o,n)))&&(o=n,d=t)}n=n.next}while(n!==p)}return o}function Dx(e,t){return Bx(e.prev,e,t.prev)<0&&Bx(t.next,e,e.next)<0}var Ox=[],kx=[],Ax=new Uint32Array,jx=new Uint32Array,Mx=new Uint32Array(256);function Nx(e,t,n,r){let i=e,a=0;do i.z=Ix(i.x,i.y,t,n,r),Ox[a++]=i,i=i.next;while(i!==e);Px(a);let o=null;for(let e=0;e=0&&Ox[r].z>n;)Ox[r+1]=Ox[r],r--;Ox[r+1]=e}return}Ax.length>>a&255]++;let o=0;for(let e=0;e<256;e++){let t=Mx[e];Mx[e]=o,o+=t}for(let o=0;o>>a&255]++;r[s]=t[o],i[s]=e}}function Ix(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 Lx(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function zx(e,t){let n=Vx(e,t)&&Bx(e.prev,e,e.next)>0&&Bx(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||Gx(e,t)&&Gx(t,e)&&(Bx(e.prev,e,t.prev)!==0||Bx(e,t.prev,t)!==0))&&!Wx(e,t)&&(n||Kx(e,t))}function Bx(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Vx(e,t){return e.x===t.x&&e.y===t.y}function Hx(e,t,n,r,i=!0){let a=Bx(e,t,n),o=Bx(e,t,r),s=Bx(n,r,e),c=Bx(n,r,t);return(a>0&&o<0||a<0&&o>0)&&(s>0&&c<0||s<0&&c>0)?!0:i?!!(a===0&&Ux(e,n,t)||o===0&&Ux(e,r,t)||s===0&&Ux(n,e,r)||c===0&&Ux(n,t,r)):!1}function Ux(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 Wx(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),i=Math.min(e.y,t.y),a=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.xa&&s.y>a||o.y=0&&Bx(e,e.prev,t)>=0:Bx(e,t,e.prev)<0||Bx(e,e.next,t)<0}function Kx(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{let e=n.next;n.y>a!=e.y>a&&i<(e.x-n.x)*(a-n.y)/(e.y-n.y)+n.x&&(r=!r),n=e}while(n!==e);return r}function qx(e,t){let n=Xx(e.i,e.x,e.y),r=Xx(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 Jx(e,t,n,r){let i=Xx(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 Yx(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),fx&&Cx(e.prev,e.next)}function Xx(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function Zx(e,t,n,r){let i=0;for(let a=t,o=n-r;ae.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function sS(e){return sS=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},sS(e)}function cS(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&hS(e,t)}function lS(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lS=function(){return!!e})()}function uS(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function dS(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 fS(){throw TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pS(){throw TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mS(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return nS(e)}function hS(e,t){return hS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},hS(e,t)}function gS(e,t){return eS(e)||dS(e,t)||vS(e,t)||fS()}function _S(e){return tS(e)||uS(e)||vS(e)||pS()}function vS(e,t){if(e){if(typeof e==`string`)return $x(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)?$x(e,t):void 0}}var yS=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(e){if(r){var i=uy(e,r)*180/Math.PI;if(i>t)for(var a=wy(r,e),o=r.length>2||e.length>2?Vh(r[2]||0,e[2]||0):null,s=o?function(e){return[].concat(_S(a(e)),[o(e)])}:a,c=1/Math.ceil(i/t),l=c;l<1;)n.push(s(l)),l+=c}n.push(r=e)}),n},bS=typeof window<`u`&&window.THREE?window.THREE:{BufferGeometry:Wi,Float32BufferAttribute:Mi},xS=new bS.BufferGeometry().setAttribute?`setAttribute`:`addAttribute`,SS=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;iS(this,t),n=rS(this,t),n.type=`GeoJsonGeometry`,n.parameters={geoJson:e,radius:r,resolution:i};var a=({Point:l,MultiPoint:u,LineString:d,MultiLineString:f,Polygon:p,MultiPolygon:m}[e.type]||function(){return[]})(e.coordinates,r),o=[],s=[],c=0;a.forEach(function(e){var t=o.length;CS({indices:o,vertices:s},e),n.addGroup(t,o.length-t,c++)}),o.length&&n.setIndex(o),s.length&&n[xS](`position`,new bS.Float32BufferAttribute(s,3));function l(e,t){return[{vertices:TS(e[1],e[0],t+(e[2]||0)),indices:[]}]}function u(e,t){var n={vertices:[],indices:[]};return e.map(function(e){return l(e,t)}).forEach(function(e){var t=gS(e,1)[0];CS(n,t)}),[n]}function d(e,t){for(var n=Qx([yS(e,i).map(function(e){var n=gS(e,3),r=n[0],i=n[1],a=n[2];return TS(i,r,t+(a===void 0?0:a))})]).vertices,r=Math.round(n.length/3),a=[],o=1;o2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}var ES=s({computeMikkTSpaceTangents:()=>DS,computeMorphedAttributes:()=>LS,deepCloneAttribute:()=>AS,deinterleaveAttribute:()=>MS,deinterleaveGeometry:()=>NS,estimateBytesUsed:()=>PS,interleaveAttributes:()=>jS,mergeAttributes:()=>kS,mergeGeometries:()=>OS,mergeGroups:()=>RS,mergeVertices:()=>FS,toCreasedNormals:()=>zS,toTrianglesDrawMode:()=>IS});function DS(e,t,n=!0){if(!t||!t.isReady)throw Error(`THREE.BufferGeometryUtils: Initialized MikkTSpace library required.`);if(!e.hasAttribute(`position`)||!e.hasAttribute(`normal`)||!e.hasAttribute(`uv`))throw Error(`THREE.BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.`);function r(e){if(e.normalized||e.isInterleavedBufferAttribute){let t=new Float32Array(e.count*e.itemSize);for(let n=0,r=0;n2&&(t[r++]=e.getZ(n));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}let i=e.index?e.toNonIndexed():e,a=t.generateTangents(r(i.attributes.position),r(i.attributes.normal),r(i.attributes.uv));if(n)for(let e=3;e=2&&o.setY(t,e.getY(t)),r>=3&&o.setZ(t,e.getZ(t)),r>=4&&o.setW(t,e.getW(t));return o}function NS(e){let t=e.attributes,n=e.morphTargets,r=new Map;for(let e in t){let n=t[e];n.isInterleavedBufferAttribute&&(r.has(n)||r.set(n,MS(n)),t[e]=r.get(n))}for(let e in n){let t=n[e];t.isInterleavedBufferAttribute&&(r.has(t)||r.set(t,MS(t)),n[e]=r.get(t))}}function PS(e){let t=0;for(let n in e.attributes){let r=e.getAttribute(n);t+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}let n=e.getIndex();return t+=n?n.count*n.itemSize*n.array.BYTES_PER_ELEMENT:0,t}function FS(e,t=1e-4){t=Math.max(t,2**-52);let n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),c={},l={},u=[],d=[`getX`,`getY`,`getZ`,`getW`],f=[`setX`,`setY`,`setZ`,`setW`];for(let t=0,n=s.length;t{let r=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=t*.5,m=10**Math.log10(1/t),h=p*m;for(let t=0;te.materialIndex===t.materialIndex?e.start-t.start:e.materialIndex-t.materialIndex),e.getIndex()===null){let t=e.getAttribute(`position`),n=[];for(let e=0;eo&&(c+=a,d+=s,f+=u)}let p=1/(Math.sqrt(c*c+d*d+f*f)||1);y[3*a+0]=c*p,y[3*a+1]=d*p,y[3*a+2]=f*p}}return n.setAttribute(`normal`,new Oi(y,3,!1)),n}var U=(function(e){return typeof e==`function`?e:typeof e==`string`?function(t){return t[e]}:function(t){return e}});function BS(e){"@babel/helpers - typeof";return BS=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},BS(e)}var VS=/^\s+/,HS=/\s+$/;function US(e,t){if(e||=``,t||={},e instanceof US)return e;if(!(this instanceof US))return new US(e,t);var n=WS(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}US.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=t<=.03928?t/12.92:((t+.055)/1.055)**2.4,a=n<=.03928?n/12.92:((n+.055)/1.055)**2.4,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4;return .2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=uC(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=JS(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=JS(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?`hsv(`+t+`, `+n+`%, `+r+`%)`:`hsva(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHsl:function(){var e=KS(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=KS(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?`hsl(`+t+`, `+n+`%, `+r+`%)`:`hsla(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHex:function(e){return XS(this._r,this._g,this._b,e)},toHexString:function(e){return`#`+this.toHex(e)},toHex8:function(e){return ZS(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return`#`+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?`rgb(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`)`:`rgba(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`, `+this._roundA+`)`},toPercentageRgb:function(){return{r:Math.round(dC(this._r,255)*100)+`%`,g:Math.round(dC(this._g,255)*100)+`%`,b:Math.round(dC(this._b,255)*100)+`%`,a:this._a}},toPercentageRgbString:function(){return this._a==1?`rgb(`+Math.round(dC(this._r,255)*100)+`%, `+Math.round(dC(this._g,255)*100)+`%, `+Math.round(dC(this._b,255)*100)+`%)`:`rgba(`+Math.round(dC(this._r,255)*100)+`%, `+Math.round(dC(this._g,255)*100)+`%, `+Math.round(dC(this._b,255)*100)+`%, `+this._roundA+`)`},toName:function(){return this._a===0?`transparent`:this._a<1?!1:hee[XS(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t=`#`+QS(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?`GradientType = 1, `:``;if(e){var i=US(e);n=`#`+QS(i._r,i._g,i._b,i._a)}return`progid:DXImageTransform.Microsoft.gradient(`+r+`startColorstr=`+t+`,endColorstr=`+n+`)`},toString:function(e){var t=!!e;e||=this._format;var n=!1,r=this._a<1&&this._a>=0;return!t&&r&&(e===`hex`||e===`hex6`||e===`hex3`||e===`hex4`||e===`hex8`||e===`name`)?e===`name`&&this._a===0?this.toName():this.toRgbString():(e===`rgb`&&(n=this.toRgbString()),e===`prgb`&&(n=this.toPercentageRgbString()),(e===`hex`||e===`hex6`)&&(n=this.toHexString()),e===`hex3`&&(n=this.toHexString(!0)),e===`hex4`&&(n=this.toHex8String(!0)),e===`hex8`&&(n=this.toHex8String()),e===`name`&&(n=this.toName()),e===`hsl`&&(n=this.toHslString()),e===`hsv`&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return US(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(nC,arguments)},brighten:function(){return this._applyModification(rC,arguments)},darken:function(){return this._applyModification(iC,arguments)},desaturate:function(){return this._applyModification($S,arguments)},saturate:function(){return this._applyModification(eC,arguments)},greyscale:function(){return this._applyModification(tC,arguments)},spin:function(){return this._applyModification(aC,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(pee,arguments)},complement:function(){return this._applyCombination(oC,arguments)},monochromatic:function(){return this._applyCombination(mee,arguments)},splitcomplement:function(){return this._applyCombination(cC,arguments)},triad:function(){return this._applyCombination(sC,[3])},tetrad:function(){return this._applyCombination(sC,[4])}},US.fromRatio=function(e,t){if(BS(e)==`object`){var n={};for(var r in e)e.hasOwnProperty(r)&&(r===`a`?n[r]=e[r]:n[r]=hC(e[r]));e=n}return US(e,t)};function WS(e){var t={r:0,g:0,b:0},n=1,r=null,i=null,a=null,o=!1,s=!1;return typeof e==`string`&&(e=yee(e)),BS(e)==`object`&&(yC(e.r)&&yC(e.g)&&yC(e.b)?(t=GS(e.r,e.g,e.b),o=!0,s=String(e.r).substr(-1)===`%`?`prgb`:`rgb`):yC(e.h)&&yC(e.s)&&yC(e.v)?(r=hC(e.s),i=hC(e.v),t=YS(e.h,r,i),o=!0,s=`hsv`):yC(e.h)&&yC(e.s)&&yC(e.l)&&(r=hC(e.s),a=hC(e.l),t=qS(e.h,r,a),o=!0,s=`hsl`),e.hasOwnProperty(`a`)&&(n=e.a)),n=uC(n),{ok:o,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}function GS(e,t,n){return{r:dC(e,255)*255,g:dC(t,255)*255,b:dC(n,255)*255}}function KS(e,t,n){e=dC(e,255),t=dC(t,255),n=dC(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=(r+i)/2;if(r==i)a=o=0;else{var c=r-i;switch(o=s>.5?c/(2-r-i):c/(r+i),r){case e:a=(t-n)/c+(t1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(t===0)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return{r:r*255,g:i*255,b:a*255}}function JS(e,t,n){e=dC(e,255),t=dC(t,255),n=dC(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=r,c=r-i;if(o=r===0?0:c/r,r==i)a=0;else{switch(r){case e:a=(t-n)/c+(t>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(US(r));return a}function mee(e,t){t||=6;for(var n=US(e).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(US({h:r,s:i,v:a})),a=(a+s)%1;return o}US.mix=function(e,t,n){n=n===0?0:n||50;var r=US(e).toRgb(),i=US(t).toRgb(),a=n/100;return US({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},US.readability=function(e,t){var n=US(e),r=US(t);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},US.isReadable=function(e,t,n){var r=US.readability(e,t),i,a=!1;switch(i=bee(n),i.level+i.size){case`AAsmall`:case`AAAlarge`:a=r>=4.5;break;case`AAlarge`:a=r>=3;break;case`AAAsmall`:a=r>=7;break}return a},US.mostReadable=function(e,t,n){var r=null,i=0,a,o,s,c;n||={},o=n.includeFallbackColors,s=n.level,c=n.size;for(var l=0;li&&(i=a,r=US(t[l]));return US.isReadable(e,r,{level:s,size:c})||!o?r:(n.includeFallbackColors=!1,US.mostReadable(e,[`#fff`,`#000`],n))};var lC=US.names={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`0ff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`00f`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,burntsienna:`ea7e5d`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`0ff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`f0f`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`},hee=US.hexNames=gee(lC);function gee(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}function uC(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function dC(e,t){_ee(e)&&(e=`100%`);var n=vee(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function fC(e){return Math.min(1,Math.max(0,e))}function pC(e){return parseInt(e,16)}function _ee(e){return typeof e==`string`&&e.indexOf(`.`)!=-1&&parseFloat(e)===1}function vee(e){return typeof e==`string`&&e.indexOf(`%`)!=-1}function mC(e){return e.length==1?`0`+e:``+e}function hC(e){return e<=1&&(e=e*100+`%`),e}function gC(e){return Math.round(parseFloat(e)*255).toString(16)}function _C(e){return pC(e)/255}var vC=function(){var e=`(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)`,t=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`,n=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`;return{CSS_UNIT:new RegExp(e),rgb:RegExp(`rgb`+t),rgba:RegExp(`rgba`+n),hsl:RegExp(`hsl`+t),hsla:RegExp(`hsla`+n),hsv:RegExp(`hsv`+t),hsva:RegExp(`hsva`+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function yC(e){return!!vC.CSS_UNIT.exec(e)}function yee(e){e=e.replace(VS,``).replace(HS,``).toLowerCase();var t=!1;if(lC[e])e=lC[e],t=!0;else if(e==`transparent`)return{r:0,g:0,b:0,a:0,format:`name`};var n;return(n=vC.rgb.exec(e))?{r:n[1],g:n[2],b:n[3]}:(n=vC.rgba.exec(e))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=vC.hsl.exec(e))?{h:n[1],s:n[2],l:n[3]}:(n=vC.hsla.exec(e))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=vC.hsv.exec(e))?{h:n[1],s:n[2],v:n[3]}:(n=vC.hsva.exec(e))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=vC.hex8.exec(e))?{r:pC(n[1]),g:pC(n[2]),b:pC(n[3]),a:_C(n[4]),format:t?`name`:`hex8`}:(n=vC.hex6.exec(e))?{r:pC(n[1]),g:pC(n[2]),b:pC(n[3]),format:t?`name`:`hex`}:(n=vC.hex4.exec(e))?{r:pC(n[1]+``+n[1]),g:pC(n[2]+``+n[2]),b:pC(n[3]+``+n[3]),a:_C(n[4]+``+n[4]),format:t?`name`:`hex8`}:(n=vC.hex3.exec(e))?{r:pC(n[1]+``+n[1]),g:pC(n[2]+``+n[2]),b:pC(n[3]+``+n[3]),format:t?`name`:`hex`}:!1}function bee(e){var t,n;return e||={level:`AA`,size:`small`},t=(e.level||`AA`).toUpperCase(),n=(e.size||`small`).toLowerCase(),t!==`AA`&&t!==`AAA`&&(t=`AA`),n!==`small`&&n!==`large`&&(n=`small`),{level:t,size:n}}function bC(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(`FrameTicker`,[],r):typeof e==`object`?e.FrameTicker=r():n.FrameTicker=r()})(e,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){var r=n(1),i=function(){function e(e,t,n){e===void 0&&(e=NaN),t===void 0&&(t=NaN),n===void 0&&(n=!1),this._minFPS=t,this._maxFPS=e,this._timeScale=1,this._currentTick=0,this._currentTime=0,this._tickDeltaTime=0,this._isRunning=!1,this._maxInterval=isNaN(this._minFPS)?NaN:1e3/this._minFPS,this._minInterval=isNaN(this._maxFPS)?NaN:1e3/this._maxFPS,this._onResume=new r.default,this._onPause=new r.default,this._onTick=new r.default,this._onTickOncePerFrame=new r.default,n||this.resume()}return e.prototype.updateOnce=function(e){e(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},e.prototype.resume=function(){this._isRunning||(this._isRunning=!0,this._lastTimeUpdated=this.getTimer(),this._onResume.dispatch(),this.animateOnce())},e.prototype.pause=function(){this._isRunning&&(this._isRunning=!1,this._onPause.dispatch(),window.cancelAnimationFrame(this._animationFrameHandle))},e.prototype.dispose=function(){this.pause(),this._onResume.removeAll(),this._onPause.removeAll(),this._onTick.removeAll()},Object.defineProperty(e.prototype,"currentTick",{get:function(){return this._currentTick},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTimeSeconds",{get:function(){return this._currentTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tickDeltaTimeSeconds",{get:function(){return this._tickDeltaTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"timeScale",{get:function(){return this._timeScale},set:function(e){this._timeScale!==e&&(this._timeScale=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onResume",{get:function(){return this._onResume},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onPause",{get:function(){return this._onPause},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTick",{get:function(){return this._onTick},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTickOncePerFrame",{get:function(){return this._onTickOncePerFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRunning",{get:function(){return this._isRunning},enumerable:!0,configurable:!0}),e.prototype.animateOnce=function(){var e=this;this._animationFrameHandle=window.requestAnimationFrame(function(){return e.onFrame()})},e.prototype.onFrame=function(){if(this._now=this.getTimer(),this._frameDeltaTime=this._now-this._lastTimeUpdated,isNaN(this._minInterval)||this._frameDeltaTime>=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},e.prototype.update=function(e,t){t===void 0&&(t=!0),this._currentTick++,this._currentTime+=e,this._tickDeltaTime=e,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),t&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},e.prototype.getTimer=function(){return Date.now()},e}();Object.defineProperty(t,"__esModule",{value:!0}),t.default=i},function(e,t,n){(function(t,n){e.exports=n()})(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t){var n=function(){function e(){this.functions=[]}return e.prototype.add=function(e){return this.functions.indexOf(e)===-1&&(this.functions.push(e),!0)},e.prototype.remove=function(e){var t=this.functions.indexOf(e);return t>-1&&(this.functions.splice(t,1),!0)},e.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},e.prototype.dispatch=function(){var e=[...arguments];this.functions.concat().forEach(function(t){t.apply(void 0,e)})},Object.defineProperty(e.prototype,"numItems",{get:function(){return this.functions.length},enumerable:!0,configurable:!0}),e}();Object.defineProperty(t,"__esModule",{value:!0}),t.default=n}])})}])})}))(),1),FC=11102230246251565e-32,IC=134217729,LC=3.000000000000001*FC;function RC(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(dl==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);dl==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d=A||-k>=A||(d=e-T,s=e-(T+d)+(d-i),d=n-E,l=n-(E+d)+(d-i),d=t-D,c=t-(D+d)+(d-a),d=r-O,u=r-(O+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(A=HC*o+LC*Math.abs(k),k+=T*u+O*s-(D*l+E*c),k>=A||-k>=A))return k;b=s*O,f=IC*s,p=f-(f-s),m=s-p,f=IC*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=c*E,f=IC*c,p=f-(f-c),m=c-p,f=IC*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,qC[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,qC[1]=y-(_+d)+(d-S),w=v+_,d=w-v,qC[2]=v-(w-d)+(_-d),qC[3]=w;let j=RC(4,UC,4,qC,WC);b=T*u,f=IC*T,p=f-(f-T),m=T-p,f=IC*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=D*l,f=IC*D,p=f-(f-D),m=D-p,f=IC*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,qC[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,qC[1]=y-(_+d)+(d-S),w=v+_,d=w-v,qC[2]=v-(w-d)+(_-d),qC[3]=w;let M=RC(j,WC,4,qC,GC);return b=s*u,f=IC*s,p=f-(f-s),m=s-p,f=IC*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=IC*c,p=f-(f-c),m=c-p,f=IC*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,qC[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,qC[1]=y-(_+d)+(d-S),w=v+_,d=w-v,qC[2]=v-(w-d)+(_-d),qC[3]=w,KC[RC(M,GC,4,qC,KC)-1]}function YC(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=BC*l?c:-JC(e,t,n,r,i,a,l)}(7+56*FC)*FC,(3+28*FC)*FC,(26+288*FC)*FC*FC,zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(8),zC(8),zC(8),zC(4),zC(8),zC(8),zC(16),zC(12),zC(192),zC(192),(10+96*FC)*FC,(4+48*FC)*FC,(44+576*FC)*FC*FC,zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(8),zC(8),zC(8),zC(8),zC(8),zC(8),zC(8),zC(8),zC(8),zC(4),zC(4),zC(4),zC(8),zC(16),zC(16),zC(16),zC(32),zC(32),zC(48),zC(64),zC(1152),zC(1152),(16+224*FC)*FC,(5+72*FC)*FC,(71+1408*FC)*FC*FC,zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(4),zC(24),zC(24),zC(24),zC(24),zC(24),zC(24),zC(24),zC(24),zC(24),zC(24),zC(1152),zC(1152),zC(1152),zC(1152),zC(1152),zC(2304),zC(2304),zC(3456),zC(5760),zC(8),zC(8),zC(8),zC(16),zC(24),zC(48),zC(48),zC(96),zC(192),zC(384),zC(384),zC(384),zC(768),zC(96),zC(96),zC(96),zC(1152);var XC=2**-52,ZC=new Uint32Array(512),QC=class e{static from(t,n=ow,r=sw){let i=t.length,a=new Float64Array(i*2);for(let e=0;e>1;if(t>0&&typeof e[0]!=`number`)throw Error(`Expected coords to contain numbers.`);this.coords=e;let n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){let{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=e.length>>1,o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t=0;tc&&(c=n),r>l&&(l=r),this._ids[t]=t}let u=(o+c)/2,d=(s+l)/2,f=0,p=0,m=0;for(let t=0,n=1/0;t0&&(p=t,n=r)}let _=e[2*p],v=e[2*p+1],y=1/0;for(let t=0;tr&&(t[n++]=i,r=a)}this.hull=t.subarray(0,n),this.triangles=new Uint32Array,this.halfedges=new Int32Array;return}if(YC(h,g,_,v,b,x)<0){let e=p,t=_,n=v;p=m,_=b,v=x,m=e,b=t,x=n}let S=rw(h,g,_,v,b,x);this._cx=S.x,this._cy=S.y;for(let t=0;t0&&Math.abs(l-o)<=XC&&Math.abs(u-s)<=XC||(o=l,s=u,c===f||c===p||c===m))continue;let d=0;for(let e=0,t=this._hashKey(l,u);e=0;)if(h=g,h===d){h=-1;break}if(h===-1)continue;let _=this._addTriangle(h,c,n[h],-1,-1,r[h]);r[c]=this._legalize(_+2),r[h]=_,C++;let v=n[h];for(;g=n[v],YC(l,u,e[2*v],e[2*v+1],e[2*g],e[2*g+1])<0;)_=this._addTriangle(v,c,g,r[c],-1,r[v]),r[c]=this._legalize(_+2),n[v]=v,C--,v=g;if(h===d)for(;g=t[h],YC(l,u,e[2*g],e[2*g+1],e[2*h],e[2*h+1])<0;)_=this._addTriangle(g,c,h,-1,r[h],r[g]),this._legalize(_+2),r[g]=_,n[h]=h,C--,h=g;this._hullStart=t[c]=h,n[h]=t[v]=c,n[c]=v,i[this._hashKey(l,u)]=c,i[this._hashKey(e[2*h],e[2*h+1])]=h}this.hull=new Uint32Array(C);for(let e=0,t=this._hullStart;e0?3-n:1+n)/4}function ew(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function tw(e,t,n,r,i,a,o,s){let c=e-o,l=t-s,u=n-o,d=r-s,f=i-o,p=a-s,m=c*c+l*l,h=u*u+d*d,g=f*f+p*p;return c*(d*g-h*p)-l*(u*g-h*f)+m*(u*p-d*f)<0}function nw(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c),p=(l*u-s*d)*f,m=(o*d-c*u)*f;return p*p+m*m}function rw(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c);return{x:e+(l*u-s*d)*f,y:t+(o*d-c*u)*f}}function iw(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){let r=e[i],a=t[r],o=i-1;for(;o>=n&&t[e[o]]>a;)e[o+1]=e[o--];e[o+1]=r}else{let i=n+r>>1,a=n+1,o=r;aw(e,i,a),t[e[n]]>t[e[r]]&&aw(e,n,r),t[e[a]]>t[e[r]]&&aw(e,a,r),t[e[n]]>t[e[a]]&&aw(e,n,a);let s=e[a],c=t[s];for(;;){do a++;while(t[e[a]]c);if(o=o-n?(iw(e,t,a,r),iw(e,t,n,o-1)):(iw(e,t,n,o-1),iw(e,t,a,r))}}function aw(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function ow(e){return e[0]}function sw(e){return e[1]}function cw(e,t){var n,r,i=0,a,o,s,c,l,u,d,f=e[0],p=e[1],m=t.length;for(n=0;n=0||o<=0&&c>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(a=YC(o,c,s,l,0,0),a===0)return 0;(a>0&&l>0&&s<=0||a<0&&l<=0&&s>0)&&i++}u=d,s=l,o=c}}return i%2!=0}function lw(e){if(!e)throw Error(`coord is required`);if(!Array.isArray(e)){if(e.type===`Feature`&&e.geometry!==null&&e.geometry.type===`Point`)return[...e.geometry.coordinates];if(e.type===`Point`)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw Error(`coord must be GeoJSON Point or an Array of numbers`)}function uw(e){return e.type===`Feature`?e.geometry:e}function dw(e,t,n={}){if(!e)throw Error(`point is required`);if(!t)throw Error(`polygon is required`);let r=lw(e),i=uw(t),a=i.type,o=t.bbox,s=i.coordinates;if(o&&fw(r,o)===!1)return!1;a===`Polygon`&&(s=[s]);let c=!1;for(var l=0;l=e[0]&&t[3]>=e[1]}var pw=dw,mw=1e-6,hw=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=``}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;let r=e+n,i=t;if(n<0)throw Error(`negative radius`);this._x1===null?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>mw||Math.abs(this._y1-i)>mw)&&(this._+=`L`+r+`,`+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}},gw=class{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}},_w=class{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((i=+i)>=(n=+n)))throw Error(`invalid bounds`);this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){let{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i,a,o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r=0,s=0,c=n.length,l,u;r1;)i-=2;for(let e=2;e0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function Cw(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}var ww=class e{static from(t,n=bw,r=xw,i){return new e(`length`in t?Tw(t,n,r,i):Float64Array.from(Ew(t,n,r,i)))}constructor(e){this._delaunator=new QC(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){let e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&Sw(e)){this.collinear=Int32Array.from({length:t.length/2},(e,t)=>t).sort((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]);let e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new _w(this,e)}*neighbors(e){let{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:a,collinear:o}=this;if(o){let t=o.indexOf(e);t>0&&(yield o[t-1]),t=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){let{inedges:r,hull:i,_hullIndex:a,halfedges:o,triangles:s,points:c}=this;if(r[e]===-1||!c.length)return(e+1)%(c.length>>1);let l=e,u=yw(t-c[e*2],2)+yw(n-c[e*2+1],2),d=r[e],f=d;do{let r=s[f],d=yw(t-c[r*2],2)+yw(n-c[r*2+1],2);if(d0?1:e<0?-1:0},Lw=Math.sqrt;function Rw(e){return e>1?Ow:e<-1?-Ow:Math.asin(e)}function zw(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Bw(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Vw(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function Hw(e){var t=Lw(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]}function Uw(e){return[jw(e[1],e[0])*kw,Rw(Nw(-1,Pw(1,e[2])))*kw]}function Ww(e){let t=e[0]*Aw,n=e[1]*Aw,r=Mw(n);return[r*Mw(t),r*Fw(t),Fw(n)]}function Gw(e){return e=e.map(e=>Ww(e)),zw(e[0],Bw(e[2],e[1]))}function Fee(e){let t=qw(e),n=Yw(t),r=Jw(n,e),i=Zw(n,e.length),a=Kw(i,e),{polygons:o,centers:s}=Iee(Xw(n,e),n,e);return{delaunay:t,edges:r,triangles:n,centers:s,neighbors:i,polygons:o,mesh:$w(o),hull:tT(n,e),urquhart:eT(r,n),find:a}}function Kw(e,t){function n(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return n*n+r*r+i*i}return function(r,i,a){a===void 0&&(a=0);let o,s,c=a,l=Ww([r,i]);do o=a,a=null,s=n(l,Ww(t[o])),e[o].forEach(e=>{let r=n(l,Ww(t[e]));if(r1e32?i.push(t):n>a&&(a=n)}let o=1e6*Lw(a);i.forEach(t=>e[t]=[o,0]),e.push([0,o]),e.push([-o,0]),e.push([0,-o]);let s=ww.from(e);s.projection=r;let{triangles:c,halfedges:l,inedges:u}=s,d=[];for(let n=0,r=l.length;ne.length-3-1&&(c[n]=t);return s}function Jw(e,t){let n=new Set;return t.length===2?[[0,1]]:(e.forEach(e=>{if(e[0]!==e[1]&&!(Gw(e.map(e=>t[e]))<0))for(let t=0,r;t<3;t++)r=(t+1)%3,n.add(km([e[t],e[r]]).join(`-`))}),Array.from(n,e=>e.split(`-`).map(Number)))}function Yw(e){let{triangles:t}=e;if(!t)return[];let n=[];for(let e=0,r=t.length/3;e{let n=e.map(e=>t[e]).map(Ww);return Uw(Hw(Vw(Vw(Bw(n[1],n[0]),Bw(n[2],n[1])),Bw(n[0],n[2]))))})}function Zw(e,t){let n=[];return e.forEach(e=>{for(let t=0;t<3;t++){let r=e[t],i=e[(t+1)%3];n[r]=n[r]||[],n[r].push(i)}}),e.length===0&&(t===2?(n[0]=[1],n[1]=[0]):t===1&&(n[0]=[])),n}function Iee(e,t,n){let r=[],i=e.slice();if(t.length===0){if(n.length<2)return{polygons:r,centers:i};if(n.length===2){let e=Ww(n[0]),t=Ww(n[1]),a=Hw(Vw(e,t)),s=Bw(a,Hw(Bw(e,t))),c=[a,Bw(a,s),Bw(Bw(a,s),s),Bw(Bw(Bw(a,s),s),s)].map(Uw).map(o);return r.push(c),r.push(c.slice().reverse()),{polygons:r,centers:i}}}t.forEach((e,t)=>{for(let n=0;n<3;n++){let i=e[n],a=e[(n+1)%3],o=e[(n+2)%3];r[i]=r[i]||[],r[i].push([a,o,t,[i,a,o]])}});let a=r.map(e=>{let t=[e[0][2]],r=e[0][1];for(let n=1;n2)return t;if(t.length==2){let r=Qw(n[e[0][3][0]],n[e[0][3][1]],i[t[0]]),a=Qw(n[e[0][3][2]],n[e[0][3][0]],i[t[0]]),s=o(r),c=o(a);return[t[0],c,t[1],s]}});function o(e){let n=-1;return i.slice(t.length,1/0).forEach((r,i)=>{r[0]===e[0]&&r[1]===e[1]&&(n=i+t.length)}),n<0&&(n=i.length,i.push(e)),n}return{polygons:a,centers:i}}function Qw(e,t,n){e=Ww(e),t=Ww(t),n=Ww(n);let r=Iw(zw(Bw(t,e),n));return Uw(Hw(Vw(e,t)).map(e=>r*e))}function $w(e){let t=[];return e.forEach(e=>{if(!e)return;let n=e[e.length-1];for(let r of e)r>n&&t.push([n,r]),n=r}),t}function eT(e,t){return function(n){let r=new Map,i=new Map;return e.forEach((e,t)=>{let a=e.join(`-`);r.set(a,n[t]),i.set(a,!0)}),t.forEach(e=>{let t=0,n=-1;for(let i=0;i<3;i++){let a=km([e[i],e[(i+1)%3]]).join(`-`);r.get(a)>t&&(t=r.get(a),n=a)}i.set(n,!1)}),e.map(e=>i.get(e.join(`-`)))}}function tT(e,t){let n=new Set,r=[];e.map(e=>{if(!(Gw(e.map(e=>t[e>t.length?0:e]))>1e-12))for(let t=0;t<3;t++){let r=[e[t],e[(t+1)%3]],i=`${r[0]}-${r[1]}`;n.has(i)?n.delete(i):n.add(`${r[1]}-${r[0]}`)}});let i=new Map,a;if(n.forEach(e=>{e=e.split(`-`).map(Number),i.set(e[0],e[1]),a=e[0]}),a===void 0)return r;let o=a;do{r.push(o);let e=i.get(o);i.set(o,-1),o=e}while(o>-1&&o!==a);return r}function nT(e){let t=function(e){if(t.delaunay=null,t._data=e,typeof t._data==`object`&&t._data.type===`FeatureCollection`&&(t._data=t._data.features),typeof t._data==`object`){let e=t._data.map(e=>[t._vx(e),t._vy(e),e]).filter(e=>isFinite(e[0]+e[1]));t.points=e.map(e=>[e[0],e[1]]),t.valid=e.map(e=>e[2]),t.delaunay=Fee(t.points)}return t};return t._vx=function(e){if(typeof e==`object`&&`type`in e)return Dv(e)[0];if(0 in e)return e[0]},t._vy=function(e){if(typeof e==`object`&&`type`in e)return Dv(e)[1];if(1 in e)return e[1]},t.x=function(e){return e?(t._vx=e,t):t._vx},t.y=function(e){return e?(t._vy=e,t):t._vy},t.polygons=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let n={type:`FeatureCollection`,features:[]};return t.valid.length===0?n:(t.delaunay.polygons.forEach((e,r)=>n.features.push({type:`Feature`,geometry:e?{type:`Polygon`,coordinates:[[...e,e[0]].map(e=>t.delaunay.centers[e])]}:null,properties:{site:t.valid[r],sitecoordinates:t.points[r],neighbours:t.delaunay.neighbors[r]}})),t.valid.length===1&&n.features.push({type:`Feature`,geometry:{type:`Sphere`},properties:{site:t.valid[0],sitecoordinates:t.points[0],neighbours:[]}}),n)},t.triangles=function(e){return e!==void 0&&t(e),t.delaunay?{type:`FeatureCollection`,features:t.delaunay.triangles.map((e,n)=>(e=e.map(e=>t.points[e]),e.center=t.delaunay.centers[n],e)).filter(e=>Gw(e)>0).map(e=>({type:`Feature`,properties:{circumcenter:e.center},geometry:{type:`Polygon`,coordinates:[[...e,e[0]]]}}))}:!1},t.links=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let n=t.delaunay.edges.map(e=>uy(t.points[e[0]],t.points[e[1]])),r=t.delaunay.urquhart(n);return{type:`FeatureCollection`,features:t.delaunay.edges.map((e,i)=>({type:`Feature`,properties:{source:t.valid[e[0]],target:t.valid[e[1]],length:n[i],urquhart:!!r[i]},geometry:{type:`LineString`,coordinates:[t.points[e[0]],t.points[e[1]]]}}))}},t.mesh=function(e){return e!==void 0&&t(e),t.delaunay?{type:`MultiLineString`,coordinates:t.delaunay.edges.map(e=>[t.points[e[0]],t.points[e[1]]])}:!1},t.cellMesh=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let{centers:n,polygons:r}=t.delaunay,i=[];for(let e of r)if(e)for(let t=e.length,r=e[t-1],a=e[0],o=0;or&&i.push([n[r],n[a]]);return{type:`MultiLineString`,coordinates:i}},t._found=void 0,t.find=function(e,n,r){if(t._found=t.delaunay.find(e,n,t._found),!r||uy([e,n],t.points[t._found])r[e]),r[n[0]]]]}},e?t(e):t}function rT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&arguments[1]!==void 0?arguments[1]:{}).resolution,n=t===void 0?1/0:t,r=bT(e,n),i=Vm(r),a=xT(e,n),o=[].concat(_T(i),_T(a)),s={type:`Polygon`,coordinates:e},c=gT($_(s),2),l=gT(c[0],2),u=l[0],d=l[1],f=gT(c[1],2),p=f[0],m=f[1],h=u>p||m>=89||d<=-89,g=[];if(h){var _=nT(o).triangles(),v=new Map(o.map(function(e,t){var n=gT(e,2);return[`${n[0]}-${n[1]}`,t]}));_.features.forEach(function(e){var t,n=e.geometry.coordinates[0].slice(0,3).reverse(),r=[];if(n.forEach(function(e){var t=gT(e,2),n=`${t[0]}-${t[1]}`;v.has(n)&&r.push(v.get(n))}),r.length===3){if(r.some(function(e){return et)for(var a=wy(r,e),o=1/Math.ceil(i/t),s=o;s<1;)n.push(a(s)),s+=o}n.push(r=e)}),n})}function xT(e,t){var n={type:`Polygon`,coordinates:e},r=gT($_(n),2),i=gT(r[0],2),a=i[0],o=i[1],s=gT(r[1],2),c=s[0],l=s[1];if(Math.min(Math.abs(c-a),Math.abs(l-o))c||l>=89||o<=-89;return ST(t,{minLng:a,maxLng:c,minLat:o,maxLat:l}).filter(function(e){return CT(e,n,u)})}function ST(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.minLng,r=t.maxLng,i=t.minLat,a=t.maxLat,o=Math.round((360/e)**2/Math.PI),s=(1+Math.sqrt(5))/2,c=function(e){return e/s*360%360-180},l=function(e){return Math.acos(2*e/o-1)/Math.PI*180-90},u=function(e){return o*(Math.cos((e+90)*Math.PI/180)+1)/2},d=[a===void 0?0:Math.ceil(u(a)),i===void 0?o-1:Math.floor(u(i))],f=n===void 0&&r===void 0?function(){return!0}:n===void 0?function(e){return e<=r}:r===void 0?function(e){return e>=n}:r>=n?function(e){return e>=n&&e<=r}:function(e){return e>=n||e<=r},p=[],m=d[0];m<=d[1];m++){var h=c(m);f(h)&&p.push([h,l(m)])}return p}function CT(e,t){return arguments.length>2&&arguments[2]!==void 0&&arguments[2]?yy(t,e):pw(e,t)}var wT=window.THREE?window.THREE:{BufferGeometry:Wi,Float32BufferAttribute:Mi},TT=new wT.BufferGeometry().setAttribute?`setAttribute`:`addAttribute`,ET=function(e){function t(e,n,r,i,a,o,s){var c;oT(this,t),c=Ree(this,t),c.type=`ConicPolygonGeometry`,c.parameters={polygonGeoJson:e,bottomHeight:n,topHeight:r,closedBottom:i,closedTop:a,includeSides:o,curvatureResolution:s},n||=0,r||=1,i=i===void 0||i,a=a===void 0||a,o=o===void 0||o,s||=5;var l=yT(e,{resolution:s}),u=l.contour,d=l.triangles,f=Vm(d.uvs),p=[],m=[],h=[],g=0,_=function(e){var t=Math.round(p.length/3),n=h.length;p=p.concat(e.vertices),m=m.concat(e.uvs),h=h.concat(t?e.indices.map(function(e){return e+t}):e.indices),c.addGroup(n,h.length-n,g++)};o&&_(y()),i&&_(b(n,!1)),a&&_(b(r,!0)),c.setIndex(h),c[TT](`position`,new wT.Float32BufferAttribute(p,3)),c[TT](`uv`,new wT.Float32BufferAttribute(m,2)),c.computeVertexNormals();function v(e,t){var n=typeof t==`function`?t:function(){return t};return Qx(e.map(function(e){return e.map(function(e){var t=gT(e,2),r=t[0],i=t[1];return DT(i,r,n(r,i))})}))}function y(){for(var e=v(u,n),t=e.vertices,i=e.holes,a=v(u,r).vertices,o=Vm([a,t]),s=Math.round(a.length/3),c=new Set(i),l=0,d=[],f=0;f=0;g--)for(var _=0;_1&&arguments[1]!==void 0)||arguments[1]?d.indices:d.indices.slice().reverse(),vertices:v([d.points],e).vertices,uvs:f}}return c}return lT(t,e),sT(t)}(wT.BufferGeometry);function DT(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}function OT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3&&arguments[3]!==void 0&&arguments[3],i=(t instanceof Array?t.length?t:[void 0]:[t]).map(function(e){return{keyAccessor:e,isProp:!(e instanceof Function)}}),a=e.reduce(function(e,t){var r=e,a=t;return i.forEach(function(e,t){var o=e.keyAccessor,s=e.isProp,c;if(s){var l=a,u=l[o],d=FT(l,[o].map(BT));c=u,a=d}else c=o(a,t);t+11&&arguments[1]!==void 0?arguments[1]:1;r===i.length?Object.keys(t).forEach(function(e){return t[e]=n(t[e])}):Object.values(t).forEach(function(t){return e(t,r+1)})})(a);var o=a;return r&&(o=[],(function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];n.length===i.length?o.push({keys:n,vals:t}):Object.entries(t).forEach(function(t){var r=LT(t,2),i=r[0],a=r[1];return e(a,[].concat(RT(n),[i]))})})(a),t instanceof Array&&t.length===0&&o.length===1&&(o[0].keys=[])),o}),UT=function(e){e||={};var t=e===void 0?{}:e,n={},r;for(r in t)t.hasOwnProperty(r)&&(n[r]=t[r]);var i=[],a=``;function o(e){return t.locateFile?t.locateFile(e,a):a+e}var s;typeof document<`u`&&document.currentScript&&(a=document.currentScript.src),a=a.indexOf(`blob:`)===0?``:a.substr(0,a.lastIndexOf(`/`)+1),s=function(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=function(){if(r.status==200||r.status==0&&r.response){t(r.response);return}var i=Ve(e);if(i){t(i.buffer);return}n()},r.onerror=n,r.send(null)};var c=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(r in n)n.hasOwnProperty(r)&&(t[r]=n[r]);n=null,t.arguments&&(i=t.arguments);var u=0,d=function(e){u=e},f=function(){return u},p=8;function m(e,t,n,r){switch(n||=`i8`,n.charAt(n.length-1)===`*`&&(n=`i32`),n){case`i1`:k[e>>0]=t;break;case`i8`:k[e>>0]=t;break;case`i16`:j[e>>1]=t;break;case`i32`:M[e>>2]=t;break;case`i64`:Ee=[t>>>0,(Te=t,+me(Te)>=1?Te>0?(_e(+ge(Te/4294967296),4294967295)|0)>>>0:~~+he((Te-+(~~Te>>>0))/4294967296)>>>0:0)],M[e>>2]=Ee[0],M[e+4>>2]=Ee[1];break;case`float`:N[e>>2]=t;break;case`double`:P[e>>3]=t;break;default:Qe(`invalid type for setValue: `+n)}}function h(e,t,n){switch(t||=`i8`,t.charAt(t.length-1)===`*`&&(t=`i32`),t){case`i1`:return k[e>>0];case`i8`:return k[e>>0];case`i16`:return j[e>>1];case`i32`:return M[e>>2];case`i64`:return M[e>>2];case`float`:return N[e>>2];case`double`:return P[e>>3];default:Qe(`invalid type for getValue: `+t)}return null}var g=!1;function _(e,t){e||Qe(`Assertion failed: `+t)}function v(e){var n=t[`_`+e];return _(n,`Cannot call unknown function `+e+`, make sure it is exported`),n}function y(e,t,n,r,i){var a={string:function(e){var t=0;if(e!=null&&e!==0){var n=(e.length<<2)+1;t=Ue(n),T(e,t,n)}return t},array:function(e){var t=Ue(e.length);return E(e,t),t}};function o(e){return t===`string`?C(e):t===`boolean`?!!e:e}var s=v(e),c=[],l=0;if(r)for(var u=0;u=r);)++i;if(i-t>16&&e.subarray&&x)return x.decode(e.subarray(t,i));for(var a=``;t>10,56320|l&1023)}}return a}function C(e,t){return e?S(A,e,t):``}function w(e,t,n,r){if(!(r>0))return 0;for(var i=n,a=n+r-1,o=0;o=55296&&s<=57343){var c=e.charCodeAt(++o);s=65536+((s&1023)<<10)|c&1023}if(s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|s&63}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|s&63}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|s&63}}return t[n]=0,n-i}function T(e,t,n){return w(e,A,t,n)}typeof TextDecoder<`u`&&new TextDecoder(`utf-16le`);function E(e,t){k.set(e,t)}function D(e,t){return e%t>0&&(e+=t-e%t),e}var O,k,A,j,M,N,P;function ee(e){O=e,t.HEAP8=k=new Int8Array(e),t.HEAP16=j=new Int16Array(e),t.HEAP32=M=new Int32Array(e),t.HEAPU8=A=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=new Uint32Array(e),t.HEAPF32=N=new Float32Array(e),t.HEAPF64=P=new Float64Array(e)}var F=5271296,te=28384,ne=t.TOTAL_MEMORY||33554432;O=t.buffer?t.buffer:new ArrayBuffer(ne),ne=O.byteLength,ee(O),M[te>>2]=F;function re(e){for(;e.length>0;){var n=e.shift();if(typeof n==`function`){n();continue}var r=n.func;typeof r==`number`?n.arg===void 0?t.dynCall_v(r):t.dynCall_vi(r,n.arg):r(n.arg===void 0?null:n.arg)}}var ie=[],ae=[],oe=[],se=[];function ce(){if(t.preRun)for(typeof t.preRun==`function`&&(t.preRun=[t.preRun]);t.preRun.length;)fe(t.preRun.shift());re(ie)}function le(){re(ae)}function ue(){re(oe)}function de(){if(t.postRun)for(typeof t.postRun==`function`&&(t.postRun=[t.postRun]);t.postRun.length;)pe(t.postRun.shift());re(se)}function fe(e){ie.unshift(e)}function pe(e){se.unshift(e)}var me=Math.abs,he=Math.ceil,ge=Math.floor,_e=Math.min,ve=0,ye=null,be=null;function xe(e){ve++,t.monitorRunDependencies&&t.monitorRunDependencies(ve)}function Se(e){if(ve--,t.monitorRunDependencies&&t.monitorRunDependencies(ve),ve==0&&(ye!==null&&(clearInterval(ye),ye=null),be)){var n=be;be=null,n()}}t.preloadedImages={},t.preloadedAudios={};var I=null,Ce=`data:application/octet-stream;base64,`;function we(e){return String.prototype.startsWith?e.startsWith(Ce):e.indexOf(Ce)===0}var Te,Ee;I=`data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAABgtRFT7IQlAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCUAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAABgtRFT7IQnAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCcAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAMpi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAABAAAAAAEAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAOgehWlKfUEEz1zLi+JsiQa2og3wcMfVAWCbHorc0yEDi+Yn/Y6mbQJ11/mfsnG9At6bnG4UQQkBvMCQWKqUUQJVmwwswmOc/3hVgVBL3uj//qqOEOdGOPw/WDN4gnGE/H3ANkCUgND+AA8btKgAHPwTXBqJVSdo+XfRQAqsKrj4fc+zLYbSPQklEmCZHv2FCUP+uDso1NEKYtPhwphUHQptxnyFXYdpB7CddZAMmrkGAt1AxSTqBQUibBVdTsFNBSuX3MV+AJkFocv82SLf5QAqmgj7AY81A23VDSEnLoEDGEJVSeDFzQDYrqvBk70VA8U157pcRGUBWfEF+ZKbsP6phvycGBZRAJbod0OgwfkCp+L8jatBmQCjl3pGrPlFAfMWm114SOkButwtqS7UjQHQwbcjXyw1A8jnLuuyA9j9KwjL0VwHhPyotk0lcs8k/Q5PvEs9rsz+SfsOQEVqdPzUAKDojLoY/WJz/kcjCcD8YFu070FRZPyoLC2BdJEM/YOXQAuiMM0HIBz1bw3sdQdV46aaHRwZByatzjDPX8EDb3Jie8HXZQCJxj6ULP8NAUaG6uRAZrUCWdmou5/mVQLb9huRPm4BAhvoCHygZaUCuX/I3SPdSQC9/bC/1qTxAfKxsYQ6pJUCuslH+N14QQMS/cv7SvPg/Ol8maYKx4j8AAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAD/////AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAP////8AAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////BQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAEAAQAAAQEAAAAAAAEAAAABAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAKriWFiWZfg/Y2nmTbY/8z8MHSPSqmnjv6hnn18HR3c/quJYWJZl+D/jq5TzDdzyPwwdI9KqaeO/u0kC1eFSBECq4lhYlmX4P69pJmt7c/E/NnkJi6jSBsDESFlzKkr6P33ArMz7sfY/o2q2uqM08D+oZ59fB0d3PzEqCi3qrvK/kmm4ANp49D+4wS2wzhzvP9WJvyAnx+E/upcY75RVx7+95t+9y0T1P9L18g1caO0/k6CkRyVzAEBf99+e/GjxP6QMsuuLQ/U/PlP4Qr8q7j8Mb/GO2GMCwLl2K/DQIghAePiwytEp9D9UHrsuI/nqPzjMedJ+yuy/k6xgf58n/L+XoQtn22DzP2lzCnsYk+s/JhUSDI4P8z+8lFcBhgTcPxOqKRxEX/M/89MEdoPQ6j8OKQaXDob7vzWwNvblgAPAzGkxMcl88j9Nm4okPkbpP0vI89vxSgRAdac2Z6W2/T+6UFOMC3zyP/+2XEF3hug/QqhELwGKCMAwdlQerEoEQFcr/B+VnvE/hB1hfFzT5j8wdsE/Da64P0hIvnF/sOC/KH/hrXUg8T9bI5OQHaLlP+mYzla7td6/CtKG6iOm8b8FW3TV8oXwP8ORhtNuJ+c/q8JrTMz/AcC8PaUl+PUFwAXv9rkMT/A/m+sAswr15D+7hk/O3yvkP6c/yVsOHKI/qqAX9idJ8D/8hNz1KNPiP7xSXh3Ggvg/epbkiKr57T/23/LB1GLvP4GTTeNZi+M/W4TqlTheBcDupZgIdYUIQGwlcW3YZO8/tQvDXQ3H4j8Bt+sf9DkAQMdFie+nNvg/Z5Uh1wDX7j9h5X2d4KjhPxMJ1ZVT4Pa/evqB8xB//7+W183U9QLsPwzNxsC7AOA/af/LqCnK/r/lPceQ0FQDwHoY0nYIW+w/bHNSHrTg4D/DFcMAdabuv2sz5Ojhnve/FvLf01HN6z/tEDL2Hz/gP0bBv0KUhPA/pd7sEnMc4D8EGon4Lo7sP5NVbYtSON8/DAMC50odBkB+Z2J8MGYCQIhlM1gubOo/FssiPwWy4D8OIlGqRnkCQAd1vopp6f4/QS1keLLK6T9rfoBuT7LZP3KQbH5ugwjAjqVPXTmbBUBL/JxcqR3qP3oSeovuktg/Y6pRhJmqy7+0kwuU0Yjmv2wvsfFmQ+g/R98lJFqQ2T/IGb5gjLkCwK3mNff3kQbAqDznPFM86T+iiP0FfsvYP7fzKG6Mls0/h7+at2btzL8tsUTgk+LmP/YEIrTDINU/WmwKoVjA5L9aC02r6FHxvzzFCT/Qg+Y/nx0V97en0j8+1toJOm77P1kZ7h8KjfQ/GBbbqxgk5j9RGXM79G/SP+beHsWmweQ/9REi4eX0xD/V9s+kmMHkP+pb9yNs09A/c5ERjVDTAECqEr3OBCH7P14ILfMECOU/piRx4P8P0j+JYU//bfL0Pw62fw28B+w/l5YW2Ga45D9+CyKRbenOP5cH6fHy1/S/o/egk03++r91nTYRL/bjP3fHN6OJVdA/7xXQh1XLBcAB3g6tBdUIQKW2KnGYjeQ/SqIpagclyz8F9P3YgNL6v9H6NBsZ8QDAW2k5L5Qs4z/0axa1l6zLP1GE65Mu4wNAwfX+BYmWAEBBgJP90M3hP6/03qhPLdA/zqo5bJz2778/ESlPCTn1v7JkhGyvzuE/DM7sj5twwz/6xbXLavYGQH29RFRGkgNA7bOXVSJ54T9fEhTHO/TDP+8t+HMOiwDAxa0SbGTtA8Atii7y0mLgP4cecHFB3sM/uPUpyv+K7j8nktD1/WvhP2cWmi772d8/Fj7uU9kEvD8oKOESLzKmvwSdCqrHdNu/XCluGsvI3T929OW5md+uP9dP6rXcZNq/gXM+ggzL6b+eKjsPgJncP6i1e9aVu7E/2CnPNJyD1D/DnyGgSe+xvy8k7g9bp9s/nYmLvHn1sz9cFOwApH8IwGa6Mjy9cgZAJr95SiSW2z8rCkhOFvqdP3SIKmO/UwPAEy0zkN7bBsCds8Hg/13YP1zv413hVGi/FVtqixSn6L9XAPQGul3yv7SGu2BoCNk/n94bv7Maj79p13T6X9z3P45MPCW3WvI/rU/8/LRj1T9cgR6SXd+ZPymL2DstbPI/8s/pAkIz6z/fmoB+8efYPz2XyfWgYaa/6wys72AW/j8LZImhgrf3P729Zla/n9U/ySB8B3PBqL8O2nhevvbxv17+5A+n6fe/YrGIqEGB1T+wCEGbkhaxv989QHVE5wFAzd12PTu3/T9AHUPZY2DUP3SQDST0zq2/JCxAlIoj5T+Mhe1IJkrQP/cRpl8QhtU/amc4seFts79khiUSVaz3vxYfWtjPwf2/CHscxQqD0j/ctUBQ9my3v0POnFiyXv2/pjjn2Ju/AcDk45DwBhPRP/GjwlCrv7m/aT2ciwolBsAQOzHr/wUJQCzpq5UYvtI/gDCf3SlCwb+4i7S+mukEQBDA1f8mowFA2utnRN3KyT9T+9EYAVG6v9/IVZ0enrE/7NbRtdGfzr/8y8GpRz7LP3U0vTSk18e/JzHEcwiBB0AGm8Q7AJkEQNLciyt4Esk/gLou5zoQxr+RrOfM91oBwEzd36KybgTAgLou5zoQxj/S3IsreBLJv1gCch0OHO8/FD+RxSLN4j91NL00pNfHP/zLwalHPsu/nL7/By4Pyr8tSP5h7CPiv1P70RgBUbo/2utnRN3Kyb/KfllfCpUIwLkP5zj+NwdAgDCf3SlCwT8s6auVGL7Sv2aFPlaC4eC/XrS5UVH77b/xo8JQq7+5P+TjkPAGE9G/Q30/RYbn1z8FF/ISafuLv9y1QFD2bLc/CHscxQqD0r/fi+tPROX0P6vRc+19ie0/amc4seFtsz/3EaZfEIbVv77TYpahl/o/DDsu0CaC9D90kA0k9M6tP0AdQ9ljYNS/CCI0rxjZA8BgfCaLthgHwLAIQZuSFrE/YrGIqEGB1b8kvQ982+rsv4J8EWu7jPS/ySB8B3PBqD+9vWZWv5/VvwrAByWcJgBAxFujmE9a+j89l8n1oGGmP9+agH7x59i/N03cuJUt9L8X9v4GdIz6v1yBHpJd35m/rU/8/LRj1b8mz69sydf/vyu5idMqVQLAn94bv7Majz8AhrtgaAjZv+aCE66WZ/q/lA1Mgz/p/79c7+Nd4VRoP52zweD/Xdi/TJZpMTb4AkDLWZShPOb/PysKSE4W+p2/Jr95SiSW27/PkmbE7zjnP6UAiCDmMNI/nYmLvHn1s78vJO4PW6fbv5MWA2vqSrQ/V5WLwPB51b+otXvWlbuxv54qOw+Amdy/1keqzYeRBsApIEMHgZIIQHb05bmZ366/XCluGsvI3b8W44a9X9UFQEeQtDM4rwJAFj7uU9kEvL9nFpou+9nfv3Co+JcyyQhAcdkCX2KzBUCHHnBxQd7Dvy2KLvLSYuC/o6+5YTt/AcCHCNDW+8YEwF8SFMc79MO/7bOXVSJ54b9E/pfA2S3xPzD9xaBb0uQ/DM7sj5tww7+yZIRsr87hv7c4c0SEXNG/Tr79/9M+5r+v9N6oTy3Qv5uAk/3QzeG/XcI1OVQkAUAQSV9Z7Qr9P/RrFrWXrMu/W2k5L5Qs479Zo2IBM/vkv6FuipzkFvG/SqIpagcly7+ltipxmI3kv0pmis91cfc/gWQecsRh8D93xzejiVXQv3WdNhEv9uO/D7mgYy612j+PyVPNaT2jv34LIpFt6c6/l5YW2Ga45L+LUp+2A2z9P39i5xSpRfc/piRx4P8P0r9eCC3zBAjlv5n4OKmIUf2/jj/kUAwgAsDqW/cjbNPQv9X2z6SYweS/aTdljlWd8L94R8vZ8SL3v1EZczv0b9K/GBbbqxgk5r9XdfyikfEDwPILMvas0gfAnx0V97en0r88xQk/0IPmvxGErZ681fa/9kCaiOy2/b/2BCK0wyDVvy2xROCT4ua/+5EBLOXxA0B7p53+BnkAQKKI/QV+y9i/qDznPFM86b/snWGNkkgHwC+ByugkUwdAR98lJFqQ2b9sL7HxZkPovyJNGM67oek/HzNy6BqA1D96EnqL7pLYv0v8nFypHeq/axL/u1FnB0AkSEHvxn8DQGt+gG5Pstm/QS1keLLK6b/Sk/O6mtGzPxU8pLcPNty/FssiPwWy4L+IZTNYLmzqvw4szKfSouq/G+XJHY1a87+TVW2LUjjfvwQaifgujuy/3VARaoMl2L9NFodfK+/qv+0QMvYfP+C/FvLf01HN67+ETOQysd8AwH71iI/eGgXAbHNSHrTg4L96GNJ2CFvsv6BnExReeAFA5CakvxSl+j8MzcbAuwDgv5bXzdT1Auy/uVq8/8x58z+uvPMNqzTnP2HlfZ3gqOG/Z5Uh1wDX7r8PUbMSo2P7P9VfBrXlxPI/tQvDXQ3H4r9sJXFt2GTvvyDssGgO0PG/WxT/uE4N+r+Bk03jWYvjv/bf8sHUYu+/rUXN8hUe3j9m5HB1yZCzv/yE3PUo0+K/qqAX9idJ8L9mByqLMMH5v4kHC7KQowHAm+sAswr15L8F7/a5DE/wv2JLsGADFwTAKQjVGovZCMDDkYbTbifnvwVbdNXyhfC/malhH7yI7D+oevd0GWDZP1sjk5AdouW/KH/hrXUg8b8KWmrpQ0sFQAzEAF/pTgBAhB1hfFzT5r9XK/wflZ7xv18hRuqKXAjA/5rUd9v1BED/tlxBd4bov7pQU4wLfPK/4pnwn0T/sj/c277XPF3jv02biiQ+Rum/zGkxMcl88r8Yk0HhJVzjv62yUUFRjfS/89MEdoPQ6r8TqikcRF/zvxQxghHovfY/cfM1eFWE5j9pcwp7GJPrv5ehC2fbYPO/KUV2nGg0/795OhmUaqEFwFQeuy4j+eq/ePiwytEp9L8DuqWfW+8BQLytJylXHPY/PlP4Qr8q7r+kDLLri0P1vxT4ShWL+Oo/DMsWg0zlv7/S9fINXGjtv73m373LRPW/+xg/Gaxd8b94MdQEfW0AwLjBLbDOHO+/kmm4ANp49L+cShSMMbAEwKyjUgWirAdAo2q2uqM08L99wKzM+7H2v3RdlNBXFgnA8S9+ewyV/z+vaSZre3Pxv6riWFiWZfi/2J7VSZZ60j+LES81zPn3v+OrlPMN3PK/quJYWJZl+L/OZbufkEcEQLCNB/1lPOO/Y2nmTbY/87+q4lhYlmX4v7CNB/1lPOO/zmW7n5BHBEBwKD1Aa57LP/XsSsw7RbU/PMDPJGsfoD/TqningGKIPzFtCLYmb3I/qYfrJr7eWz9pQmleXRFFP0rWlJkA2i8/pCvcttgTGD9Dt8IWbjMCPyCG4GRlhOs+1JI2GhDN1D7ns8cGvXK/Pi8m8UTJxac+hNTfA2z4kT7GI8kjLyt7Pv//////HwAI//////8zEAj/////fzIgCP////9vMjAI/////2MyQAj///8/YjJQCP///zdiMmAI////M2IycAj//78zYjKACP//qzNiMpAI/3+rM2IyoAj/D6szYjKwCP8DqzNiMsAIvwOrM2Iy0AifA6szYjLgCJkDqzNiMvAI//////8/Dwj//////ysfCP////9/KS8I/////z8pPwj/////OSlPCP///z84KV8I////Dzgpbwj///8OOCl/CP//Hw44KY8I//8PDjgpnwj/fw0OOCmvCP8PDQ44Kb8I/w0NDjgpzwj/DA0OOCnfCMcMDQ44Ke8IxAwNDjgp/wgHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAgAAAAEAAAADAAAADgAAAAYAAAALAAAAAgAAAAcAAAABAAAAGAAAAAUAAAAKAAAAAQAAAAYAAAAAAAAAJgAAAAcAAAAMAAAAAwAAAAgAAAACAAAAMQAAAAkAAAAOAAAAAAAAAAUAAAAEAAAAOgAAAAgAAAANAAAABAAAAAkAAAADAAAAPwAAAAsAAAAGAAAADwAAAAoAAAAQAAAASAAAAAwAAAAHAAAAEAAAAAsAAAARAAAAUwAAAAoAAAAFAAAAEwAAAA4AAAAPAAAAYQAAAA0AAAAIAAAAEQAAAAwAAAASAAAAawAAAA4AAAAJAAAAEgAAAA0AAAATAAAAdQAAAA8AAAATAAAAEQAAABIAAAAQAAAABgAAAAIAAAADAAAABQAAAAQAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAMAAAABAAAABQAAAAQAAAAAAAAAAAAAAAcAAAAFAAAAAwAAAAQAAAABAAAAAAAAAAIAAAAAAAAAAgAAAAMAAAABAAAABQAAAAQAAAAGAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifm/GC1EVPshCUAYLURU+yEJwGFsZ29zLmMAaDNOZWlnaGJvclJvdGF0aW9ucwBjZWxsc1RvTXVsdGlQb2x5LmMAY2VsbFRvRWRnZUFyY3MAAAEDAgQABAMFAQJjYW5jZWxBcmNQYWlycwBjcmVhdGVTb3J0YWJsZUxvb3AAZGlyZWN0ZWRFZGdlLmMAZGlyZWN0ZWRFZGdlVG9Cb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0NlbGxCb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbY2VudGVySUpLLmZhY2VdW2ZhY2UyXSA9PSBLSQBfZmFjZUlqa1RvQ2VsbEJvdW5kYXJ5AGgzSW5kZXguYwBjb21wYWN0Q2VsbHMAdmVjM1RvQ2VsbABjZWxsVG9DaGlsZFBvcwB2YWxpZGF0ZUNoaWxkUG9zAHJldkRpciAhPSBJTlZBTElEX0RJR0lUAGxvY2FsaWouYwBjZWxsVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAYmFzZUNlbGwgPT0gb3JpZ2luQmFzZUNlbGwALi4vaW5jbHVkZS9jb29yZGlqay5oAF91cEFwN0NoZWNrZWQAX3VwQXA3ckNoZWNrZWQAYmFzZUNlbGwgIT0gSU5WQUxJRF9CQVNFX0NFTEwAbG9jYWxJamtUb0NlbGwAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAZ3JpZFBhdGhDZWxsc0ludGVycG9sYXRlAHBvbHlmaWxsLmMAaXRlclN0ZXBQb2x5Z29uQ29tcGFjdAAwAHZlcnRleC5jAHZlcnRleFJvdGF0aW9ucwBjZWxsVG9WZXJ0ZXg=`;var De=28400;function Oe(e){return e}function ke(e){return e.replace(/\b__Z[\w\d_]+/g,function(e){var t=Oe(e);return e===t?e:t+` [`+e+`]`})}function Ae(){var e=Error();if(!e.stack){try{throw Error(0)}catch(t){e=t}if(!e.stack)return`(no stack trace available)`}return e.stack.toString()}function je(){var e=Ae();return t.extraStackTrace&&(e+=` +`+t.extraStackTrace()),ke(e)}function Me(e,t,n,r){Qe(`Assertion failed: `+C(e)+`, at: `+[t?C(t):`unknown filename`,n,r?C(r):`unknown function`])}function Ne(){return k.length}function Pe(e,t,n){A.set(A.subarray(t,t+n),e)}function Fe(e){return t.___errno_location&&(M[t.___errno_location()>>2]=e),e}function Ie(e){Qe(`OOM`)}function Le(e){try{var t=new ArrayBuffer(e);return t.byteLength==e?(new Int8Array(t).set(k),He(t),ee(t),1):void 0}catch{}}function Re(e){var t=Ne(),n=16777216,r=2147483648-n;if(e>r)return!1;for(var i=Math.max(t,16777216);i>4,i=(s&15)<<4|c>>2,a=(c&3)<<6|l,n+=String.fromCharCode(r),c!==64&&(n+=String.fromCharCode(i)),l!==64&&(n+=String.fromCharCode(a));while(u13780509?(t=nn(15,t)|0,t|0):(n=((e|0)<0)<<31>>31,a=pr(e|0,n|0,3,0)|0,r=T()|0,n=sr(e|0,n|0,1,0)|0,n=pr(a|0,r|0,n|0,T()|0)|0,n=sr(n|0,T()|0,1,0)|0,e=T()|0,i[t>>2]=n,i[t+4>>2]=e,t=0,t|0)}function re(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,ie(e,t,n,r,0)|0}function ie(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0;if(l=M,M=M+16|0,s=l,!(ae(e,t,n,r,a)|0))return r=0,M=l,r|0;do if((n|0)>=0){if((n|0)>13780509){if(o=nn(15,s)|0,o|0)break;c=s,s=i[c>>2]|0,c=i[c+4>>2]|0}else o=((n|0)<0)<<31>>31,u=pr(n|0,o|0,3,0)|0,c=T()|0,o=sr(n|0,o|0,1,0)|0,o=pr(u|0,c|0,o|0,T()|0)|0,o=sr(o|0,T()|0,1,0)|0,c=T()|0,i[s>>2]=o,i[s+4>>2]=c,s=o;if(wr(r|0,0,s<<3|0)|0,a|0){wr(a|0,0,s<<2|0)|0,o=oe(e,t,n,r,a,s,c,0)|0;break}o=rr(s,4)|0,o?(u=oe(e,t,n,r,o,s,c,0)|0,nr(o),o=u):o=13}else o=2;while(0);return u=o,M=l,u|0}function ae(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(g=M,M=M+16|0,m=g,h=g+8|0,p=m,i[p>>2]=e,i[p+4>>2]=t,(n|0)<0)return h=2,M=g,h|0;if(o=r,i[o>>2]=e,i[o+4>>2]=t,o=(a|0)!=0,o&&(i[a>>2]=0),vt(e,t)|0)return h=9,M=g,h|0;i[h>>2]=0;a:do if((n|0)>=1)if(o)for(d=1,u=0,f=0,p=1,o=e;;){if(!(u|f)){if(o=se(o,t,4,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,vt(o,t)|0){o=9;break a}}if(o=se(o,t,i[26864+(f<<2)>>2]|0,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,e=r+(d<<3)|0,i[e>>2]=o,i[e+4>>2]=t,i[a+(d<<2)>>2]=p,e=u+1|0,s=(e|0)==(p|0),c=f+1|0,l=(c|0)==6,vt(o,t)|0){o=9;break a}if(p=p+(l&s&1)|0,(p|0)>(n|0)){o=0;break}else d=d+1|0,u=s?0:e,f=s?l?0:c:f}else for(d=1,u=0,f=0,p=1,o=e;;){if(!(u|f)){if(o=se(o,t,4,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,vt(o,t)|0){o=9;break a}}if(o=se(o,t,i[26864+(f<<2)>>2]|0,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,e=r+(d<<3)|0,i[e>>2]=o,i[e+4>>2]=t,e=u+1|0,s=(e|0)==(p|0),c=f+1|0,l=(c|0)==6,vt(o,t)|0){o=9;break a}if(p=p+(l&s&1)|0,(p|0)>(n|0)){o=0;break}else d=d+1|0,u=s?0:e,f=s?l?0:c:f}else o=0;while(0);return h=o,M=g,h|0}function oe(e,t,n,r,a,o,s,c){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0,c|=0;var l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(g=M,M=M+16|0,m=g+8|0,h=g,l=hr(e|0,t|0,o|0,s|0)|0,d=T()|0,f=r+(l<<3)|0,_=f,v=i[_>>2]|0,_=i[_+4>>2]|0,u=(v|0)==(e|0)&(_|0)==(t|0),!((v|0)==0&(_|0)==0|u))do l=sr(l|0,d|0,1,0)|0,l=mr(l|0,T()|0,o|0,s|0)|0,d=T()|0,f=r+(l<<3)|0,v=f,_=i[v>>2]|0,v=i[v+4>>2]|0,u=(_|0)==(e|0)&(v|0)==(t|0);while(!((_|0)==0&(v|0)==0|u));if(l=a+(l<<2)|0,u&&(i[l>>2]|0)<=(c|0)||(v=f,i[v>>2]=e,i[v+4>>2]=t,i[l>>2]=c,(c|0)>=(n|0)))return v=0,M=g,v|0;switch(u=c+1|0,i[m>>2]=0,l=se(e,t,2,m,h)|0,l|0){case 9:p=9;break;case 0:l=h,l=oe(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l||(p=9);break;default:}a:do if((p|0)==9){switch(i[m>>2]=0,l=se(e,t,3,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=oe(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=se(e,t,1,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=oe(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=se(e,t,5,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=oe(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=se(e,t,4,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=oe(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=se(e,t,6,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=oe(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}return v=0,M=g,v|0}while(0);return v=l,M=g,v|0}function se(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(n>>>0>6)return a=1,a|0;s=(i[r>>2]|0)%6|0,i[r>>2]=s;a:do if((s|0)>0)for(o=0;;){switch(n|0){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1;break;default:}if(o=o+1|0,(o|0)==(s|0))break a}while(0);if(f=H(e|0,t|0,45)|0,T()|0,d=f&127,d>>>0>121)return a=5,a|0;l=Et(e,t)|0,o=H(e|0,t|0,52)|0,T()|0,o&=15;b:do if(!o)u=15;else{for(;;){if(s=(15-o|0)*3|0,c=H(e|0,t|0,s|0)|0,T()|0,c&=7,(c|0)==7){t=5;break}if(h=(Mt(o)|0)==0,o=o+-1|0,p=_r(7,0,s|0)|0,t&=~(T()|0),m=_r(i[(h?432:16)+(c*28|0)+(n<<2)>>2]|0,0,s|0)|0,s=T()|0,n=i[(h?640:224)+(c*28|0)+(n<<2)>>2]|0,e=m|e&~p,t=s|t,!n){n=0;break b}if(!o){u=15;break b}}return t|0}while(0);(u|0)==15&&(h=i[848+(d*28|0)+(n<<2)>>2]|0,m=_r(h|0,0,45)|0,e=m|e,t=T()|0|t&-1040385,n=i[4272+(d*28|0)+(n<<2)>>2]|0,(h&127|0)==127&&(h=_r(i[848+(d*28|0)+20>>2]|0,0,45)|0,t=T()|0|t&-1040385,n=i[4272+(d*28|0)+20>>2]|0,e=Ot(h|e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+1)),c=H(e|0,t|0,45)|0,T()|0,c&=127;c:do if(be(c)|0){d:do if((Et(e,t)|0)==1){if((d|0)!=(c|0))if(Te(c,i[7696+(d*28|0)>>2]|0)|0){e=At(e,t)|0,s=1,t=T()|0;break}else E(27634,26928,533,26936);switch(l|0){case 3:e=Ot(e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+1,s=0;break d;case 5:e=At(e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+5,s=0;break d;case 0:return h=9,h|0;default:return h=1,h|0}}else s=0;while(0);if((n|0)>0){o=0;do e=Dt(e,t)|0,t=T()|0,o=o+1|0;while((o|0)!=(n|0))}if((d|0)!=(c|0)){if(!(xe(c)|0)){if((s|0)!=0|(Et(e,t)|0)!=5)break;i[r>>2]=(i[r>>2]|0)+1;break}switch(f&127){case 8:case 118:break c;default:}(Et(e,t)|0)!=3&&(i[r>>2]=(i[r>>2]|0)+1)}}else if((n|0)>0){o=0;do e=Ot(e,t)|0,t=T()|0,o=o+1|0;while((o|0)!=(n|0))}while(0);return i[r>>2]=((i[r>>2]|0)+n|0)%6|0,h=a,i[h>>2]=e,i[h+4>>2]=t,h=0,h|0}function ce(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,le(e,t,n,r)|0?(wr(r|0,0,n*48|0)|0,r=ue(e,t,n,r)|0,r|0):(r=0,r|0)}function le(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(h=M,M=M+16|0,p=h,m=h+8|0,f=p,i[f>>2]=e,i[f+4>>2]=t,(n|0)<0)return m=2,M=h,m|0;if(!n)return m=r,i[m>>2]=e,i[m+4>>2]=t,m=0,M=h,m|0;i[m>>2]=0;a:do if(vt(e,t)|0)e=9;else{a=0,f=e;do{if(e=se(f,t,4,m,p)|0,e|0)break a;if(t=p,f=i[t>>2]|0,t=i[t+4>>2]|0,a=a+1|0,vt(f,t)|0){e=9;break a}}while((a|0)<(n|0));d=r,i[d>>2]=f,i[d+4>>2]=t,d=n+-1|0,u=0,e=1;do{if(a=26864+(u<<2)|0,(u|0)==5)for(s=i[a>>2]|0,o=0,a=e;;){if(e=p,e=se(i[e>>2]|0,i[e+4>>2]|0,s,m,p)|0,e|0)break a;if((o|0)!=(d|0))if(l=p,c=i[l>>2]|0,l=i[l+4>>2]|0,e=r+(a<<3)|0,i[e>>2]=c,i[e+4>>2]=l,!(vt(c,l)|0))e=a+1|0;else{e=9;break a}else e=a;if(o=o+1|0,(o|0)>=(n|0))break;a=e}else for(s=p,l=i[a>>2]|0,c=0,a=e,o=i[s>>2]|0,s=i[s+4>>2]|0;;){if(e=se(o,s,l,m,p)|0,e|0)break a;if(s=p,o=i[s>>2]|0,s=i[s+4>>2]|0,e=r+(a<<3)|0,i[e>>2]=o,i[e+4>>2]=s,e=a+1|0,vt(o,s)|0){e=9;break a}if(c=c+1|0,(c|0)>=(n|0))break;a=e}u=u+1|0}while(u>>>0<6);e=p,e=(f|0)==(i[e>>2]|0)&&(t|0)==(i[e+4>>2]|0)?0:9}while(0);return m=e,M=h,m|0}function ue(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;if(f=M,M=M+16|0,s=f,!n)return i[r>>2]=e,i[r+4>>2]=t,r=0,M=f,r|0;do if((n|0)>=0){if((n|0)>13780509){if(a=nn(15,s)|0,a|0)break;o=s,a=i[o>>2]|0,o=i[o+4>>2]|0}else a=((n|0)<0)<<31>>31,d=pr(n|0,a|0,3,0)|0,o=T()|0,a=sr(n|0,a|0,1,0)|0,a=pr(d|0,o|0,a|0,T()|0)|0,a=sr(a|0,T()|0,1,0)|0,o=T()|0,d=s,i[d>>2]=a,i[d+4>>2]=o;if(u=rr(a,8)|0,!u)a=13;else{if(d=rr(a,4)|0,!d){nr(u),a=13;break}if(a=oe(e,t,n,u,d,a,o,0)|0,a|0){nr(u),nr(d);break}if(t=i[s>>2]|0,s=i[s+4>>2]|0,(s|0)>0|(s|0)==0&t>>>0>0){a=0,c=0,l=0;do e=u+(c<<3)|0,o=i[e>>2]|0,e=i[e+4>>2]|0,!((o|0)==0&(e|0)==0)&&(i[d+(c<<2)>>2]|0)==(n|0)&&(p=r+(a<<3)|0,i[p>>2]=o,i[p+4>>2]=e,a=a+1|0),c=sr(c|0,l|0,1,0)|0,l=T()|0;while((l|0)<(s|0)|(l|0)==(s|0)&c>>>0>>0)}nr(u),nr(d),a=0}}else a=2;while(0);return p=a,M=f,p|0}function de(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;for(c=M,M=M+16|0,o=c,s=c+8|0,a=(vt(e,t)|0)==0,a=a?1:2;;){if(i[s>>2]=0,u=(se(e,t,a,s,o)|0)==0,l=o,u&((i[l>>2]|0)==(n|0)?(i[l+4>>2]|0)==(r|0):0)){e=4;break}if(a=a+1|0,a>>>0>=7){a=7,e=4;break}}return(e|0)==4?(M=c,a|0):0}function fe(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;if(c=M,M=M+48|0,a=c+16|0,o=c+8|0,s=c,n=wn(n)|0,n|0)return s=n,M=c,s|0;if(u=e,l=i[u+4>>2]|0,n=o,i[n>>2]=i[u>>2],i[n+4>>2]=l,Cn(o,a),n=Re(a,t,s)|0,!n){if(t=i[o>>2]|0,o=i[e+8>>2]|0,(o|0)>0){a=i[e+12>>2]|0,n=0;do t=(i[a+(n<<3)>>2]|0)+t|0,n=n+1|0;while((n|0)<(o|0))}n=s,a=i[n>>2]|0,n=i[n+4>>2]|0,o=((t|0)<0)<<31>>31,(n|0)<(o|0)|(n|0)==(o|0)&a>>>0>>0?(n=s,i[n>>2]=t,i[n+4>>2]=o,n=o):t=a,l=sr(t|0,n|0,12,0)|0,u=T()|0,n=s,i[n>>2]=l,i[n+4>>2]=u,n=r,i[n>>2]=l,i[n+4>>2]=u,n=0}return u=n,M=c,u|0}function pe(e,t,n,r,o,s,c){e|=0,t|=0,n|=0,r|=0,o|=0,s|=0,c|=0;var l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,E=0,D=0,O=0,k=0,A=0,j=0,N=0,P=0,ee=0,F=0,te=0,ne=0,re=0;if(ee=M,M=M+64|0,A=ee+48|0,j=ee+32|0,N=ee+24|0,C=ee+8|0,w=ee,u=i[e>>2]|0,(u|0)<=0)return P=0,M=ee,P|0;for(E=e+4|0,D=A+8|0,O=j+8|0,k=C+8|0,l=0,x=0;;){d=i[E>>2]|0,b=d+(x<<4)|0,i[A>>2]=i[b>>2],i[A+4>>2]=i[b+4>>2],i[A+8>>2]=i[b+8>>2],i[A+12>>2]=i[b+12>>2],(x|0)==(u+-1|0)?(i[j>>2]=i[d>>2],i[j+4>>2]=i[d+4>>2],i[j+8>>2]=i[d+8>>2],i[j+12>>2]=i[d+12>>2]):(b=d+(x+1<<4)|0,i[j>>2]=i[b>>2],i[j+4>>2]=i[b+4>>2],i[j+8>>2]=i[b+8>>2],i[j+12>>2]=i[b+12>>2]),u=ze(A,j,r,N)|0;a:do if(u)d=0,l=u;else if(u=N,d=i[u>>2]|0,u=i[u+4>>2]|0,(u|0)>0|(u|0)==0&d>>>0>0){y=0,b=0;b:for(;;){if(te=1/(+(d>>>0)+4294967296*(u|0)),re=+a[A>>3],u=cr(d|0,u|0,y|0,b|0)|0,ne=+(u>>>0)+4294967296*(T()|0),F=+(y>>>0)+4294967296*(b|0),a[C>>3]=re*ne*te+te*(+a[j>>3]*F),a[k>>3]=te*(+a[D>>3]*ne)+te*(+a[O>>3]*F),u=Nt(C,r,w)|0,u|0){l=u;break}v=w,_=i[v>>2]|0,v=i[v+4>>2]|0,m=hr(_|0,v|0,t|0,n|0)|0,f=T()|0,u=c+(m<<3)|0,p=u,d=i[p>>2]|0,p=i[p+4>>2]|0;c:do if((d|0)==0&(p|0)==0)S=u,P=16;else for(h=0,g=0;;){if((h|0)>(n|0)|(h|0)==(n|0)&g>>>0>t>>>0){l=1;break b}if((d|0)==(_|0)&(p|0)==(v|0))break c;if(u=sr(m|0,f|0,1,0)|0,m=mr(u|0,T()|0,t|0,n|0)|0,f=T()|0,g=sr(g|0,h|0,1,0)|0,h=T()|0,u=c+(m<<3)|0,p=u,d=i[p>>2]|0,p=i[p+4>>2]|0,(d|0)==0&(p|0)==0){S=u,P=16;break}}while(0);if((P|0)==16&&(P=0,!((_|0)==0&(v|0)==0))&&(g=S,i[g>>2]=_,i[g+4>>2]=v,g=s+(i[o>>2]<<3)|0,i[g>>2]=_,i[g+4>>2]=v,g=o,g=sr(i[g>>2]|0,i[g+4>>2]|0,1,0)|0,_=T()|0,v=o,i[v>>2]=g,i[v+4>>2]=_),y=sr(y|0,b|0,1,0)|0,b=T()|0,u=N,d=i[u>>2]|0,u=i[u+4>>2]|0,!((u|0)>(b|0)|(u|0)==(b|0)&d>>>0>y>>>0)){d=1;break a}}d=0}else d=1;while(0);if(x=x+1|0,!d){P=21;break}if(u=i[e>>2]|0,(x|0)>=(u|0)){l=0,P=21;break}}return(P|0)==21?(M=ee,l|0):0}function me(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,E=0,D=0,O=0,k=0,A=0,j=0,N=0,P=0,ee=0,F=0,te=0;if(te=M,M=M+112|0,N=te+80|0,l=te+72|0,P=te,ee=te+56|0,a=wn(n)|0,a|0)return F=a,M=te,F|0;if(u=e+8|0,F=tr((i[u>>2]<<5)+32|0)|0,!F)return F=13,M=te,F|0;if(Tn(e,F),a=wn(n)|0,!a){if(A=e,j=i[A+4>>2]|0,a=l,i[a>>2]=i[A>>2],i[a+4>>2]=j,Cn(l,N),a=Re(N,t,P)|0,a)A=0,j=0;else{if(a=i[l>>2]|0,o=i[u>>2]|0,(o|0)>0){s=i[e+12>>2]|0,n=0;do a=(i[s+(n<<3)>>2]|0)+a|0,n=n+1|0;while((n|0)!=(o|0));n=a}else n=a;a=P,o=i[a>>2]|0,a=i[a+4>>2]|0,s=((n|0)<0)<<31>>31,(a|0)<(s|0)|(a|0)==(s|0)&o>>>0>>0?(a=P,i[a>>2]=n,i[a+4>>2]=s,a=s):n=o,A=sr(n|0,a|0,12,0)|0,j=T()|0,a=P,i[a>>2]=A,i[a+4>>2]=j,a=0}if(!a){if(n=rr(A,8)|0,!n)return nr(F),F=13,M=te,F|0;if(c=rr(A,8)|0,!c)return nr(F),nr(n),F=13,M=te,F|0;O=N,i[O>>2]=0,i[O+4>>2]=0,O=e,k=i[O+4>>2]|0,a=l,i[a>>2]=i[O>>2],i[a+4>>2]=k,a=pe(l,A,j,t,N,n,c)|0;a:do if(a)nr(n),nr(c),nr(F);else{b:do if((i[u>>2]|0)>0){for(s=e+12|0,o=0;a=pe((i[s>>2]|0)+(o<<3)|0,A,j,t,N,n,c)|0,o=o+1|0,!(a|0);)if((o|0)>=(i[u>>2]|0))break b;nr(n),nr(c),nr(F);break a}while(0);(j|0)>0|(j|0)==0&A>>>0>0&&wr(c|0,0,A<<3|0)|0,k=N,O=i[k+4>>2]|0;c:do if((O|0)>0|(O|0)==0&(i[k>>2]|0)>>>0>0){w=n,E=c,D=n,O=c,k=n,a=n,x=n,S=c,C=c,n=c;d:for(;;){for(_=0,v=0,y=0,b=0,o=0,s=0;;){c=P,l=c+56|0;do i[c>>2]=0,c=c+4|0;while((c|0)<(l|0));if(t=w+(_<<3)|0,u=i[t>>2]|0,t=i[t+4>>2]|0,ae(u,t,1,P,0)|0){c=P,l=c+56|0;do i[c>>2]=0,c=c+4|0;while((c|0)<(l|0));c=rr(7,4)|0,c|0&&(oe(u,t,1,P,c,7,0,0)|0,nr(c))}for(g=0;;){h=P+(g<<3)|0,m=i[h>>2]|0,h=i[h+4>>2]|0;e:do if((m|0)==0&(h|0)==0)c=o,l=s;else{if(d=hr(m|0,h|0,A|0,j|0)|0,u=T()|0,c=r+(d<<3)|0,t=c,l=i[t>>2]|0,t=i[t+4>>2]|0,!((l|0)==0&(t|0)==0)){f=0,p=0;do{if((f|0)>(j|0)|(f|0)==(j|0)&p>>>0>A>>>0)break d;if((l|0)==(m|0)&(t|0)==(h|0)){c=o,l=s;break e}c=sr(d|0,u|0,1,0)|0,d=mr(c|0,T()|0,A|0,j|0)|0,u=T()|0,p=sr(p|0,f|0,1,0)|0,f=T()|0,c=r+(d<<3)|0,t=c,l=i[t>>2]|0,t=i[t+4>>2]|0}while(!((l|0)==0&(t|0)==0))}if((m|0)==0&(h|0)==0){c=o,l=s;break}It(m,h,ee)|0,En(e,F,ee)|0&&(p=sr(o|0,s|0,1,0)|0,s=T()|0,f=c,i[f>>2]=m,i[f+4>>2]=h,o=E+(o<<3)|0,i[o>>2]=m,i[o+4>>2]=h,o=p),c=o,l=s}while(0);if(g=g+1|0,g>>>0>=7)break;o=c,s=l}if(_=sr(_|0,v|0,1,0)|0,v=T()|0,y=sr(y|0,b|0,1,0)|0,b=T()|0,s=N,o=i[s>>2]|0,s=i[s+4>>2]|0,(b|0)<(s|0)|(b|0)==(s|0)&y>>>0>>0)o=c,s=l;else break}if((s|0)>0|(s|0)==0&o>>>0>0){o=0,s=0;do b=w+(o<<3)|0,i[b>>2]=0,i[b+4>>2]=0,o=sr(o|0,s|0,1,0)|0,s=T()|0,b=N,y=i[b+4>>2]|0;while((s|0)<(y|0)|((s|0)==(y|0)?o>>>0<(i[b>>2]|0)>>>0:0))}if(b=N,i[b>>2]=c,i[b+4>>2]=l,(l|0)>0|(l|0)==0&c>>>0>0)g=n,_=C,v=k,y=S,b=E,n=x,C=a,S=D,x=g,a=_,k=O,O=v,D=y,E=w,w=b;else break c}nr(D),nr(O),nr(F),a=1;break a}else a=c;while(0);nr(F),nr(n),nr(a),a=0}while(0);return F=a,M=te,F|0}}return nr(F),F=a,M=te,F|0}function he(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0;if(c=M,M=M+16|0,s=c,e=Ve(e,t,((t|0)<0)<<31>>31,s)|0,e|0)return s=e,M=c,s|0;if(o=z(s,n)|0,n=s+4|0,(i[s>>2]|0)>0){t=0;do{if(a=i[n>>2]|0,r=a+(t<<4)+4|0,nr(i[r>>2]|0),i[r>>2]=0,i[a+(t<<4)>>2]=0,r=a+(t<<4)+8|0,a=a+(t<<4)+12|0,(i[r>>2]|0)>0){e=0;do l=i[a>>2]|0,u=l+(e<<3)+4|0,nr(i[u>>2]|0),i[u>>2]=0,i[l+(e<<3)>>2]=0,e=e+1|0;while((e|0)<(i[r>>2]|0))}nr(i[a>>2]|0),i[a>>2]=0,i[r>>2]=0,t=t+1|0}while((t|0)<(i[s>>2]|0))}return nr(i[n>>2]|0),i[n>>2]=0,i[s>>2]=0,u=o,M=c,u|0}function ge(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,l=0,u=0,p=0,m=0,h=0;if(c=i[e>>2]|0,(c|0)<=0)return o=0,r=0,c=o<0,r=12.566370614359172-r,r=o+r,o=c?r:o,a[t>>3]=o,0;if(s=i[e+4>>2]|0,e=(c|0)!=1&1,l=a[s>>3]*.5+.7853981633974483,o=a[s+(e<<4)>>3]*.5+.7853981633974483,n=f(+l)*+f(+o),r=a[s+(e<<4)+8>>3]-+a[s+8>>3],n=_(+(+f(+r)*n),+(d(+l)*+d(+o)+ +d(+r)*n))*-2,r=n+0,n=r-n,(c|0)==1)return l=r,o=n,c=l<0,o=12.566370614359172-o,o=l+o,l=c?o:l,a[t>>3]=l,0;for(e=1,o=r;m=e,e=e+1|0,h=(e|0)%(c|0)|0,p=a[s+(m<<4)>>3]*.5+.7853981633974483,u=a[s+(h<<4)>>3]*.5+.7853981633974483,r=f(+p)*+f(+u),l=a[s+(h<<4)+8>>3]-+a[s+(m<<4)+8>>3],n=_(+(+f(+l)*r),+(d(+p)*+d(+u)+ +d(+l)*r))*-2-n,r=o+n,n=r-o-n,!((e|0)>=(c|0));)o=r;return h=r<0,p=12.566370614359172-n,p=r+p,p=h?p:r,a[t>>3]=p,0}function _e(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return s=M,M=M+192|0,r=s+176|0,a=s,o=s+168|0,e=Lt(e,t,a)|0,e|0?(o=e,M=s,o|0):(i[o>>2]=i[a>>2],i[o+4>>2]=a+8,i[r>>2]=i[o>>2],i[r+4>>2]=i[o+4>>2],ge(r,n)|0,o=0,M=s,o|0)}function ve(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0;return c=M,M=M+192|0,r=c+176|0,o=c,s=c+168|0,e=Lt(e,t,o)|0,e?(s=e,M=c,s|0):(i[s>>2]=i[o>>2],i[s+4>>2]=o+8,i[r>>2]=i[s>>2],i[r+4>>2]=i[s+4>>2],ge(r,n)|0,a[n>>3]=a[n>>3]*40589732.49931477,s=0,M=c,s|0)}function ye(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0;return c=M,M=M+192|0,r=c+176|0,o=c,s=c+168|0,e=Lt(e,t,o)|0,e?(s=e,M=c,s|0):(i[s>>2]=i[o>>2],i[s+4>>2]=o+8,i[r>>2]=i[s>>2],i[r+4>>2]=i[s+4>>2],ge(r,n)|0,a[n>>3]=a[n>>3]*40589732.49931477*1e6,s=0,M=c,s|0)}function be(e){return e|=0,e>>>0>121?(e=0,e|0):(e=i[7696+(e*28|0)+16>>2]|0,e|0)}function xe(e){return e|=0,(e|0)==4|(e|0)==117|0}function Se(e){return e|=0,i[11120+((i[e>>2]|0)*216|0)+((i[e+4>>2]|0)*72|0)+((i[e+8>>2]|0)*24|0)+(i[e+12>>2]<<3)>>2]|0}function I(e){return e|=0,i[11120+((i[e>>2]|0)*216|0)+((i[e+4>>2]|0)*72|0)+((i[e+8>>2]|0)*24|0)+(i[e+12>>2]<<3)+4>>2]|0}function Ce(e,t){e|=0,t|=0,e=7696+(e*28|0)|0,i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2]}function we(e,t){e|=0,t|=0;var n=0,r=0;if(t>>>0>20)return t=-1,t|0;do if((i[11120+(t*216|0)>>2]|0)!=(e|0))if((i[11120+(t*216|0)+8>>2]|0)!=(e|0))if((i[11120+(t*216|0)+16>>2]|0)!=(e|0))if((i[11120+(t*216|0)+24>>2]|0)!=(e|0))if((i[11120+(t*216|0)+32>>2]|0)!=(e|0))if((i[11120+(t*216|0)+40>>2]|0)!=(e|0))if((i[11120+(t*216|0)+48>>2]|0)!=(e|0))if((i[11120+(t*216|0)+56>>2]|0)!=(e|0))if((i[11120+(t*216|0)+64>>2]|0)!=(e|0))if((i[11120+(t*216|0)+72>>2]|0)!=(e|0))if((i[11120+(t*216|0)+80>>2]|0)!=(e|0))if((i[11120+(t*216|0)+88>>2]|0)!=(e|0))if((i[11120+(t*216|0)+96>>2]|0)!=(e|0))if((i[11120+(t*216|0)+104>>2]|0)!=(e|0))if((i[11120+(t*216|0)+112>>2]|0)!=(e|0))if((i[11120+(t*216|0)+120>>2]|0)!=(e|0))if((i[11120+(t*216|0)+128>>2]|0)!=(e|0))if((i[11120+(t*216|0)+136>>2]|0)==(e|0))e=2,n=1,r=2;else{if((i[11120+(t*216|0)+144>>2]|0)==(e|0)){e=0,n=2,r=0;break}if((i[11120+(t*216|0)+152>>2]|0)==(e|0)){e=0,n=2,r=1;break}if((i[11120+(t*216|0)+160>>2]|0)==(e|0)){e=0,n=2,r=2;break}if((i[11120+(t*216|0)+168>>2]|0)==(e|0)){e=1,n=2,r=0;break}if((i[11120+(t*216|0)+176>>2]|0)==(e|0)){e=1,n=2,r=1;break}if((i[11120+(t*216|0)+184>>2]|0)==(e|0)){e=1,n=2,r=2;break}if((i[11120+(t*216|0)+192>>2]|0)==(e|0)){e=2,n=2,r=0;break}if((i[11120+(t*216|0)+200>>2]|0)==(e|0)){e=2,n=2,r=1;break}if((i[11120+(t*216|0)+208>>2]|0)==(e|0)){e=2,n=2,r=2;break}else e=-1;return e|0}else e=2,n=1,r=1;else e=2,n=1,r=0;else e=1,n=1,r=2;else e=1,n=1,r=1;else e=1,n=1,r=0;else e=0,n=1,r=2;else e=0,n=1,r=1;else e=0,n=1,r=0;else e=2,n=0,r=2;else e=2,n=0,r=1;else e=2,n=0,r=0;else e=1,n=0,r=2;else e=1,n=0,r=1;else e=1,n=0,r=0;else e=0,n=0,r=2;else e=0,n=0,r=1;else e=0,n=0,r=0;while(0);return t=i[11120+(t*216|0)+(n*72|0)+(e*24|0)+(r<<3)+4>>2]|0,t|0}function Te(e,t){return e|=0,t|=0,(i[7696+(e*28|0)+20>>2]|0)==(t|0)?(t=1,t|0):(t=(i[7696+(e*28|0)+24>>2]|0)==(t|0),t|0)}function Ee(e,t){return e|=0,t|=0,i[848+(e*28|0)+(t<<2)>>2]|0}function De(e,t){return e|=0,t|=0,(i[848+(e*28|0)>>2]|0)==(t|0)?(t=0,t|0):(i[848+(e*28|0)+4>>2]|0)==(t|0)?(t=1,t|0):(i[848+(e*28|0)+8>>2]|0)==(t|0)?(t=2,t|0):(i[848+(e*28|0)+12>>2]|0)==(t|0)?(t=3,t|0):(i[848+(e*28|0)+16>>2]|0)==(t|0)?(t=4,t|0):(i[848+(e*28|0)+20>>2]|0)==(t|0)?(t=5,t|0):((i[848+(e*28|0)+24>>2]|0)==(t|0)?6:7)|0}function Oe(){return 122}function ke(e){e|=0;var t=0,n=0,r=0;t=0;do _r(t|0,0,45)|0,r=T()|134225919,n=e+(t<<3)|0,i[n>>2]=-1,i[n+4>>2]=r,t=t+1|0;while((t|0)!=122);return 0}function Ae(e){e|=0;var t=0,n=0,r=0;return r=+a[e+16>>3],n=+a[e+24>>3],t=r-n,+(r>3]<+a[e+24>>3]|0}function Me(e){return e|=0,+(a[e>>3]-+a[e+8>>3])}function Ne(e,t){e|=0,t|=0;var n=0,r=0,i=0;return n=+a[t>>3],!(n>=+a[e+8>>3])||!(n<=+a[e>>3])?(t=0,t|0):(r=+a[e+16>>3],n=+a[e+24>>3],i=+a[t+8>>3],t=i>=n,e=i<=r&1,r>3]<+a[t+8>>3]||+a[e+8>>3]>+a[t>>3]?(r=0,r|0):(o=+a[e+16>>3],n=e+24|0,d=+a[n>>3],s=o>3],i=t+24|0,l=+a[i>>3],c=u>3],t)||(d=+Jt(+a[n>>3],e),d>+Jt(+a[r>>3],t))?(c=0,c|0):(c=1,c|0))}function Fe(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0;s=+a[e+16>>3],u=+a[e+24>>3],e=s>3],c=+a[t+24>>3],o=l>2]=e?o|t?1:2:0,i[r>>2]=o?e?1:t?2:1:0}function Ie(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;return+a[e>>3]<+a[t>>3]||+a[e+8>>3]>+a[t+8>>3]?(r=0,r|0):(r=e+16|0,l=+a[r>>3],o=+a[e+24>>3],s=l>3],i=t+24|0,u=+a[i>>3],c=d>3],t)?(d=+Jt(+a[r>>3],e),c=d>=+Jt(+a[n>>3],t),c|0):(c=0,c|0))}function Le(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,l=0;o=M,M=M+176|0,r=o,i[r>>2]=4,l=+a[t>>3],a[r+8>>3]=l,s=+a[t+16>>3],a[r+16>>3]=s,a[r+24>>3]=l,l=+a[t+24>>3],a[r+32>>3]=l,c=+a[t+8>>3],a[r+40>>3]=c,a[r+48>>3]=l,a[r+56>>3]=c,a[r+64>>3]=s,t=r+72|0,n=t+96|0;do i[t>>2]=0,t=t+4|0;while((t|0)<(n|0));Sr(e|0,r|0,168)|0,M=o}function Re(e,t,n){e|=0,t|=0,n|=0;var r=0,s=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,y=0,x=0,S=0,C=0;x=M,M=M+288|0,h=x+264|0,g=x+96|0,m=x,f=m,p=f+96|0;do i[f>>2]=0,f=f+4|0;while((f|0)<(p|0));return t=Vt(t,m)|0,t|0?(y=t,M=x,y|0):(p=m,m=i[p>>2]|0,p=i[p+4>>2]|0,It(m,p,h)|0,Lt(m,p,g)|0,d=+Xt(h,g+8|0),a[h>>3]=+a[e>>3],p=h+8|0,a[p>>3]=+a[e+16>>3],a[g>>3]=+a[e+8>>3],m=g+8|0,a[m>>3]=+a[e+24>>3],s=+Xt(h,g),C=a[p>>3]-+a[m>>3],u=+l(+C),S=a[h>>3]-+a[g>>3],r=+l(+S),!(C==0|S==0)&&(C=+yr(+u,+r),C=+v(+(s*s/+br(+(C/+br(+u,+r)),3)/(d*2.59807621135*d*.8))),a[o>>3]=C,_=~~C>>>0,y=+l(C)>=1?C>0?~~+b(+c(C/4294967296),4294967295)>>>0:~~+v((C-+(~~C>>>0))/4294967296)>>>0:0,(i[o+4>>2]&2146435072|0)!=2146435072)?(g=(_|0)==0&(y|0)==0,t=n,i[t>>2]=g?1:_,i[t+4>>2]=g?0:y,t=0):t=1,y=t,M=x,y|0)}function ze(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var s=0,u=0,d=0,f=0,p=0,m=0,h=0;m=M,M=M+288|0,d=m+264|0,f=m+96|0,p=m,s=p,u=s+96|0;do i[s>>2]=0,s=s+4|0;while((s|0)<(u|0));return n=Vt(n,p)|0,n|0?(r=n,M=m,r|0):(n=p,s=i[n>>2]|0,n=i[n+4>>2]|0,It(s,n,d)|0,Lt(s,n,f)|0,h=+Xt(d,f+8|0),h=+v(+(Xt(e,t)/(h*2))),a[o>>3]=h,n=~~h>>>0,s=+l(h)>=1?h>0?~~+b(+c(h/4294967296),4294967295)>>>0:~~+v((h-+(~~h>>>0))/4294967296)>>>0:0,(i[o+4>>2]&2146435072|0)==2146435072?(r=1,M=m,r|0):(p=(n|0)==0&(s|0)==0,i[r>>2]=p?1:n,i[r+4>>2]=p?0:s,r=0,M=m,r|0))}function Be(e,t){e|=0,t=+t;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;o=e+16|0,s=+a[o>>3],n=e+24|0,i=+a[n>>3],r=s-i,r=s>3],c=e+8|0,l=+a[c>>3],d=u-l,r=(r*t-r)*.5,t=(d*t-d)*.5,u+=t,a[e>>3]=u>1.5707963267948966?1.5707963267948966:u,t=l-t,a[c>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=s+r,t=t>3.141592653589793?t+-6.283185307179586:t,a[o>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=i-r,t=t>3.141592653589793?t+-6.283185307179586:t,a[n>>3]=t<-3.141592653589793?t+6.283185307179586:t}function Ve(e,t,n,o){e|=0,t|=0,n|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0,O=0,k=0,A=0,j=0,N=0,P=0,ee=0;if(ee=M,M=M+224|0,A=ee,w=ee+48|0,d=(n|0)>0|(n|0)==0&t>>>0>0,d&(n>>>0>0|(n|0)==0&t>>>0>17895697))return P=14,M=ee,P|0;if((n|0)<0)return P=2,M=ee,P|0;if((t|0)==0&(n|0)==0)return i[o>>2]=0,i[o+4>>2]=0,P=0,M=ee,P|0;for(s=e,s=lt(i[s>>2]|0,i[s+4>>2]|0)|0,l=0,u=0;;){if(c=e+(l<<3)|0,P=c,!(pt(i[P>>2]|0,i[P+4>>2]|0)|0)){s=5,j=159;break}if(P=c,P=(lt(i[P>>2]|0,i[P+4>>2]|0)|0)==(s|0),l=sr(l|0,u|0,1,0)|0,u=T()|0,!P){s=12,j=159;break}if(!((u|0)<(n|0)|(u|0)==(n|0)&l>>>0>>0)){j=8;break}}if((j|0)==8){do if((n|0)>0|(n|0)==0&t>>>0>1){if(s=t<<3,l=tr(s)|0,!l)return P=13,M=ee,P|0;for(Sr(l|0,e|0,s|0)|0,Kn(l,t,8,1),s=1,c=0;N=l+(s<<3)|0,P=l+(s+-1<<3)|0,P=(i[N>>2]|0)==(i[P>>2]|0)?(i[N+4>>2]|0)==(i[P+4>>2]|0):0,s=sr(s|0,c|0,1,0)|0,c=T()|0,!P;)if(!((c|0)<(n|0)|(c|0)==(n|0)&s>>>0>>0)){j=14;break}if((j|0)==14){nr(l);break}return nr(l),P=10,M=ee,P|0}while(0);if(s=pr(t|0,n|0,6,0)|0,c=T()|0,d){l=0,u=0;do P=e+(u<<3)|0,P=((vt(i[P>>2]|0,i[P+4>>2]|0)|0)!=0)<<31>>31,s=sr(s|0,c|0,P|0,((P|0)<0)<<31>>31|0)|0,c=T()|0,u=sr(u|0,l|0,1,0)|0,l=T()|0;while((l|0)<(n|0)|(l|0)==(n|0)&u>>>0>>0);C=s,S=c}else C=s,S=c;if(b=pr(C|0,S|0,10,0)|0,x=T()|0,N=tr(C<<5)|0,!N)return P=13,M=ee,P|0;if(P=rr(b,4)|0,!P)return nr(N),P=13,M=ee,P|0;a:do if(d){for(k=e,Ze(i[k>>2]|0,i[k+4>>2]|0,A)|0,g=N,_=0,v=0,s=0,y=0;;){d=A,d=(i[d>>2]|0)==0&(i[d+4>>2]|0)==0,c=d?26990:26995,l=d?5:6,u=0,d=A+((d&1)<<3)|0,f=sr(l|0,u|0,-1,-1)|0,p=T()|0,m=0,h=0;do O=d+(m<<3)|0,D=i[O+4>>2]|0,k=g+(m<<5)|0,i[k>>2]=i[O>>2],i[k+4>>2]=D,r[g+(m<<5)+9>>0]=0,r[g+(m<<5)+8>>0]=0,i[g+(m<<5)+20>>2]=g,k=g+(m<<5)+24|0,i[k>>2]=1,i[k+4>>2]=0,k=r[c+m>>0]|0,D=sr(f|0,p|0,m|0,h|0)|0,D=hr(D|0,T()|0,l|0,u|0)|0,T()|0,D=r[c+D>>0]|0,m=sr(m|0,h|0,1,0)|0,h=T()|0,O=r[c+((m|0)==(l|0)&(h|0)==(u|0)?0:m)>>0]|0,k&=255,i[g+(k<<5)+16>>2]=g+((D&255)<<5),i[g+(k<<5)+12>>2]=g+((O&255)<<5);while(h>>>0>>0|(h|0)==(u|0)&m>>>0>>0);if(_=sr(_|0,v|0,1,0)|0,v=T()|0,s=sr(l|0,u|0,s|0,y|0)|0,y=T()|0,!((v|0)<(n|0)|(v|0)==(n|0)&_>>>0>>0))break a;k=e+(_<<3)|0,Ze(i[k>>2]|0,i[k+4>>2]|0,A)|0||(g=N+(s<<5)|0)}E(27634,26956,108,26975)}while(0);if((S|0)>0|(S|0)==0&C>>>0>0){u=0,d=0;do{if(c=N+(u<<5)|0,l=i[c>>2]|0,c=i[c+4>>2]|0,s=H(l|0,c|0,30)|0,c=pr(s^l|0,(T()|0)^c|0,484763065,-1084733587)|0,l=T()|0,s=H(c|0,l|0,27)|0,l=pr(s^c|0,(T()|0)^l|0,321982955,-1798288965)|0,c=T()|0,s=H(l|0,c|0,31)|0,c=hr(s^l|0,(T()|0)^c|0,b|0,x|0)|0,l=T()|0,s=P+(c<<2)|0,i[s>>2]|0)do s=sr(c|0,l|0,1,0)|0,c=mr(s|0,T()|0,b|0,x|0)|0,l=T()|0,s=P+(c<<2)|0;while(i[s>>2]|0);i[s>>2]=N+(u<<5),u=sr(u|0,d|0,1,0)|0,d=T()|0}while((d|0)<(S|0)|(d|0)==(S|0)&u>>>0>>0);m=0,h=0;do{if(u=N+(m<<5)|0,d=N+(m<<5)+9|0,!(r[d>>0]|0)){if(k=u,$e(i[k>>2]|0,i[k+4>>2]|0,A)|0){j=39;break}p=A,f=i[p>>2]|0,p=i[p+4>>2]|0,c=H(f|0,p|0,30)|0,c=pr(c^f|0,(T()|0)^p|0,484763065,-1084733587)|0,l=T()|0,s=H(c|0,l|0,27)|0,l=pr(s^c|0,(T()|0)^l|0,321982955,-1798288965)|0,c=T()|0,s=H(l|0,c|0,31)|0,c=hr(s^l|0,(T()|0)^c|0,b|0,x|0)|0,l=T()|0,s=i[P+(c<<2)>>2]|0;b:do if(s|0){for(;k=s,!((i[k>>2]|0)==(f|0)&&(i[k+4>>2]|0)==(p|0));)if(s=sr(c|0,l|0,1,0)|0,c=mr(s|0,T()|0,b|0,x|0)|0,l=T()|0,s=i[P+(c<<2)>>2]|0,!s)break b;r[d>>0]=1,r[s+9>>0]=1,c=s+16|0,k=N+(m<<5)+12|0,i[(i[k>>2]|0)+16>>2]=i[c>>2],n=s+12|0,O=i[N+(m<<5)+16>>2]|0,i[O+12>>2]=i[n>>2],i[(i[n>>2]|0)+16>>2]=O,i[(i[c>>2]|0)+12>>2]=i[k>>2],c=He(u)|0,k=He(s)|0,s=c+24|0,n=i[s+4>>2]|0,O=k+24|0,D=i[O+4>>2]|0,O=(n|0)<(D|0)|((n|0)==(D|0)?(i[s>>2]|0)>>>0<(i[O>>2]|0)>>>0:0),s=O?c:k,c=O?k:c,(c|0)!=(s|0)&&(D=s+24|0,k=c+24|0,O=k,D=sr(i[O>>2]|0,i[O+4>>2]|0,i[D>>2]|0,i[D+4>>2]|0)|0,O=T()|0,i[k>>2]=D,i[k+4>>2]=O,i[s+20>>2]=c)}while(0)}m=sr(m|0,h|0,1,0)|0,h=T()|0}while((h|0)<(S|0)|(h|0)==(S|0)&m>>>0>>0);(j|0)==39&&E(27634,26956,258,27001),s=0,c=0;do r[N+(s<<5)+8>>0]=0,s=sr(s|0,c|0,1,0)|0,c=T()|0;while((c|0)<(S|0)|(c|0)==(S|0)&s>>>0>>0);for(f=0,l=0,d=0,p=0;;){if(s=N+(f<<5)|0,!(r[N+(f<<5)+8>>0]|0)&&!(r[N+(f<<5)+9>>0]|0)){u=s,c=i[u>>2]|0,u=i[u+4>>2]|0;do r[s+8>>0]=1,s=i[s+12>>2]|0,k=s;while(!((i[k>>2]|0)==(c|0)&&(i[k+4>>2]|0)==(u|0)));l=sr(l|0,d|0,1,0)|0,u=T()|0}else u=d;if(f=sr(f|0,p|0,1,0)|0,p=T()|0,(p|0)<(S|0)|(p|0)==(S|0)&f>>>0>>0)d=u;else break}s=0,c=0;do r[N+(s<<5)+8>>0]=0,s=sr(s|0,c|0,1,0)|0,c=T()|0;while((c|0)<(S|0)|(c|0)==(S|0)&s>>>0>>0);O=l,D=u,s=1}else O=0,D=0,s=0;k=tr(O*24|0)|0;c:do if(k|0){d:do if(s){e=0,b=0,n=0,t=0;e:for(;;){if(s=N+(e<<5)|0,!(r[N+(e<<5)+8>>0]|0)&&!(r[N+(e<<5)+9>>0]|0)){y=s,v=i[y>>2]|0,y=i[y+4>>2]|0,c=0,l=0;do c=sr(c|0,l|0,2,0)|0,l=T()|0,s=i[s+12>>2]|0,x=s;while(!((i[x>>2]|0)==(v|0)&&(i[x+4>>2]|0)==(y|0)));if(_=tr(c<<4)|0,!_)break;c=v,l=y,g=0,h=0,u=0,d=0;do{if(Qe(c,l,w)|0){j=69;break e}if(x=i[w>>2]|0,p=x+-1|0,m=((p|0)<0)<<31>>31,(x|0)>1){l=u,f=0,c=d,u=0;do x=_+(l<<4)|0,d=w+8+(f<<4)|0,i[x>>2]=i[d>>2],i[x+4>>2]=i[d+4>>2],i[x+8>>2]=i[d+8>>2],i[x+12>>2]=i[d+12>>2],l=sr(l|0,c|0,1,0)|0,c=T()|0,f=sr(f|0,u|0,1,0)|0,u=T()|0;while((u|0)<(m|0)|(u|0)==(m|0)&f>>>0

>>0);u=l,d=c}g=sr(g|0,h|0,p|0,m|0)|0,h=T()|0,r[s+8>>0]=1,s=i[s+12>>2]|0,l=s,c=i[l>>2]|0,l=i[l+4>>2]|0}while(!((c|0)==(v|0)&(l|0)==(y|0)));if(c=ir(_,g<<4)|0,!c){j=75;break}y=He(s)|0,x=i[y+4>>2]|0,s=k+(n*24|0)|0,i[s>>2]=i[y>>2],i[s+4>>2]=x,s=k+(n*24|0)+16|0,i[s>>2]=g,i[k+(n*24|0)+20>>2]=c,i[A>>2]=i[s>>2],i[A+4>>2]=i[s+4>>2],ge(A,k+(n*24|0)+8|0)|0,c=sr(n|0,b|0,1,0)|0,s=T()|0}else c=n,s=b;if(e=sr(e|0,t|0,1,0)|0,t=T()|0,(t|0)<(S|0)|(t|0)==(S|0)&e>>>0>>0)b=s,n=c;else break d}if((j|0)==69?E(27634,26956,351,27016):(j|0)==75&&nr(_),(b|0)>0|(b|0)==0&n>>>0>0)for(u=0,d=0,s=n,l=b;c=i[k+(u*24|0)+20>>2]|0,c?(nr(c),c=b,s=n):c=l,u=sr(u|0,d|0,1,0)|0,d=T()|0,(d|0)<(c|0)|(d|0)==(c|0)&u>>>0>>0;)l=c;nr(k);break c}while(0);Kn(k,O,24,2);f:do if((O|0)==0&(D|0)==0){if(x=tr(192)|0,x|0){if(i[x+16>>2]=0,i[x+20>>2]=0,h=x+8|0,i[h>>2]=3,s=tr(48)|0,g=x+12|0,i[g>>2]=s,s|0){i[s>>2]=i[3860],i[s+4>>2]=i[3861],i[s+8>>2]=i[3862],i[s+12>>2]=i[3863],m=s+16|0,i[m>>2]=i[3864],i[m+4>>2]=i[3865],i[m+8>>2]=i[3866],i[m+12>>2]=i[3867],m=s+32|0,i[m>>2]=i[3868],i[m+4>>2]=i[3869],i[m+8>>2]=i[3870],i[m+12>>2]=i[3871],i[A>>2]=i[h>>2],i[A+4>>2]=i[h+4>>2],ge(A,x)|0,i[x+40>>2]=0,i[x+44>>2]=0,m=x+32|0,i[m>>2]=3,s=tr(48)|0,_=x+36|0,i[_>>2]=s;do if(!s)u=0,d=1;else{if(i[s>>2]=i[3872],i[s+4>>2]=i[3873],i[s+8>>2]=i[3874],i[s+12>>2]=i[3875],p=s+16|0,i[p>>2]=i[3876],i[p+4>>2]=i[3877],i[p+8>>2]=i[3878],i[p+12>>2]=i[3879],p=s+32|0,i[p>>2]=i[3880],i[p+4>>2]=i[3881],i[p+8>>2]=i[3882],i[p+12>>2]=i[3883],i[A>>2]=i[m>>2],i[A+4>>2]=i[m+4>>2],ge(A,x+24|0)|0,i[x+64>>2]=0,i[x+68>>2]=0,p=x+56|0,i[p>>2]=3,s=tr(48)|0,v=x+60|0,i[v>>2]=s,!s){u=0,d=2;break}if(i[s>>2]=i[3884],i[s+4>>2]=i[3885],i[s+8>>2]=i[3886],i[s+12>>2]=i[3887],f=s+16|0,i[f>>2]=i[3888],i[f+4>>2]=i[3889],i[f+8>>2]=i[3890],i[f+12>>2]=i[3891],f=s+32|0,i[f>>2]=i[3892],i[f+4>>2]=i[3893],i[f+8>>2]=i[3894],i[f+12>>2]=i[3895],i[A>>2]=i[p>>2],i[A+4>>2]=i[p+4>>2],ge(A,x+48|0)|0,i[x+88>>2]=0,i[x+92>>2]=0,f=x+80|0,i[f>>2]=3,s=tr(48)|0,y=x+84|0,i[y>>2]=s,!s){u=0,d=3;break}if(i[s>>2]=i[3896],i[s+4>>2]=i[3897],i[s+8>>2]=i[3898],i[s+12>>2]=i[3899],d=s+16|0,i[d>>2]=i[3900],i[d+4>>2]=i[3901],i[d+8>>2]=i[3902],i[d+12>>2]=i[3903],d=s+32|0,i[d>>2]=i[3904],i[d+4>>2]=i[3905],i[d+8>>2]=i[3906],i[d+12>>2]=i[3907],i[A>>2]=i[f>>2],i[A+4>>2]=i[f+4>>2],ge(A,x+72|0)|0,i[x+112>>2]=0,i[x+116>>2]=0,d=x+104|0,i[d>>2]=3,s=tr(48)|0,e=x+108|0,i[e>>2]=s,!s){u=0,d=4;break}if(i[s>>2]=i[3908],i[s+4>>2]=i[3909],i[s+8>>2]=i[3910],i[s+12>>2]=i[3911],u=s+16|0,i[u>>2]=i[3912],i[u+4>>2]=i[3913],i[u+8>>2]=i[3914],i[u+12>>2]=i[3915],u=s+32|0,i[u>>2]=i[3916],i[u+4>>2]=i[3917],i[u+8>>2]=i[3918],i[u+12>>2]=i[3919],i[A>>2]=i[d>>2],i[A+4>>2]=i[d+4>>2],ge(A,x+96|0)|0,i[x+136>>2]=0,i[x+140>>2]=0,u=x+128|0,i[u>>2]=3,s=tr(48)|0,t=x+132|0,i[t>>2]=s,!s){u=0,d=5;break}if(i[s>>2]=i[3920],i[s+4>>2]=i[3921],i[s+8>>2]=i[3922],i[s+12>>2]=i[3923],l=s+16|0,i[l>>2]=i[3924],i[l+4>>2]=i[3925],i[l+8>>2]=i[3926],i[l+12>>2]=i[3927],l=s+32|0,i[l>>2]=i[3928],i[l+4>>2]=i[3929],i[l+8>>2]=i[3930],i[l+12>>2]=i[3931],i[A>>2]=i[u>>2],i[A+4>>2]=i[u+4>>2],ge(A,x+120|0)|0,i[x+160>>2]=0,i[x+164>>2]=0,l=x+152|0,i[l>>2]=3,s=tr(48)|0,n=x+156|0,i[n>>2]=s,!s){u=0,d=6;break}if(i[s>>2]=i[3932],i[s+4>>2]=i[3933],i[s+8>>2]=i[3934],i[s+12>>2]=i[3935],c=s+16|0,i[c>>2]=i[3936],i[c+4>>2]=i[3937],i[c+8>>2]=i[3938],i[c+12>>2]=i[3939],c=s+32|0,i[c>>2]=i[3940],i[c+4>>2]=i[3941],i[c+8>>2]=i[3942],i[c+12>>2]=i[3943],i[A>>2]=i[l>>2],i[A+4>>2]=i[l+4>>2],ge(A,x+144|0)|0,i[x+184>>2]=0,i[x+188>>2]=0,c=x+176|0,i[c>>2]=3,s=tr(48)|0,b=x+180|0,i[b>>2]=s,!s){u=0,d=7;break}if(i[s>>2]=i[3944],i[s+4>>2]=i[3945],i[s+8>>2]=i[3946],i[s+12>>2]=i[3947],w=s+16|0,i[w>>2]=i[3948],i[w+4>>2]=i[3949],i[w+8>>2]=i[3950],i[w+12>>2]=i[3951],s=s+32|0,i[s>>2]=i[3952],i[s+4>>2]=i[3953],i[s+8>>2]=i[3954],i[s+12>>2]=i[3955],i[A>>2]=i[c>>2],i[A+4>>2]=i[c+4>>2],ge(A,x+168|0)|0,Kn(x,8,24,3),s=tr(128)|0,i[o+4>>2]=s,s|0){i[o>>2]=8,i[s>>2]=i[h>>2],i[s+4>>2]=i[h+4>>2],i[s+8>>2]=i[h+8>>2],i[s+12>>2]=i[h+12>>2],j=s+16|0,i[j>>2]=i[m>>2],i[j+4>>2]=i[m+4>>2],i[j+8>>2]=i[m+8>>2],i[j+12>>2]=i[m+12>>2],j=s+32|0,i[j>>2]=i[p>>2],i[j+4>>2]=i[p+4>>2],i[j+8>>2]=i[p+8>>2],i[j+12>>2]=i[p+12>>2],j=s+48|0,i[j>>2]=i[f>>2],i[j+4>>2]=i[f+4>>2],i[j+8>>2]=i[f+8>>2],i[j+12>>2]=i[f+12>>2],j=s+64|0,i[j>>2]=i[d>>2],i[j+4>>2]=i[d+4>>2],i[j+8>>2]=i[d+8>>2],i[j+12>>2]=i[d+12>>2],j=s+80|0,i[j>>2]=i[u>>2],i[j+4>>2]=i[u+4>>2],i[j+8>>2]=i[u+8>>2],i[j+12>>2]=i[u+12>>2],j=s+96|0,i[j>>2]=i[l>>2],i[j+4>>2]=i[l+4>>2],i[j+8>>2]=i[l+8>>2],i[j+12>>2]=i[l+12>>2],j=s+112|0,i[j>>2]=i[c>>2],i[j+4>>2]=i[c+4>>2],i[j+8>>2]=i[c+8>>2],i[j+12>>2]=i[c+12>>2],nr(x),j=158;break f}s=i[g>>2]|0,s|0&&nr(s),s=i[_>>2]|0,s|0&&nr(s),s=i[v>>2]|0,s|0&&nr(s),s=i[y>>2]|0,s|0&&nr(s),s=i[e>>2]|0,s|0&&nr(s),s=i[t>>2]|0,s|0&&nr(s),s=i[n>>2]|0,s|0&&nr(s),s=i[b>>2]|0,s|0&&nr(s),nr(x);break f}while(0);s=0,l=0;do c=i[x+(s*24|0)+12>>2]|0,c|0&&nr(c),s=sr(s|0,l|0,1,0)|0,l=T()|0;while(l>>>0>>0|(l|0)==(u|0)&s>>>0>>0)}nr(x),j=152}}else{if((D|0)>0|(D|0)==0&O>>>0>0){l=0,u=0,d=0,c=0,s=0,f=0;do w=k+(l*24|0)|0,A=u,u=i[w>>2]|0,j=d,d=i[w+4>>2]|0,c=sr(c|0,s|0,((u|0)!=(A|0)|(d|0)!=(j|0))&1|0,0)|0,s=T()|0,l=sr(l|0,f|0,1,0)|0,f=T()|0;while((f|0)<(D|0)|(f|0)==(D|0)&l>>>0>>0);y=c,v=s}else y=0,v=0;if(e=tr(y*24|0)|0,e){g:do if((D|0)>=0){for(h=0,g=0,c=0,l=0,_=0,u=0;;){if(!((h|0)==(O|0)&(g|0)==(D|0))&&(A=k+(c*24|0)|0,j=k+(h*24|0)|0,(i[A>>2]|0)==(i[j>>2]|0)&&(i[A+4>>2]|0)==(i[j+4>>2]|0)))s=_;else{if(p=k+(c*24|0)|0,j=cr(h|0,g|0,c|0,l|0)|0,A=T()|0,m=sr(j|0,A|0,-1,-1)|0,l=T()|0,(A|0)>0|(A|0)==0&j>>>0>1){if(s=tr(m<<3)|0,!s)break;d=0,f=0;do j=d,d=sr(d|0,f|0,1,0)|0,f=T()|0,w=p+(d*24|0)+16|0,A=i[w+4>>2]|0,j=s+(j<<3)|0,i[j>>2]=i[w>>2],i[j+4>>2]=A;while((f|0)<(l|0)|(f|0)==(l|0)&d>>>0>>0)}else s=0;A=k+(c*24|0)+16|0,j=i[A+4>>2]|0,l=e+(u*24|0)+8|0,i[l>>2]=i[A>>2],i[l+4>>2]=j,i[e+(u*24|0)+16>>2]=m,i[e+(u*24|0)+20>>2]=s,a[e+(u*24|0)>>3]=+a[k+(c*24|0)+8>>3],u=sr(u|0,_|0,1,0)|0,c=h,l=g,s=T()|0}if(j=h,h=sr(h|0,g|0,1,0)|0,A=g,g=T()|0,(A|0)<(D|0)|(A|0)==(D|0)&j>>>0>>0)_=s;else break g}if((_|0)>0|(_|0)==0&u>>>0>0){s=0,l=0;do c=i[e+(s*24|0)+20>>2]|0,c|0&&nr(c),s=sr(s|0,l|0,1,0)|0,l=T()|0;while((l|0)<(_|0)|(l|0)==(_|0)&s>>>0>>0)}nr(e),j=152;break f}while(0);if(Kn(e,y,24,3),s=tr(y<<4)|0,l=o+4|0,i[l>>2]=s,s){i[o>>2]=y;do if((v|0)>0|(v|0)==0&y>>>0>0){if(o=e+8|0,i[s>>2]=i[o>>2],i[s+4>>2]=i[o+4>>2],i[s+8>>2]=i[o+8>>2],i[s+12>>2]=i[o+12>>2],(y|0)==1&(v|0)==0||(o=s+16|0,j=e+32|0,i[o>>2]=i[j>>2],i[o+4>>2]=i[j+4>>2],i[o+8>>2]=i[j+8>>2],i[o+12>>2]=i[j+12>>2],!((v|0)>0|(v|0)==0&y>>>0>2)))break;s=2,c=0;do o=(i[l>>2]|0)+(s<<4)|0,j=e+(s*24|0)+8|0,i[o>>2]=i[j>>2],i[o+4>>2]=i[j+4>>2],i[o+8>>2]=i[j+8>>2],i[o+12>>2]=i[j+12>>2],s=sr(s|0,c|0,1,0)|0,c=T()|0;while((c|0)<(v|0)|(c|0)==(v|0)&s>>>0>>0)}while(0);nr(e),j=158;break}else{if((v|0)>0|(v|0)==0&y>>>0>0){s=0,l=0;do c=i[e+(s*24|0)+20>>2]|0,c|0&&nr(c),s=sr(s|0,l|0,1,0)|0,l=T()|0;while((l|0)<(v|0)|(l|0)==(v|0)&s>>>0>>0)}nr(e),j=152;break}}else j=152}while(0);if((j|0)==158)return nr(N),nr(P),nr(k),P=0,M=ee,P|0;if((j|0)==152&&(D|0)>0|(D|0)==0&O>>>0>0)for(u=0,d=0,s=O,l=D;c=i[k+(u*24|0)+20>>2]|0,c?(nr(c),c=D,s=O):c=l,u=sr(u|0,d|0,1,0)|0,d=T()|0,(d|0)<(c|0)|(d|0)==(c|0)&u>>>0>>0;)l=c;return nr(k),nr(N),nr(P),P=13,M=ee,P|0}while(0);return nr(N),nr(P),P=13,M=ee,P|0}else if((j|0)==159)return M=ee,s|0;return 0}function L(e,t){e|=0,t|=0;var n=0,r=0;return r=e,e=i[r>>2]|0,r=i[r+4>>2]|0,n=t,t=i[n>>2]|0,n=i[n+4>>2]|0,(r>>>0>>0|(r|0)==(n|0)&e>>>0>>0?-1:(r>>>0>n>>>0|(r|0)==(n|0)&e>>>0>t>>>0)&1)|0}function He(e){e|=0;var t=0,n=0;return t=e+20|0,n=i[t>>2]|0,(n|0)==(e|0)?e|0:(n=He(n)|0,i[t>>2]=n,n|0)}function Ue(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,l=0;return l=e,c=i[l>>2]|0,l=i[l+4>>2]|0,s=t,o=i[s>>2]|0,s=i[s+4>>2]|0,l>>>0>>0|(l|0)==(s|0)&c>>>0>>0?(t=-1,t|0):l>>>0>s>>>0|(l|0)==(s|0)&c>>>0>o>>>0?(t=1,t|0):(r=+a[e+8>>3],n=+a[t+8>>3],rn&1,t|0))}function We(e,t){e|=0,t|=0;var n=0,r=0;return r=+a[e>>3],n=+a[t>>3],(r>n?-1:r>2]=0,a=0,M=f,a|0;if(s=H(e|0,t|0,52)|0,T()|0,s&=15,u=H(n|0,r|0,52)|0,T()|0,(s|0)!=(u&15|0))return a=12,M=f,a|0;if(o=s+-1|0,s>>>0>1){gt(e,t,o,d)|0,gt(n,r,o,c)|0,u=d,l=i[u>>2]|0,u=i[u+4>>2]|0;a:do if((l|0)==(i[c>>2]|0)&&(u|0)==(i[c+4>>2]|0)){s=(s^15)*3|0,o=H(e|0,t|0,s|0)|0,T()|0,o&=7,s=H(n|0,r|0,s|0)|0,T()|0,s&=7;do if((o|0)==0|(s|0)==0)i[a>>2]=1,o=0;else if((o|0)==7)o=5;else{if((o|0)==1|(s|0)==1&&vt(l,u)|0){o=5;break}if((i[15824+(o<<2)>>2]|0)!=(s|0)&&(i[15856+(o<<2)>>2]|0)!=(s|0))break a;i[a>>2]=1,o=0}while(0);return a=o,M=f,a|0}while(0)}o=d,s=o+56|0;do i[o>>2]=0,o=o+4|0;while((o|0)<(s|0));return re(e,t,1,d)|0,t=d,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0))&&(t=d+8|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+16|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+24|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+32|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+40|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))?(o=d+48|0,o=((i[o>>2]|0)==(n|0)?(i[o+4>>2]|0)==(r|0):0)&1):o=1,i[a>>2]=o,a=0,M=f,a|0}function Ke(e,t,n,r,a){return e|=0,t|=0,n|=0,r|=0,a|=0,n=de(e,t,n,r)|0,(n|0)==7?(a=11,a|0):(r=_r(n|0,0,56)|0,t=t&-2130706433|T()|268435456,i[a>>2]=e|r,i[a+4>>2]=t,a=0,a|0)}function qe(e,t,n){return e|=0,t|=0,n|=0,!0&(t&2013265920|0)==268435456?(i[n>>2]=e,i[n+4>>2]=t&-2130706433|134217728,n=0,n|0):(n=6,n|0)}function Je(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;return a=M,M=M+16|0,r=a,i[r>>2]=0,!0&(t&2013265920|0)==268435456?(o=H(e|0,t|0,56)|0,T()|0,r=se(e,t&-2130706433|134217728,o&7,r,n)|0,M=a,r|0):(r=6,M=a,r|0)}function Ye(e,t){e|=0,t|=0;var n=0;switch(n=H(e|0,t|0,56)|0,T()|0,n&7){case 0:case 7:return n=0,n|0;default:}return n=t&-2130706433|134217728,!(!0&(t&2013265920|0)==268435456)||!0&(t&117440512|0)==16777216&(vt(e,n)|0)!=0?(n=0,n|0):(n=pt(e,n)|0,n|0)}function Xe(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return a=M,M=M+16|0,r=a,!0&(t&2013265920|0)==268435456?(o=t&-2130706433|134217728,s=n,i[s>>2]=e,i[s+4>>2]=o,i[r>>2]=0,t=H(e|0,t|0,56)|0,T()|0,r=se(e,o,t&7,r,n+8|0)|0,M=a,r|0):(r=6,M=a,r|0)}function Ze(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0;return a=(vt(e,t)|0)==0,t&=-2130706433,r=n,i[r>>2]=a?e:0,i[r+4>>2]=a?t|285212672:0,r=n+8|0,i[r>>2]=e,i[r+4>>2]=t|301989888,r=n+16|0,i[r>>2]=e,i[r+4>>2]=t|318767104,r=n+24|0,i[r>>2]=e,i[r+4>>2]=t|335544320,r=n+32|0,i[r>>2]=e,i[r+4>>2]=t|352321536,n=n+40|0,i[n>>2]=e,i[n+4>>2]=t|369098752,0}function Qe(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return s=M,M=M+16|0,a=s,o=t&-2130706433|134217728,!0&(t&2013265920|0)==268435456?(r=H(e|0,t|0,56)|0,T()|0,r=V(e,o,r&7)|0,(r|0)==-1?(i[n>>2]=0,o=6,M=s,o|0):(Ft(e,o,a)|0&&E(27634,27035,282,27050),t=H(e|0,t|0,52)|0,T()|0,t&=15,vt(e,o)|0?rt(a,t,r,2,n):st(a,t,r,2,n),o=0,M=s,o|0)):(o=6,M=s,o|0)}function $e(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return s=M,M=M+16|0,r=s+8|0,a=s,o=t&-2130706433|134217728,!0&(t&2013265920|0)==268435456?(i[r>>2]=0,t=H(e|0,t|0,56)|0,T()|0,t=se(e,o,t&7,r,a)|0,t|0?(n=t,M=s,n|0):(r=i[a>>2]|0,a=i[a+4>>2]|0,t=de(r,a,e,o)|0,(t|0)==7?(n=11,M=s,n|0):(e=_r(t|0,0,56)|0,o=a&-2130706433|T()|268435456,i[n>>2]=r|e,i[n+4>>2]=o,n=0,M=s,n|0))):(n=6,M=s,n|0)}function et(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,h=0,g=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,E=0,D=0,O=0,k=0,A=0,j=0;i[n>>2]=0,v=+a[e>>3],y=+a[e+8>>3],g=+a[e+16>>3],o=0,s=5,r=5,e=0;do w=+a[15888+(o*24|0)>>3]-v,C=+a[15888+(o*24|0)+8>>3]-y,c=+a[15888+(o*24|0)+16>>3]-g,c=w*w+C*C+c*c,c>2]=o,s=c,e=o,r=c),o=o+1|0;while((o|0)!=20);if(s=+m(+(1-s*.5)),s<1e-16)g=0,c=0;else{if(A=+a[16368+(e*24|0)>>3],O=+a[15888+(e*24|0)>>3],k=+a[15888+(e*24|0)+8>>3],D=+a[15888+(e*24|0)+16>>3],j=-(D+(O*0+k*0)),c=O*j+0,w=k*j+0,j=D*j+1,E=+u(+(j*j+(c*c+w*w))),E=E>0?1/E:0,c*=E,w*=E,E=j*E,j=-(v*O+y*k+g*D),C=v+O*j,r=y+k*j,v=g+D*j,y=+u(+(v*v+(C*C+r*r))),y=y>0?1/y:0,C*=y,r*=y,y=v*y,r=+qt(A-+qt(+_(+(y*(k*c-O*w)+(C*(D*w-k*E)+r*(O*E-D*c))),+(E*y+(c*C+w*r))))),c=Mt(t)|0?+qt(r+-.3334731722518321):r,r=p(+s)*2.618033988749896,(t|0)>0){e=0;do r*=2.6457513110645907,e=e+1|0;while((e|0)!=(t|0))}g=+d(+c)*r,c=+f(+c)*r}t=n+4|0,S=n+12|0,i[S>>2]=0,s=l(+c)*1.1547005383792515,r=+l(+g)+s*.5,e=~~r,o=~~s,r-=+(e|0),s-=+(o|0);do if(r<.5)if(r<.3333333333333333)if(i[t>>2]=e,s<(r+1)*.5){i[n+8>>2]=o;break}else{o=o+1|0,i[n+8>>2]=o;break}else if(j=1-r,o=(!(s>2]=o,j<=s&s>2]=e;break}else{i[t>>2]=e;break}else{if(!(r<.6666666666666666))if(e=e+1|0,i[t>>2]=e,s>2]=o;break}else{o=o+1|0,i[n+8>>2]=o;break}if(s<1-r){if(i[n+8>>2]=o,r*2+-1>2]=e;break}}else o=o+1|0,i[n+8>>2]=o;e=e+1|0,i[t>>2]=e}while(0);do if(g<0)if(o&1){x=(o+1|0)/2|0,x=cr(e|0,((e|0)<0)<<31>>31|0,x|0,((x|0)<0)<<31>>31|0)|0,e=~~((e|0)-((+(x>>>0)+4294967296*(T()|0))*2+1)),i[t>>2]=e,x=t;break}else{x=(o|0)/2|0,x=cr(e|0,((e|0)<0)<<31>>31|0,x|0,((x|0)<0)<<31>>31|0)|0,e=~~((e|0)-(+(x>>>0)+4294967296*(T()|0))*2),i[t>>2]=e,x=t;break}else x=t;while(0);b=n+8|0,t=0-o|0,c<0?(n=e-((o<<1|1)/2|0)|0,i[x>>2]=n,i[b>>2]=t,o=t):n=e,e=o-n|0,t=0-n|0,(n|0)<0?(i[b>>2]=e,i[S>>2]=t,i[x>>2]=0,h=0):(e=o,h=n,t=0),n=h-e|0,o=t-e|0,(e|0)<0?(i[x>>2]=n,i[S>>2]=o,i[b>>2]=0,h=n,e=0):o=t,n=h-o|0,t=e-o|0,(o|0)<0?(i[x>>2]=n,i[b>>2]=t,i[S>>2]=0,o=0):(t=e,n=h),e=(t|0)<(n|0)?t:n,e=(o|0)<(e|0)?o:e,!((e|0)<=0)&&(i[x>>2]=n-e,i[b>>2]=t-e,i[S>>2]=o-e)}function tt(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0;r=M,M=M+16|0,o=r,c=i[e+12>>2]|0,s=+((i[e+8>>2]|0)-c|0),a[o>>3]=((i[e+4>>2]|0)-c|0)-s*.5,a[o+8>>3]=s*.8660254037844386,nt(o,i[e>>2]|0,t,0,n),M=r}function nt(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0,p=0,m=0,h=0,v=0,y=0,b=0,x=0,S=0,C=0;if(s=+Rn(e),s<1e-16){t=15888+(t*24|0)|0,i[o>>2]=i[t>>2],i[o+4>>2]=i[t+4>>2],i[o+8>>2]=i[t+8>>2],i[o+12>>2]=i[t+12>>2],i[o+16>>2]=i[t+16>>2],i[o+20>>2]=i[t+20>>2];return}if(c=+_(+ +a[e+8>>3],+ +a[e>>3]),(n|0)>0){e=0;do s*=.37796447300922725,e=e+1|0;while((e|0)!=(n|0))}l=s*.3333333333333333,r?(n=(Mt(n)|0)==0,s=+g(+((n?l:l*.37796447300922725)*.381966011250105))):(s=+g(+(s*.381966011250105)),Mt(n)|0&&(c=+qt(c+.3334731722518321))),v=+qt(+a[16368+(t*24|0)>>3]-c),l=+a[15888+(t*24|0)>>3],h=+a[15888+(t*24|0)+8>>3],S=+a[15888+(t*24|0)+16>>3],b=-(S+(l*0+h*0)),m=l*b+0,c=h*b+0,b=S*b+1,y=+u(+(b*b+(m*m+c*c))),y=y>0?1/y:0,m*=y,c*=y,y=b*y,b=+d(+v),v=+f(+v),C=+d(+s),x=+f(+s),p=C*l+x*(b*m+v*(S*c-h*y)),s=C*h+x*(b*c+v*(l*y-S*m)),c=C*S+x*(b*y+v*(h*m-l*c)),l=+u(+(c*c+(p*p+s*s))),l=l>0?1/l:0,a[o>>3]=p*l,a[o+8>>3]=s*l,a[o+16>>3]=c*l}function rt(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,g=0,v=0,b=0,x=0,S=0,C=0,w=0,T=0,D=0,O=0,k=0,A=0,j=0,N=0,P=0,ee=0,F=0,te=0,ne=0,re=0,ie=0,ae=0,oe=0,se=0,ce=0,le=0,ue=0,de=0,fe=0,pe=0,me=0,he=0,ge=0,_e=0;if(de=M,M=M+256|0,s=de+240|0,te=de+224|0,ce=de,le=de+208|0,ue=de+192|0,ne=de+168|0,re=de+152|0,ie=de+136|0,ae=de+120|0,oe=de+104|0,se=de+80|0,i[s>>2]=t,i[te>>2]=i[e>>2],i[te+4>>2]=i[e+4>>2],i[te+8>>2]=i[e+8>>2],i[te+12>>2]=i[e+12>>2],it(te,s,ce),i[o>>2]=0,te=r+n+((r|0)==5&1)|0,(te|0)<=(n|0)){M=de;return}T=i[s>>2]|0,w=le+4|0,S=le+8|0,C=le+12|0,D=ue+8|0,O=n+5|0,k=16848+(T<<2)|0,A=ne+8|0,j=16928+(T<<2)|0,N=re+8|0,P=ie+8|0,ee=ae+8|0,F=ue+8|0,g=ne+8|0,b=ne+16|0,v=se+8|0,x=se+16|0,m=n,r=0,c=0,l=0,u=0;a:for(;;){p=ce+(((m|0)%5|0)<<4)|0,i[le>>2]=i[p>>2],i[le+4>>2]=i[p+4>>2],i[le+8>>2]=i[p+8>>2],i[le+12>>2]=i[p+12>>2];do;while((at(le,T,0,1)|0)==2);if((m|0)>(n|0)&(Mt(t)|0)!=0){if(p=i[le>>2]|0,e=i[w>>2]|0,d=i[S>>2]|0,s=i[C>>2]|0,fe=+(l-u|0),a[ue>>3]=(c-u|0)-fe*.5,a[D>>3]=fe*.8660254037844386,u=i[17008+(p*80|0)+(r<<2)>>2]|0,f=i[18608+(p*80|0)+(u*20|0)>>2]|0,l=i[18608+(p*80|0)+(u*20|0)+16>>2]|0,(l|0)>0){c=0,r=d;do he=s+e|0,ge=(he|0)<0,d=r+e-(ge?he:0)|0,me=(d|0)<0,pe=s+r-(ge?he:0)-(me?d:0)|0,s=(pe|0)<0,e=(ge?0:he)-(me?d:0)-(s?pe:0)|0,r=(me?0:d)-(s?pe:0)|0,pe=s?0:pe,s=(r|0)<(e|0)?r:e,s=(pe|0)<(s|0)?pe:s,d=(s|0)>0,e=e-(d?s:0)|0,r=r-(d?s:0)|0,s=pe-(d?s:0)|0,c=c+1|0;while((c|0)<(l|0))}else r=d;switch(ge=(i[k>>2]|0)*3|0,pe=(y(ge,i[18608+(p*80|0)+(u*20|0)+4>>2]|0)|0)+e|0,d=(y(ge,i[18608+(p*80|0)+(u*20|0)+8>>2]|0)|0)+r|0,ge=(y(ge,i[18608+(p*80|0)+(u*20|0)+12>>2]|0)|0)+s|0,u=(pe|0)<0,d=d-(u?pe:0)|0,me=(d|0)<0,ge=ge+(u?0-pe|0:0)+(me?0-d|0:0)|0,he=(ge|0)<0,pe=(u?0:pe)-(me?d:0)-(he?ge:0)|0,d=(me?0:d)-(he?ge:0)|0,ge=he?0:ge,he=(d|0)<(pe|0)?d:pe,he=(ge|0)<(he|0)?ge:he,me=(he|0)>0,ge=ge-(me?he:0)|0,fe=+(d-(me?he:0)-ge|0),a[ne>>3]=(pe-(me?he:0)-ge|0)-fe*.5,a[A>>3]=fe*.8660254037844386,fe=+(i[j>>2]|0),a[re>>3]=fe*3,a[N>>3]=0,_e=fe*-1.5,a[ie>>3]=_e,a[P>>3]=fe*2.598076211353316,a[ae>>3]=_e,a[ee>>3]=fe*-2.598076211353316,i[17008+(f*80|0)+(p<<2)>>2]|0){case 1:e=ie,r=re;break;case 3:e=ae,r=ie;break;case 2:e=re,r=ae;break;default:e=12;break a}B(ue,ne,r,e,oe),nt(oe,f,T,1,se),ge=i[o>>2]|0,fe=+h(+ +a[x>>3]),_e=+_(+ +a[v>>3],+ +a[se>>3]),a[o+8+(ge<<4)>>3]=fe,a[o+8+(ge<<4)+8>>3]=_e,i[o>>2]=(i[o>>2]|0)+1}if((m|0)<(O|0)&&(ge=i[C>>2]|0,fe=+((i[S>>2]|0)-ge|0),a[ue>>3]=((i[w>>2]|0)-ge|0)-fe*.5,a[F>>3]=fe*.8660254037844386,nt(ue,i[le>>2]|0,T,1,ne),ge=i[o>>2]|0,fe=+h(+ +a[b>>3]),_e=+_(+ +a[g>>3],+ +a[ne>>3]),a[o+8+(ge<<4)>>3]=fe,a[o+8+(ge<<4)+8>>3]=_e,i[o>>2]=(i[o>>2]|0)+1),m=m+1|0,(m|0)>=(te|0)){e=3;break}else r=i[le>>2]|0,c=i[w>>2]|0,l=i[S>>2]|0,u=i[C>>2]|0}if((e|0)==3){M=de;return}else(e|0)==12&&E(27073,27120,599,27130)}function it(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;h=M,M=M+128|0,r=h+64|0,a=h,o=r,s=20208,c=o+60|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));o=a,s=20272,c=o+60|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));if(d=(Mt(i[t>>2]|0)|0)==0,d=d?r:a,m=e+4|0,o=i[m>>2]|0,f=e+8|0,r=i[f>>2]|0,p=e+12|0,a=i[p>>2]|0,s=r+(o<<1)|0,i[m>>2]=s,r=a+(r<<1)|0,i[f>>2]=r,o=(a<<1)+o|0,i[p>>2]=o,a=r-s|0,c=o-s|0,(s|0)<0&&(i[f>>2]=a,i[p>>2]=c,i[m>>2]=0,r=a,s=0,o=c),c=s-r|0,a=o-r|0,(r|0)<0?(i[m>>2]=c,i[p>>2]=a,i[f>>2]=0,r=0):(a=o,c=s),s=c-a|0,o=r-a|0,(a|0)<0?(i[m>>2]=s,i[f>>2]=o,i[p>>2]=0,a=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(a|0)<(r|0)?a:r,(r|0)>0&&(a=a-r|0,o=o-r|0,s=s-r|0,i[m>>2]=s,i[f>>2]=o,i[p>>2]=a),l=(o<<1)+s|0,c=a+(s<<1)|0,i[m>>2]=c,i[f>>2]=l,o=(a<<1)+o|0,i[p>>2]=o,r=l-c|0,a=o-c|0,(c|0)<0?(i[f>>2]=r,i[p>>2]=a,i[m>>2]=0,c=0,o=a):r=l,s=c-r|0,a=o-r|0,(r|0)<0?(i[m>>2]=s,i[p>>2]=a,i[f>>2]=0,c=s,r=0):a=o,s=c-a|0,o=r-a|0,(a|0)<0?(i[m>>2]=s,i[f>>2]=o,i[p>>2]=0,a=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(a|0)<(r|0)?a:r,(r|0)>0&&(i[m>>2]=s-r,i[f>>2]=o-r,i[p>>2]=a-r),Mt(i[t>>2]|0)|0&&(o=i[m>>2]|0,s=i[f>>2]|0,a=i[p>>2]|0,r=(s*3|0)+o|0,o=a+(o*3|0)|0,i[m>>2]=o,i[f>>2]=r,s=(a*3|0)+s|0,i[p>>2]=s,a=r-o|0,c=s-o|0,(o|0)<0?(i[f>>2]=a,i[p>>2]=c,i[m>>2]=0,r=a,l=0):(l=o,c=s),o=l-r|0,a=c-r|0,(r|0)<0?(i[m>>2]=o,i[p>>2]=a,i[f>>2]=0,l=o,s=0):(s=r,a=c),o=l-a|0,r=s-a|0,(a|0)<0?(i[m>>2]=o,i[f>>2]=r,i[p>>2]=0,s=r,a=0):o=l,r=(s|0)<(o|0)?s:o,r=(a|0)<(r|0)?a:r,(r|0)>0&&(i[m>>2]=o-r,i[f>>2]=s-r,i[p>>2]=a-r),i[t>>2]=(i[t>>2]|0)+1),i[n>>2]=i[e>>2],a=i[f>>2]|0,r=i[p>>2]|0,t=i[d+4>>2]|0,u=i[d+8>>2]|0,s=(i[d>>2]|0)+(i[m>>2]|0)|0,l=n+4|0,i[l>>2]=s,a=t+a|0,t=n+8|0,i[t>>2]=a,r=u+r|0,u=n+12|0,i[u>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[t>>2]=o,i[u>>2]=r,i[l>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[l>>2]=s,r=r-a|0,i[u>>2]=r,i[t>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[l>>2]=c,i[t>>2]=o,i[u>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[l>>2]=s-a,i[t>>2]=o-a,i[u>>2]=r-a),i[n+16>>2]=i[e>>2],a=i[f>>2]|0,r=i[p>>2]|0,t=i[d+16>>2]|0,u=i[d+20>>2]|0,s=(i[d+12>>2]|0)+(i[m>>2]|0)|0,l=n+20|0,i[l>>2]=s,a=t+a|0,t=n+24|0,i[t>>2]=a,r=u+r|0,u=n+28|0,i[u>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[t>>2]=o,i[u>>2]=r,i[l>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[l>>2]=s,r=r-a|0,i[u>>2]=r,i[t>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[l>>2]=c,i[t>>2]=o,i[u>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[l>>2]=s-a,i[t>>2]=o-a,i[u>>2]=r-a),i[n+32>>2]=i[e>>2],a=i[f>>2]|0,r=i[p>>2]|0,t=i[d+28>>2]|0,u=i[d+32>>2]|0,s=(i[d+24>>2]|0)+(i[m>>2]|0)|0,l=n+36|0,i[l>>2]=s,a=t+a|0,t=n+40|0,i[t>>2]=a,r=u+r|0,u=n+44|0,i[u>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[t>>2]=o,i[u>>2]=r,i[l>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[l>>2]=s,r=r-a|0,i[u>>2]=r,i[t>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[l>>2]=c,i[t>>2]=o,i[u>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[l>>2]=s-a,i[t>>2]=o-a,i[u>>2]=r-a),i[n+48>>2]=i[e>>2],a=i[f>>2]|0,r=i[p>>2]|0,t=i[d+40>>2]|0,u=i[d+44>>2]|0,s=(i[d+36>>2]|0)+(i[m>>2]|0)|0,l=n+52|0,i[l>>2]=s,a=t+a|0,t=n+56|0,i[t>>2]=a,r=u+r|0,u=n+60|0,i[u>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[t>>2]=o,i[u>>2]=r,i[l>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[l>>2]=s,r=r-a|0,i[u>>2]=r,i[t>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[l>>2]=c,i[t>>2]=o,i[u>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[l>>2]=s-a,i[t>>2]=o-a,i[u>>2]=r-a),i[n+64>>2]=i[e>>2],o=i[f>>2]|0,r=i[p>>2]|0,u=i[d+52>>2]|0,l=i[d+56>>2]|0,s=(i[d+48>>2]|0)+(i[m>>2]|0)|0,t=n+68|0,i[t>>2]=s,o=u+o|0,u=n+72|0,i[u>>2]=o,r=l+r|0,l=n+76|0,i[l>>2]=r,a=o-s|0,(s|0)<0?(r=r-s|0,i[u>>2]=a,i[l>>2]=r,i[t>>2]=0,o=0):(a=o,o=s),(a|0)<0&&(o=o-a|0,i[t>>2]=o,r=r-a|0,i[l>>2]=r,i[u>>2]=0,a=0),c=o-r|0,s=a-r|0,(r|0)<0?(i[t>>2]=c,i[u>>2]=s,i[l>>2]=0,o=c,r=0):s=a,a=(s|0)<(o|0)?s:o,a=(r|0)<(a|0)?r:a,(a|0)<=0){M=h;return}i[t>>2]=o-a,i[u>>2]=s-a,i[l>>2]=r-a,M=h}function at(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(p=i[16928+(t<<2)>>2]|0,f=(r|0)!=0,p=f?p*3|0:p,d=e+4|0,c=i[d>>2]|0,u=e+8|0,o=i[u>>2]|0,f){if(s=e+12|0,r=i[s>>2]|0,a=o+c+r|0,(a|0)==(p|0))return p=1,p|0;l=s}else l=e+12|0,a=i[l>>2]|0,r=a,a=o+c+a|0;if((a|0)<=(p|0))return p=0,p|0;do if((r|0)>0){if(a=i[e>>2]|0,(o|0)>0){a=18608+(a*80|0)+60|0,s=c;break}a=18608+(a*80|0)+40|0,n?(s=c-p|0,n=o+s|0,m=(n|0)<0,o=r+o-(m?n:0)|0,c=(o|0)<0,r=r+s-(m?n:0)-(c?o:0)|0,s=(r|0)<0,n=(m?0:n)-(c?o:0)-(s?r:0)|0,o=(c?0:o)-(s?r:0)|0,r=s?0:r,s=(o|0)<(n|0)?o:n,s=(r|0)<(s|0)?r:s,c=(s|0)>0,o=o-(c?s:0)|0,r=r-(c?s:0)|0,s=n-(c?s:0)+p|0,i[d>>2]=s,i[u>>2]=o,i[l>>2]=r):s=c}else a=18608+((i[e>>2]|0)*80|0)+20|0,s=c;while(0);if(i[e>>2]=i[a>>2],c=i[a+16>>2]|0,(c|0)>0){n=0;do m=r+s|0,h=(m|0)<0,v=h?m:0,g=o+s-v|0,_=(g|0)<0,e=_?g:0,s=r+o-v-e|0,o=(s|0)<0,r=o?0:s,s=o?s:0,o=(_?0:g)-s|0,s=(h?0:m)-e-s|0,e=(o|0)<(s|0)?o:s,e=(r|0)<(e|0)?r:e,(e|0)>0&&(s=s-e|0,o=o-e|0,r=r-e|0),n=n+1|0;while((n|0)<(c|0));i[d>>2]=s,i[u>>2]=o,i[l>>2]=r}return g=i[16848+(t<<2)>>2]|0,g=f?g*3|0:g,_=y(g,i[a+8>>2]|0)|0,v=y(g,i[a+12>>2]|0)|0,s=(y(g,i[a+4>>2]|0)|0)+s|0,i[d>>2]=s,o=_+o|0,i[u>>2]=o,r=v+r|0,i[l>>2]=r,a=o-s|0,(s|0)<0?(r=r-s|0,i[u>>2]=a,i[l>>2]=r,i[d>>2]=0,o=0):(a=o,o=s),(a|0)<0?(e=o-a|0,i[d>>2]=e,r=r-a|0,i[l>>2]=r,i[u>>2]=0,s=0):(e=o,s=a),o=e-r|0,a=s-r|0,(r|0)<0?(i[d>>2]=o,i[u>>2]=a,i[l>>2]=0,r=0):(a=s,o=e),s=(a|0)<(o|0)?a:o,s=(r|0)<(s|0)?r:s,(s|0)>0&&(o=o-s|0,a=a-s|0,r=r-s|0,i[d>>2]=o,i[u>>2]=a,i[l>>2]=r),f?(v=(a+o+r|0)==(p|0)?1:2,v|0):(v=2,v|0)}function ot(e,t){e|=0,t|=0;var n=0;do n=at(e,t,0,1)|0;while((n|0)==2);return n|0}function st(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,g=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,D=0,O=0,k=0,A=0,j=0,N=0,P=0,ee=0,F=0,te=0,ne=0,re=0,ie=0,ae=0,oe=0,se=0,ce=0,le=0;if(oe=M,M=M+272|0,s=oe+256|0,c=oe+240|0,re=oe,ie=oe+224|0,ae=oe+208|0,j=oe+184|0,N=oe+168|0,P=oe+152|0,ee=oe+136|0,F=oe+120|0,te=oe+96|0,i[s>>2]=t,i[c>>2]=i[e>>2],i[c+4>>2]=i[e+4>>2],i[c+8>>2]=i[e+8>>2],i[c+12>>2]=i[e+12>>2],ct(c,s,re),i[o>>2]=0,A=r+n+((r|0)==6&1)|0,(A|0)<=(n|0)){M=oe;return}x=i[s>>2]|0,S=n+6|0,C=ae+8|0,w=j+8|0,T=16928+(x<<2)|0,D=N+8|0,O=P+8|0,k=ee+8|0,y=i[c>>2]|0,m=ie+4|0,g=ie+8|0,v=ie+12|0,b=ae+8|0,u=j+8|0,f=j+16|0,d=te+8|0,p=te+16|0,c=0,l=n,r=-1;a:for(;;){if(s=(l|0)%6|0,e=re+(s<<4)|0,i[ie>>2]=i[e>>2],i[ie+4>>2]=i[e+4>>2],i[ie+8>>2]=i[e+8>>2],i[ie+12>>2]=i[e+12>>2],e=c,c=at(ie,x,0,1)|0,(l|0)>(n|0)&(Mt(t)|0)!=0&&(ne=i[ie>>2]|0,(e|0)!=1&(ne|0)!=(r|0))){switch(le=(s+5|0)%6|0,e=i[re+(le<<4)+12>>2]|0,se=+((i[re+(le<<4)+8>>2]|0)-e|0),a[ae>>3]=((i[re+(le<<4)+4>>2]|0)-e|0)-se*.5,a[C>>3]=se*.8660254037844386,e=i[re+(s<<4)+12>>2]|0,se=+((i[re+(s<<4)+8>>2]|0)-e|0),a[j>>3]=((i[re+(s<<4)+4>>2]|0)-e|0)-se*.5,a[w>>3]=se*.8660254037844386,se=+(i[T>>2]|0),a[N>>3]=se*3,a[D>>3]=0,ce=se*-1.5,a[P>>3]=ce,a[O>>3]=se*2.598076211353316,a[ee>>3]=ce,a[k>>3]=se*-2.598076211353316,i[17008+(y*80|0)+(((r|0)==(y|0)?ne:r)<<2)>>2]|0){case 1:e=P,r=N;break;case 3:e=ee,r=P;break;case 2:e=N,r=ee;break;default:e=8;break a}B(ae,j,r,e,F),!(zn(ae,F)|0)&&!(zn(j,F)|0)&&(nt(F,y,x,1,te),le=i[o>>2]|0,se=+h(+ +a[p>>3]),ce=+_(+ +a[d>>3],+ +a[te>>3]),a[o+8+(le<<4)>>3]=se,a[o+8+(le<<4)+8>>3]=ce,i[o>>2]=(i[o>>2]|0)+1)}if((l|0)<(S|0)&&(le=i[v>>2]|0,se=+((i[g>>2]|0)-le|0),a[ae>>3]=((i[m>>2]|0)-le|0)-se*.5,a[b>>3]=se*.8660254037844386,nt(ae,i[ie>>2]|0,x,1,j),le=i[o>>2]|0,se=+h(+ +a[f>>3]),ce=+_(+ +a[u>>3],+ +a[j>>3]),a[o+8+(le<<4)>>3]=se,a[o+8+(le<<4)+8>>3]=ce,i[o>>2]=(i[o>>2]|0)+1),l=l+1|0,(l|0)>=(A|0)){e=3;break}else r=i[ie>>2]|0}if((e|0)==3){M=oe;return}else(e|0)==8&&E(27157,27120,766,27202)}function ct(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;g=M,M=M+160|0,r=g+80|0,a=g,o=r,s=20336,c=o+72|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));o=a,s=20416,c=o+72|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));f=(Mt(i[t>>2]|0)|0)==0,f=f?r:a,h=e+4|0,o=i[h>>2]|0,p=e+8|0,r=i[p>>2]|0,m=e+12|0,a=i[m>>2]|0,s=r+(o<<1)|0,i[h>>2]=s,r=a+(r<<1)|0,i[p>>2]=r,o=(a<<1)+o|0,i[m>>2]=o,a=r-s|0,c=o-s|0,(s|0)<0&&(i[p>>2]=a,i[m>>2]=c,i[h>>2]=0,r=a,s=0,o=c),c=s-r|0,a=o-r|0,(r|0)<0?(i[h>>2]=c,i[m>>2]=a,i[p>>2]=0,r=0):(a=o,c=s),s=c-a|0,o=r-a|0,(a|0)<0?(i[h>>2]=s,i[p>>2]=o,i[m>>2]=0,a=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(a|0)<(r|0)?a:r,(r|0)>0&&(a=a-r|0,o=o-r|0,s=s-r|0,i[h>>2]=s,i[p>>2]=o,i[m>>2]=a),l=(o<<1)+s|0,c=a+(s<<1)|0,i[h>>2]=c,i[p>>2]=l,o=(a<<1)+o|0,i[m>>2]=o,r=l-c|0,a=o-c|0,(c|0)<0?(i[p>>2]=r,i[m>>2]=a,i[h>>2]=0,c=0,o=a):r=l,s=c-r|0,a=o-r|0,(r|0)<0?(i[h>>2]=s,i[m>>2]=a,i[p>>2]=0,c=s,r=0):a=o,s=c-a|0,o=r-a|0,(a|0)<0?(i[h>>2]=s,i[p>>2]=o,i[m>>2]=0,a=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(a|0)<(r|0)?a:r,(r|0)>0&&(i[h>>2]=s-r,i[p>>2]=o-r,i[m>>2]=a-r),Mt(i[t>>2]|0)|0&&(o=i[h>>2]|0,s=i[p>>2]|0,a=i[m>>2]|0,r=(s*3|0)+o|0,o=a+(o*3|0)|0,i[h>>2]=o,i[p>>2]=r,s=(a*3|0)+s|0,i[m>>2]=s,a=r-o|0,c=s-o|0,(o|0)<0?(i[p>>2]=a,i[m>>2]=c,i[h>>2]=0,r=a,l=0):(l=o,c=s),o=l-r|0,a=c-r|0,(r|0)<0?(i[h>>2]=o,i[m>>2]=a,i[p>>2]=0,l=o,s=0):(s=r,a=c),o=l-a|0,r=s-a|0,(a|0)<0?(i[h>>2]=o,i[p>>2]=r,i[m>>2]=0,s=r,a=0):o=l,r=(s|0)<(o|0)?s:o,r=(a|0)<(r|0)?a:r,(r|0)>0&&(i[h>>2]=o-r,i[p>>2]=s-r,i[m>>2]=a-r),i[t>>2]=(i[t>>2]|0)+1),l=0;do i[n+(l<<4)>>2]=i[e>>2],a=i[p>>2]|0,r=i[m>>2]|0,u=i[f+(l*12|0)+4>>2]|0,d=i[f+(l*12|0)+8>>2]|0,s=(i[f+(l*12|0)>>2]|0)+(i[h>>2]|0)|0,t=n+(l<<4)+4|0,i[t>>2]=s,a=u+a|0,u=n+(l<<4)+8|0,i[u>>2]=a,r=d+r|0,d=n+(l<<4)+12|0,i[d>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[u>>2]=o,i[d>>2]=r,i[t>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[t>>2]=s,r=r-a|0,i[d>>2]=r,i[u>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[t>>2]=c,i[u>>2]=o,i[d>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[t>>2]=s-a,i[u>>2]=o-a,i[d>>2]=r-a),l=l+1|0;while((l|0)!=6);M=g}function lt(e,t){return e|=0,t|=0,t=H(e|0,t|0,52)|0,T()|0,t&15|0}function ut(e,t){return e|=0,t|=0,t=H(e|0,t|0,45)|0,T()|0,t&127|0}function dt(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,(n+-1|0)>>>0>14?(r=4,r|0):(n=H(e|0,t|0,(15-n|0)*3|0)|0,T()|0,i[r>>2]=n&7,r=0,r|0)}function ft(e,t,n,a){e|=0,t|=0,n|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0;if(e>>>0>15)return a=4,a|0;if(t>>>0>121)return a=17,a|0;c=_r(e|0,0,52)|0,o=T()|0,l=_r(t|0,0,45)|0,o=o|T()|134225919;a:do if((e|0)>=1){for(l=1,c=(r[20496+t>>0]|0)!=0,s=-1;;){if(t=i[n+(l+-1<<2)>>2]|0,t>>>0>6){o=18,t=10;break}if(!((t|0)==0|c^1))if((t|0)==1){o=19,t=10;break}else c=0;if(d=(15-l|0)*3|0,u=_r(7,0,d|0)|0,o&=~(T()|0),t=_r(t|0,((t|0)<0)<<31>>31|0,d|0)|0,s=t|s&~u,o=T()|0|o,(l|0)<(e|0))l=l+1|0;else break a}if((t|0)==10)return o|0}else s=-1;while(0);return d=a,i[d>>2]=s,i[d+4>>2]=o,d=0,d|0}function pt(e,t){e|=0,t|=0;var n=0,i=0,a=0,o=0,s=0;return!(!0&(t&-16777216|0)==134217728)||(i=H(e|0,t|0,52)|0,T()|0,i&=15,n=H(e|0,t|0,45)|0,T()|0,n&=127,n>>>0>121)?(e=0,e|0):(s=(i^15)*3|0,a=H(e|0,t|0,s|0)|0,s=_r(a|0,T()|0,s|0)|0,a=T()|0,o=cr(-1227133514,-1171,s|0,a|0)|0,!((s&613566756&o|0)==0&(a&4681&(T()|0)|0)==0)||(s=(i*3|0)+19|0,o=_r(~e|0,~t|0,s|0)|0,s=H(o|0,T()|0,s|0)|0,!((i|0)==15|(s|0)==0&(T()|0)==0))?(s=0,s|0):!(r[20496+n>>0]|0)||(t&=8191,(e|0)==0&(t|0)==0)?(s=1,s|0):(s=vr(e|0,t|0,0)|0,T()|0,((63-s|0)%3|0)!=0|0))}function mt(e,t){e|=0,t|=0;var n=0,i=0,a=0,o=0,s=0;return!0&(t&-16777216|0)==134217728&&(i=H(e|0,t|0,52)|0,T()|0,i&=15,n=H(e|0,t|0,45)|0,T()|0,n&=127,n>>>0<=121)&&(s=(i^15)*3|0,a=H(e|0,t|0,s|0)|0,s=_r(a|0,T()|0,s|0)|0,a=T()|0,o=cr(-1227133514,-1171,s|0,a|0)|0,(s&613566756&o|0)==0&(a&4681&(T()|0)|0)==0)&&(s=(i*3|0)+19|0,o=_r(~e|0,~t|0,s|0)|0,s=H(o|0,T()|0,s|0)|0,(i|0)==15|(s|0)==0&(T()|0)==0)&&(!(r[20496+n>>0]|0)||(n=t&8191,(e|0)==0&(n|0)==0)||(s=vr(e|0,n|0,0)|0,T()|0,(63-s|0)%3|0))||Ye(e,t)|0?(s=1,s|0):(s=(Wn(e,t)|0)!=0&1,s|0)}function ht(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0;if(a=_r(t|0,0,52)|0,o=T()|0,n=_r(n|0,0,45)|0,n=o|T()|134225919,(t|0)<1){o=-1,r=n,t=e,i[t>>2]=o,e=e+4|0,i[e>>2]=r;return}for(o=1,a=-1;s=(15-o|0)*3|0,c=_r(7,0,s|0)|0,n&=~(T()|0),s=_r(r|0,0,s|0)|0,a=a&~c|s,n=n|T()|0,(o|0)!=(t|0);)o=o+1|0;c=e,s=c,i[s>>2]=a,c=c+4|0,i[c>>2]=n}function gt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;if(o=H(e|0,t|0,52)|0,T()|0,o&=15,n>>>0>15)return r=4,r|0;if((o|0)<(n|0))return r=12,r|0;if((o|0)==(n|0))return i[r>>2]=e,i[r+4>>2]=t,r=0,r|0;if(a=_r(n|0,0,52)|0,a|=e,e=T()|0|t&-15728641,(o|0)>(n|0))do t=_r(7,0,(14-n|0)*3|0)|0,n=n+1|0,a=t|a,e=T()|0|e;while((n|0)<(o|0));return i[r>>2]=a,i[r+4>>2]=e,r=0,r|0}function _t(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;if(o=H(e|0,t|0,52)|0,T()|0,o&=15,!((n|0)<16&(o|0)<=(n|0)))return r=4,r|0;a=n-o|0,n=H(e|0,t|0,45)|0,T()|0;a:do if(!(be(n&127)|0))n=hn(7,0,a,((a|0)<0)<<31>>31)|0,a=T()|0;else{b:do if(o|0){for(n=1;s=_r(7,0,(15-n|0)*3|0)|0,(s&e|0)==0&((T()|0)&t|0)==0;)if(n>>>0>>0)n=n+1|0;else break b;n=hn(7,0,a,((a|0)<0)<<31>>31)|0,a=T()|0;break a}while(0);n=hn(7,0,a,((a|0)<0)<<31>>31)|0,n=pr(n|0,T()|0,5,0)|0,n=sr(n|0,T()|0,-5,-1)|0,n=dr(n|0,T()|0,6,0)|0,n=sr(n|0,T()|0,1,0)|0,a=T()|0}while(0);return s=r,i[s>>2]=n,i[s+4>>2]=a,s=0,s|0}function vt(e,t){e|=0,t|=0;var n=0,r=0,i=0;if(i=H(e|0,t|0,45)|0,T()|0,!(be(i&127)|0))return i=0,i|0;i=H(e|0,t|0,52)|0,T()|0,i&=15;a:do if(!i)n=0;else for(r=1;;){if(n=H(e|0,t|0,(15-r|0)*3|0)|0,T()|0,n&=7,n|0)break a;if(r>>>0>>0)r=r+1|0;else{n=0;break}}while(0);return i=(n|0)==0&1,i|0}function yt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0;if(s=M,M=M+16|0,o=s,Wt(o,e,t,n),t=o,e=i[t>>2]|0,t=i[t+4>>2]|0,(e|0)==0&(t|0)==0)return M=s,0;a=0,n=0;do c=r+(a<<3)|0,i[c>>2]=e,i[c+4>>2]=t,a=sr(a|0,n|0,1,0)|0,n=T()|0,Kt(o),c=o,e=i[c>>2]|0,t=i[c+4>>2]|0;while(!((e|0)==0&(t|0)==0));return M=s,0}function bt(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,(r|0)<(n|0)?(n=t,r=e,w(n|0),r|0):(n=_r(-1,-1,((r-n|0)*3|0)+3|0)|0,r=_r(~n|0,~(T()|0)|0,(15-r|0)*3|0)|0,n=~(T()|0)&t,r=~r&e,w(n|0),r|0)}function xt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0;return a=H(e|0,t|0,52)|0,T()|0,a&=15,(n|0)<16&(a|0)<=(n|0)?((a|0)<(n|0)&&(a=_r(-1,-1,((n+-1-a|0)*3|0)+3|0)|0,a=_r(~a|0,~(T()|0)|0,(15-n|0)*3|0)|0,t=~(T()|0)&t,e=~a&e),a=_r(n|0,0,52)|0,n=t&-15728641|T()|0,i[r>>2]=e|a,i[r+4>>2]=n,r=0,r|0):(r=4,r|0)}function St(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0,O=0,k=0,A=0,j=0,M=0;if((n|0)==0&(r|0)==0)return M=0,M|0;if(a=e,o=i[a>>2]|0,a=i[a+4>>2]|0,!0&(a&15728640|0)==0){if(!((r|0)>0|(r|0)==0&n>>>0>0)||(M=t,i[M>>2]=o,i[M+4>>2]=a,(n|0)==1&(r|0)==0))return M=0,M|0;a=1,o=0;do A=e+(a<<3)|0,j=i[A+4>>2]|0,M=t+(a<<3)|0,i[M>>2]=i[A>>2],i[M+4>>2]=j,a=sr(a|0,o|0,1,0)|0,o=T()|0;while((o|0)<(r|0)|(o|0)==(r|0)&a>>>0>>0);return a=0,a|0}if(k=n<<3,j=tr(k)|0,!j)return M=13,M|0;if(Sr(j|0,e|0,k|0)|0,A=rr(n,8)|0,!A)return nr(j),M=13,M|0;a:for(;;){a=j,u=i[a>>2]|0,a=i[a+4>>2]|0,D=H(u|0,a|0,52)|0,T()|0,D&=15,O=D+-1|0,w=(D|0)!=0,C=(r|0)>0|(r|0)==0&n>>>0>0;b:do if(w&C){if(y=_r(O|0,0,52)|0,b=T()|0,O>>>0>15){if(!((u|0)==0&(a|0)==0)){M=16;break a}for(o=0,e=0;;){if(o=sr(o|0,e|0,1,0)|0,e=T()|0,!((e|0)<(r|0)|(e|0)==(r|0)&o>>>0>>0))break b;if(s=j+(o<<3)|0,S=i[s>>2]|0,s=i[s+4>>2]|0,!((S|0)==0&(s|0)==0)){a=s,M=16;break a}}}for(c=u,e=a,o=0,s=0;;){if(!((c|0)==0&(e|0)==0)){if(!(!0&(e&117440512|0)==0)){M=21;break a}if(d=H(c|0,e|0,52)|0,T()|0,d&=15,(d|0)<(O|0)){a=12,M=27;break a}if((d|0)!=(O|0)&&(c|=y,e=e&-15728641|b,d>>>0>=D>>>0)){l=O;do S=_r(7,0,(14-l|0)*3|0)|0,l=l+1|0,c=S|c,e=T()|0|e;while(l>>>0>>0)}if(p=hr(c|0,e|0,n|0,r|0)|0,m=T()|0,l=A+(p<<3)|0,d=l,f=i[d>>2]|0,d=i[d+4>>2]|0,!((f|0)==0&(d|0)==0)){_=0,v=0;do{if((_|0)>(r|0)|(_|0)==(r|0)&v>>>0>n>>>0){M=31;break a}if((f|0)==(c|0)&(d&-117440513|0)==(e|0)){h=H(f|0,d|0,56)|0,T()|0,h&=7,g=h+1|0,S=H(f|0,d|0,45)|0,T()|0;c:do if(!(be(S&127)|0))d=7;else{if(f=H(f|0,d|0,52)|0,T()|0,f&=15,!f){d=6;break}for(d=1;;){if(S=_r(7,0,(15-d|0)*3|0)|0,!((S&c|0)==0&((T()|0)&e|0)==0)){d=7;break c}if(d>>>0>>0)d=d+1|0;else{d=6;break}}}while(0);if((h+2|0)>>>0>d>>>0){M=41;break a}S=_r(g|0,0,56)|0,e=T()|0|e&-117440513,x=l,i[x>>2]=0,i[x+4>>2]=0,c=S|c}else p=sr(p|0,m|0,1,0)|0,p=mr(p|0,T()|0,n|0,r|0)|0,m=T()|0;v=sr(v|0,_|0,1,0)|0,_=T()|0,l=A+(p<<3)|0,d=l,f=i[d>>2]|0,d=i[d+4>>2]|0}while(!((f|0)==0&(d|0)==0))}S=l,i[S>>2]=c,i[S+4>>2]=e}if(o=sr(o|0,s|0,1,0)|0,s=T()|0,!((s|0)<(r|0)|(s|0)==(r|0)&o>>>0>>0))break b;e=j+(o<<3)|0,c=i[e>>2]|0,e=i[e+4>>2]|0}}while(0);if(S=sr(n|0,r|0,5,0)|0,x=T()|0,x>>>0<0|(x|0)==0&S>>>0<11){M=85;break}if(S=dr(n|0,r|0,6,0)|0,T()|0,S=rr(S,8)|0,!S){M=48;break}do if(C){for(g=0,e=0,h=0,_=0;;){if(d=A+(g<<3)|0,s=d,o=i[s>>2]|0,s=i[s+4>>2]|0,(o|0)==0&(s|0)==0)x=h;else{f=H(o|0,s|0,56)|0,T()|0,f&=7,c=f+1|0,p=s&-117440513,x=H(o|0,s|0,45)|0,T()|0;d:do if(be(x&127)|0){if(m=H(o|0,s|0,52)|0,T()|0,m&=15,m|0)for(l=1;;){if(x=_r(7,0,(15-l|0)*3|0)|0,!((o&x|0)==0&(p&(T()|0)|0)==0))break d;if(l>>>0>>0)l=l+1|0;else break}s=_r(c|0,0,56)|0,o=s|o,s=T()|0|p,c=d,i[c>>2]=o,i[c+4>>2]=s,c=f+2|0}while(0);(c|0)==7?(x=S+(e<<3)|0,i[x>>2]=o,i[x+4>>2]=s&-117440513,e=sr(e|0,h|0,1,0)|0,x=T()|0):x=h}if(g=sr(g|0,_|0,1,0)|0,_=T()|0,(_|0)<(r|0)|(_|0)==(r|0)&g>>>0>>0)h=x;else break}if(C){if(v=O>>>0>15,y=_r(O|0,0,52)|0,b=T()|0,!w){for(o=0,l=0,c=0,s=0;(u|0)==0&(a|0)==0||(O=t+(o<<3)|0,i[O>>2]=u,i[O+4>>2]=a,o=sr(o|0,l|0,1,0)|0,l=T()|0),c=sr(c|0,s|0,1,0)|0,s=T()|0,(s|0)<(r|0)|(s|0)==(r|0)&c>>>0>>0;)a=j+(c<<3)|0,u=i[a>>2]|0,a=i[a+4>>2]|0;a=x;break}for(o=0,l=0,s=0,c=0;;){do if(!((u|0)==0&(a|0)==0)){if(m=H(u|0,a|0,52)|0,T()|0,m&=15,v|(m|0)<(O|0)){M=80;break a}if((m|0)!=(O|0)){if(d=u|y,f=a&-15728641|b,m>>>0>=D>>>0){p=O;do w=_r(7,0,(14-p|0)*3|0)|0,p=p+1|0,d=w|d,f=T()|0|f;while(p>>>0>>0)}}else d=u,f=a;h=hr(d|0,f|0,n|0,r|0)|0,p=0,m=0,_=T()|0;do{if((p|0)>(r|0)|(p|0)==(r|0)&m>>>0>n>>>0){M=81;break a}if(w=A+(h<<3)|0,g=i[w+4>>2]|0,(g&-117440513|0)==(f|0)&&(i[w>>2]|0)==(d|0)){M=65;break}w=sr(h|0,_|0,1,0)|0,h=mr(w|0,T()|0,n|0,r|0)|0,_=T()|0,m=sr(m|0,p|0,1,0)|0,p=T()|0,w=A+(h<<3)|0}while(!((i[w>>2]|0)==(d|0)&&(i[w+4>>2]|0)==(f|0)));if((M|0)==65&&(M=0,!0&(g&117440512|0)==100663296))break;w=t+(o<<3)|0,i[w>>2]=u,i[w+4>>2]=a,o=sr(o|0,l|0,1,0)|0,l=T()|0}while(0);if(s=sr(s|0,c|0,1,0)|0,c=T()|0,!((c|0)<(r|0)|(c|0)==(r|0)&s>>>0>>0))break;a=j+(s<<3)|0,u=i[a>>2]|0,a=i[a+4>>2]|0}a=x}else o=0,a=x}else o=0,e=0,a=0;while(0);if(wr(A|0,0,k|0)|0,Sr(j|0,S|0,e<<3|0)|0,nr(S),(e|0)==0&(a|0)==0){M=89;break}else t=t+(o<<3)|0,r=a,n=e}if((M|0)==16)!0&(a&117440512|0)==0?(a=4,M=27):M=21;else if((M|0)==31)E(27634,27225,620,27235);else if((M|0)==41)return nr(j),nr(A),M=10,M|0;else if((M|0)==48)return nr(j),nr(A),M=13,M|0;else(M|0)==80?E(27634,27225,711,27235):(M|0)==81?E(27634,27225,723,27235):(M|0)==85&&(Sr(t|0,j|0,n<<3|0)|0,M=89);return(M|0)==21?(nr(j),nr(A),M=5,M|0):(M|0)==27?(nr(j),nr(A),M=a,M|0):(M|0)==89?(nr(j),nr(A),M=0,M|0):0}function Ct(e,t,n,r,a,o,s){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0;var c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(g=M,M=M+16|0,h=g,!((n|0)>0|(n|0)==0&t>>>0>0))return h=0,M=g,h|0;if((s|0)>=16)return h=12,M=g,h|0;p=0,m=0,f=0,c=0;a:for(;;){if(u=e+(p<<3)|0,l=i[u>>2]|0,u=i[u+4>>2]|0,d=H(l|0,u|0,52)|0,T()|0,(d&15|0)>(s|0)){c=12,l=11;break}if(Wt(h,l,u,s),d=h,u=i[d>>2]|0,d=i[d+4>>2]|0,(u|0)==0&(d|0)==0)l=f;else{l=f;do{if(!((c|0)<(o|0)|(c|0)==(o|0)&l>>>0>>0)){l=10;break a}f=r+(l<<3)|0,i[f>>2]=u,i[f+4>>2]=d,l=sr(l|0,c|0,1,0)|0,c=T()|0,Kt(h),f=h,u=i[f>>2]|0,d=i[f+4>>2]|0}while(!((u|0)==0&(d|0)==0))}if(p=sr(p|0,m|0,1,0)|0,m=T()|0,(m|0)<(n|0)|(m|0)==(n|0)&p>>>0>>0)f=l;else{c=0,l=11;break}}return(l|0)==10?(h=14,M=g,h|0):(l|0)==11?(M=g,c|0):0}function wt(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;p=M,M=M+16|0,f=p;a:do if((n|0)>0|(n|0)==0&t>>>0>0){for(u=0,s=0,o=0,d=0;;){if(l=e+(u<<3)|0,c=i[l>>2]|0,l=i[l+4>>2]|0,!((c|0)==0&(l|0)==0)&&(l=(_t(c,l,r,f)|0)==0,c=f,s=sr(i[c>>2]|0,i[c+4>>2]|0,s|0,o|0)|0,o=T()|0,!l)){o=12;break}if(u=sr(u|0,d|0,1,0)|0,d=T()|0,!((d|0)<(n|0)|(d|0)==(n|0)&u>>>0>>0))break a}return M=p,o|0}else s=0,o=0;while(0);return i[a>>2]=s,i[a+4>>2]=o,a=0,M=p,a|0}function Tt(e,t){return e|=0,t|=0,t=H(e|0,t|0,52)|0,T()|0,t&1|0}function Et(e,t){e|=0,t|=0;var n=0,r=0,i=0;if(i=H(e|0,t|0,52)|0,T()|0,i&=15,!i)return i=0,i|0;for(r=1;;){if(n=H(e|0,t|0,(15-r|0)*3|0)|0,T()|0,n&=7,n|0){r=5;break}if(r>>>0>>0)r=r+1|0;else{n=0,r=5;break}}return(r|0)==5?n|0:0}function Dt(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0,u=0;if(u=H(e|0,t|0,52)|0,T()|0,u&=15,!u)return l=t,u=e,w(l|0),u|0;for(l=1,n=0;;){switch(r=(15-l|0)*3|0,s=_r(7,0,r|0)|0,c=T()|0,a=e&~s,o=t&~c,e=H(e|0,t|0,r|0)|0,T()|0,e&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e&=7}r=_r(e|0,0,r|0)|0,i=T()|0,e=r|a,t=i|o;a:do if(!n)if((r&s|0)==0&(i&c|0)==0)n=0;else if(o=H(e|0,t|0,52)|0,T()|0,o&=15,!o)n=1;else{n=1;b:for(;;){switch(c=H(e|0,t|0,(15-n|0)*3|0)|0,T()|0,c&7){case 1:break b;case 0:break;default:n=1;break a}if(n>>>0>>0)n=n+1|0;else{n=1;break a}}for(a=1;;){switch(i=(15-a|0)*3|0,n=H(e|0,t|0,i|0)|0,T()|0,r=_r(7,0,i|0)|0,r=e&~r,t&=~(T()|0),n&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=n&7}if(e=_r(e|0,0,i|0)|0,e|=r,t=T()|0|t,a>>>0>>0)a=a+1|0;else{n=1;break a}}}while(0);if(l>>>0>>0)l=l+1|0;else break}return w(t|0),e|0}function Ot(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0;if(o=H(e|0,t|0,52)|0,T()|0,o&=15,!o)return a=t,o=e,w(a|0),o|0;for(a=1;;){switch(i=(15-a|0)*3|0,n=H(e|0,t|0,i|0)|0,T()|0,r=_r(7,0,i|0)|0,r=e&~r,t&=~(T()|0),n&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=n&7}if(e=_r(e|0,0,i|0)|0,e|=r,t=T()|0|t,a>>>0>>0)a=a+1|0;else break}return w(t|0),e|0}function kt(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0,u=0;if(u=H(e|0,t|0,52)|0,T()|0,u&=15,!u)return l=t,u=e,w(l|0),u|0;for(l=1,n=0;;){switch(r=(15-l|0)*3|0,s=_r(7,0,r|0)|0,c=T()|0,a=e&~s,o=t&~c,e=H(e|0,t|0,r|0)|0,T()|0,e&7){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}r=_r(e|0,0,r|0)|0,i=T()|0,e=r|a,t=i|o;a:do if(!n)if((r&s|0)==0&(i&c|0)==0)n=0;else if(o=H(e|0,t|0,52)|0,T()|0,o&=15,!o)n=1;else{n=1;b:for(;;){switch(c=H(e|0,t|0,(15-n|0)*3|0)|0,T()|0,c&7){case 1:break b;case 0:break;default:n=1;break a}if(n>>>0>>0)n=n+1|0;else{n=1;break a}}for(a=1;;){switch(n=(15-a|0)*3|0,r=_r(7,0,n|0)|0,r=e&~r,i=t&~(T()|0),e=H(e|0,t|0,n|0)|0,T()|0,e&7){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(e=_r(e|0,0,n|0)|0,e|=r,t=T()|0|i,a>>>0>>0)a=a+1|0;else{n=1;break a}}}while(0);if(l>>>0>>0)l=l+1|0;else break}return w(t|0),e|0}function At(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0;if(o=H(e|0,t|0,52)|0,T()|0,o&=15,!o)return a=t,o=e,w(a|0),o|0;for(a=1;;){switch(r=(15-a|0)*3|0,n=_r(7,0,r|0)|0,n=e&~n,i=t&~(T()|0),e=H(e|0,t|0,r|0)|0,T()|0,e&7){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(e=_r(e|0,0,r|0)|0,e|=n,t=T()|0|i,a>>>0>>0)a=a+1|0;else break}return w(t|0),e|0}function jt(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,E=0;if(x=M,M=M+16|0,b=x,_r(t|0,0,52)|0,n=T()|134225919,!t)return(i[e+4>>2]|0)>2||(i[e+8>>2]|0)>2||(i[e+12>>2]|0)>2?(y=0,b=0,w(y|0),M=x,b|0):(_r(Se(e)|0,0,45)|0,y=T()|0|n,b=-1,w(y|0),M=x,b|0);i[b>>2]=i[e>>2],i[b+4>>2]=i[e+4>>2],i[b+8>>2]=i[e+8>>2],i[b+12>>2]=i[e+12>>2],y=b+4|0;a:do if((t|0)>0)for(g=b+8|0,_=b+12|0,h=t,f=i[g>>2]|0,p=i[_>>2]|0,t=-1,d=i[b+4>>2]|0;;){m=h,h=h+-1|0,e=d-p|0,r=f-p|0,m&1?(o=er(((e*3|0)-r|0)*.14285714285714285)|0,i[y>>2]=o,e=er(((r<<1)+e|0)*.14285714285714285)|0,i[g>>2]=e,i[_>>2]=0,r=e-o|0,a=0-o|0,(o|0)<0?(i[g>>2]=r,i[_>>2]=a,i[y>>2]=0,e=r,s=0):(s=o,a=0),o=s-e|0,r=a-e|0,(e|0)<0?(i[y>>2]=o,i[_>>2]=r,i[g>>2]=0,s=o,o=0):(r=a,o=e),e=s-r|0,a=o-r|0,(r|0)<0?(i[y>>2]=e,i[g>>2]=a,i[_>>2]=0,o=0):(a=o,e=s,o=r),r=(a|0)<(e|0)?a:e,r=(o|0)<(r|0)?o:r,(r|0)>0&&(o=o-r|0,a=a-r|0,e=e-r|0,i[y>>2]=e,i[g>>2]=a,i[_>>2]=o),C=a+(e*3|0)|0,S=(C|0)<0,u=o+(a*3|0)-(S?C:0)|0,l=(u|0)<0,r=(o*3|0)+e-(S?C:0)-(l?u:0)|0,c=(r|0)<0,E=c?0:r,s=(l?0:u)-(c?r:0)|0,r=(S?0:C)-(l?u:0)-(c?r:0)|0,c=(s|0)<(r|0)?s:r,c=(E|0)<(c|0)?E:c,u=(c|0)>0,l=u?c:0,s=s-(u?c:0)|0,c=E-(u?c:0)|0,u=o):(c=er(((e<<1)+r|0)*.14285714285714285)|0,i[y>>2]=c,a=er(((r*3|0)-e|0)*.14285714285714285)|0,i[g>>2]=a,i[_>>2]=0,r=a-c|0,e=0-c|0,(c|0)<0?(i[g>>2]=r,i[_>>2]=e,i[y>>2]=0,a=r,c=0):e=0,s=c-a|0,r=e-a|0,(a|0)<0?(i[y>>2]=s,i[_>>2]=r,i[g>>2]=0,o=r,a=0):(o=e,s=c),e=s-o|0,r=a-o|0,(o|0)<0?(i[y>>2]=e,i[g>>2]=r,i[_>>2]=0,a=r,o=0):e=s,r=(a|0)<(e|0)?a:e,r=(o|0)<(r|0)?o:r,(r|0)>0&&(o=o-r|0,a=a-r|0,e=e-r|0,i[y>>2]=e,i[g>>2]=a,i[_>>2]=o),C=o+(e*3|0)|0,E=(C|0)<0,u=(a*3|0)+e-(E?C:0)|0,l=(u|0)<0,r=(o*3|0)+a-(E?C:0)-(l?u:0)|0,c=(r|0)<0,S=c?0:r,s=(l?0:u)-(c?r:0)|0,r=(E?0:C)-(l?u:0)-(c?r:0)|0,c=(s|0)<(r|0)?s:r,c=(S|0)<(c|0)?S:c,u=(c|0)>0,l=u?c:0,s=s-(u?c:0)|0,c=S-(u?c:0)|0,u=o),r=d+(l-r)|0,o=(r|0)<0,l=f-s-(o?r:0)|0,s=(l|0)<0,p=p-c+(o?0-r|0:0)+(s?0-l|0:0)|0,d=(p|0)<0,c=d?0:p,E=(s?0:l)-(d?p:0)|0,p=(o?0:r)-(s?l:0)-(d?p:0)|0,d=(E|0)<(p|0)?E:p,d=(c|0)<(d|0)?c:d,l=(d|0)>0,p=p-(l?d:0)|0,s=(15-m|0)*3|0,r=_r(7,0,s|0)|0,r=t&~r,o=n&~(T()|0),f=(p|0)<0,C=f?p:0,E=E-(l?d:0)-C|0,S=(E|0)<0,C=(S?0-E|0:0)+(c-(l?d:0)-C)|0,n=(C|0)<0,t=n?0:C,C=n?C:0,n=(S?0:E)-C|0,C=(f?0:p)-(S?E:0)-C|0,E=(n|0)<(C|0)?n:C,E=(t|0)<(E|0)?t:E,E=(E|0)>0?E:0,t=t-E|0,n=n-E|0;b:do switch(C-E|0){case 0:switch(n|0){case 0:t=t|0?(t|0)==1?1:7:0;break b;case 1:t=t|0?(t|0)==1?3:7:2;break b;default:v=36;break b}case 1:switch(n|0){case 0:t=t|0?(t|0)==1?5:7:4;break b;case 1:if(t){v=36;break b}else{t=6;break b}default:v=36;break b}default:v=36}while(0);if((v|0)==36&&(v=0,t=7),t=_r(t|0,0,s|0)|0,t|=r,n=T()|0|o,(m|0)<=1)break a;f=a,p=u,d=e}else t=-1,e=i[y>>2]|0;while(0);c:do if((e|0)<=2&&(i[b+8>>2]|0)<=2&&(i[b+12>>2]|0)<=2){if(r=Se(b)|0,e=_r(r|0,0,45)|0,t=e|t,e=T()|0|n&-1040385,l=I(b)|0,!(be(r)|0)){if((l|0)<=0)break;for(c=0;;){s=H(t|0,e|0,52)|0,T()|0,s&=15;d:do if(s)for(o=1;;){switch(a=(15-o|0)*3|0,n=H(t|0,e|0,a|0)|0,T()|0,r=_r(7,0,a|0)|0,t&=~r,r=e&~(T()|0),n&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=n&7}if(e=_r(e|0,0,a|0)|0,t=e|t,e=T()|0|r,o>>>0>>0)o=o+1|0;else break d}while(0);if(c=c+1|0,(c|0)==(l|0))break c}}s=H(t|0,e|0,52)|0,T()|0,s&=15;e:do if(s){n=1;f:for(;;){switch(E=H(t|0,e|0,(15-n|0)*3|0)|0,T()|0,E&7){case 1:break f;case 0:break;default:break e}if(n>>>0>>0)n=n+1|0;else break e}if(Te(r,i[b>>2]|0)|0)for(o=1;;){switch(n=(15-o|0)*3|0,r=_r(7,0,n|0)|0,r=t&~r,a=e&~(T()|0),e=H(t|0,e|0,n|0)|0,T()|0,e&7){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(t=_r(e|0,0,n|0)|0,t|=r,e=T()|0|a,o>>>0>>0)o=o+1|0;else break e}else for(o=1;;){switch(a=(15-o|0)*3|0,n=H(t|0,e|0,a|0)|0,T()|0,r=_r(7,0,a|0)|0,t&=~r,r=e&~(T()|0),n&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=n&7}if(e=_r(e|0,0,a|0)|0,t=e|t,e=T()|0|r,o>>>0>>0)o=o+1|0;else break e}}while(0);if((l|0)>0){n=0;do t=Dt(t,e)|0,e=T()|0,n=n+1|0;while((n|0)!=(l|0))}}else t=0,e=0;while(0);return C=e,E=t,w(C|0),M=x,E|0}function Mt(e){return e|=0,(e|0)%2|0}function Nt(e,t,n){e|=0,t|=0,n|=0;var r=0,s=0,c=0,l=0,u=0,p=0,m=0,h=0,g=0;if(h=M,M=M+64|0,u=h+24|0,p=h+48|0,m=h,t>>>0>15)return m=4,M=h,m|0;if(c=+a[e>>3],a[o>>3]=c,(i[o+4>>2]&2146435072|0)==2146435072||(r=+a[e+8>>3],a[o>>3]=r,(i[o+4>>2]&2146435072|0)==2146435072))return m=3,M=h,m|0;s=+d(+c),g=s*+d(+r),s*=+f(+r),r=+f(+c),a[m>>3]=g,a[m+8>>3]=s,a[m+16>>3]=r,a[o>>3]=g;do if((i[o+4>>2]&2146435072|0)!=2146435072&&(a[o>>3]=r,e=i[o+4>>2]|0,a[o>>3]=s,!((i[o+4>>2]&2146435072|0)==2146435072|!0&(e&2146435072|0)==2146435072)))if(i[u>>2]=i[m>>2],i[u+4>>2]=i[m+4>>2],i[u+8>>2]=i[m+8>>2],i[u+12>>2]=i[m+12>>2],i[u+16>>2]=i[m+16>>2],i[u+20>>2]=i[m+20>>2],et(u,t,p),p=jt(p,t)|0,m=T()|0,i[n>>2]=p,i[n+4>>2]=m,(p|0)==0&(m|0)==0)E(27634,27225,1073,27248);else{l=0;break}else l=2;while(0);return m=l,M=h,m|0}function Pt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(m=n+4|0,h=H(e|0,t|0,52)|0,T()|0,h&=15,p=H(e|0,t|0,45)|0,T()|0,r=(h|0)==0,!(be(p&127)|0)){if(r)return h=0,h|0;r=!(i[m>>2]|0)&&!(i[n+8>>2]|0)?(i[n+12>>2]|0)!=0&1:1}else if(r)return h=1,h|0;else r=1;for(p=n+8|0,f=n+12|0,d=1,n=i[m>>2]|0,s=i[p>>2]|0,o=i[f>>2]|0;a=n*3|0,c=s*3|0,u=o*3|0,d&1?(l=s+a|0,i[m>>2]=l,o=o+c|0,i[p>>2]=o,a=u+n|0,i[f>>2]=a,n=o-l|0,s=a-l|0,(l|0)<0?(i[p>>2]=n,i[f>>2]=s,i[m>>2]=0,c=0,a=s):(n=o,c=l),s=c-n|0,o=a-n|0,(n|0)<0?(i[m>>2]=s,i[f>>2]=o,i[p>>2]=0,c=s,a=0):(o=a,a=n),n=c-o|0,s=a-o|0,(o|0)<0?(i[m>>2]=n,i[p>>2]=s,i[f>>2]=0,o=0):(s=a,n=c),a=(s|0)<(n|0)?s:n,a=(o|0)<(a|0)?o:a,(a|0)>0&&(o=o-a|0,s=s-a|0,n=n-a|0,i[m>>2]=n,i[p>>2]=s,i[f>>2]=o)):(l=c+n|0,c=o+a|0,i[m>>2]=c,i[p>>2]=l,a=u+s|0,i[f>>2]=a,n=l-c|0,o=a-c|0,(c|0)<0?(i[p>>2]=n,i[f>>2]=o,i[m>>2]=0,c=0,a=o):n=l,s=c-n|0,o=a-n|0,(n|0)<0?(i[m>>2]=s,i[f>>2]=o,i[p>>2]=0,c=s,a=0):(o=a,a=n),n=c-o|0,s=a-o|0,(o|0)<0?(i[m>>2]=n,i[p>>2]=s,i[f>>2]=0,o=0):(s=a,n=c),a=(s|0)<(n|0)?s:n,a=(o|0)<(a|0)?o:a,(a|0)>0&&(o=o-a|0,s=s-a|0,n=n-a|0,i[m>>2]=n,i[p>>2]=s,i[f>>2]=o)),a=H(e|0,t|0,(15-d|0)*3|0)|0,T()|0,a&=7,(a+-1|0)>>>0<6&&(l=i[22032+(a*12|0)+4>>2]|0,u=i[22032+(a*12|0)+8>>2]|0,c=(i[22032+(a*12|0)>>2]|0)+n|0,i[m>>2]=c,s=l+s|0,i[p>>2]=s,n=u+o|0,i[f>>2]=n,o=s-c|0,a=n-c|0,(c|0)<0&&(i[p>>2]=o,i[f>>2]=a,i[m>>2]=0,c=0,n=a,s=o),a=c-s|0,o=n-s|0,(s|0)<0?(i[m>>2]=a,i[f>>2]=o,i[p>>2]=0,c=a,s=0):o=n,n=c-o|0,a=s-o|0,(o|0)<0?(i[m>>2]=n,i[p>>2]=a,i[f>>2]=0,s=a,o=0):n=c,a=(s|0)<(n|0)?s:n,a=(o|0)<(a|0)?o:a,(a|0)>0&&(o=o-a|0,s=s-a|0,n=n-a|0,i[m>>2]=n,i[p>>2]=s,i[f>>2]=o)),d>>>0>>0;)d=d+1|0;return r|0}function Ft(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(h=M,M=M+16|0,f=h,p=H(e|0,t|0,45)|0,T()|0,p&=127,p>>>0>121)return i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,i[n+12>>2]=0,m=5,M=h,m|0;a:do if(be(p)|0&&(c=H(e|0,t|0,52)|0,T()|0,c&=15,c|0)){r=1;b:for(;;){switch(m=H(e|0,t|0,(15-r|0)*3|0)|0,T()|0,m&7){case 5:break b;case 0:break;default:u=t;break a}if(r>>>0>>0)r=r+1|0;else{u=t;break a}}for(s=1,r=t;;){switch(t=(15-s|0)*3|0,a=_r(7,0,t|0)|0,a=e&~a,o=r&~(T()|0),r=H(e|0,r|0,t|0)|0,T()|0,r&7){case 1:r=3;break;case 3:r=2;break;case 2:r=6;break;case 6:r=4;break;case 4:r=5;break;case 5:r=1;break;default:r&=7}if(e=_r(r|0,0,t|0)|0,e|=a,r=T()|0|o,s>>>0>>0)s=s+1|0;else{u=r;break a}}}else u=t;while(0);if(m=7696+(p*28|0)|0,i[n>>2]=i[m>>2],i[n+4>>2]=i[m+4>>2],i[n+8>>2]=i[m+8>>2],i[n+12>>2]=i[m+12>>2],!(Pt(e,u,n)|0))return m=0,M=h,m|0;if(m=n+4|0,i[f>>2]=i[m>>2],i[f+4>>2]=i[m+4>>2],i[f+8>>2]=i[m+8>>2],l=H(e|0,u|0,52)|0,T()|0,d=l&15,l&1?(o=i[m>>2]|0,c=n+8|0,a=i[c>>2]|0,l=n+12|0,t=i[l>>2]|0,r=(a*3|0)+o|0,o=t+(o*3|0)|0,i[m>>2]=o,i[c>>2]=r,a=(t*3|0)+a|0,i[l>>2]=a,t=r-o|0,s=a-o|0,(o|0)<0&&(i[c>>2]=t,i[l>>2]=s,i[m>>2]=0,r=t,o=0,a=s),s=o-r|0,t=a-r|0,(r|0)<0?(i[m>>2]=s,i[l>>2]=t,i[c>>2]=0,r=0):(t=a,s=o),o=s-t|0,a=r-t|0,(t|0)<0?(i[m>>2]=o,i[c>>2]=a,i[l>>2]=0,t=0):(a=r,o=s),r=(a|0)<(o|0)?a:o,r=(t|0)<(r|0)?t:r,(r|0)>0&&(i[m>>2]=o-r,i[c>>2]=a-r,i[l>>2]=t-r),a=d+1|0):a=d,!(be(p)|0))r=0;else{c:do if(!d)r=0;else for(t=1;;){if(r=H(e|0,u|0,(15-t|0)*3|0)|0,T()|0,r&=7,r|0)break c;if(t>>>0>>0)t=t+1|0;else{r=0;break}}while(0);r=(r|0)==4&1}if(!(at(n,a,r,0)|0))(a|0)!=(d|0)&&(i[m>>2]=i[f>>2],i[m+4>>2]=i[f+4>>2],i[m+8>>2]=i[f+8>>2]);else{if(be(p)|0)do;while(at(n,a,0,0)|0);(a|0)!=(d|0)&&(c=n+12|0,e=i[c>>2]|0,r=(i[m>>2]|0)-e|0,s=n+8|0,e=(i[s>>2]|0)-e|0,t=er(((r<<1)+e|0)*.14285714285714285)|0,i[m>>2]=t,r=er(((e*3|0)-r|0)*.14285714285714285)|0,i[s>>2]=r,i[c>>2]=0,e=r-t|0,a=0-t|0,(t|0)<0?(i[s>>2]=e,i[c>>2]=a,i[m>>2]=0,r=e,t=0):a=0,o=t-r|0,e=a-r|0,(r|0)<0?(i[m>>2]=o,i[c>>2]=e,i[s>>2]=0,t=o,r=0):e=a,o=t-e|0,a=r-e|0,(e|0)<0?(i[m>>2]=o,i[s>>2]=a,i[c>>2]=0,t=o,e=0):a=r,r=(a|0)<(t|0)?a:t,r=(e|0)<(r|0)?e:r,(r|0)>0&&(i[m>>2]=t-r,i[s>>2]=a-r,i[c>>2]=e-r))}return m=0,M=h,m|0}function It(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0,c=0,l=0;return s=M,M=M+48|0,r=s+24|0,i=s,o=Ft(e,t,r)|0,o?(M=s,o|0):(o=H(e|0,t|0,52)|0,T()|0,tt(r,o&15,i),l=+h(+ +a[i+16>>3]),c=+_(+ +a[i+8>>3],+ +a[i>>3]),a[n>>3]=l,a[n+8>>3]=c,o=0,M=s,o|0)}function Lt(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,a=0,o=0,s=0;if(o=M,M=M+16|0,a=o,r=Ft(e,t,a)|0,r|0)return a=r,M=o,a|0;r=H(e|0,t|0,45)|0,T()|0,r=(be(r&127)|0)==0,i=H(e|0,t|0,52)|0,T()|0,i&=15;a:do if(!r){if(i|0)for(r=1;;){if(s=_r(7,0,(15-r|0)*3|0)|0,!((s&e|0)==0&((T()|0)&t|0)==0))break a;if(r>>>0>>0)r=r+1|0;else break}return rt(a,i,0,5,n),s=0,M=o,s|0}while(0);return st(a,i,0,6,n),s=0,M=o,s|0}function Rt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(a=H(e|0,t|0,45)|0,T()|0,!(be(a&127)|0))return a=2,i[n>>2]=a,0;if(a=H(e|0,t|0,52)|0,T()|0,a&=15,!a)return a=5,i[n>>2]=a,0;for(r=1;;){if(o=_r(7,0,(15-r|0)*3|0)|0,!((o&e|0)==0&((T()|0)&t|0)==0)){r=2,e=6;break}if(r>>>0>>0)r=r+1|0;else{r=5,e=6;break}}return(e|0)==6&&(i[n>>2]=r),0}function zt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;f=M,M=M+128|0,u=f+112|0,o=f+96|0,d=f,a=H(e|0,t|0,52)|0,T()|0,c=a&15,i[u>>2]=c,s=H(e|0,t|0,45)|0,T()|0,s&=127;a:do if(be(s)|0){if(c|0)for(r=1;;){if(l=_r(7,0,(15-r|0)*3|0)|0,!((l&e|0)==0&((T()|0)&t|0)==0)){a=0;break a}if(r>>>0>>0)r=r+1|0;else break}if(a&1)a=1;else return l=_r(c+1|0,0,52)|0,d=T()|0|t&-15728641,u=_r(7,0,(14-c|0)*3|0)|0,d=zt((l|e)&~u,d&~(T()|0),n)|0,M=f,d|0}else a=0;while(0);if(r=Ft(e,t,o)|0,!r){a?(it(o,u,d),l=5):(ct(o,u,d),l=6);b:do if(be(s)|0)if(!c)e=5;else for(r=1;;){if(s=_r(7,0,(15-r|0)*3|0)|0,!((s&e|0)==0&((T()|0)&t|0)==0)){e=2;break b}if(r>>>0>>0)r=r+1|0;else{e=5;break}}else e=2;while(0);wr(n|0,-1,e<<2|0)|0;c:do if(a)for(o=0;;){if(s=d+(o<<4)|0,ot(s,i[u>>2]|0)|0,s=i[s>>2]|0,c=i[n>>2]|0,(c|0)==-1|(c|0)==(s|0))r=n;else{a=0;do{if(a=a+1|0,a>>>0>=e>>>0){r=1;break c}r=n+(a<<2)|0,c=i[r>>2]|0}while(!((c|0)==-1|(c|0)==(s|0)))}if(i[r>>2]=s,o=o+1|0,o>>>0>=l>>>0){r=0;break}}else for(o=0;;){if(s=d+(o<<4)|0,at(s,i[u>>2]|0,0,1)|0,s=i[s>>2]|0,c=i[n>>2]|0,(c|0)==-1|(c|0)==(s|0))r=n;else{a=0;do{if(a=a+1|0,a>>>0>=e>>>0){r=1;break c}r=n+(a<<2)|0,c=i[r>>2]|0}while(!((c|0)==-1|(c|0)==(s|0)))}if(i[r>>2]=s,o=o+1|0,o>>>0>=l>>>0){r=0;break}}while(0)}return d=r,M=f,d|0}function Bt(){return 12}function Vt(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0;if(e>>>0>15)return c=4,c|0;if(_r(e|0,0,52)|0,c=T()|134225919,!e){n=0,r=0;do be(r)|0&&(_r(r|0,0,45)|0,s=c|T()|0,e=t+(n<<3)|0,i[e>>2]=-1,i[e+4>>2]=s,n=n+1|0),r=r+1|0;while((r|0)!=122);return n=0,n|0}n=0,s=0;do{if(be(s)|0){for(_r(s|0,0,45)|0,r=1,a=-1,o=c|T()|0;l=_r(7,0,(15-r|0)*3|0)|0,a&=~l,o&=~(T()|0),(r|0)!=(e|0);)r=r+1|0;l=t+(n<<3)|0,i[l>>2]=a,i[l+4>>2]=o,n=n+1|0}s=s+1|0}while((s|0)!=122);return n=0,n|0}function Ht(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0;if(y=M,M=M+16|0,_=y,v=H(e|0,t|0,52)|0,T()|0,v&=15,n>>>0>15)return v=4,M=y,v|0;if((v|0)<(n|0))return v=12,M=y,v|0;if((v|0)!=(n|0))if(o=_r(n|0,0,52)|0,o|=e,c=T()|0|t&-15728641,(v|0)>(n|0)){l=n;do g=_r(7,0,(14-l|0)*3|0)|0,l=l+1|0,o=g|o,c=T()|0|c;while((l|0)<(v|0));g=o}else g=o;else g=e,c=t;h=H(g|0,c|0,45)|0,T()|0;a:do if(be(h&127)|0){if(l=H(g|0,c|0,52)|0,T()|0,l&=15,l|0)for(o=1;;){if(h=_r(7,0,(15-o|0)*3|0)|0,!((h&g|0)==0&((T()|0)&c|0)==0)){u=33;break a}if(o>>>0>>0)o=o+1|0;else break}if(h=r,i[h>>2]=0,i[h+4>>2]=0,(v|0)>(n|0)){for(h=t&-15728641,m=v;;){if(p=m,m=m+-1|0,m>>>0>15|(v|0)<(m|0)){u=19;break}if((v|0)!=(m|0))if(o=_r(m|0,0,52)|0,o|=e,l=T()|0|h,(v|0)<(p|0))f=o;else{u=m;do f=_r(7,0,(14-u|0)*3|0)|0,u=u+1|0,o=f|o,l=T()|0|l;while((u|0)<(v|0));f=o}else f=e,l=t;if(d=H(f|0,l|0,45)|0,T()|0,!(be(d&127)|0))o=0;else{d=H(f|0,l|0,52)|0,T()|0,d&=15;b:do if(!d)o=0;else for(u=1;;){if(o=H(f|0,l|0,(15-u|0)*3|0)|0,T()|0,o&=7,o|0)break b;if(u>>>0>>0)u=u+1|0;else{o=0;break}}while(0);o=(o|0)==0&1}if(l=H(e|0,t|0,(15-p|0)*3|0)|0,T()|0,l&=7,(l|0)==7){a=5,u=42;break}if(o=(o|0)!=0,(l|0)==1&o){a=5,u=42;break}if(f=l+(((l|0)!=0&o)<<31>>31)|0,f|0&&(u=v-p|0,u=hn(7,0,u,((u|0)<0)<<31>>31)|0,d=T()|0,o?(o=pr(u|0,d|0,5,0)|0,o=sr(o|0,T()|0,-5,-1)|0,o=dr(o|0,T()|0,6,0)|0,o=sr(o|0,T()|0,1,0)|0,l=T()|0):(o=u,l=d),p=f+-1|0,p=pr(u|0,d|0,p|0,((p|0)<0)<<31>>31|0)|0,p=sr(o|0,l|0,p|0,T()|0)|0,f=T()|0,d=r,d=sr(p|0,f|0,i[d>>2]|0,i[d+4>>2]|0)|0,f=T()|0,p=r,i[p>>2]=d,i[p+4>>2]=f),(m|0)<=(n|0)){u=37;break}}if((u|0)==19)E(27634,27225,1407,27259);else if((u|0)==37){s=r,a=i[s+4>>2]|0,s=i[s>>2]|0;break}else if((u|0)==42)return M=y,a|0}else a=0,s=0}else u=33;while(0);c:do if((u|0)==33)if(h=r,i[h>>2]=0,i[h+4>>2]=0,(v|0)>(n|0)){for(o=v;;){if(a=H(e|0,t|0,(15-o|0)*3|0)|0,T()|0,a&=7,(a|0)==7){a=5;break}if(s=v-o|0,s=hn(7,0,s,((s|0)<0)<<31>>31)|0,a=pr(s|0,T()|0,a|0,0)|0,s=T()|0,h=r,s=sr(i[h>>2]|0,i[h+4>>2]|0,a|0,s|0)|0,a=T()|0,h=r,i[h>>2]=s,i[h+4>>2]=a,o=o+-1|0,(o|0)<=(n|0))break c}return M=y,a|0}else a=0,s=0;while(0);return _t(g,c,v,_)|0&&E(27634,27225,1367,27274),v=_,_=i[v+4>>2]|0,((a|0)>-1|(a|0)==-1&s>>>0>4294967295)&((_|0)>(a|0)|((_|0)==(a|0)?(i[v>>2]|0)>>>0>s>>>0:0))?(v=0,M=y,v|0):(E(27634,27225,1447,27259),0)}function Ut(e,t,n,r,a,o){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(f=M,M=M+16|0,s=f,a>>>0>15)return o=4,M=f,o|0;if(c=H(n|0,r|0,52)|0,T()|0,c&=15,(c|0)>(a|0))return o=12,M=f,o|0;if(_t(n,r,a,s)|0&&E(27634,27225,1367,27274),d=s,u=i[d+4>>2]|0,!(((t|0)>-1|(t|0)==-1&e>>>0>4294967295)&((u|0)>(t|0)|((u|0)==(t|0)?(i[d>>2]|0)>>>0>e>>>0:0))))return o=2,M=f,o|0;d=a-c|0,a=_r(a|0,0,52)|0,l=T()|0|r&-15728641,u=o,i[u>>2]=a|n,i[u+4>>2]=l,u=H(n|0,r|0,45)|0,T()|0;a:do if(be(u&127)|0){if(c|0)for(s=1;;){if(u=_r(7,0,(15-s|0)*3|0)|0,!((u&n|0)==0&((T()|0)&r|0)==0))break a;if(s>>>0>>0)s=s+1|0;else break}if((d|0)<1)return o=0,M=f,o|0;for(u=c^15,r=-1,l=1,s=1;;){c=d-l|0,c=hn(7,0,c,((c|0)<0)<<31>>31)|0,n=T()|0;do if(s)if(s=pr(c|0,n|0,5,0)|0,s=sr(s|0,T()|0,-5,-1)|0,s=dr(s|0,T()|0,6,0)|0,a=T()|0,(t|0)>(a|0)|(t|0)==(a|0)&e>>>0>s>>>0){t=sr(e|0,t|0,-1,-1)|0,t=cr(t|0,T()|0,s|0,a|0)|0,s=T()|0,p=o,h=i[p>>2]|0,p=i[p+4>>2]|0,g=(u+r|0)*3|0,m=_r(7,0,g|0)|0,p&=~(T()|0),r=dr(t|0,s|0,c|0,n|0)|0,e=T()|0,a=sr(r|0,e|0,2,0)|0,g=_r(a|0,T()|0,g|0)|0,p=T()|0|p,a=o,i[a>>2]=g|h&~m,i[a+4>>2]=p,e=pr(r|0,e|0,c|0,n|0)|0,e=cr(t|0,s|0,e|0,T()|0)|0,s=0,t=T()|0;break}else{g=o,m=i[g>>2]|0,g=i[g+4>>2]|0,h=_r(7,0,(u+r|0)*3|0)|0,g&=~(T()|0),s=o,i[s>>2]=m&~h,i[s+4>>2]=g,s=1;break}else m=o,a=i[m>>2]|0,m=i[m+4>>2]|0,r=(u+r|0)*3|0,p=_r(7,0,r|0)|0,m&=~(T()|0),g=dr(e|0,t|0,c|0,n|0)|0,s=T()|0,r=_r(g|0,s|0,r|0)|0,m=T()|0|m,h=o,i[h>>2]=r|a&~p,i[h+4>>2]=m,s=pr(g|0,s|0,c|0,n|0)|0,e=cr(e|0,t|0,s|0,T()|0)|0,s=0,t=T()|0;while(0);if((d|0)>(l|0))r=~l,l=l+1|0;else{t=0;break}}return M=f,t|0}while(0);if((d|0)<1)return g=0,M=f,g|0;for(a=c^15,s=1;;)if(h=d-s|0,h=hn(7,0,h,((h|0)<0)<<31>>31)|0,g=T()|0,l=o,n=i[l>>2]|0,l=i[l+4>>2]|0,c=(a-s|0)*3|0,r=_r(7,0,c|0)|0,l&=~(T()|0),p=dr(e|0,t|0,h|0,g|0)|0,m=T()|0,c=_r(p|0,m|0,c|0)|0,l=T()|0|l,u=o,i[u>>2]=c|n&~r,i[u+4>>2]=l,g=pr(p|0,m|0,h|0,g|0)|0,e=cr(e|0,t|0,g|0,T()|0)|0,t=T()|0,(d|0)<=(s|0)){t=0;break}else s=s+1|0;return M=f,t|0}function Wt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;a=H(t|0,n|0,52)|0,T()|0,a&=15,(t|0)==0&(n|0)==0|((r|0)>15|(a|0)>(r|0))?(o=-1,t=-1,n=0,a=0):(t=bt(t,n,a+1|0,r)|0,s=(T()|0)&-15728641,n=_r(r|0,0,52)|0,n=t|n,s=s|T()|0,t=(vt(n,s)|0)==0,o=a,t=t?-1:r,a=s),s=e,i[s>>2]=n,i[s+4>>2]=a,i[e+8>>2]=o,i[e+12>>2]=t}function Gt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;if(a=H(e|0,t|0,52)|0,T()|0,a&=15,o=r+8|0,i[o>>2]=a,(e|0)==0&(t|0)==0|((n|0)>15|(a|0)>(n|0))){n=r,i[n>>2]=0,i[n+4>>2]=0,i[o>>2]=-1,i[r+12>>2]=-1;return}if(e=bt(e,t,a+1|0,n)|0,o=(T()|0)&-15728641,a=_r(n|0,0,52)|0,a=e|a,o=o|T()|0,e=r,i[e>>2]=a,i[e+4>>2]=o,e=r+12|0,vt(a,o)|0){i[e>>2]=n;return}else{i[e>>2]=-1;return}}function Kt(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0;if(n=e,t=i[n>>2]|0,n=i[n+4>>2]|0,!((t|0)==0&(n|0)==0)&&(r=H(t|0,n|0,52)|0,T()|0,r&=15,c=_r(1,0,(r^15)*3|0)|0,t=sr(c|0,T()|0,t|0,n|0)|0,n=T()|0,c=e,i[c>>2]=t,i[c+4>>2]=n,c=e+8|0,s=i[c>>2]|0,!((r|0)<(s|0)))){for(l=e+12|0,o=r;;){if((o|0)==(s|0)){r=5;break}if(u=(o|0)==(i[l>>2]|0),a=(15-o|0)*3|0,r=H(t|0,n|0,a|0)|0,T()|0,r&=7,u&(r|0)==1&!0){r=7;break}if(!((r|0)==7&!0)){r=10;break}if(u=_r(1,0,a|0)|0,t=sr(t|0,n|0,u|0,T()|0)|0,n=T()|0,u=e,i[u>>2]=t,i[u+4>>2]=n,(o|0)>(s|0))o=o+-1|0;else{r=10;break}}if((r|0)==5){u=e,i[u>>2]=0,i[u+4>>2]=0,i[c>>2]=-1,i[l>>2]=-1;return}else if((r|0)==7){s=_r(1,0,a|0)|0,s=sr(t|0,n|0,s|0,T()|0)|0,c=T()|0,u=e,i[u>>2]=s,i[u+4>>2]=c,i[l>>2]=o+-1;return}else if((r|0)==10)return}}function qt(e){e=+e;var t=0;return t=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function Jt(e,t){switch(e=+e,t|=0,t|0){case 1:e=e<0?e+6.283185307179586:e;break;case 2:e=e>0?e+-6.283185307179586:e;break;default:}return+e}function Yt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+f(+((i-r)*.5)),n=+f(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(d(+i)*+d(+r)*n),+(_(+ +u(+n),+ +u(+(1-n)))*2)}function Xt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+f(+((i-r)*.5)),n=+f(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(d(+i)*+d(+r)*n),+(_(+ +u(+n),+ +u(+(1-n)))*2*6371.007180918475)}function Zt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+f(+((i-r)*.5)),n=+f(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(d(+i)*+d(+r)*n),+(_(+ +u(+n),+ +u(+(1-n)))*2*6371.007180918475*1e3)}function Qt(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20624+(e<<3)>>3],t=0,t|0)}function $t(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20752+(e<<3)>>3],t=0,t|0)}function en(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20880+(e<<3)>>3],t=0,t|0)}function tn(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[21008+(e<<3)>>3],t=0,t|0)}function nn(e,t){e|=0,t|=0;var n=0;return e>>>0>15?(t=4,t|0):(n=hn(7,0,e,((e|0)<0)<<31>>31)|0,n=pr(n|0,T()|0,120,0)|0,e=T()|0,i[t>>2]=n|2,i[t+4>>2]=e,t=0,t|0)}function rn(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,p=0,m=0,h=0;if(l=M,M=M+176|0,c=l,e=Qe(e,t,c)|0,e|0)return c=e,M=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,M=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+f(+((r-m)*.5)),p=o,o=+a[c+8+(e<<4)+8>>3],p=+f(+((o-p)*.5)),p=h*h+p*(d(+r)*+d(+m)*p),s+=_(+ +u(+p),+ +u(+(1-p)))*2;while((e|0)<(t|0));return a[n>>3]=s,c=0,M=l,c|0}function an(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,p=0,m=0,h=0;if(l=M,M=M+176|0,c=l,e=Qe(e,t,c)|0,e|0)return c=e,s=+a[n>>3],s*=6371.007180918475,a[n>>3]=s,M=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,s=0,s*=6371.007180918475,a[n>>3]=s,M=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+f(+((r-m)*.5)),p=o,o=+a[c+8+(e<<4)+8>>3],p=+f(+((o-p)*.5)),p=h*h+p*(d(+m)*+d(+r)*p),s+=_(+ +u(+p),+ +u(+(1-p)))*2;while((e|0)!=(t|0));return a[n>>3]=s,c=0,h=s,h*=6371.007180918475,a[n>>3]=h,M=l,c|0}function on(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,p=0,m=0,h=0;if(l=M,M=M+176|0,c=l,e=Qe(e,t,c)|0,e|0)return c=e,s=+a[n>>3],s*=6371.007180918475,s*=1e3,a[n>>3]=s,M=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,s=0,s*=6371.007180918475,s*=1e3,a[n>>3]=s,M=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+f(+((r-m)*.5)),p=o,o=+a[c+8+(e<<4)+8>>3],p=+f(+((o-p)*.5)),p=h*h+p*(d(+m)*+d(+r)*p),s+=_(+ +u(+p),+ +u(+(1-p)))*2;while((e|0)!=(t|0));return a[n>>3]=s,c=0,h=s,h*=6371.007180918475,h*=1e3,a[n>>3]=h,M=l,c|0}function R(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;if(e)for(o=e+4|0,s=e+8|0,r=1,a=e;;){if(t=i[a>>2]|0,t|0)do{if(n=i[t>>2]|0,n|0)do c=n,n=i[n+16>>2]|0,nr(c);while(n|0);c=t,t=i[t+8>>2]|0,nr(c)}while(t|0);if(t=a,a=i[a+8>>2]|0,r?(i[e>>2]=0,i[o>>2]=0,i[s>>2]=0):nr(t),a)r=0;else break}}function z(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(i[t>>2]=0,_=t+4|0,i[_>>2]=0,v=t+8|0,i[v>>2]=0,g=i[e>>2]|0,(g|0)<=0)return t=0,t|0;h=e+4|0,e=t,m=0;a:for(;;){if(m){if(n=rr(1,12)|0,!n){n=5;break}i[e+8>>2]=n,e=n}if(l=i[h>>2]|0,u=rr(1,12)|0,!u){e=13,n=37;break}if(p=e+4|0,r=i[p>>2]|0,i[(r|0?r+8|0:e)>>2]=u,i[p>>2]=u,r=i[l+(m<<4)>>2]|0,(r|0)<3){e=1,n=37;break}a=l+(m<<4)+4|0,o=u+4|0,n=0,s=0;do{if(c=s,s=tr(24)|0,!s){e=13,n=37;break a}Cr(s|0,(i[a>>2]|0)+(n<<4)|0,16)|0,i[s+16>>2]=0,c?i[c+16>>2]=s:i[u>>2]=s,i[o>>2]=s,n=n+1|0}while((n|0)<(r|0));if(f=i[l+(m<<4)+8>>2]|0,(f|0)>0){d=l+(m<<4)+12|0,l=0;do{if(r=i[d>>2]|0,n=u,u=rr(1,12)|0,!u){e=13,n=37;break a}if(i[n+8>>2]=u,i[p>>2]=u,c=i[r+(l<<3)>>2]|0,(c|0)<3){e=1,n=37;break a}r=r+(l<<3)+4|0,a=u+4|0,n=0,o=0;do{if(s=o,o=tr(24)|0,!o){e=13,n=37;break a}Cr(o|0,(i[r>>2]|0)+(n<<4)|0,16)|0,i[o+16>>2]=0,s?i[s+16>>2]=o:i[u>>2]=o,i[a>>2]=o,n=n+1|0}while((n|0)<(c|0));l=l+1|0}while((l|0)<(f|0))}if(m=m+1|0,(m|0)>=(g|0)){e=0,n=50;break}}if((n|0)==5){if(!t)return t=13,t|0;for(r=1,a=t;;){if(e=i[a>>2]|0,e|0)do{if(n=i[e>>2]|0,n|0)do g=n,n=i[n+16>>2]|0,nr(g);while(n|0);g=e,e=i[e+8>>2]|0,nr(g)}while(e|0);if(e=a,a=i[a+8>>2]|0,r?(i[t>>2]=0,i[_>>2]=0,i[v>>2]=0):nr(e),a)r=0;else{e=13;break}}return e|0}else if((n|0)==37){if(!t)return t=e,t|0;for(a=1,o=t;;){if(n=i[o>>2]|0,n|0)do{if(r=i[n>>2]|0,r|0)do g=r,r=i[r+16>>2]|0,nr(g);while(r|0);g=n,n=i[n+8>>2]|0,nr(g)}while(n|0);if(n=o,o=i[o+8>>2]|0,a?(i[t>>2]=0,i[_>>2]=0,i[v>>2]=0):nr(n),o)a=0;else break}return e|0}else if((n|0)==50)return e|0;return 0}function sn(e,t,n,a,o){e|=0,t|=0,n|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;if(y=M,M=M+16|0,v=y,f=H(e|0,t|0,52)|0,T()|0,f&=15,h=H(n|0,a|0,52)|0,T()|0,(f|0)!=(h&15|0))return v=12,M=y,v|0;if(u=H(e|0,t|0,45)|0,T()|0,u&=127,d=H(n|0,a|0,45)|0,T()|0,d&=127,u>>>0>121|d>>>0>121)return v=5,M=y,v|0;if(h=(u|0)!=(d|0),h){if(c=De(u,d)|0,(c|0)==7)return v=1,M=y,v|0;l=De(d,u)|0,(l|0)==7?E(27291,27315,164,27325):(_=c,s=l)}else _=0,s=0;p=be(u)|0,m=be(d)|0,i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0;do if(_){d=i[4272+(u*28|0)+(_<<2)>>2]|0,c=(d|0)>0;a:do if(!m)if(c)for(u=0,l=n,c=a;;){switch(l=At(l,c)|0,c=T()|0,s|0){case 1:s=3;break;case 3:s=2;break;case 2:s=6;break;case 6:s=4;break;case 4:s=5;break;case 5:s=1;break;default:}if(u=u+1|0,(u|0)==(d|0)){d=s,u=l,l=c;break a}}else d=s,u=n,l=a;else if(c)for(u=0,l=n,c=a;;){switch(l=kt(l,c)|0,c=T()|0,s|0){case 5:case 1:s=3;break;case 3:s=2;break;case 2:s=6;break;case 6:s=4;break;case 4:s=5;break;default:}if(u=u+1|0,(u|0)==(d|0)){d=s,u=l,l=c;break a}}else d=s,u=n,l=a;while(0);if(Pt(u,l,v)|0,h||E(27340,27315,194,27325),c=(p|0)!=0,s=(m|0)!=0,c&s&&E(27367,27315,195,27325),c){if(s=Et(e,t)|0,(s|0)==7){s=5;break}if(r[21968+(s*7|0)+_>>0]|0){s=1;break}m=i[21136+(s*28|0)+(_<<2)>>2]|0,h=m}else if(s){if(s=Et(u,l)|0,(s|0)==7){s=5;break}if(r[21968+(s*7|0)+d>>0]|0){s=1;break}h=0,m=i[21136+(d*28|0)+(s<<2)>>2]|0}else h=0,m=0;if((h|m|0)>=0){if((m|0)>0){n=v+4|0,a=v+8|0,p=v+12|0,d=0,l=i[n>>2]|0,c=i[a>>2]|0,s=i[p>>2]|0;do g=c+l|0,t=(g|0)<0,b=t?g:0,c=s+c-b|0,e=(c|0)<0,u=e?c:0,l=s+l-b-u|0,b=(l|0)<0,s=b?0:l,l=b?l:0,c=(e?0:c)-l|0,l=(t?0:g)-u-l|0,u=(c|0)<(l|0)?c:l,u=(s|0)<(u|0)?s:u,(u|0)>0&&(l=l-u|0,c=c-u|0,s=s-u|0),d=d+1|0;while((d|0)!=(m|0));i[n>>2]=l,i[a>>2]=c,i[p>>2]=s}if((_+-1|0)>>>0<6?(s=i[22032+(_*12|0)>>2]|0,l=i[22032+(_*12|0)+4>>2]|0,b=i[22032+(_*12|0)+8>>2]|0,c=(l|0)<(s|0)?l:s,c=(b|0)<(c|0)?b:c,c=(c|0)>0?c:0,s=s-c|0,l=l-c|0,c=b-c|0):(s=0,l=0,c=0),f)for(;;)if(u=s*3|0,d=l*3|0,n=c*3|0,Mt(f)|0?(t=u+l|0,e=(t|0)<0,b=d+c-(e?t:0)|0,g=(b|0)<0,l=s+n-(e?t:0)-(g?b:0)|0,c=(l|0)<0,_=c?0:l,u=(g?0:b)-(c?l:0)|0,l=(e?0:t)-(g?b:0)-(c?l:0)|0,c=(u|0)<(l|0)?u:l,c=(_|0)<(c|0)?_:c,b=(c|0)>0,s=b?c:0,u=u-(b?c:0)|0,c=_-(b?c:0)|0):(g=u+c|0,t=(g|0)<0,b=d+s-(t?g:0)|0,s=(b|0)<0,l=n+l-(t?g:0)-(s?b:0)|0,c=(l|0)<0,_=c?0:l,u=(s?0:b)-(c?l:0)|0,l=(t?0:g)-(s?b:0)-(c?l:0)|0,c=(u|0)<(l|0)?u:l,c=(_|0)<(c|0)?_:c,b=(c|0)>0,s=b?c:0,u=u-(b?c:0)|0,c=_-(b?c:0)|0),s=l-s|0,(f|0)>1)f=f+-1|0,l=u;else{l=u;break}if((h|0)>0){u=0;do t=s+l|0,e=(t|0)<0,b=l+c-(e?t:0)|0,g=(b|0)<0,_=s+c-(e?t:0)-(g?b:0)|0,s=(_|0)<0,c=s?0:_,l=(g?0:b)-(s?_:0)|0,_=(e?0:t)-(g?b:0)-(s?_:0)|0,s=(l|0)<(_|0)?l:_,s=(c|0)<(s|0)?c:s,b=(s|0)>0,c=c-(b?s:0)|0,l=l-(b?s:0)|0,s=_-(b?s:0)|0,u=u+1|0;while((u|0)!=(h|0))}n=v+4|0,f=v+8|0,_=i[f>>2]|0,a=v+12|0,b=i[a>>2]|0,u=(i[n>>2]|0)+s|0,i[n>>2]=u,l=_+l|0,i[f>>2]=l,s=b+c|0,i[a>>2]=s,c=l-u|0,(u|0)<0?(s=s-u|0,i[f>>2]=c,i[a>>2]=s,i[n>>2]=0,l=0):(c=l,l=u),(c|0)<0&&(l=l-c|0,i[n>>2]=l,s=s-c|0,i[a>>2]=s,i[f>>2]=0,c=0),d=l-s|0,u=c-s|0,(s|0)<0?(i[n>>2]=d,i[f>>2]=u,i[a>>2]=0,l=d,s=0):u=c,c=(u|0)<(l|0)?u:l,c=(s|0)<(c|0)?s:c,(c|0)>0?(i[n>>2]=l-c,i[f>>2]=u-c,i[a>>2]=s-c,g=77):g=77}else s=5}else if(Pt(n,a,v)|0,(p|0)!=0&(m|0)!=0)if((d|0)!=(u|0)&&E(27398,27315,264,27325),c=Et(e,t)|0,s=Et(n,a)|0,(c|0)==7|(s|0)==7)s=5;else if(r[21968+(c*7|0)+s>>0]|0)s=1;else if(n=i[21136+(c*28|0)+(s<<2)>>2]|0,(n|0)>0){f=v+4|0,a=v+8|0,p=v+12|0,d=0,l=i[f>>2]|0,c=i[a>>2]|0,s=i[p>>2]|0;do _=c+l|0,g=(_|0)<0,e=g?_:0,c=s+c-e|0,t=(c|0)<0,u=t?c:0,l=s+l-e-u|0,e=(l|0)<0,s=e?0:l,l=e?l:0,c=(t?0:c)-l|0,l=(g?0:_)-u-l|0,u=(c|0)<(l|0)?c:l,u=(s|0)<(u|0)?s:u,(u|0)>0&&(l=l-u|0,c=c-u|0,s=s-u|0),d=d+1|0;while((d|0)!=(n|0));i[f>>2]=l,i[a>>2]=c,i[p>>2]=s,g=77}else g=77;else g=77;while(0);return(g|0)==77&&(s=v+4|0,i[o>>2]=i[s>>2],i[o+4>>2]=i[s+4>>2],i[o+8>>2]=i[s+8>>2],s=0),b=s,M=y,b|0}function cn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0;if(o=H(e|0,t|0,52)|0,T()|0,o&=15,x=H(e|0,t|0,45)|0,T()|0,x&=127,x>>>0>121)return r=5,r|0;if(_=be(x)|0,_r(o|0,0,52)|0,c=T()|134225919,s=r,i[s>>2]=-1,i[s+4>>2]=c,s=i[n>>2]|0,c=i[n+4>>2]|0,n=i[n+8>>2]|0,!o){t=(s|0)<0,v=t?s:0,b=c-v|0,_=(b|0)<0,v=(_?0-b|0:0)+(n-v)|0,n=(v|0)<0,a=n?0:v,v=n?v:0,n=(_?0:b)-v|0,v=(t?0:s)-(_?b:0)-v|0,b=(n|0)<(v|0)?n:v,b=(a|0)<(b|0)?a:b,b=(b|0)>0?b:0,a=a-b|0,n=n-b|0;a:do switch(v-b|0){case 0:switch(n|0){case 0:if(a){a=(a|0)==1?1:7,y=11;break a}else{a=0;break a}case 1:if(a){a=(a|0)==1?3:7,y=11;break a}else{a=2;break a}default:return r=1,r|0}case 1:switch(n|0){case 0:if(a){a=(a|0)==1?5:7,y=11;break a}else{a=4;break a}case 1:if(a)a=1;else{a=6;break a}return a|0;default:return r=1,r|0}default:return r=1,r|0}while(0);return(y|0)==11&&(a|0)==7||(a=Ee(x,a)|0,(a|0)==127)?(r=1,r|0):(b=_r(a|0,0,45)|0,x=T()|0,y=r,x=i[y+4>>2]&-1040385|x,i[r>>2]=i[y>>2]|b,i[r+4>>2]=x,r=0,r|0)}for(;;){if(g=o,o=o+-1|0,h=s-n|0,m=c-n|0,l=h>>>0>715827881|m>>>0>715827881,Mt(g)|0){if(l){if(d=(h|0)>0,f=2147483647-h|0,p=-2147483648-h|0,d?(f|0)<(h|0):(p|0)>(h|0)){a=1,y=107;break}if(D=h<<1,d?(2147483647-D|0)<(h|0):(-2147483648-D|0)>(h|0)){a=1,y=107;break}if((m|0)>0?(2147483647-m|0)<(m|0):(-2147483648-m|0)>(m|0)){a=1,y=107;break}if(l=h*3|0,u=m<<1,(d?(f|0)<(u|0):(p|0)>(u|0))||((h|0)>-1?(l|-2147483648)>=(m|0):(l^-2147483648|0)<(m|0))){a=1,y=107;break}}else l=h*3|0,u=m<<1;if(f=er((l-m|0)*.14285714285714285)|0,d=er((u+h|0)*.14285714285714285)|0,u=(d|0)<(f|0),l=u?f:d,u=u?d:f,(u|0)<0){if((u|0)==-2147483648||((l|0)>0?(2147483647-l|0)<(u|0):(-2147483648-l|0)>(u|0))){y=24;break}if((l|0)>-1?(l|-2147483648)>=(u|0):(l^-2147483648|0)<(u|0)){y=24;break}}p=(f|0)<0,m=d-(p?f:0)|0,C=(m|0)<0,S=(p?0-f|0:0)-(C?m:0)|0,h=(S|0)<0,p=(p?0:f)-(C?m:0)-(h?S:0)|0,m=(C?0:m)-(h?S:0)|0,S=h?0:S,h=(m|0)<(p|0)?m:p,h=(S|0)<(h|0)?S:h,C=(h|0)>0,p=p-(C?h:0)|0,m=m-(C?h:0)|0,h=S-(C?h:0)|0,C=(p*3|0)+m|0,S=(C|0)<0,D=(m*3|0)+h-(S?C:0)|0,l=(D|0)<0,f=(h*3|0)+p-(S?C:0)-(l?D:0)|0,d=(f|0)<0,w=d?0:f,u=(l?0:D)-(d?f:0)|0,f=(S?0:C)-(l?D:0)-(d?f:0)|0,d=(u|0)<(f|0)?u:f,d=(w|0)<(d|0)?w:d,D=(d|0)>0,l=D?d:0,u=u-(D?d:0)|0,d=w-(D?d:0)|0}else{if(l){if(u=(h|0)>0,u?(2147483647-h|0)<(h|0):(-2147483648-h|0)>(h|0)){a=1,y=107;break}if(l=h<<1,d=(m|0)>0,d?(2147483647-m|0)<(m|0):(-2147483648-m|0)>(m|0)){a=1,y=107;break}if(p=m<<1,d?(2147483647-p|0)<(m|0):(-2147483648-p|0)>(m|0)){a=1,y=107;break}if(u?(2147483647-l|0)<(m|0):(-2147483648-l|0)>(m|0)){a=1,y=107;break}if(u=m*3|0,(m|0)>-1?(u|-2147483648)>=(h|0):(u^-2147483648|0)<(h|0)){a=1,y=107;break}}else l=h<<1,u=m*3|0;if(f=er((l+m|0)*.14285714285714285)|0,d=er((u-h|0)*.14285714285714285)|0,u=(d|0)<(f|0),l=u?f:d,u=u?d:f,(u|0)<0){if((u|0)==-2147483648||((l|0)>0?(2147483647-l|0)<(u|0):(-2147483648-l|0)>(u|0))){y=36;break}if((l|0)>-1?(l|-2147483648)>=(u|0):(l^-2147483648|0)<(u|0)){y=36;break}}p=(f|0)<0,m=d-(p?f:0)|0,w=(m|0)<0,D=(p?0-f|0:0)-(w?m:0)|0,h=(D|0)<0,p=(p?0:f)-(w?m:0)-(h?D:0)|0,m=(w?0:m)-(h?D:0)|0,D=h?0:D,h=(m|0)<(p|0)?m:p,h=(D|0)<(h|0)?D:h,w=(h|0)>0,p=p-(w?h:0)|0,m=m-(w?h:0)|0,h=D-(w?h:0)|0,w=(p*3|0)+h|0,D=(w|0)<0,S=(m*3|0)+p-(D?w:0)|0,l=(S|0)<0,f=(h*3|0)+m-(D?w:0)-(l?S:0)|0,d=(f|0)<0,C=d?0:f,u=(l?0:S)-(d?f:0)|0,f=(D?0:w)-(l?S:0)-(d?f:0)|0,d=(u|0)<(f|0)?u:f,d=(C|0)<(d|0)?C:d,S=(d|0)>0,l=S?d:0,u=u-(S?d:0)|0,d=C-(S?d:0)|0}l=s+(l-f)|0,w=(l|0)<0,u=c-u-(w?l:0)|0,f=(u|0)<0,S=n-d+(w?0-l|0:0)+(f?0-u|0:0)|0,s=(S|0)<0,d=s?0:S,D=(f?0:u)-(s?S:0)|0,S=(w?0:l)-(f?u:0)-(s?S:0)|0,s=(D|0)<(S|0)?D:S,s=(d|0)<(s|0)?d:s,n=(s|0)>0,S=S-(n?s:0)|0,u=r,f=i[u>>2]|0,u=i[u+4>>2]|0,c=(15-g|0)*3|0,l=_r(7,0,c|0)|0,l=f&~l,u&=~(T()|0),f=(S|0)<0,w=f?S:0,D=D-(n?s:0)-w|0,C=(D|0)<0,w=(C?0-D|0:0)+(d-(n?s:0)-w)|0,s=(w|0)<0,n=s?0:w,w=s?w:0,s=(C?0:D)-w|0,w=(f?0:S)-(C?D:0)-w|0,D=(s|0)<(w|0)?s:w,D=(n|0)<(D|0)?n:D,D=(D|0)>0?D:0,n=n-D|0,s=s-D|0;b:do switch(w-D|0){case 0:switch(s|0){case 0:n=n|0?(n|0)==1?1:7:0;break b;case 1:n=n|0?(n|0)==1?3:7:2;break b;default:y=45;break b}case 1:switch(s|0){case 0:n=n|0?(n|0)==1?5:7:4;break b;case 1:if(n){y=45;break b}else{n=6;break b}default:y=45;break b}default:y=45}while(0);if((y|0)==45&&(y=0,n=7),C=_r(n|0,0,c|0)|0,w=T()|0|u,D=r,i[D>>2]=C|l,i[D+4>>2]=w,(g|0)<=1){y=47;break}else s=p,c=m,n=h}if((y|0)==24)E(27634,27425,416,27447);else if((y|0)==36)E(27634,27425,464,27461);else if((y|0)==47){if((p|0)>1|(m|0)>1|(h|0)>1)return D=1,D|0;S=(p|0)<0,w=S?p:0,D=m-w|0,C=(D|0)<0,w=(C?0-D|0:0)+(h-w)|0,o=(w|0)<0,n=o?0:w,w=o?w:0,o=(C?0:D)-w|0,w=(S?0:p)-(C?D:0)-w|0,D=(o|0)<(w|0)?o:w,D=(n|0)<(D|0)?n:D,D=(D|0)>0?D:0,n=n-D|0,o=o-D|0;c:do switch(w-D|0){case 0:switch(o|0){case 0:o=n|0?(n|0)==1?1:7:0;break c;case 1:o=n|0?(n|0)==1?3:7:2;break c;default:y=55;break c}case 1:switch(o|0){case 0:o=n|0?(n|0)==1?5:7:4;break c;case 1:if(n){y=55;break c}else{o=6;break c}default:y=55;break c}default:y=55}while(0);(y|0)==55&&(o=7),c=Ee(x,o)|0,u=(c|0)==127?0:be(c)|0;d:do if(o){if(_){if(n=Et(e,t)|0,(n|0)==7)return D=5,D|0;s=i[21344+(n*28|0)+(o<<2)>>2]|0;e:do if((s|0)>0)for(n=o,o=0;;){switch(n|0){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1;break;default:}if(o=o+1|0,(o|0)==(s|0))break e}else n=o;while(0);if((n|0)==1)return D=9,D|0;o=Ee(x,n)|0,(o|0)==127&&E(27476,27315,415,27506),be(o)|0?E(27521,27315,416,27506):(a=o,b=s,v=n)}else a=c,b=0,v=o;if(l=i[4272+(x*28|0)+(v<<2)>>2]|0,(l|0)<=-1&&E(27552,27315,423,27506),!u){if((b|0)<0)return D=5,D|0;if(b|0){s=r,n=0,o=i[s>>2]|0,s=i[s+4>>2]|0;do o=Ot(o,s)|0,s=T()|0,D=r,i[D>>2]=o,i[D+4>>2]=s,n=n+1|0;while((n|0)<(b|0))}if((l|0)<=0){y=104;break}for(s=r,n=0,o=i[s>>2]|0,s=i[s+4>>2]|0;;)if(o=Ot(o,s)|0,s=T()|0,D=r,i[D>>2]=o,i[D+4>>2]=s,n=n+1|0,(n|0)==(l|0)){y=104;break d}}if(c=De(a,x)|0,(c|0)==7&&E(27291,27315,432,27506),n=r,o=i[n>>2]|0,n=i[n+4>>2]|0,(l|0)>0){s=0;do o=Ot(o,n)|0,n=T()|0,D=r,i[D>>2]=o,i[D+4>>2]=n,s=s+1|0;while((s|0)!=(l|0))}if(n=Et(o,n)|0,(n|0)==7&&E(27634,27315,444,27506),o=xe(a)|0,o=i[(o?21760:21552)+(c*28|0)+(n<<2)>>2]|0,(o|0)<0&&E(27634,27315,458,27506),!o)y=104;else{c=r,n=0,s=i[c>>2]|0,c=i[c+4>>2]|0;do s=Dt(s,c)|0,c=T()|0,D=r,i[D>>2]=s,i[D+4>>2]=c,n=n+1|0;while((n|0)<(o|0));y=104}}else if((_|0)!=0&(u|0)!=0){if(a=Et(e,t)|0,n=r,n=Et(i[n>>2]|0,i[n+4>>2]|0)|0,(a|0)==7|(n|0)==7||(n=i[21344+(a*28|0)+(n<<2)>>2]|0,(n|0)<0))return D=5,D|0;if(!n)a=c,y=105;else{s=r,a=0,o=i[s>>2]|0,s=i[s+4>>2]|0;do o=Ot(o,s)|0,s=T()|0,D=r,i[D>>2]=o,i[D+4>>2]=s,a=a+1|0;while((a|0)<(n|0));a=c,y=104}}else a=c,y=104;while(0);return(y|0)==104&&u&&(y=105),(y|0)==105&&(D=r,(Et(i[D>>2]|0,i[D+4>>2]|0)|0)==1)?(D=9,D|0):(w=r,S=i[w>>2]|0,w=i[w+4>>2]&-1040385,C=_r(a|0,0,45)|0,w=w|T()|0,D=r,i[D>>2]=S|C,i[D+4>>2]=w,D=0,D|0)}else if((y|0)==107)return a|0;return 0}function ln(e,t,n,r,a,o){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0;var s=0,c=0;return c=M,M=M+16|0,s=c,a|0?(s=15,M=c,s|0):(e=sn(e,t,n,r,s)|0,e||=(a=i[s+4>>2]|0,e=i[s+8>>2]|0,i[o>>2]=(i[s>>2]|0)-e,i[o+4>>2]=a-e,0),s=e,M=c,s|0)}function un(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0;return f=M,M=M+16|0,d=f,r|0?(d=15,M=f,d|0):(c=i[n>>2]|0,s=i[n+4>>2]|0,i[d>>2]=c,l=d+4|0,i[l>>2]=s,u=d+8|0,i[u>>2]=0,n=(s|0)<(c|0),r=n?c:s,n=n?s:c,(n|0)<0?!((n|0)==-2147483648||((r|0)>0?(2147483647-r|0)<(n|0):(-2147483648-r|0)>(n|0)))&&!((r|0)>-1?(r|-2147483648)>=(n|0):(r^-2147483648|0)<(n|0))?o=5:r=1:o=5,(o|0)==5&&(r=s-c|0,o=0-c|0,(c|0)<0?(i[l>>2]=r,i[u>>2]=o,i[d>>2]=0,c=0):(r=s,o=0),s=c-r|0,n=o-r|0,(r|0)<0?(i[d>>2]=s,i[u>>2]=n,i[l>>2]=0,c=s,r=0):n=o,s=c-n|0,o=r-n|0,(n|0)<0?(i[d>>2]=s,i[l>>2]=o,i[u>>2]=0,n=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(n|0)<(r|0)?n:r,(r|0)>0&&(i[d>>2]=s-r,i[l>>2]=o-r,i[u>>2]=n-r),r=cn(e,t,d,a)|0),d=r,M=f,d|0)}function dn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0;return l=M,M=M+32|0,s=l+12|0,c=l,o=sn(e,t,e,t,s)|0,o|0?(c=o,M=l,c|0):(e=sn(e,t,n,r,c)|0,e|0?(c=e,M=l,c|0):(e=(i[s>>2]|0)-(i[c>>2]|0)|0,u=(e|0)<0,r=u?0-e|0:0,n=r+((i[s+4>>2]|0)-(i[c+4>>2]|0))|0,t=(n|0)<0,r=(i[s+8>>2]|0)-(i[c+8>>2]|0)+r+(t?0-n|0:0)|0,o=(r|0)<0,s=o?0:r,r=o?r:0,o=(t?0:n)-r|0,r=(u?0:e)-(t?n:0)-r|0,c=(o|0)<(r|0)?o:r,c=(s|0)<(c|0)?s:c,c=(c|0)>0?c:0,s=s-c|0,o=o-c|0,c=r-c|0,c=(c|0)>-1?c:0-c|0,o=(o|0)>-1?o:0-o|0,s=(s|0)>-1?s:0-s|0,s=(o|0)>(s|0)?o:s,s=(c|0)>(s|0)?c:s,c=a,i[c>>2]=s,i[c+4>>2]=((s|0)<0)<<31>>31,c=0,M=l,c|0))}function fn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0;return s=M,M=M+16|0,o=s,e=dn(e,t,n,r,o)|0,e|0?(o=e,M=s,o|0):(n=o,n=sr(i[n>>2]|0,i[n+4>>2]|0,1,0)|0,r=T()|0,o=a,i[o>>2]=n,i[o+4>>2]=r,o=0,M=s,o|0)}function pn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0;return l=M,M=M+16|0,o=l,s=dn(e,t,n,r,o)|0,s|0?(a=s,M=l,a|0):(s=o,o=i[s>>2]|0,s=i[s+4>>2]|0,(o|0)==0&(s|0)==0?(i[a>>2]=e,i[a+4>>2]=t,a=0,M=l,a|0):(c=mn(e,t,n,r,o,s,a,0,0,1,0)|0,c?(a=(mn(n,r,e,t,o,s,a,o,s,-1,-1)|0)==0,a=a?0:c,M=l,a|0):(a=0,M=l,a|0)))}function mn(e,t,n,r,a,o,s,c,u,d,f){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0,c|=0,u|=0,d|=0,f|=0;var p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0,O=0,k=0,A=0,j=0,N=0;if(j=M,M=M+48|0,p=j+24|0,m=j+12|0,A=j,i[p>>2]=0,i[p+4>>2]=0,i[p+8>>2]=0,i[m>>2]=0,i[m+4>>2]=0,i[m+8>>2]=0,sn(e,t,e,t,p)|0&&E(27634,27315,696,27575),sn(e,t,n,r,m)|0&&E(27634,27315,701,27575),_=p+8|0,r=i[_>>2]|0,n=r-(i[p>>2]|0)|0,i[p>>2]=n,k=p+4|0,r=(i[k>>2]|0)-r|0,i[k>>2]=r,k=r+n|0,p=0-k|0,i[_>>2]=p,_=m+8|0,b=i[_>>2]|0,y=b-(i[m>>2]|0)|0,i[m>>2]=y,O=m+4|0,b=(i[O>>2]|0)-b|0,i[O>>2]=b,O=b+y|0,i[_>>2]=0-O,D=1/(+(a>>>0)+4294967296*(o|0)),C=D*+(y-n|0),w=D*+(b-r|0),D*=+(k-O|0),i[A>>2]=n,O=A+4|0,i[O>>2]=r,k=A+8|0,i[k>>2]=p,(o|0)<0)return d=0,M=j,d|0;for(S=+(n|0),x=+(r|0),v=+(p|0),y=0,b=0;;){if(g=+(y>>>0)+4294967296*(b|0),N=C*g+S,h=w*g+x,g=D*g+v,r=~~+xr(+N),p=~~+xr(+h),n=~~+xr(+g),N=+l(+(+(r|0)-N)),h=+l(+(+(p|0)-h)),g=+l(+(+(n|0)-g)),N>h&N>g?(m=n+p|0,r=0-m|0):(m=0-r|0,h>g&&(p=m-n|0)),i[O>>2]=p,i[A>>2]=m,i[k>>2]=0,n=r+p|0,(r|0)>0?(i[O>>2]=n,i[k>>2]=r,i[A>>2]=0,m=0):(n=p,r=0),(n|0)<0?(p=m-n|0,i[A>>2]=p,r=r-n|0,i[k>>2]=r,i[O>>2]=0,m=p-r|0,n=0-r|0,(r|0)<0?(i[A>>2]=m,i[O>>2]=n,i[k>>2]=0,_=n,r=0):(_=0,m=p)):_=n,n=(_|0)<(m|0)?_:m,n=(r|0)<(n|0)?r:n,(n|0)>0&&(i[A>>2]=m-n,i[O>>2]=_-n,i[k>>2]=r-n),n=pr(y|0,b|0,d|0,f|0)|0,n=sr(n|0,T()|0,c|0,u|0)|0,T()|0,n=cn(e,t,A,s+(n<<3)|0)|0,n|0){r=20;break}if(_=y,y=sr(y|0,b|0,1,0)|0,m=b,b=T()|0,!((m|0)<(o|0)|(m|0)==(o|0)&_>>>0>>0)){n=0,r=20;break}}return(r|0)==20?(M=j,n|0):0}function hn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0,o=0;if((n|0)==0&(r|0)==0)return i=0,a=1,w(i|0),a|0;a=e,i=t,e=1,t=0;do o=(n&1|0)==0&!0,e=pr((o?1:a)|0,(o?0:i)|0,e|0,t|0)|0,t=T()|0,n=gr(n|0,r|0,1)|0,r=T()|0,a=pr(a|0,i|0,a|0,i|0)|0,i=T()|0;while(!((n|0)==0&(r|0)==0));return w(t|0),e|0}function gn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0,f=0,p=0;l=M,M=M+16|0,s=l,c=H(e|0,t|0,52)|0,T()|0,c&=15;do if(c){if(o=It(e,t,s)|0,!o){f=+a[s>>3],u=1/d(+f),p=+a[26032+(c<<3)>>3],a[n>>3]=f+p,a[n+8>>3]=f-p,f=+a[s+8>>3],u=p*u,a[n+16>>3]=u+f,a[n+24>>3]=f-u;break}return c=o,M=l,c|0}else{if(o=H(e|0,t|0,45)|0,T()|0,o&=127,o>>>0>121)return c=5,M=l,c|0;s=22128+(o<<5)|0,i[n>>2]=i[s>>2],i[n+4>>2]=i[s+4>>2],i[n+8>>2]=i[s+8>>2],i[n+12>>2]=i[s+12>>2],i[n+16>>2]=i[s+16>>2],i[n+20>>2]=i[s+20>>2],i[n+24>>2]=i[s+24>>2],i[n+28>>2]=i[s+28>>2];break}while(0);return Be(n,r?1.4:1.1),r=26160+(c<<3)|0,(i[r>>2]|0)==(e|0)&&(i[r+4>>2]|0)==(t|0)&&(a[n>>3]=1.5707963267948966),c=26288+(c<<3)|0,(i[c>>2]|0)==(e|0)&&(i[c+4>>2]|0)==(t|0)&&(a[n+8>>3]=-1.5707963267948966),+a[n>>3]!=1.5707963267948966&&+a[n+8>>3]!=-1.5707963267948966?(c=0,M=l,c|0):(a[n+16>>3]=3.141592653589793,a[n+24>>3]=-3.141592653589793,c=0,M=l,c|0)}function _n(e,t,n,a){e|=0,t|=0,n|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0;d=M,M=M+48|0,c=d+32|0,s=d+40|0,l=d,ht(c,0,0,0),u=i[c>>2]|0,c=i[c+4>>2]|0;do if(n>>>0<=15){if(o=wn(a)|0,o|0){a=l,i[a>>2]=0,i[a+4>>2]=0,i[l+8>>2]=o,i[l+12>>2]=-1,a=l+16|0,u=l+29|0,i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12>>0]=0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}if(o=rr((i[t+8>>2]|0)+1|0,32)|0,o){Tn(t,o),f=l,i[f>>2]=u,i[f+4>>2]=c,i[l+8>>2]=0,i[l+12>>2]=n,i[l+16>>2]=a,i[l+20>>2]=t,i[l+24>>2]=o,r[l+28>>0]=0,u=l+29|0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}else{a=l,i[a>>2]=0,i[a+4>>2]=0,i[l+8>>2]=13,i[l+12>>2]=-1,a=l+16|0,u=l+29|0,i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12>>0]=0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}}else u=l,i[u>>2]=0,i[u+4>>2]=0,i[l+8>>2]=4,i[l+12>>2]=-1,u=l+16|0,f=l+29|0,i[u>>2]=0,i[u+4>>2]=0,i[u+8>>2]=0,r[u+12>>0]=0,r[f>>0]=r[s>>0]|0,r[f+1>>0]=r[s+1>>0]|0,r[f+2>>0]=r[s+2>>0]|0;while(0);vn(l),i[e>>2]=i[l>>2],i[e+4>>2]=i[l+4>>2],i[e+8>>2]=i[l+8>>2],i[e+12>>2]=i[l+12>>2],i[e+16>>2]=i[l+16>>2],i[e+20>>2]=i[l+20>>2],i[e+24>>2]=i[l+24>>2],i[e+28>>2]=i[l+28>>2],M=d}function vn(e){e|=0;var t=0,n=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0;if(S=M,M=M+336|0,h=S+168|0,g=S,a=e,n=i[a>>2]|0,a=i[a+4>>2]|0,(n|0)==0&(a|0)==0){M=S;return}if(t=e+28|0,r[t>>0]|0?(n=yn(n,a)|0,a=T()|0):r[t>>0]=1,x=e+20|0,!(i[i[x>>2]>>2]|0)){t=e+24|0,n=i[t>>2]|0,n|0&&nr(n),b=e,i[b>>2]=0,i[b+4>>2]=0,i[e+8>>2]=0,i[x>>2]=0,i[e+12>>2]=-1,i[e+16>>2]=0,i[t>>2]=0,M=S;return}b=e+16|0,t=i[b>>2]|0,o=t&15;a:do if((n|0)==0&(a|0)==0)y=e+24|0;else{_=e+12|0,p=(o|0)==3,f=t&255,u=(o|1)==3,m=e+24|0,d=(o+-1|0)>>>0<3,c=(o|2)==3,l=g+8|0;b:for(;;){if(s=H(n|0,a|0,52)|0,T()|0,s&=15,(s|0)==(i[_>>2]|0)){switch(f&15){case 0:case 2:case 3:if(o=It(n,a,h)|0,o|0){v=15;break b}if(En(i[x>>2]|0,i[m>>2]|0,h)|0){v=19;break b}break;default:}if(u&&(o=i[(i[x>>2]|0)+4>>2]|0,i[h>>2]=i[o>>2],i[h+4>>2]=i[o+4>>2],i[h+8>>2]=i[o+8>>2],i[h+12>>2]=i[o+12>>2],Ne(26896,h)|0)){if(Nt(i[(i[x>>2]|0)+4>>2]|0,s,g)|0){v=25;break}if(o=g,(i[o>>2]|0)==(n|0)&&(i[o+4>>2]|0)==(a|0)){v=29;break}}if(d){if(o=Lt(n,a,h)|0,o|0){v=32;break}if(gn(n,a,g,0)|0){v=36;break}if(c&&Dn(i[x>>2]|0,i[m>>2]|0,h,g)|0){v=42;break}if(u&&kn(i[x>>2]|0,i[m>>2]|0,h,g)|0){v=42;break}}if(p){if(t=gn(n,a,h,1)|0,o=i[m>>2]|0,t|0){v=45;break}if(Pe(o,h)|0){if(Le(g,h),Ie(h,i[m>>2]|0)|0){v=53;break}if(En(i[x>>2]|0,i[m>>2]|0,l)|0){v=53;break}if(kn(i[x>>2]|0,i[m>>2]|0,g,h)|0){v=53;break}}}}do if((s|0)<(i[_>>2]|0)){if(t=gn(n,a,h,1)|0,o=i[m>>2]|0,t|0){v=58;break b}if(!(Pe(o,h)|0)){v=73;break}if(Ie(i[m>>2]|0,h)|0&&(Le(g,h),Dn(i[x>>2]|0,i[m>>2]|0,g,h)|0)){v=65;break b}if(n=xt(n,a,s+1|0,g)|0,n|0){v=67;break b}a=g,n=i[a>>2]|0,a=i[a+4>>2]|0}else v=73;while(0);if((v|0)==73&&(v=0,n=yn(n,a)|0,a=T()|0),(n|0)==0&(a|0)==0){y=m;break a}}switch(v|0){case 15:t=i[m>>2]|0,t|0&&nr(t),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=o,v=20;break;case 19:i[e>>2]=n,i[e+4>>2]=a,v=20;break;case 25:E(27634,27600,470,27611);break;case 29:i[e>>2]=n,i[e+4>>2]=a,M=S;return;case 32:t=i[m>>2]|0,t|0&&nr(t),y=e,i[y>>2]=0,i[y+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=o,M=S;return;case 36:E(27634,27600,493,27611);break;case 42:i[e>>2]=n,i[e+4>>2]=a,M=S;return;case 45:o|0&&nr(o),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=t,v=55;break;case 53:i[e>>2]=n,i[e+4>>2]=a,v=55;break;case 58:o|0&&nr(o),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=t,v=71;break;case 65:i[e>>2]=n,i[e+4>>2]=a,v=71;break;case 67:t=i[m>>2]|0,t|0&&nr(t),y=e,i[y>>2]=0,i[y+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=n,M=S;return}if((v|0)==20){M=S;return}else if((v|0)==55){M=S;return}else if((v|0)==71){M=S;return}}while(0);t=i[y>>2]|0,t|0&&nr(t),v=e,i[v>>2]=0,i[v+4>>2]=0,i[e+8>>2]=0,i[x>>2]=0,i[e+12>>2]=-1,i[b>>2]=0,i[y>>2]=0,M=S}function yn(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;f=M,M=M+16|0,d=f,r=H(e|0,t|0,52)|0,T()|0,r&=15,n=H(e|0,t|0,45)|0,T()|0;do if(r){for(;n=_r(r+4095|0,0,52)|0,a=T()|0|t&-15728641,o=(15-r|0)*3|0,s=_r(7,0,o|0)|0,c=T()|0,n=n|e|s,a|=c,l=H(e|0,t|0,o|0)|0,T()|0,l&=7,r=r+-1|0,!(l>>>0<6);)if(r)t=a,e=n;else{u=4;break}if((u|0)==4){n=H(n|0,a|0,45)|0,T()|0;break}return d=(l|0)==0&(vt(n,a)|0)!=0,d=_r((d?2:1)+l|0,0,o|0)|0,u=T()|0|t&~c,d|=e&~s,w(u|0),M=f,d|0}while(0);return n&=127,n>>>0>120?(u=0,d=0,w(u|0),M=f,d|0):(ht(d,0,n+1|0,0),u=i[d+4>>2]|0,d=i[d>>2]|0,w(u|0),M=f,d|0)}function bn(e,t,n,r,a,o){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0;_=M,M=M+160|0,f=_+80|0,c=_+64|0,p=_+112|0,g=_,_n(f,e,t,n),u=f,Wt(c,i[u>>2]|0,i[u+4>>2]|0,t),u=c,l=i[u>>2]|0,u=i[u+4>>2]|0,s=i[f+8>>2]|0,m=p+4|0,i[m>>2]=i[f>>2],i[m+4>>2]=i[f+4>>2],i[m+8>>2]=i[f+8>>2],i[m+12>>2]=i[f+12>>2],i[m+16>>2]=i[f+16>>2],i[m+20>>2]=i[f+20>>2],i[m+24>>2]=i[f+24>>2],i[m+28>>2]=i[f+28>>2],m=g,i[m>>2]=l,i[m+4>>2]=u,m=g+8|0,i[m>>2]=s,e=g+12|0,t=p,n=e+36|0;do i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0;while((e|0)<(n|0));if(p=g+48|0,i[p>>2]=i[c>>2],i[p+4>>2]=i[c+4>>2],i[p+8>>2]=i[c+8>>2],i[p+12>>2]=i[c+12>>2],(l|0)==0&(u|0)==0)return g=s,M=_,g|0;n=g+16|0,d=g+24|0,f=g+28|0,s=0,c=0,t=l,e=u;do{if(!((s|0)<(a|0)|(s|0)==(a|0)&c>>>0>>0)){h=4;break}if(u=c,c=sr(c|0,s|0,1,0)|0,s=T()|0,u=o+(u<<3)|0,i[u>>2]=t,i[u+4>>2]=e,Kt(p),e=p,t=i[e>>2]|0,e=i[e+4>>2]|0,(t|0)==0&(e|0)==0){if(vn(n),t=n,e=i[t>>2]|0,t=i[t+4>>2]|0,(e|0)==0&(t|0)==0){h=10;break}Gt(e,t,i[f>>2]|0,p),e=p,t=i[e>>2]|0,e=i[e+4>>2]|0}u=g,i[u>>2]=t,i[u+4>>2]=e}while(!((t|0)==0&(e|0)==0));return(h|0)==4?(e=g+40|0,t=i[e>>2]|0,t|0&&nr(t),h=g+16|0,i[h>>2]=0,i[h+4>>2]=0,i[d>>2]=0,i[g+36>>2]=0,i[f>>2]=-1,i[g+32>>2]=0,i[e>>2]=0,Gt(0,0,0,p),i[g>>2]=0,i[g+4>>2]=0,i[m>>2]=0,g=14,M=_,g|0):((h|0)==10&&(i[g>>2]=0,i[g+4>>2]=0,i[m>>2]=i[d>>2]),g=i[m>>2]|0,M=_,g|0)}function xn(e,t,n,o){e|=0,t|=0,n|=0,o|=0;var s=0,c=0,u=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(g=M,M=M+48|0,p=g+32|0,f=g+40|0,m=g,!(i[e>>2]|0))return h=o,i[h>>2]=0,i[h+4>>2]=0,h=0,M=g,h|0;ht(p,0,0,0),u=p,s=i[u>>2]|0,u=i[u+4>>2]|0;do if(t>>>0>15)h=m,i[h>>2]=0,i[h+4>>2]=0,i[m+8>>2]=4,i[m+12>>2]=-1,h=m+16|0,n=m+29|0,i[h>>2]=0,i[h+4>>2]=0,i[h+8>>2]=0,r[h+12>>0]=0,r[n>>0]=r[f>>0]|0,r[n+1>>0]=r[f+1>>0]|0,r[n+2>>0]=r[f+2>>0]|0,n=4,h=9;else{if(n=wn(n)|0,n|0){p=m,i[p>>2]=0,i[p+4>>2]=0,i[m+8>>2]=n,i[m+12>>2]=-1,p=m+16|0,h=m+29|0,i[p>>2]=0,i[p+4>>2]=0,i[p+8>>2]=0,r[p+12>>0]=0,r[h>>0]=r[f>>0]|0,r[h+1>>0]=r[f+1>>0]|0,r[h+2>>0]=r[f+2>>0]|0,h=9;break}if(n=rr((i[e+8>>2]|0)+1|0,32)|0,!n){h=m,i[h>>2]=0,i[h+4>>2]=0,i[m+8>>2]=13,i[m+12>>2]=-1,h=m+16|0,n=m+29|0,i[h>>2]=0,i[h+4>>2]=0,i[h+8>>2]=0,r[h+12>>0]=0,r[n>>0]=r[f>>0]|0,r[n+1>>0]=r[f+1>>0]|0,r[n+2>>0]=r[f+2>>0]|0,n=13,h=9;break}Tn(e,n),v=m,i[v>>2]=s,i[v+4>>2]=u,u=m+8|0,i[u>>2]=0,i[m+12>>2]=t,i[m+20>>2]=e,i[m+24>>2]=n,r[m+28>>0]=0,s=m+29|0,r[s>>0]=r[f>>0]|0,r[s+1>>0]=r[f+1>>0]|0,r[s+2>>0]=r[f+2>>0]|0,i[m+16>>2]=3,_=+Me(n),_*=+Ae(n),c=+l(+ +a[n>>3]),c=_/+d(+ +br(+c,+ +l(+ +a[n+8>>3])))*6371.007180918475*6371.007180918475,s=m+12|0,n=i[s>>2]|0;a:do if((n|0)>0)do{if(Qt(n+-1|0,p)|0,!(c/+a[p>>3]>10))break a;v=i[s>>2]|0,n=v+-1|0,i[s>>2]=n}while((v|0)>1);while(0);if(vn(m),s=o,i[s>>2]=0,i[s+4>>2]=0,s=m,n=i[s>>2]|0,s=i[s+4>>2]|0,!((n|0)==0&(s|0)==0))do _t(n,s,t,p)|0,f=p,e=o,f=sr(i[e>>2]|0,i[e+4>>2]|0,i[f>>2]|0,i[f+4>>2]|0)|0,e=T()|0,v=o,i[v>>2]=f,i[v+4>>2]=e,vn(m),v=m,n=i[v>>2]|0,s=i[v+4>>2]|0;while(!((n|0)==0&(s|0)==0));n=i[u>>2]|0}while(0);return v=n,M=g,v|0}function Sn(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;if(!(Ne(t,n)|0)||(t=je(t)|0,r=+a[n>>3],o=+a[n+8>>3],o=t&o<0?o+6.283185307179586:o,m=i[e>>2]|0,(m|0)<=0))return m=0,m|0;if(p=i[e+4>>2]|0,t){t=0,f=o,n=-1,e=0;a:for(;;){for(d=e;c=+a[p+(d<<4)>>3],o=+a[p+(d<<4)+8>>3],e=(n+2|0)%(m|0)|0,s=+a[p+(e<<4)>>3],l=+a[p+(e<<4)+8>>3],c>s?(u=c,c=l):(u=s,s=c,c=o,o=l),r=r==s|r==u?r+2220446049250313e-31:r,ru;)if(n=d+1|0,(n|0)>=(m|0)){n=22;break a}else e=d,d=n,n=e;if(l=c<0?c+6.283185307179586:c,c=o<0?o+6.283185307179586:o,f=l==f|c==f?f+-2220446049250313e-31:f,u=l+(c-l)*((r-s)/(u-s)),(u<0?u+6.283185307179586:u)>f&&(t^=1),e=d+1|0,(e|0)>=(m|0)){n=22;break}else n=d}if((n|0)==22)return t|0}else{t=0,f=o,n=-1,e=0;b:for(;;){for(d=e;c=+a[p+(d<<4)>>3],o=+a[p+(d<<4)+8>>3],e=(n+2|0)%(m|0)|0,s=+a[p+(e<<4)>>3],l=+a[p+(e<<4)+8>>3],c>s?(u=c,c=l):(u=s,s=c,c=o,o=l),r=r==s|r==u?r+2220446049250313e-31:r,ru;)if(n=d+1|0,(n|0)>=(m|0)){n=22;break b}else e=d,d=n,n=e;if(f=c==f|o==f?f+-2220446049250313e-31:f,c+(o-c)*((r-s)/(u-s))>f&&(t^=1),e=d+1|0,(e|0)>=(m|0)){n=22;break}else n=d}if((n|0)==22)return t|0}return 0}function Cn(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0;if(_=i[e>>2]|0,!_){i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;return}if(v=t+8|0,a[v>>3]=17976931348623157e292,y=t+24|0,a[y>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,b=t+16|0,a[b>>3]=-17976931348623157e292,!((_|0)<=0)){for(h=i[e+4>>2]|0,f=17976931348623157e292,p=-17976931348623157e292,m=0,e=-1,s=17976931348623157e292,c=17976931348623157e292,d=-17976931348623157e292,r=-17976931348623157e292,g=0;n=+a[h+(g<<4)>>3],u=+a[h+(g<<4)+8>>3],e=e+2|0,o=+a[h+(((e|0)==(_|0)?0:e)<<4)+8>>3],n>3]=n,s=n),u>3]=u,c=u),n>d?a[t>>3]=n:n=d,u>r&&(a[b>>3]=u,r=u),f=u>0&up?u:p,m|=+l(+(u-o))>3.141592653589793,e=g+1|0,(e|0)!=(_|0);)x=g,d=n,g=e,e=x;m&&(a[b>>3]=p,a[y>>3]=f)}}function wn(e){return e|=0,(e>>>0<4?0:15)|0}function Tn(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0;if(_=i[e>>2]|0,_){if(v=t+8|0,a[v>>3]=17976931348623157e292,y=t+24|0,a[y>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,b=t+16|0,a[b>>3]=-17976931348623157e292,(_|0)>0){for(o=i[e+4>>2]|0,h=17976931348623157e292,g=-17976931348623157e292,r=0,n=-1,d=17976931348623157e292,f=17976931348623157e292,m=-17976931348623157e292,c=-17976931348623157e292,x=0;s=+a[o+(x<<4)>>3],p=+a[o+(x<<4)+8>>3],T=n+2|0,u=+a[o+(((T|0)==(_|0)?0:T)<<4)+8>>3],s>3]=s,d=s),p>3]=p,f=p),s>m?a[t>>3]=s:s=m,p>c&&(a[b>>3]=p,c=p),h=p>0&pg?p:g,r|=+l(+(p-u))>3.141592653589793,n=x+1|0,(n|0)!=(_|0);)T=x,m=s,x=n,n=T;r&&(a[b>>3]=g,a[y>>3]=h)}}else i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;if(T=e+8|0,n=i[T>>2]|0,!((n|0)<=0)){w=e+12|0,C=0;do if(o=i[w>>2]|0,r=C,C=C+1|0,y=t+(C<<5)|0,b=i[o+(r<<3)>>2]|0,b){if(x=t+(C<<5)+8|0,a[x>>3]=17976931348623157e292,e=t+(C<<5)+24|0,a[e>>3]=17976931348623157e292,a[y>>3]=-17976931348623157e292,S=t+(C<<5)+16|0,a[S>>3]=-17976931348623157e292,(b|0)>0){for(_=i[o+(r<<3)+4>>2]|0,h=17976931348623157e292,g=-17976931348623157e292,o=0,r=-1,v=0,d=17976931348623157e292,f=17976931348623157e292,p=-17976931348623157e292,c=-17976931348623157e292;s=+a[_+(v<<4)>>3],m=+a[_+(v<<4)+8>>3],r=r+2|0,u=+a[_+(((r|0)==(b|0)?0:r)<<4)+8>>3],s>3]=s,d=s),m>3]=m,f=m),s>p?a[y>>3]=s:s=p,m>c&&(a[S>>3]=m,c=m),h=m>0&mg?m:g,o|=+l(+(m-u))>3.141592653589793,r=v+1|0,(r|0)!=(b|0);)E=v,v=r,p=s,r=E;o&&(a[S>>3]=g,a[e>>3]=h)}}else i[y>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[y+12>>2]=0,i[y+16>>2]=0,i[y+20>>2]=0,i[y+24>>2]=0,i[y+28>>2]=0,n=i[T>>2]|0;while((C|0)<(n|0))}}function En(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(!(Sn(e,t,n)|0))return a=0,a|0;if(a=e+8|0,(i[a>>2]|0)<=0)return a=1,a|0;for(r=e+12|0,e=0;;){if(o=e,e=e+1|0,Sn((i[r>>2]|0)+(o<<3)|0,t+(e<<5)|0,n)|0){e=0,r=6;break}if((e|0)>=(i[a>>2]|0)){e=1,r=6;break}}return(r|0)==6?e|0:0}function Dn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(u=M,M=M+16|0,c=u,s=n+8|0,!(Sn(e,t,s)|0))return l=0,M=u,l|0;l=e+8|0;a:do if((i[l>>2]|0)>0){for(o=e+12|0,a=0;;){if(d=a,a=a+1|0,Sn((i[o>>2]|0)+(d<<3)|0,t+(a<<5)|0,s)|0){a=0;break}if((a|0)>=(i[l>>2]|0))break a}return M=u,a|0}while(0);if(On(e,t,n,r)|0)return d=0,M=u,d|0;i[c>>2]=i[n>>2],i[c+4>>2]=s,a=i[l>>2]|0;b:do if((a|0)>0)for(e=e+12|0,s=0,o=a;;){if(a=i[e>>2]|0,(i[a+(s<<3)>>2]|0)>0){if(Sn(c,r,i[a+(s<<3)+4>>2]|0)|0){a=0;break b}if(a=s+1|0,On((i[e>>2]|0)+(s<<3)|0,t+(a<<5)|0,n,r)|0){a=0;break b}o=i[l>>2]|0}else a=s+1|0;if((a|0)<(o|0))s=a;else{a=1;break}}else a=1;while(0);return d=a,M=u,d|0}function On(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0;if(w=M,M=M+176|0,b=w+172|0,o=w+168|0,x=w,!(Pe(t,r)|0))return e=0,M=w,e|0;if(Fe(t,r,b,o),Sr(x|0,n|0,168)|0,(i[n>>2]|0)>0){t=0;do T=x+8+(t<<4)+8|0,y=+Jt(+a[T>>3],i[o>>2]|0),a[T>>3]=y,t=t+1|0;while((t|0)<(i[n>>2]|0))}_=+a[r>>3],v=+a[r+8>>3],y=+Jt(+a[r+16>>3],i[o>>2]|0),h=+Jt(+a[r+24>>3],i[o>>2]|0);a:do if((i[e>>2]|0)>0){if(r=e+4|0,o=i[x>>2]|0,(o|0)<=0){for(t=0;;)if(t=t+1|0,(t|0)>=(i[e>>2]|0)){t=0;break a}}for(n=0;;){if(t=i[r>>2]|0,m=+a[t+(n<<4)>>3],g=+Jt(+a[t+(n<<4)+8>>3],i[b>>2]|0),t=i[r>>2]|0,n=n+1|0,T=(n|0)%(i[e>>2]|0)|0,s=+a[t+(T<<4)>>3],c=+Jt(+a[t+(T<<4)+8>>3],i[b>>2]|0),!(m>=_)|!(s>=_)&&!(m<=v)|!(s<=v)&&!(g<=h)|!(c<=h)&&!(g>=y)|!(c>=y)){p=s-m,d=c-g,t=0;do if(E=t,t=t+1|0,T=(t|0)==(o|0)?0:t,s=+a[x+8+(E<<4)+8>>3],c=+a[x+8+(T<<4)+8>>3]-s,l=+a[x+8+(E<<4)>>3],u=+a[x+8+(T<<4)>>3]-l,f=p*c-d*u,f!=0&&(S=g-s,C=m-l,u=(S*u-c*C)/f,!(u<0|u>1))&&(f=(p*S-d*C)/f,f>=0&f<=1)){t=1;break a}while((t|0)<(o|0))}if((n|0)>=(i[e>>2]|0)){t=0;break}}}else t=0;while(0);return E=t,M=w,E|0}function kn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;if(On(e,t,n,r)|0)return o=1,o|0;if(o=e+8|0,(i[o>>2]|0)<=0)return o=0,o|0;for(a=e+12|0,e=0;;){if(s=e,e=e+1|0,On((i[a>>2]|0)+(s<<3)|0,t+(e<<5)|0,n,r)|0){e=1,a=6;break}if((e|0)>=(i[o>>2]|0)){e=0,a=6;break}}return(a|0)==6?e|0:0}function An(){return 8}function jn(){return 16}function Mn(){return 168}function Nn(){return 8}function Pn(){return 16}function Fn(){return 12}function In(){return 8}function Ln(e){return e|=0,+(+((i[e>>2]|0)>>>0)+4294967296*(i[e+4>>2]|0))}function Rn(e){e|=0;var t=0,n=0;return n=+a[e>>3],t=+a[e+8>>3],+ +u(+(n*n+t*t))}function B(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;u=+a[e>>3],l=+a[t>>3]-u,c=+a[e+8>>3],s=+a[t+8>>3]-c,f=+a[n>>3],o=+a[r>>3]-f,p=+a[n+8>>3],d=+a[r+8>>3]-p,o=(o*(c-p)-(u-f)*d)/(l*d-s*o),a[i>>3]=u+l*o,a[i+8>>3]=c+s*o}function zn(e,t){return e|=0,t|=0,+l(+(a[e>>3]-+a[t>>3]))<1.1920928955078125e-7?(t=+l(+(a[e+8>>3]-+a[t+8>>3]))<1.1920928955078125e-7,t|0):(t=0,t|0)}function V(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(o=M,M=M+16|0,a=o,r=vt(e,t)|0,(n+-1|0)>>>0>5||(r=(r|0)!=0,(n|0)==1&r))return a=-1,M=o,a|0;do if(Bn(e,t,a)|0)r=-1;else if(r){r=((i[26416+(n<<2)>>2]|0)+5-(i[a>>2]|0)|0)%5|0;break}else{r=((i[26448+(n<<2)>>2]|0)+6-(i[a>>2]|0)|0)%6|0;break}while(0);return a=r,M=o,a|0}function Bn(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(d=M,M=M+32|0,c=d+16|0,l=d,r=Ft(e,t,c)|0,r|0)return n=r,M=d,n|0;o=ut(e,t)|0,u=Et(e,t)|0,Ce(o,l),r=we(o,i[c>>2]|0)|0;do if(be(o)|0){do switch(o|0){case 4:a=0;break;case 14:a=1;break;case 24:a=2;break;case 38:a=3;break;case 49:a=4;break;case 58:a=5;break;case 63:a=6;break;case 72:a=7;break;case 83:a=8;break;case 97:a=9;break;case 107:a=10;break;case 117:a=11;break;default:E(27634,27636,75,27645)}while(0);if(s=i[26480+(a*24|0)+8>>2]|0,t=i[26480+(a*24|0)+16>>2]|0,e=i[c>>2]|0,(e|0)!=(i[l>>2]|0)&&(l=xe(o)|0,e=i[c>>2]|0,l|(e|0)==(t|0)&&(r=(r+1|0)%6|0)),(u|0)==3&(e|0)==(t|0)){r=(r+5|0)%6|0;break}(u|0)==5&(e|0)==(s|0)&&(r=(r+1|0)%6|0)}while(0);return i[n>>2]=r,n=0,M=d,n|0}function Vn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;if(b=M,M=M+32|0,y=b+24|0,_=b+20|0,h=b+8|0,m=b+16|0,p=b,l=(vt(e,t)|0)==0,l=l?6:5,d=H(e|0,t|0,52)|0,T()|0,d&=15,l>>>0<=n>>>0)return r=2,M=b,r|0;f=(d|0)==0,!f&&(g=_r(7,0,(d^15)*3|0)|0,(g&e|0)==0&((T()|0)&t|0)==0)?a=n:o=4;a:do if((o|0)==4){if(a=(vt(e,t)|0)!=0,((a?4:5)|0)<(n|0)||Bn(e,t,y)|0||(o=(i[y>>2]|0)+n|0,a=a?26768+(((o|0)%5|0)<<2)|0:26800+(((o|0)%6|0)<<2)|0,g=i[a>>2]|0,(g|0)==7))return r=1,M=b,r|0;i[_>>2]=0,a=se(e,t,g,_,h)|0;do if(!a){if(c=h,u=i[c>>2]|0,c=i[c+4>>2]|0,s=c>>>0>>0|(c|0)==(t|0)&u>>>0>>0,o=s?u:e,s=s?c:t,!f&&(f=_r(7,0,(d^15)*3|0)|0,(u&f|0)==0&(c&(T()|0)|0)==0))a=n;else{if(c=(n+-1+l|0)%(l|0)|0,a=vt(e,t)|0,(c|0)<0&&E(27634,27636,248,27661),l=(a|0)!=0,((l?4:5)|0)<(c|0)&&E(27634,27636,248,27661),Bn(e,t,y)|0&&E(27634,27636,248,27661),a=(i[y>>2]|0)+c|0,a=l?26768+(((a|0)%5|0)<<2)|0:26800+(((a|0)%6|0)<<2)|0,c=i[a>>2]|0,(c|0)==7&&E(27634,27636,248,27661),i[m>>2]=0,a=se(e,t,c,m,p)|0,a|0)break;u=p,l=i[u>>2]|0,u=i[u+4>>2]|0;do if(u>>>0>>0|(u|0)==(s|0)&l>>>0>>0){if(o=vt(l,u)|0?de(l,u,e,t)|0:i[26864+((((i[m>>2]|0)+(i[26832+(c<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,a=vt(l,u)|0,(o+-1|0)>>>0>5){a=-1,o=l,s=u;break}if(a=(a|0)!=0,(o|0)==1&a){a=-1,o=l,s=u;break}do if(Bn(l,u,y)|0)a=-1;else if(a){a=((i[26416+(o<<2)>>2]|0)+5-(i[y>>2]|0)|0)%5|0;break}else{a=((i[26448+(o<<2)>>2]|0)+6-(i[y>>2]|0)|0)%6|0;break}while(0);o=l,s=u}else a=n;while(0);c=h,u=i[c>>2]|0,c=i[c+4>>2]|0}if((o|0)==(u|0)&(s|0)==(c|0)){if(l=(vt(u,c)|0)!=0,e=l?de(u,c,e,t)|0:i[26864+((((i[_>>2]|0)+(i[26832+(g<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,a=vt(u,c)|0,(e+-1|0)>>>0<=5&&(v=(a|0)!=0,!((e|0)==1&v)))do if(Bn(u,c,y)|0)a=-1;else if(v){a=((i[26416+(e<<2)>>2]|0)+5-(i[y>>2]|0)|0)%5|0;break}else{a=((i[26448+(e<<2)>>2]|0)+6-(i[y>>2]|0)|0)%6|0;break}while(0);else a=-1;a=a+1|0,a=(a|0)==6|l&(a|0)==5?0:a}t=s,e=o;break a}while(0);return r=a,M=b,r|0}while(0);return v=_r(a|0,0,56)|0,y=T()|0|t&-2130706433|536870912,i[r>>2]=v|e,i[r+4>>2]=y,r=0,M=b,r|0}function Hn(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;return o=(vt(e,t)|0)==0,r=Vn(e,t,0,n)|0,a=(r|0)==0,o?!a||(r=Vn(e,t,1,n+8|0)|0,r|0)||(r=Vn(e,t,2,n+16|0)|0,r|0)||(r=Vn(e,t,3,n+24|0)|0,r|0)||(r=Vn(e,t,4,n+32|0)|0,r)?(o=r,o|0):Vn(e,t,5,n+40|0)|0:!a||(r=Vn(e,t,1,n+8|0)|0,r|0)||(r=Vn(e,t,2,n+16|0)|0,r|0)||(r=Vn(e,t,3,n+24|0)|0,r|0)||(r=Vn(e,t,4,n+32|0)|0,r|0)?(o=r,o|0):(o=n+40|0,i[o>>2]=0,i[o+4>>2]=0,o=0,o|0)}function Un(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0;return l=M,M=M+192|0,a=l,o=l+168|0,s=H(e|0,t|0,56)|0,T()|0,s&=7,c=t&-2130706433|134217728,r=Ft(e,c,o)|0,r|0?(c=r,M=l,c|0):(t=H(e|0,t|0,52)|0,T()|0,t&=15,vt(e,c)|0?rt(o,t,s,1,a):st(o,t,s,1,a),c=a+8|0,i[n>>2]=i[c>>2],i[n+4>>2]=i[c+4>>2],i[n+8>>2]=i[c+8>>2],i[n+12>>2]=i[c+12>>2],c=0,M=l,c|0)}function Wn(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0;return a=M,M=M+16|0,n=a,!(!0&(t&2013265920|0)==536870912)||(r=t&-2130706433|134217728,!(pt(e,r)|0))?(r=0,M=a,r|0):(o=H(e|0,t|0,56)|0,T()|0,o=(Vn(e,r,o&7,n)|0)==0,r=n,r=o&((i[r>>2]|0)==(e|0)?(i[r+4>>2]|0)==(t|0):0)&1,M=a,r|0)}function Gn(){return 27680}function Kn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;f=M,M=M+208|0,l=f,u=f+192|0,s=y(n,t)|0,c=u,i[c>>2]=1,i[c+4>>2]=0;a:do if(s|0){for(c=0-n|0,i[l+4>>2]=n,i[l>>2]=n,a=2,t=n,o=n;t=t+n+o|0,i[l+(a<<2)>>2]=t,t>>>0>>0;)p=o,a=a+1|0,o=t,t=p;if(o=e+s+c|0,o>>>0>e>>>0){s=o,a=1,t=1;do{do if((t&3|0)!=3)if(t=a+-1|0,(i[l+(t<<2)>>2]|0)>>>0<(s-e|0)>>>0?qn(e,n,r,a,l):Yn(e,n,r,u,a,0,l),(a|0)==1){Xn(u,1),a=0;break}else{Xn(u,t),a=1;break}else qn(e,n,r,a,l),Jn(u,2),a=a+2|0;while(0);t=i[u>>2]|1,i[u>>2]=t,e=e+n|0}while(e>>>0>>0)}else a=1,t=1;for(Yn(e,n,r,u,a,0,l),o=u+4|0;;){if((a|0)==1&(t|0)==1)if(i[o>>2]|0)d=19;else break a;else(a|0)<2?d=19:(Xn(u,2),p=a+-2|0,i[u>>2]=i[u>>2]^7,Jn(u,1),Yn(e+(0-(i[l+(p<<2)>>2]|0))+c|0,n,r,u,a+-1|0,1,l),Xn(u,1),t=i[u>>2]|1,i[u>>2]=t,e=e+c|0,Yn(e,n,r,u,p,1,l),a=p);(d|0)==19&&(d=0,t=Zn(u)|0,Jn(u,t),e=e+c|0,a=t+a|0,t=i[u>>2]|0)}}while(0);M=f}function qn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0;f=M,M=M+240|0,d=f,i[d>>2]=e;a:do if((r|0)>1)for(u=0-t|0,c=e,o=r,r=1,s=e;;){if(c=c+u|0,l=o+-2|0,e=c+(0-(i[a+(l<<2)>>2]|0))|0,(kr[n&3](s,e)|0)>-1&&(kr[n&3](s,c)|0)>-1||(s=d+(r<<2)|0,(kr[n&3](e,c)|0)>-1?(i[s>>2]=e,o=o+-1|0):(i[s>>2]=c,e=c,o=l),r=r+1|0,(o|0)<=1))break a;c=e,s=i[d>>2]|0}else r=1;while(0);$n(t,d,r),M=f}function Jn(e,t){e|=0,t|=0;var n=0,r=0,a=0;a=e+4|0,t>>>0>31?(r=i[a>>2]|0,i[e>>2]=r,i[a>>2]=0,t=t+-32|0,n=0):(n=i[a>>2]|0,r=i[e>>2]|0),i[e>>2]=n<<32-t|r>>>t,i[a>>2]=n>>>t}function Yn(e,t,n,r,a,o,s){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0;var c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;m=M,M=M+240|0,f=m+232|0,p=m,h=i[r>>2]|0,i[f>>2]=h,l=i[r+4>>2]|0,u=f+4|0,i[u>>2]=l,i[p>>2]=e;a:do if((h|0)!=1|(l|0)!=0&&(d=0-t|0,c=e+(0-(i[s+(a<<2)>>2]|0))|0,(kr[n&3](c,e)|0)>=1))for(r=1,o=(o|0)==0,l=c;;){if(o&(a|0)>1){if(o=e+d|0,c=i[s+(a+-2<<2)>>2]|0,(kr[n&3](o,l)|0)>-1){c=10;break a}if((kr[n&3](o+(0-c)|0,l)|0)>-1){c=10;break a}}if(o=r+1|0,i[p+(r<<2)>>2]=l,h=Zn(f)|0,Jn(f,h),a=h+a|0,!((i[f>>2]|0)!=1|(i[u>>2]|0)!=0)){r=o,e=l,c=10;break a}if(e=l+(0-(i[s+(a<<2)>>2]|0))|0,(kr[n&3](e,i[p>>2]|0)|0)<1){e=l,r=o,o=0,c=9;break}else h=l,r=o,o=1,l=e,e=h}else r=1,c=9;while(0);(c|0)==9&&!(o|0)&&(c=10),(c|0)==10&&($n(t,p,r),qn(e,t,n,a,s)),M=m}function Xn(e,t){e|=0,t|=0;var n=0,r=0,a=0;a=e+4|0,t>>>0>31?(r=i[e>>2]|0,i[a>>2]=r,i[e>>2]=0,t=t+-32|0,n=0):(n=i[e>>2]|0,r=i[a>>2]|0),i[a>>2]=n>>>(32-t|0)|r<>2]=n<>2]|0)+-1|0)|0,t?t|0:(t=Qn(i[e+4>>2]|0)|0,(t|0?t+32|0:0)|0)}function Qn(e){e|=0;var t=0;if(e)if(e&1)e=0;else for(t=e,e=0;e=e+1|0,!(t&2);)t>>>=1;else e=32;return e|0}function $n(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0;s=M,M=M+256|0,r=s;a:do if((n|0)>=2&&(o=t+(n<<2)|0,i[o>>2]=r,e|0))for(;;){a=e>>>0<256?e:256,Sr(r|0,i[t>>2]|0,a|0)|0,r=0;do c=t+(r<<2)|0,r=r+1|0,Sr(i[c>>2]|0,i[t+(r<<2)>>2]|0,a|0)|0,i[c>>2]=(i[c>>2]|0)+a;while((r|0)!=(n|0));if(e=e-a|0,!e)break a;r=i[o>>2]|0}while(0);M=s}function er(e){return e=+e,~~+Tr(+e)|0}function tr(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0;S=M,M=M+16|0,p=S;do if(e>>>0<245){if(u=e>>>0<11?16:e+11&-8,e=u>>>3,f=i[6921]|0,n=f>>>e,n&3|0)return t=(n&1^1)+e|0,e=27724+(t<<1<<2)|0,n=e+8|0,r=i[n>>2]|0,a=r+8|0,o=i[a>>2]|0,(o|0)==(e|0)?i[6921]=f&~(1<>2]=e,i[n>>2]=o),x=t<<3,i[r+4>>2]=x|3,x=r+x+4|0,i[x>>2]=i[x>>2]|1,x=a,M=S,x|0;if(d=i[6923]|0,u>>>0>d>>>0){if(n|0)return t=2<>>12&16,t>>>=c,n=t>>>5&8,t>>>=n,o=t>>>2&4,t>>>=o,e=t>>>1&2,t>>>=e,r=t>>>1&1,r=(n|c|o|e|r)+(t>>>r)|0,t=27724+(r<<1<<2)|0,e=t+8|0,o=i[e>>2]|0,c=o+8|0,n=i[c>>2]|0,(n|0)==(t|0)?(e=f&~(1<>2]=t,i[e>>2]=n,e=f),x=r<<3,s=x-u|0,i[o+4>>2]=u|3,a=o+u|0,i[a+4>>2]=s|1,i[o+x>>2]=s,d|0&&(r=i[6926]|0,t=d>>>3,n=27724+(t<<1<<2)|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=r,i[t+12>>2]=r,i[r+8>>2]=t,i[r+12>>2]=n),i[6923]=s,i[6926]=a,x=c,M=S,x|0;if(o=i[6922]|0,o){for(n=(o&0-o)+-1|0,a=n>>>12&16,n>>>=a,r=n>>>5&8,n>>>=r,s=n>>>2&4,n>>>=s,c=n>>>1&2,n>>>=c,l=n>>>1&1,l=i[27988+((r|a|s|c|l)+(n>>>l)<<2)>>2]|0,n=l,c=l,l=(i[l+4>>2]&-8)-u|0;e=i[n+16>>2]|0,!(!e&&(e=i[n+20>>2]|0,!e));)s=(i[e+4>>2]&-8)-u|0,a=s>>>0>>0,n=e,c=a?e:c,l=a?s:l;if(s=c+u|0,s>>>0>c>>>0){a=i[c+24>>2]|0,t=i[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+20|0,t=i[e>>2]|0,!t&&(e=c+16|0,t=i[e>>2]|0,!t)){n=0;break}for(;;)if(r=t+20|0,n=i[r>>2]|0,n)t=n,e=r;else if(r=t+16|0,n=i[r>>2]|0,n)t=n,e=r;else break;i[e>>2]=0,n=t}else n=i[c+8>>2]|0,i[n+12>>2]=t,i[t+8>>2]=n,n=t;while(0);do if(a|0){if(t=i[c+28>>2]|0,e=27988+(t<<2)|0,(c|0)==(i[e>>2]|0)){if(i[e>>2]=n,!n){i[6922]=o&~(1<>2]|0)==(c|0)?x:a+20|0)>>2]=n,!n)break;i[n+24>>2]=a,t=i[c+16>>2]|0,t|0&&(i[n+16>>2]=t,i[t+24>>2]=n),t=i[c+20>>2]|0,t|0&&(i[n+20>>2]=t,i[t+24>>2]=n)}while(0);return l>>>0<16?(x=l+u|0,i[c+4>>2]=x|3,x=c+x+4|0,i[x>>2]=i[x>>2]|1):(i[c+4>>2]=u|3,i[s+4>>2]=l|1,i[s+l>>2]=l,d|0&&(r=i[6926]|0,t=d>>>3,n=27724+(t<<1<<2)|0,t=1<>2]|0):(i[6921]=t|f,t=n,e=n+8|0),i[e>>2]=r,i[t+12>>2]=r,i[r+8>>2]=t,i[r+12>>2]=n),i[6923]=l,i[6926]=s),x=c+8|0,M=S,x|0}else f=u}else f=u}else f=u}else if(e>>>0<=4294967231)if(e=e+11|0,u=e&-8,r=i[6922]|0,r){a=0-u|0,e>>>=8,e?u>>>0>16777215?l=31:(f=(e+1048320|0)>>>16&8,g=e<>>16&4,g<<=c,l=(g+245760|0)>>>16&2,l=14-(c|f|l)+(g<>>15)|0,l=u>>>(l+7|0)&1|l<<1):l=0,n=i[27988+(l<<2)>>2]|0;a:do if(!n)n=0,e=0,g=61;else for(e=0,c=u<<((l|0)==31?0:25-(l>>>1)|0),o=0;;){if(s=(i[n+4>>2]&-8)-u|0,s>>>0>>0)if(s)e=n,a=s;else{e=n,a=0,g=65;break a}if(g=i[n+20>>2]|0,n=i[n+16+(c>>>31<<2)>>2]|0,o=(g|0)==0|(g|0)==(n|0)?o:g,n)c<<=1;else{n=o,g=61;break}}while(0);if((g|0)==61){if((n|0)==0&(e|0)==0){if(e=2<>>12&16,f>>>=s,o=f>>>5&8,f>>>=o,c=f>>>2&4,f>>>=c,l=f>>>1&2,f>>>=l,n=f>>>1&1,e=0,n=i[27988+((o|s|c|l|n)+(f>>>n)<<2)>>2]|0}n?g=65:(c=e,s=a)}if((g|0)==65)for(o=n;;)if(f=(i[o+4>>2]&-8)-u|0,n=f>>>0>>0,a=n?f:a,e=n?o:e,n=i[o+16>>2]|0,n||=i[o+20>>2]|0,n)o=n;else{c=e,s=a;break}if(c|0&&s>>>0<((i[6923]|0)-u|0)>>>0&&(d=c+u|0,d>>>0>c>>>0)){o=i[c+24>>2]|0,t=i[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+20|0,t=i[e>>2]|0,!t&&(e=c+16|0,t=i[e>>2]|0,!t)){t=0;break}for(;;)if(a=t+20|0,n=i[a>>2]|0,n)t=n,e=a;else if(a=t+16|0,n=i[a>>2]|0,n)t=n,e=a;else break;i[e>>2]=0}else x=i[c+8>>2]|0,i[x+12>>2]=t,i[t+8>>2]=x;while(0);do if(o){if(e=i[c+28>>2]|0,n=27988+(e<<2)|0,(c|0)==(i[n>>2]|0)){if(i[n>>2]=t,!t){r&=~(1<>2]|0)==(c|0)?x:o+20|0)>>2]=t,!t)break;i[t+24>>2]=o,e=i[c+16>>2]|0,e|0&&(i[t+16>>2]=e,i[e+24>>2]=t),e=i[c+20>>2]|0,e&&(i[t+20>>2]=e,i[e+24>>2]=t)}while(0);b:do if(s>>>0<16)x=s+u|0,i[c+4>>2]=x|3,x=c+x+4|0,i[x>>2]=i[x>>2]|1;else{if(i[c+4>>2]=u|3,i[d+4>>2]=s|1,i[d+s>>2]=s,t=s>>>3,s>>>0<256){n=27724+(t<<1<<2)|0,e=i[6921]|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=d,i[t+12>>2]=d,i[d+8>>2]=t,i[d+12>>2]=n;break}if(t=s>>>8,t?s>>>0>16777215?n=31:(b=(t+1048320|0)>>>16&8,x=t<>>16&4,x<<=y,n=(x+245760|0)>>>16&2,n=14-(y|b|n)+(x<>>15)|0,n=s>>>(n+7|0)&1|n<<1):n=0,t=27988+(n<<2)|0,i[d+28>>2]=n,e=d+16|0,i[e+4>>2]=0,i[e>>2]=0,e=1<>2]=d,i[d+24>>2]=t,i[d+12>>2]=d,i[d+8>>2]=d;break}t=i[t>>2]|0;c:do if((i[t+4>>2]&-8|0)!=(s|0)){for(r=s<<((n|0)==31?0:25-(n>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(s|0)){t=e;break c}else r<<=1,t=e;i[n>>2]=d,i[d+24>>2]=t,i[d+12>>2]=d,i[d+8>>2]=d;break b}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=d,i[b>>2]=d,i[d+8>>2]=x,i[d+12>>2]=t,i[d+24>>2]=0}while(0);return x=c+8|0,M=S,x|0}else f=u}else f=u;else f=-1;while(0);if(n=i[6923]|0,n>>>0>=f>>>0)return t=n-f|0,e=i[6926]|0,t>>>0>15?(x=e+f|0,i[6926]=x,i[6923]=t,i[x+4>>2]=t|1,i[e+n>>2]=t,i[e+4>>2]=f|3):(i[6923]=0,i[6926]=0,i[e+4>>2]=n|3,x=e+n+4|0,i[x>>2]=i[x>>2]|1),x=e+8|0,M=S,x|0;if(s=i[6924]|0,s>>>0>f>>>0)return y=s-f|0,i[6924]=y,x=i[6927]|0,b=x+f|0,i[6927]=b,i[b+4>>2]=y|1,i[x+4>>2]=f|3,x=x+8|0,M=S,x|0;if(i[7039]|0?e=i[7041]|0:(i[7041]=4096,i[7040]=4096,i[7042]=-1,i[7043]=-1,i[7044]=0,i[7032]=0,i[7039]=p&-16^1431655768,e=4096),c=f+48|0,l=f+47|0,o=e+l|0,a=0-e|0,u=o&a,u>>>0<=f>>>0||(e=i[7031]|0,e|0&&(d=i[7029]|0,p=d+u|0,p>>>0<=d>>>0|p>>>0>e>>>0)))return x=0,M=S,x|0;d:do if(i[7032]&4)t=0,g=143;else{n=i[6927]|0;e:do if(n){for(r=28132;p=i[r>>2]|0,!(p>>>0<=n>>>0&&(p+(i[r+4>>2]|0)|0)>>>0>n>>>0);)if(e=i[r+8>>2]|0,e)r=e;else{g=128;break e}if(t=o-s&a,t>>>0<2147483647)if(e=Er(t|0)|0,(e|0)==((i[r>>2]|0)+(i[r+4>>2]|0)|0)){if((e|0)!=-1){s=t,o=e,g=145;break d}}else r=e,g=136;else t=0}else g=128;while(0);do if((g|0)==128)if(n=Er(0)|0,(n|0)!=-1&&(t=n,m=i[7040]|0,h=m+-1|0,t=(h&t|0?(h+t&0-m)-t|0:0)+u|0,m=i[7029]|0,h=t+m|0,t>>>0>f>>>0&t>>>0<2147483647)){if(p=i[7031]|0,p|0&&h>>>0<=m>>>0|h>>>0>p>>>0){t=0;break}if(e=Er(t|0)|0,(e|0)==(n|0)){s=t,o=n,g=145;break d}else r=e,g=136}else t=0;while(0);do if((g|0)==136){if(n=0-t|0,!(c>>>0>t>>>0&(t>>>0<2147483647&(r|0)!=-1)))if((r|0)==-1){t=0;break}else{s=t,o=r,g=145;break d}if(e=i[7041]|0,e=l-t+e&0-e,e>>>0>=2147483647){s=t,o=r,g=145;break d}if((Er(e|0)|0)==-1){Er(n|0)|0,t=0;break}else{s=e+t|0,o=r,g=145;break d}}while(0);i[7032]|=4,g=143}while(0);if((g|0)==143&&u>>>0<2147483647&&(y=Er(u|0)|0,h=Er(0)|0,_=h-y|0,v=_>>>0>(f+40|0)>>>0,!((y|0)==-1|v^1|y>>>0>>0&((y|0)!=-1&(h|0)!=-1)^1))&&(s=v?_:t,o=y,g=145),(g|0)==145){t=(i[7029]|0)+s|0,i[7029]=t,t>>>0>(i[7030]|0)>>>0&&(i[7030]=t),l=i[6927]|0;f:do if(l){for(t=28132;;){if(e=i[t>>2]|0,n=i[t+4>>2]|0,(o|0)==(e+n|0)){g=154;break}if(r=i[t+8>>2]|0,r)t=r;else break}if((g|0)==154&&(b=t+4|0,!(i[t+12>>2]&8|0))&&o>>>0>l>>>0&e>>>0<=l>>>0){i[b>>2]=n+s,x=(i[6924]|0)+s|0,y=l+8|0,y=y&7|0?0-y&7:0,b=l+y|0,y=x-y|0,i[6927]=b,i[6924]=y,i[b+4>>2]=y|1,i[l+x+4>>2]=40,i[6928]=i[7043];break}for(o>>>0<(i[6925]|0)>>>0&&(i[6925]=o),n=o+s|0,t=28132;;){if((i[t>>2]|0)==(n|0)){g=162;break}if(e=i[t+8>>2]|0,e)t=e;else break}if((g|0)==162&&!(i[t+12>>2]&8|0)){i[t>>2]=o,d=t+4|0,i[d>>2]=(i[d>>2]|0)+s,d=o+8|0,d=o+(d&7|0?0-d&7:0)|0,t=n+8|0,t=n+(t&7|0?0-t&7:0)|0,u=d+f|0,c=t-d-f|0,i[d+4>>2]=f|3;g:do if((l|0)==(t|0))x=(i[6924]|0)+c|0,i[6924]=x,i[6927]=u,i[u+4>>2]=x|1;else{if((i[6926]|0)==(t|0)){x=(i[6923]|0)+c|0,i[6923]=x,i[6926]=u,i[u+4>>2]=x|1,i[u+x>>2]=x;break}if(e=i[t+4>>2]|0,(e&3|0)==1){s=e&-8,r=e>>>3;h:do if(e>>>0<256)if(e=i[t+8>>2]|0,n=i[t+12>>2]|0,(n|0)==(e|0)){i[6921]&=~(1<>2]=n,i[n+8>>2]=e;break}else{o=i[t+24>>2]|0,e=i[t+12>>2]|0;do if((e|0)==(t|0)){if(n=t+16|0,r=n+4|0,e=i[r>>2]|0,e)n=r;else if(e=i[n>>2]|0,!e){e=0;break}for(;;)if(a=e+20|0,r=i[a>>2]|0,r)e=r,n=a;else if(a=e+16|0,r=i[a>>2]|0,r)e=r,n=a;else break;i[n>>2]=0}else x=i[t+8>>2]|0,i[x+12>>2]=e,i[e+8>>2]=x;while(0);if(!o)break;n=i[t+28>>2]|0,r=27988+(n<<2)|0;do if((i[r>>2]|0)!=(t|0)){if(x=o+16|0,i[((i[x>>2]|0)==(t|0)?x:o+20|0)>>2]=e,!e)break h}else{if(i[r>>2]=e,e|0)break;i[6922]&=~(1<>2]=o,n=t+16|0,r=i[n>>2]|0,r|0&&(i[e+16>>2]=r,i[r+24>>2]=e),n=i[n+4>>2]|0,!n)break;i[e+20>>2]=n,i[n+24>>2]=e}while(0);t=t+s|0,a=s+c|0}else a=c;if(t=t+4|0,i[t>>2]=i[t>>2]&-2,i[u+4>>2]=a|1,i[u+a>>2]=a,t=a>>>3,a>>>0<256){n=27724+(t<<1<<2)|0,e=i[6921]|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=u,i[t+12>>2]=u,i[u+8>>2]=t,i[u+12>>2]=n;break}t=a>>>8;do if(!t)r=0;else{if(a>>>0>16777215){r=31;break}b=(t+1048320|0)>>>16&8,x=t<>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<>>15)|0,r=a>>>(r+7|0)&1|r<<1}while(0);if(t=27988+(r<<2)|0,i[u+28>>2]=r,e=u+16|0,i[e+4>>2]=0,i[e>>2]=0,e=i[6922]|0,n=1<>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break}t=i[t>>2]|0;i:do if((i[t+4>>2]&-8|0)!=(a|0)){for(r=a<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(a|0)){t=e;break i}else r<<=1,t=e;i[n>>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break g}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=u,i[b>>2]=u,i[u+8>>2]=x,i[u+12>>2]=t,i[u+24>>2]=0}while(0);return x=d+8|0,M=S,x|0}for(t=28132;e=i[t>>2]|0,!(e>>>0<=l>>>0&&(x=e+(i[t+4>>2]|0)|0,x>>>0>l>>>0));)t=i[t+8>>2]|0;a=x+-47|0,e=a+8|0,e=a+(e&7|0?0-e&7:0)|0,a=l+16|0,e=e>>>0>>0?l:e,t=e+8|0,n=s+-40|0,y=o+8|0,y=y&7|0?0-y&7:0,b=o+y|0,y=n-y|0,i[6927]=b,i[6924]=y,i[b+4>>2]=y|1,i[o+n+4>>2]=40,i[6928]=i[7043],n=e+4|0,i[n>>2]=27,i[t>>2]=i[7033],i[t+4>>2]=i[7034],i[t+8>>2]=i[7035],i[t+12>>2]=i[7036],i[7033]=o,i[7034]=s,i[7036]=0,i[7035]=t,t=e+24|0;do b=t,t=t+4|0,i[t>>2]=7;while((b+8|0)>>>0>>0);if((e|0)!=(l|0)){if(o=e-l|0,i[n>>2]=i[n>>2]&-2,i[l+4>>2]=o|1,i[e>>2]=o,t=o>>>3,o>>>0<256){n=27724+(t<<1<<2)|0,e=i[6921]|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=l,i[t+12>>2]=l,i[l+8>>2]=t,i[l+12>>2]=n;break}if(t=o>>>8,t?o>>>0>16777215?r=31:(b=(t+1048320|0)>>>16&8,x=t<>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<>>15)|0,r=o>>>(r+7|0)&1|r<<1):r=0,n=27988+(r<<2)|0,i[l+28>>2]=r,i[l+20>>2]=0,i[a>>2]=0,t=i[6922]|0,e=1<>2]=l,i[l+24>>2]=n,i[l+12>>2]=l,i[l+8>>2]=l;break}t=i[n>>2]|0;j:do if((i[t+4>>2]&-8|0)!=(o|0)){for(r=o<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(o|0)){t=e;break j}else r<<=1,t=e;i[n>>2]=l,i[l+24>>2]=t,i[l+12>>2]=l,i[l+8>>2]=l;break f}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=l,i[b>>2]=l,i[l+8>>2]=x,i[l+12>>2]=t,i[l+24>>2]=0}}else x=i[6925]|0,(x|0)==0|o>>>0>>0&&(i[6925]=o),i[7033]=o,i[7034]=s,i[7036]=0,i[6930]=i[7039],i[6929]=-1,i[6934]=27724,i[6933]=27724,i[6936]=27732,i[6935]=27732,i[6938]=27740,i[6937]=27740,i[6940]=27748,i[6939]=27748,i[6942]=27756,i[6941]=27756,i[6944]=27764,i[6943]=27764,i[6946]=27772,i[6945]=27772,i[6948]=27780,i[6947]=27780,i[6950]=27788,i[6949]=27788,i[6952]=27796,i[6951]=27796,i[6954]=27804,i[6953]=27804,i[6956]=27812,i[6955]=27812,i[6958]=27820,i[6957]=27820,i[6960]=27828,i[6959]=27828,i[6962]=27836,i[6961]=27836,i[6964]=27844,i[6963]=27844,i[6966]=27852,i[6965]=27852,i[6968]=27860,i[6967]=27860,i[6970]=27868,i[6969]=27868,i[6972]=27876,i[6971]=27876,i[6974]=27884,i[6973]=27884,i[6976]=27892,i[6975]=27892,i[6978]=27900,i[6977]=27900,i[6980]=27908,i[6979]=27908,i[6982]=27916,i[6981]=27916,i[6984]=27924,i[6983]=27924,i[6986]=27932,i[6985]=27932,i[6988]=27940,i[6987]=27940,i[6990]=27948,i[6989]=27948,i[6992]=27956,i[6991]=27956,i[6994]=27964,i[6993]=27964,i[6996]=27972,i[6995]=27972,x=s+-40|0,y=o+8|0,y=y&7|0?0-y&7:0,b=o+y|0,y=x-y|0,i[6927]=b,i[6924]=y,i[b+4>>2]=y|1,i[o+x+4>>2]=40,i[6928]=i[7043];while(0);if(t=i[6924]|0,t>>>0>f>>>0)return y=t-f|0,i[6924]=y,x=i[6927]|0,b=x+f|0,i[6927]=b,i[b+4>>2]=y|1,i[x+4>>2]=f|3,x=x+8|0,M=S,x|0}return x=Gn()|0,i[x>>2]=12,x=0,M=S,x|0}function nr(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0;if(e){n=e+-8|0,a=i[6925]|0,e=i[e+-4>>2]|0,t=e&-8,l=n+t|0;do if(e&1)c=n,s=n;else{if(r=i[n>>2]|0,!(e&3)||(s=n+(0-r)|0,o=r+t|0,s>>>0>>0))return;if((i[6926]|0)==(s|0)){if(e=l+4|0,t=i[e>>2]|0,(t&3|0)!=3){c=s,t=o;break}i[6923]=o,i[e>>2]=t&-2,i[s+4>>2]=o|1,i[s+o>>2]=o;return}if(n=r>>>3,r>>>0<256)if(e=i[s+8>>2]|0,t=i[s+12>>2]|0,(t|0)==(e|0)){i[6921]&=~(1<>2]=t,i[t+8>>2]=e,c=s,t=o;break}a=i[s+24>>2]|0,e=i[s+12>>2]|0;do if((e|0)==(s|0)){if(t=s+16|0,n=t+4|0,e=i[n>>2]|0,e)t=n;else if(e=i[t>>2]|0,!e){e=0;break}for(;;)if(r=e+20|0,n=i[r>>2]|0,n)e=n,t=r;else if(r=e+16|0,n=i[r>>2]|0,n)e=n,t=r;else break;i[t>>2]=0}else c=i[s+8>>2]|0,i[c+12>>2]=e,i[e+8>>2]=c;while(0);if(a){if(t=i[s+28>>2]|0,n=27988+(t<<2)|0,(i[n>>2]|0)==(s|0)){if(i[n>>2]=e,!e){i[6922]&=~(1<>2]|0)==(s|0)?c:a+20|0)>>2]=e,!e){c=s,t=o;break}i[e+24>>2]=a,t=s+16|0,n=i[t>>2]|0,n|0&&(i[e+16>>2]=n,i[n+24>>2]=e),t=i[t+4>>2]|0,t?(i[e+20>>2]=t,i[t+24>>2]=e,c=s,t=o):(c=s,t=o)}else c=s,t=o}while(0);if(!(s>>>0>=l>>>0)&&(e=l+4|0,r=i[e>>2]|0,r&1)){if(r&2)i[e>>2]=r&-2,i[c+4>>2]=t|1,i[s+t>>2]=t,a=t;else{if((i[6927]|0)==(l|0)){if(l=(i[6924]|0)+t|0,i[6924]=l,i[6927]=c,i[c+4>>2]=l|1,(c|0)!=(i[6926]|0))return;i[6926]=0,i[6923]=0;return}if((i[6926]|0)==(l|0)){l=(i[6923]|0)+t|0,i[6923]=l,i[6926]=s,i[c+4>>2]=l|1,i[s+l>>2]=l;return}a=(r&-8)+t|0,n=r>>>3;do if(r>>>0<256)if(t=i[l+8>>2]|0,e=i[l+12>>2]|0,(e|0)==(t|0)){i[6921]&=~(1<>2]=e,i[e+8>>2]=t;break}else{o=i[l+24>>2]|0,e=i[l+12>>2]|0;do if((e|0)==(l|0)){if(t=l+16|0,n=t+4|0,e=i[n>>2]|0,e)t=n;else if(e=i[t>>2]|0,!e){n=0;break}for(;;)if(r=e+20|0,n=i[r>>2]|0,n)e=n,t=r;else if(r=e+16|0,n=i[r>>2]|0,n)e=n,t=r;else break;i[t>>2]=0,n=e}else n=i[l+8>>2]|0,i[n+12>>2]=e,i[e+8>>2]=n,n=e;while(0);if(o|0){if(e=i[l+28>>2]|0,t=27988+(e<<2)|0,(i[t>>2]|0)==(l|0)){if(i[t>>2]=n,!n){i[6922]&=~(1<>2]|0)==(l|0)?r:o+20|0)>>2]=n,!n)break;i[n+24>>2]=o,e=l+16|0,t=i[e>>2]|0,t|0&&(i[n+16>>2]=t,i[t+24>>2]=n),e=i[e+4>>2]|0,e|0&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);if(i[c+4>>2]=a|1,i[s+a>>2]=a,(c|0)==(i[6926]|0)){i[6923]=a;return}}if(e=a>>>3,a>>>0<256){n=27724+(e<<1<<2)|0,t=i[6921]|0,e=1<>2]|0):(i[6921]=t|e,e=n,t=n+8|0),i[t>>2]=c,i[e+12>>2]=c,i[c+8>>2]=e,i[c+12>>2]=n;return}e=a>>>8,e?a>>>0>16777215?r=31:(s=(e+1048320|0)>>>16&8,l=e<>>16&4,l<<=o,r=(l+245760|0)>>>16&2,r=14-(o|s|r)+(l<>>15)|0,r=a>>>(r+7|0)&1|r<<1):r=0,e=27988+(r<<2)|0,i[c+28>>2]=r,i[c+20>>2]=0,i[c+16>>2]=0,t=i[6922]|0,n=1<>2]=c,i[c+24>>2]=e,i[c+12>>2]=c,i[c+8>>2]=c;else{e=i[e>>2]|0;b:do if((i[e+4>>2]&-8|0)!=(a|0)){for(r=a<<((r|0)==31?0:25-(r>>>1)|0);n=e+16+(r>>>31<<2)|0,t=i[n>>2]|0,t;)if((i[t+4>>2]&-8|0)==(a|0)){e=t;break b}else r<<=1,e=t;i[n>>2]=c,i[c+24>>2]=e,i[c+12>>2]=c,i[c+8>>2]=c;break a}while(0);s=e+8|0,l=i[s>>2]|0,i[l+12>>2]=c,i[s>>2]=c,i[c+8>>2]=l,i[c+12>>2]=e,i[c+24>>2]=0}while(0);if(l=(i[6929]|0)+-1|0,i[6929]=l,!(l|0)){for(e=28140;e=i[e>>2]|0,e;)e=e+8|0;i[6929]=-1}}}}function rr(e,t){e|=0,t|=0;var n=0;return e?(n=y(t,e)|0,(t|e)>>>0>65535&&(n=((n>>>0)/(e>>>0)|0)==(t|0)?n:-1)):n=0,e=tr(n)|0,!e||!(i[e+-4>>2]&3)||wr(e|0,0,n|0)|0,e|0}function ir(e,t){e|=0,t|=0;var n=0,r=0;return e?t>>>0>4294967231?(t=Gn()|0,i[t>>2]=12,t=0,t|0):(n=ar(e+-8|0,t>>>0<11?16:t+11&-8)|0,n|0?(t=n+8|0,t|0):(n=tr(t)|0,n?(r=i[e+-4>>2]|0,r=(r&-8)-(r&3|0?4:8)|0,Sr(n|0,e|0,(r>>>0>>0?r:t)|0)|0,nr(e),t=n,t|0):(t=0,t|0))):(t=tr(t)|0,t|0)}function ar(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;if(d=e+4|0,f=i[d>>2]|0,n=f&-8,c=e+n|0,!(f&3))return t>>>0<256?(e=0,e|0):(n>>>0>=(t+4|0)>>>0&&(n-t|0)>>>0<=i[7041]<<1>>>0||(e=0),e|0);if(n>>>0>=t>>>0)return n=n-t|0,n>>>0<=15?e|0:(u=e+t|0,i[d>>2]=f&1|t|2,i[u+4>>2]=n|3,f=c+4|0,i[f>>2]=i[f>>2]|1,or(u,n),e|0);if((i[6927]|0)==(c|0))return u=(i[6924]|0)+n|0,n=u-t|0,r=e+t|0,u>>>0<=t>>>0?(e=0,e|0):(i[d>>2]=f&1|t|2,i[r+4>>2]=n|1,i[6927]=r,i[6924]=n,e|0);if((i[6926]|0)==(c|0))return r=(i[6923]|0)+n|0,r>>>0>>0?(e=0,e|0):(n=r-t|0,n>>>0>15?(u=e+t|0,r=e+r|0,i[d>>2]=f&1|t|2,i[u+4>>2]=n|1,i[r>>2]=n,r=r+4|0,i[r>>2]=i[r>>2]&-2,r=u):(i[d>>2]=f&1|r|2,r=e+r+4|0,i[r>>2]=i[r>>2]|1,r=0,n=0),i[6923]=n,i[6926]=r,e|0);if(r=i[c+4>>2]|0,r&2|0||(l=(r&-8)+n|0,l>>>0>>0))return e=0,e|0;u=l-t|0,a=r>>>3;do if(r>>>0<256)if(r=i[c+8>>2]|0,n=i[c+12>>2]|0,(n|0)==(r|0)){i[6921]&=~(1<>2]=n,i[n+8>>2]=r;break}else{s=i[c+24>>2]|0,n=i[c+12>>2]|0;do if((n|0)==(c|0)){if(r=c+16|0,a=r+4|0,n=i[a>>2]|0,n)r=a;else if(n=i[r>>2]|0,!n){a=0;break}for(;;)if(o=n+20|0,a=i[o>>2]|0,a)n=a,r=o;else if(o=n+16|0,a=i[o>>2]|0,a)n=a,r=o;else break;i[r>>2]=0,a=n}else a=i[c+8>>2]|0,i[a+12>>2]=n,i[n+8>>2]=a,a=n;while(0);if(s|0){if(n=i[c+28>>2]|0,r=27988+(n<<2)|0,(i[r>>2]|0)==(c|0)){if(i[r>>2]=a,!a){i[6922]&=~(1<>2]|0)==(c|0)?o:s+20|0)>>2]=a,!a)break;i[a+24>>2]=s,n=c+16|0,r=i[n>>2]|0,r|0&&(i[a+16>>2]=r,i[r+24>>2]=a),n=i[n+4>>2]|0,n|0&&(i[a+20>>2]=n,i[n+24>>2]=a)}}while(0);return u>>>0<16?(i[d>>2]=f&1|l|2,f=e+l+4|0,i[f>>2]=i[f>>2]|1,e|0):(c=e+t|0,i[d>>2]=f&1|t|2,i[c+4>>2]=u|3,f=e+l+4|0,i[f>>2]=i[f>>2]|1,or(c,u),e|0)}function or(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0;c=e+t|0,n=i[e+4>>2]|0;do if(n&1)s=e;else{if(a=i[e>>2]|0,!(n&3))return;if(s=e+(0-a)|0,t=a+t|0,(i[6926]|0)==(s|0)){if(e=c+4|0,n=i[e>>2]|0,(n&3|0)!=3)break;i[6923]=t,i[e>>2]=n&-2,i[s+4>>2]=t|1,i[c>>2]=t;return}if(r=a>>>3,a>>>0<256)if(e=i[s+8>>2]|0,n=i[s+12>>2]|0,(n|0)==(e|0)){i[6921]&=~(1<>2]=n,i[n+8>>2]=e;break}o=i[s+24>>2]|0,e=i[s+12>>2]|0;do if((e|0)==(s|0)){if(n=s+16|0,r=n+4|0,e=i[r>>2]|0,e)n=r;else if(e=i[n>>2]|0,!e){e=0;break}for(;;)if(a=e+20|0,r=i[a>>2]|0,r)e=r,n=a;else if(a=e+16|0,r=i[a>>2]|0,r)e=r,n=a;else break;i[n>>2]=0}else a=i[s+8>>2]|0,i[a+12>>2]=e,i[e+8>>2]=a;while(0);if(o){if(n=i[s+28>>2]|0,r=27988+(n<<2)|0,(i[r>>2]|0)==(s|0)){if(i[r>>2]=e,!e){i[6922]&=~(1<>2]|0)==(s|0)?a:o+20|0)>>2]=e,!e)break;i[e+24>>2]=o,n=s+16|0,r=i[n>>2]|0,r|0&&(i[e+16>>2]=r,i[r+24>>2]=e),n=i[n+4>>2]|0,n&&(i[e+20>>2]=n,i[n+24>>2]=e)}}while(0);if(e=c+4|0,r=i[e>>2]|0,r&2)i[e>>2]=r&-2,i[s+4>>2]=t|1,i[s+t>>2]=t,a=t;else{if((i[6927]|0)==(c|0)){if(c=(i[6924]|0)+t|0,i[6924]=c,i[6927]=s,i[s+4>>2]=c|1,(s|0)!=(i[6926]|0))return;i[6926]=0,i[6923]=0;return}if((i[6926]|0)==(c|0)){c=(i[6923]|0)+t|0,i[6923]=c,i[6926]=s,i[s+4>>2]=c|1,i[s+c>>2]=c;return}a=(r&-8)+t|0,n=r>>>3;do if(r>>>0<256)if(e=i[c+8>>2]|0,t=i[c+12>>2]|0,(t|0)==(e|0)){i[6921]&=~(1<>2]=t,i[t+8>>2]=e;break}else{o=i[c+24>>2]|0,t=i[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+16|0,n=e+4|0,t=i[n>>2]|0,t)e=n;else if(t=i[e>>2]|0,!t){n=0;break}for(;;)if(r=t+20|0,n=i[r>>2]|0,n)t=n,e=r;else if(r=t+16|0,n=i[r>>2]|0,n)t=n,e=r;else break;i[e>>2]=0,n=t}else n=i[c+8>>2]|0,i[n+12>>2]=t,i[t+8>>2]=n,n=t;while(0);if(o|0){if(t=i[c+28>>2]|0,e=27988+(t<<2)|0,(i[e>>2]|0)==(c|0)){if(i[e>>2]=n,!n){i[6922]&=~(1<>2]|0)==(c|0)?r:o+20|0)>>2]=n,!n)break;i[n+24>>2]=o,t=c+16|0,e=i[t>>2]|0,e|0&&(i[n+16>>2]=e,i[e+24>>2]=n),t=i[t+4>>2]|0,t|0&&(i[n+20>>2]=t,i[t+24>>2]=n)}}while(0);if(i[s+4>>2]=a|1,i[s+a>>2]=a,(s|0)==(i[6926]|0)){i[6923]=a;return}}if(t=a>>>3,a>>>0<256){n=27724+(t<<1<<2)|0,e=i[6921]|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=s,i[t+12>>2]=s,i[s+8>>2]=t,i[s+12>>2]=n;return}if(t=a>>>8,t?a>>>0>16777215?r=31:(o=(t+1048320|0)>>>16&8,c=t<>>16&4,c<<=n,r=(c+245760|0)>>>16&2,r=14-(n|o|r)+(c<>>15)|0,r=a>>>(r+7|0)&1|r<<1):r=0,t=27988+(r<<2)|0,i[s+28>>2]=r,i[s+20>>2]=0,i[s+16>>2]=0,e=i[6922]|0,n=1<>2]=s,i[s+24>>2]=t,i[s+12>>2]=s,i[s+8>>2]=s;return}t=i[t>>2]|0;a:do if((i[t+4>>2]&-8|0)!=(a|0)){for(r=a<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(a|0)){t=e;break a}else r<<=1,t=e;i[n>>2]=s,i[s+24>>2]=t,i[s+12>>2]=s,i[s+8>>2]=s;return}while(0);o=t+8|0,c=i[o>>2]|0,i[c+12>>2]=s,i[o>>2]=s,i[s+8>>2]=c,i[s+12>>2]=t,i[s+24>>2]=0}function sr(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,n=e+n>>>0,(w(t+r+(n>>>0>>0|0)>>>0|0),n|0)|0}function cr(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,r=t-r-(n>>>0>e>>>0|0)>>>0,(w(r|0),e-n>>>0|0)|0}function lr(e){return e|=0,(e?31-(S(e^e-1)|0)|0:32)|0}function ur(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(d=e,l=t,u=l,s=n,p=r,c=p,!u)return o=(a|0)!=0,c?o?(i[a>>2]=e|0,i[a+4>>2]=t&0,p=0,a=0,(w(p|0),a)|0):(p=0,a=0,(w(p|0),a)|0):(o&&(i[a>>2]=(d>>>0)%(s>>>0),i[a+4>>2]=0),p=0,a=(d>>>0)/(s>>>0)>>>0,(w(p|0),a)|0);o=(c|0)==0;do if(s){if(!o){if(o=(S(c|0)|0)-(S(u|0)|0)|0,o>>>0<=31){f=o+1|0,c=31-o|0,t=o-31>>31,s=f,e=d>>>(f>>>0)&t|u<>>(f>>>0)&t,o=0,c=d<>2]=e|0,i[a+4>>2]=l|t&0,p=0,a=0,(w(p|0),a)|0):(p=0,a=0,(w(p|0),a)|0)}if(o=s-1|0,o&s|0){c=(S(s|0)|0)+33-(S(u|0)|0)|0,h=64-c|0,f=32-c|0,l=f>>31,m=c-32|0,t=m>>31,s=c,e=f-1>>31&u>>>(m>>>0)|(u<>>(c>>>0))&t,t&=u>>>(c>>>0),o=d<>>(m>>>0))&l|d<>31;break}return a|0&&(i[a>>2]=o&d,i[a+4>>2]=0),(s|0)==1?(m=l|t&0,h=e|0,(w(m|0),h)|0):(h=lr(s|0)|0,m=u>>>(h>>>0)|0,h=u<<32-h|d>>>(h>>>0)|0,(w(m|0),h)|0)}else{if(o)return a|0&&(i[a>>2]=(u>>>0)%(s>>>0),i[a+4>>2]=0),m=0,h=(u>>>0)/(s>>>0)>>>0,(w(m|0),h)|0;if(!d)return a|0&&(i[a>>2]=0,i[a+4>>2]=(u>>>0)%(c>>>0)),m=0,h=(u>>>0)/(c>>>0)>>>0,(w(m|0),h)|0;if(o=c-1|0,!(o&c))return a|0&&(i[a>>2]=e|0,i[a+4>>2]=o&u|t&0),m=0,h=u>>>((lr(c|0)|0)>>>0),(w(m|0),h)|0;if(o=(S(c|0)|0)-(S(u|0)|0)|0,o>>>0<=30){t=o+1|0,c=31-o|0,s=t,e=u<>>(t>>>0),t=u>>>(t>>>0),o=0,c=d<>2]=e|0,i[a+4>>2]=l|t&0,m=0,h=0,(w(m|0),h)|0):(m=0,h=0,(w(m|0),h)|0)}while(0);if(!s)u=c,l=0,c=0;else{f=n|0,d=p|r&0,u=sr(f|0,d|0,-1,-1)|0,n=T()|0,l=c,c=0;do r=l,l=o>>>31|l<<1,o=c|o<<1,r=e<<1|r>>>31|0,p=e>>>31|t<<1|0,cr(u|0,n|0,r|0,p|0)|0,h=T()|0,m=h>>31|((h|0)<0?-1:0)<<1,c=m&1,e=cr(r|0,p|0,m&f|0,(((h|0)<0?-1:0)>>31|((h|0)<0?-1:0)<<1)&d|0)|0,t=T()|0,s=s-1|0;while(s|0);u=l,l=0}return s=0,a|0&&(i[a>>2]=e,i[a+4>>2]=t),m=(o|0)>>>31|(u|s)<<1|(s<<1|o>>>31)&0|l,h=(o<<1|0)&-2|c,(w(m|0),h)|0}function dr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0,o=0,s=0,c=0,l=0;return l=t>>31|((t|0)<0?-1:0)<<1,c=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1,a=r>>31|((r|0)<0?-1:0)<<1,i=((r|0)<0?-1:0)>>31|((r|0)<0?-1:0)<<1,s=cr(l^e|0,c^t|0,l|0,c|0)|0,o=T()|0,e=a^l,t=i^c,cr((ur(s,o,cr(a^n|0,i^r|0,a|0,i|0)|0,T()|0,0)|0)^e|0,(T()|0)^t|0,e|0,t|0)|0}function fr(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0;return a=e&65535,i=t&65535,n=y(i,a)|0,r=e>>>16,e=(n>>>16)+(y(i,r)|0)|0,i=t>>>16,t=y(i,a)|0,(w((e>>>16)+(y(i,r)|0)+(((e&65535)+t|0)>>>16)|0),e+t<<16|n&65535|0)|0}function pr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0;return i=e,a=n,n=fr(i,a)|0,e=T()|0,(w((y(t,a)|0)+(y(r,i)|0)+e|e&0|0),n|0)|0}function mr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;return a=M,M=M+16|0,c=a|0,s=t>>31|((t|0)<0?-1:0)<<1,o=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1,u=r>>31|((r|0)<0?-1:0)<<1,l=((r|0)<0?-1:0)>>31|((r|0)<0?-1:0)<<1,e=cr(s^e|0,o^t|0,s|0,o|0)|0,t=T()|0,ur(e,t,cr(u^n|0,l^r|0,u|0,l|0)|0,T()|0,c)|0,r=cr(i[c>>2]^s|0,i[c+4>>2]^o|0,s|0,o|0)|0,n=T()|0,M=a,(w(n|0),r)|0}function hr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;return o=M,M=M+16|0,a=o|0,ur(e,t,n,r,a)|0,M=o,(w(i[a+4>>2]|0),i[a>>2]|0)|0}function gr(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t>>n|0),e>>>n|(t&(1<>n-32|0)}function H(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t>>>n|0),e>>>n|(t&(1<>>n-32|0)}function _r(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t<>>32-n|0),e<=0?+c(e+.5):+v(e-.5)}function Sr(e,t,n){e|=0,t|=0,n|=0;var a=0,o=0,s=0;if((n|0)>=8192)return k(e|0,t|0,n|0)|0,e|0;if(s=e|0,o=e+n|0,(e&3)==(t&3)){for(;e&3;){if(!n)return s|0;r[e>>0]=r[t>>0]|0,e=e+1|0,t=t+1|0,n=n-1|0}for(n=o&-4|0,a=n-64|0;(e|0)<=(a|0);)i[e>>2]=i[t>>2],i[e+4>>2]=i[t+4>>2],i[e+8>>2]=i[t+8>>2],i[e+12>>2]=i[t+12>>2],i[e+16>>2]=i[t+16>>2],i[e+20>>2]=i[t+20>>2],i[e+24>>2]=i[t+24>>2],i[e+28>>2]=i[t+28>>2],i[e+32>>2]=i[t+32>>2],i[e+36>>2]=i[t+36>>2],i[e+40>>2]=i[t+40>>2],i[e+44>>2]=i[t+44>>2],i[e+48>>2]=i[t+48>>2],i[e+52>>2]=i[t+52>>2],i[e+56>>2]=i[t+56>>2],i[e+60>>2]=i[t+60>>2],e=e+64|0,t=t+64|0;for(;(e|0)<(n|0);)i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}else for(n=o-4|0;(e|0)<(n|0);)r[e>>0]=r[t>>0]|0,r[e+1>>0]=r[t+1>>0]|0,r[e+2>>0]=r[t+2>>0]|0,r[e+3>>0]=r[t+3>>0]|0,e=e+4|0,t=t+4|0;for(;(e|0)<(o|0);)r[e>>0]=r[t>>0]|0,e=e+1|0,t=t+1|0;return s|0}function Cr(e,t,n){e|=0,t|=0,n|=0;var i=0;if((t|0)<(e|0)&(e|0)<(t+n|0)){for(i=e,t=t+n|0,e=e+n|0;(n|0)>0;)e=e-1|0,t=t-1|0,n=n-1|0,r[e>>0]=r[t>>0]|0;e=i}else Sr(e,t,n)|0;return e|0}function wr(e,t,n){e|=0,t|=0,n|=0;var a=0,o=0,s=0,c=0;if(s=e+n|0,t&=255,(n|0)>=67){for(;e&3;)r[e>>0]=t,e=e+1|0;for(a=s&-4|0,c=t|t<<8|t<<16|t<<24,o=a-64|0;(e|0)<=(o|0);)i[e>>2]=c,i[e+4>>2]=c,i[e+8>>2]=c,i[e+12>>2]=c,i[e+16>>2]=c,i[e+20>>2]=c,i[e+24>>2]=c,i[e+28>>2]=c,i[e+32>>2]=c,i[e+36>>2]=c,i[e+40>>2]=c,i[e+44>>2]=c,i[e+48>>2]=c,i[e+52>>2]=c,i[e+56>>2]=c,i[e+60>>2]=c,e=e+64|0;for(;(e|0)<(a|0);)i[e>>2]=c,e=e+4|0}for(;(e|0)<(s|0);)r[e>>0]=t,e=e+1|0;return s-n|0}function Tr(e){return e=+e,e>=0?+c(e+.5):+v(e-.5)}function Er(e){e|=0;var t=0,n=0,r=0;return r=O()|0,n=i[s>>2]|0,t=n+e|0,(e|0)>0&(t|0)<(n|0)|(t|0)<0?(j(t|0)|0,D(12),-1):(t|0)>(r|0)&&!(A(t|0)|0)?(D(12),-1):(i[s>>2]=t,n|0)}function Dr(e,t,n){return e|=0,t|=0,n|=0,kr[e&3](t|0,n|0)|0}function Or(e,t){return e|=0,t|=0,C(0),0}var kr=[Or,L,Ue,We];return{___divdi3:dr,___muldi3:pr,___remdi3:mr,___uremdi3:hr,_areNeighborCells:Ge,_bitshift64Ashr:gr,_bitshift64Lshr:H,_bitshift64Shl:_r,_calloc:rr,_cellAreaKm2:ve,_cellAreaM2:ye,_cellAreaRads2:_e,_cellToBoundary:Lt,_cellToCenterChild:xt,_cellToChildPos:Ht,_cellToChildren:yt,_cellToChildrenSize:_t,_cellToLatLng:It,_cellToLocalIj:ln,_cellToParent:gt,_cellToVertex:Vn,_cellToVertexes:Hn,_cellsToDirectedEdge:Ke,_cellsToLinkedMultiPolygon:he,_childPosToCell:Ut,_compactCells:St,_constructCell:ft,_destroyLinkedMultiPolygon:R,_directedEdgeToBoundary:Qe,_directedEdgeToCells:Xe,_edgeLengthKm:an,_edgeLengthM:on,_edgeLengthRads:rn,_emscripten_replace_memory:N,_free:nr,_getBaseCellNumber:ut,_getDirectedEdgeDestination:Je,_getDirectedEdgeOrigin:qe,_getHexagonAreaAvgKm2:Qt,_getHexagonAreaAvgM2:$t,_getHexagonEdgeLengthAvgKm:en,_getHexagonEdgeLengthAvgM:tn,_getIcosahedronFaces:zt,_getIndexDigit:dt,_getNumCells:nn,_getPentagons:Vt,_getRes0Cells:ke,_getResolution:lt,_greatCircleDistanceKm:Xt,_greatCircleDistanceM:Zt,_greatCircleDistanceRads:Yt,_gridDisk:re,_gridDiskDistances:ie,_gridDistance:dn,_gridPathCells:pn,_gridPathCellsSize:fn,_gridRing:ce,_gridRingUnsafe:le,_i64Add:sr,_i64Subtract:cr,_isPentagon:vt,_isResClassIII:Tt,_isValidCell:pt,_isValidDirectedEdge:Ye,_isValidIndex:mt,_isValidVertex:Wn,_latLngToCell:Nt,_llvm_ctlz_i64:vr,_llvm_maxnum_f64:yr,_llvm_minnum_f64:br,_llvm_round_f64:xr,_localIjToCell:un,_malloc:tr,_maxFaceCount:Rt,_maxGridDiskSize:ne,_maxPolygonToCellsSize:fe,_maxPolygonToCellsSizeExperimental:xn,_memcpy:Sr,_memmove:Cr,_memset:wr,_originToDirectedEdges:Ze,_pentagonCount:Bt,_polygonToCells:me,_polygonToCellsExperimental:bn,_readInt64AsDoubleFromPointer:Ln,_res0CellCount:Oe,_reverseDirectedEdge:$e,_round:Tr,_sbrk:Er,_sizeOfCellBoundary:Mn,_sizeOfCoordIJ:In,_sizeOfGeoLoop:Nn,_sizeOfGeoPolygon:Pn,_sizeOfH3Index:An,_sizeOfLatLng:jn,_sizeOfLinkedGeoPolygon:Fn,_uncompactCells:Ct,_uncompactCellsSize:wt,_vertexToLatLng:Un,dynCall_iii:Dr,establishStackSpace:te,stackAlloc:P,stackRestore:F,stackSave:ee}})({Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},{a:Qe,b:d,c:f,d:Me,e:Fe,f:Ne,g:Pe,h:Re,i:Ie,j:Oe,k:ke,l:Le,m:Ae,n:je,o:De,p:te},O);t.___divdi3=L.___divdi3,t.___muldi3=L.___muldi3,t.___remdi3=L.___remdi3,t.___uremdi3=L.___uremdi3,t._areNeighborCells=L._areNeighborCells,t._bitshift64Ashr=L._bitshift64Ashr,t._bitshift64Lshr=L._bitshift64Lshr,t._bitshift64Shl=L._bitshift64Shl,t._calloc=L._calloc,t._cellAreaKm2=L._cellAreaKm2,t._cellAreaM2=L._cellAreaM2,t._cellAreaRads2=L._cellAreaRads2,t._cellToBoundary=L._cellToBoundary,t._cellToCenterChild=L._cellToCenterChild,t._cellToChildPos=L._cellToChildPos,t._cellToChildren=L._cellToChildren,t._cellToChildrenSize=L._cellToChildrenSize,t._cellToLatLng=L._cellToLatLng,t._cellToLocalIj=L._cellToLocalIj,t._cellToParent=L._cellToParent,t._cellToVertex=L._cellToVertex,t._cellToVertexes=L._cellToVertexes,t._cellsToDirectedEdge=L._cellsToDirectedEdge,t._cellsToLinkedMultiPolygon=L._cellsToLinkedMultiPolygon,t._childPosToCell=L._childPosToCell,t._compactCells=L._compactCells,t._constructCell=L._constructCell,t._destroyLinkedMultiPolygon=L._destroyLinkedMultiPolygon,t._directedEdgeToBoundary=L._directedEdgeToBoundary,t._directedEdgeToCells=L._directedEdgeToCells,t._edgeLengthKm=L._edgeLengthKm,t._edgeLengthM=L._edgeLengthM,t._edgeLengthRads=L._edgeLengthRads;var He=t._emscripten_replace_memory=L._emscripten_replace_memory;t._free=L._free,t._getBaseCellNumber=L._getBaseCellNumber,t._getDirectedEdgeDestination=L._getDirectedEdgeDestination,t._getDirectedEdgeOrigin=L._getDirectedEdgeOrigin,t._getHexagonAreaAvgKm2=L._getHexagonAreaAvgKm2,t._getHexagonAreaAvgM2=L._getHexagonAreaAvgM2,t._getHexagonEdgeLengthAvgKm=L._getHexagonEdgeLengthAvgKm,t._getHexagonEdgeLengthAvgM=L._getHexagonEdgeLengthAvgM,t._getIcosahedronFaces=L._getIcosahedronFaces,t._getIndexDigit=L._getIndexDigit,t._getNumCells=L._getNumCells,t._getPentagons=L._getPentagons,t._getRes0Cells=L._getRes0Cells,t._getResolution=L._getResolution,t._greatCircleDistanceKm=L._greatCircleDistanceKm,t._greatCircleDistanceM=L._greatCircleDistanceM,t._greatCircleDistanceRads=L._greatCircleDistanceRads,t._gridDisk=L._gridDisk,t._gridDiskDistances=L._gridDiskDistances,t._gridDistance=L._gridDistance,t._gridPathCells=L._gridPathCells,t._gridPathCellsSize=L._gridPathCellsSize,t._gridRing=L._gridRing,t._gridRingUnsafe=L._gridRingUnsafe,t._i64Add=L._i64Add,t._i64Subtract=L._i64Subtract,t._isPentagon=L._isPentagon,t._isResClassIII=L._isResClassIII,t._isValidCell=L._isValidCell,t._isValidDirectedEdge=L._isValidDirectedEdge,t._isValidIndex=L._isValidIndex,t._isValidVertex=L._isValidVertex,t._latLngToCell=L._latLngToCell,t._llvm_ctlz_i64=L._llvm_ctlz_i64,t._llvm_maxnum_f64=L._llvm_maxnum_f64,t._llvm_minnum_f64=L._llvm_minnum_f64,t._llvm_round_f64=L._llvm_round_f64,t._localIjToCell=L._localIjToCell,t._malloc=L._malloc,t._maxFaceCount=L._maxFaceCount,t._maxGridDiskSize=L._maxGridDiskSize,t._maxPolygonToCellsSize=L._maxPolygonToCellsSize,t._maxPolygonToCellsSizeExperimental=L._maxPolygonToCellsSizeExperimental,t._memcpy=L._memcpy,t._memmove=L._memmove,t._memset=L._memset,t._originToDirectedEdges=L._originToDirectedEdges,t._pentagonCount=L._pentagonCount,t._polygonToCells=L._polygonToCells,t._polygonToCellsExperimental=L._polygonToCellsExperimental,t._readInt64AsDoubleFromPointer=L._readInt64AsDoubleFromPointer,t._res0CellCount=L._res0CellCount,t._reverseDirectedEdge=L._reverseDirectedEdge,t._round=L._round,t._sbrk=L._sbrk,t._sizeOfCellBoundary=L._sizeOfCellBoundary,t._sizeOfCoordIJ=L._sizeOfCoordIJ,t._sizeOfGeoLoop=L._sizeOfGeoLoop,t._sizeOfGeoPolygon=L._sizeOfGeoPolygon,t._sizeOfH3Index=L._sizeOfH3Index,t._sizeOfLatLng=L._sizeOfLatLng,t._sizeOfLinkedGeoPolygon=L._sizeOfLinkedGeoPolygon,t._uncompactCells=L._uncompactCells,t._uncompactCellsSize=L._uncompactCellsSize,t._vertexToLatLng=L._vertexToLatLng,t.establishStackSpace=L.establishStackSpace;var Ue=t.stackAlloc=L.stackAlloc,We=t.stackRestore=L.stackRestore,Ge=t.stackSave=L.stackSave;if(t.dynCall_iii=L.dynCall_iii,t.asm=L,t.cwrap=b,t.setValue=m,t.getValue=h,I){we(I)||(I=o(I)),xe(`memory initializer`);var Ke=function(e){e.byteLength&&(e=new Uint8Array(e)),A.set(e,p),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,Se(`memory initializer`)},qe=function(){s(I,Ke,function(){throw`could not load memory initializer `+I})},Je=Ve(I);if(Je)Ke(Je.buffer);else if(t.memoryInitializerRequest){var Ye=function(){var e=t.memoryInitializerRequest,n=e.response;if(e.status!==200&&e.status!==0){var r=Ve(t.memoryInitializerRequestURL);if(r)n=r.buffer;else{console.warn(`a problem seems to have happened with Module.memoryInitializerRequest, status: `+e.status+`, retrying `+I),qe();return}}Ke(n)};t.memoryInitializerRequest.response?setTimeout(Ye,0):t.memoryInitializerRequest.addEventListener(`load`,Ye)}else qe()}var Xe;be=function e(){Xe||Ze(),Xe||(be=e)};function Ze(e){if(e||=i,ve>0||(ce(),ve>0))return;function n(){Xe||(Xe=!0,!g&&(le(),ue(),t.onRuntimeInitialized&&t.onRuntimeInitialized(),de()))}t.setStatus?(t.setStatus(`Running...`),setTimeout(function(){setTimeout(function(){t.setStatus(``)},1),n()},1)):n()}t.run=Ze;function Qe(e){throw t.onAbort&&t.onAbort(e),e+=``,c(e),l(e),g=!0,`abort(`+e+`). Build with -s ASSERTIONS=1 for more info.`}if(t.abort=Qe,t.preInit)for(typeof t.preInit==`function`&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Ze(),e}(typeof UT==`object`?UT:{}),WT=`number`,GT=WT,KT=WT,qT=WT,JT=WT,YT=WT,XT=WT,ZT=[[`sizeOfH3Index`,WT],[`sizeOfLatLng`,WT],[`sizeOfCellBoundary`,WT],[`sizeOfGeoLoop`,WT],[`sizeOfGeoPolygon`,WT],[`sizeOfLinkedGeoPolygon`,WT],[`sizeOfCoordIJ`,WT],[`readInt64AsDoubleFromPointer`,WT],[`isValidCell`,KT,[qT,JT]],[`isValidIndex`,KT,[qT,JT]],[`latLngToCell`,GT,[WT,WT,YT,XT]],[`cellToLatLng`,GT,[qT,JT,XT]],[`cellToBoundary`,GT,[qT,JT,XT]],[`maxGridDiskSize`,GT,[WT,XT]],[`gridDisk`,GT,[qT,JT,WT,XT]],[`gridDiskDistances`,GT,[qT,JT,WT,XT,XT]],[`gridRing`,GT,[qT,JT,WT,XT]],[`gridRingUnsafe`,GT,[qT,JT,WT,XT]],[`maxPolygonToCellsSize`,GT,[XT,YT,WT,XT]],[`polygonToCells`,GT,[XT,YT,WT,XT]],[`maxPolygonToCellsSizeExperimental`,GT,[XT,YT,WT,XT]],[`polygonToCellsExperimental`,GT,[XT,YT,WT,WT,WT,XT]],[`cellsToLinkedMultiPolygon`,GT,[XT,WT,XT]],[`destroyLinkedMultiPolygon`,null,[XT]],[`compactCells`,GT,[XT,XT,WT,WT]],[`uncompactCells`,GT,[XT,WT,WT,XT,WT,YT]],[`uncompactCellsSize`,GT,[XT,WT,WT,YT,XT]],[`isPentagon`,KT,[qT,JT]],[`isResClassIII`,KT,[qT,JT]],[`getBaseCellNumber`,WT,[qT,JT]],[`getResolution`,WT,[qT,JT]],[`getIndexDigit`,WT,[qT,JT,WT]],[`constructCell`,GT,[WT,WT,XT,XT]],[`maxFaceCount`,GT,[qT,JT,XT]],[`getIcosahedronFaces`,GT,[qT,JT,XT]],[`cellToParent`,GT,[qT,JT,YT,XT]],[`cellToChildren`,GT,[qT,JT,YT,XT]],[`cellToCenterChild`,GT,[qT,JT,YT,XT]],[`cellToChildrenSize`,GT,[qT,JT,YT,XT]],[`cellToChildPos`,GT,[qT,JT,YT,XT]],[`childPosToCell`,GT,[WT,WT,qT,JT,YT,XT]],[`areNeighborCells`,GT,[qT,JT,qT,JT,XT]],[`cellsToDirectedEdge`,GT,[qT,JT,qT,JT,XT]],[`getDirectedEdgeOrigin`,GT,[qT,JT,XT]],[`getDirectedEdgeDestination`,GT,[qT,JT,XT]],[`isValidDirectedEdge`,KT,[qT,JT]],[`directedEdgeToCells`,GT,[qT,JT,XT]],[`originToDirectedEdges`,GT,[qT,JT,XT]],[`directedEdgeToBoundary`,GT,[qT,JT,XT]],[`reverseDirectedEdge`,GT,[qT,JT,XT]],[`gridDistance`,GT,[qT,JT,qT,JT,XT]],[`gridPathCells`,GT,[qT,JT,qT,JT,XT]],[`gridPathCellsSize`,GT,[qT,JT,qT,JT,XT]],[`cellToLocalIj`,GT,[qT,JT,qT,JT,WT,XT]],[`localIjToCell`,GT,[qT,JT,XT,WT,XT]],[`getHexagonAreaAvgM2`,GT,[YT,XT]],[`getHexagonAreaAvgKm2`,GT,[YT,XT]],[`getHexagonEdgeLengthAvgM`,GT,[YT,XT]],[`getHexagonEdgeLengthAvgKm`,GT,[YT,XT]],[`greatCircleDistanceM`,WT,[XT,XT]],[`greatCircleDistanceKm`,WT,[XT,XT]],[`greatCircleDistanceRads`,WT,[XT,XT]],[`cellAreaM2`,GT,[qT,JT,XT]],[`cellAreaKm2`,GT,[qT,JT,XT]],[`cellAreaRads2`,GT,[qT,JT,XT]],[`edgeLengthM`,GT,[qT,JT,XT]],[`edgeLengthKm`,GT,[qT,JT,XT]],[`edgeLengthRads`,GT,[qT,JT,XT]],[`getNumCells`,GT,[YT,XT]],[`getRes0Cells`,GT,[XT]],[`res0CellCount`,WT],[`getPentagons`,GT,[WT,XT]],[`pentagonCount`,WT],[`cellToVertex`,GT,[qT,JT,WT,XT]],[`cellToVertexes`,GT,[qT,JT,XT]],[`vertexToLatLng`,GT,[qT,JT,XT]],[`isValidVertex`,KT,[qT,JT]]],QT=0,$T=1,eE=2,tE=3,nE=4,rE=5,iE=6,aE=7,oE=8,sE=9,cE=10,lE=11,uE=12,dE=13,fE=14,pE=15,mE=16,hE=17,gE=18,Bee=19,_E={};_E[QT]=`Success`,_E[$T]=`The operation failed but a more specific error is not available`,_E[eE]=`Argument was outside of acceptable range`,_E[tE]=`Latitude or longitude arguments were outside of acceptable range`,_E[nE]=`Resolution argument was outside of acceptable range`,_E[rE]=`Cell argument was not valid`,_E[iE]=`Directed edge argument was not valid`,_E[aE]=`Undirected edge argument was not valid`,_E[oE]=`Vertex argument was not valid`,_E[sE]=`Pentagon distortion was encountered`,_E[cE]=`Duplicate input`,_E[lE]=`Cell arguments were not neighbors`,_E[uE]=`Cell arguments had incompatible resolutions`,_E[dE]=`Memory allocation failed`,_E[fE]=`Bounds of provided memory were insufficient`,_E[pE]=`Mode or flags argument was not valid`,_E[mE]=`Index argument was not valid`,_E[hE]=`Base cell number was outside of acceptable range`,_E[gE]=`Child indexing digits invalid`,_E[Bee]=`Child indexing digits refer to a deleted subsequence`;var vE=1e3,yE=1001,bE=1002,xE={};xE[vE]=`Unknown unit`,xE[yE]=`Array length out of bounds`,xE[bE]=`Got unexpected null value for H3 index`;var SE=`Unknown error`;function CE(e,t,n){var r=n&&`value`in n,i=Error((e[t]||SE)+` (code: `+t+(r?`, value: `+n.value:``)+`)`);return i.code=t,i}function wE(e,t){return CE(_E,e,arguments.length===2?{value:t}:{})}function TE(e,t){return CE(xE,e,arguments.length===2?{value:t}:{})}function EE(e){if(e!==0)throw wE(e)}var DE={};ZT.forEach(function(e){DE[e[0]]=UT.cwrap.apply(UT,e)});var OE=16,kE=4,AE=8,jE=8,ME=DE.sizeOfH3Index(),NE=DE.sizeOfLatLng(),PE=DE.sizeOfCellBoundary(),FE=DE.sizeOfGeoPolygon(),IE=DE.sizeOfGeoLoop();DE.sizeOfLinkedGeoPolygon(),DE.sizeOfCoordIJ();function LE(e){if(typeof e!=`number`||e<0||e>15||Math.floor(e)!==e)throw wE(nE,e);return e}function RE(e){if(!e)throw TE(bE);return e}var zE=2**32-1;function BE(e){if(e>zE)throw TE(yE,e);return e}var VE=/[^0-9a-fA-F]/;function HE(e){if(Array.isArray(e)&&e.length===2&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if(typeof e!=`string`||VE.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),OE);return[parseInt(e.substring(e.length-8),OE),t]}function UE(e){if(e>=0)return e.toString(OE);e&=2147483647;var t=GE(8,e.toString(OE));return t=(parseInt(t[0],OE)+8).toString(OE)+t.substring(1),t}function WE(e,t){return UE(t)+GE(8,UE(e))}function GE(e,t){for(var n=e-t.length,r=``,i=0;i0){s=UT._calloc(n,IE);for(var c=0;c0){for(var o=UT.getValue(e+r,`i32`),s=0;s0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}let{environmentIntensity:i,environmentRotation:a}=e.scene;t.environmentIntensity=i,t.environmentRotation=a.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=fD.get(e);return t===void 0&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},fD.set(e,t)),t}getMaterialData(e){let t=dD.get(e);if(t===void 0){t={_renderId:-1,_equal:!1};for(let n of this.refreshUniforms){let r=e[n];r!=null&&(typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:0}:t[n]=r.clone():t[n]=r)}dD.set(e,t)}return t}equals(e,t,n){let{object:r,material:i,geometry:a}=e,o=this.getRenderObjectData(e);if(o.worldMatrix.equals(r.matrixWorld)!==!0)return o.worldMatrix.copy(r.matrixWorld),!1;let s=this.getMaterialData(e.material);if(s._renderId!==n){s._renderId=n;for(let e in s){let t=s[e],n=i[e];if(e!==`_renderId`&&e!==`_equal`){if(t.equals!==void 0){if(t.equals(n)===!1)return t.copy(n),s._equal=!1,!1}else if(n.isTexture===!0){if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,s._equal=!1,!1}else if(t!==n)return s[e]=n,s._equal=!1,!1}}if(s.transmission>0){let{width:t,height:n}=e.context;if(o.bufferWidth!==t||o.bufferHeight!==n)return o.bufferWidth=t,o.bufferHeight=n,s._equal=!1,!1}s._equal=!0}else if(s._equal===!1)return!1;if(o.geometryId!==a.id)return o.geometryId=a.id,!1;let c=this.getGeometryData(e.geometry);if(c._renderId!==n){c._renderId=n;let e=a.attributes,t=c.attributes,r=0,i=0;for(let t in e)r++;for(let n in t){i++;let r=t[n],a=e[n];if(a===void 0)return delete t[n],c._equal=!1,!1;let o=a.isInterleavedBufferAttribute?a.data.uuid:a.id,s=a.isInterleavedBufferAttribute?a.data.version:a.version;if(r.id!==o||r.version!==s)return r.id=o,r.version=s,c._equal=!1,!1}if(i!==r)return c.attributes=this.getAttributesData(e),c._equal=!1,!1;let o=a.index,s=c.indexId,l=c.indexVersion,u=o?o.id:null,d=o?o.version:null;if(s!==u||l!==d)return c.indexId=u,c.indexVersion=d,c._equal=!1,!1;if(c.drawRange.start!==a.drawRange.start||c.drawRange.count!==a.drawRange.count)return c.drawRange.start=a.drawRange.start,c.drawRange.count=a.drawRange.count,c._equal=!1,!1;c._equal=!0}else if(c._equal===!1)return!1;if(o.morphTargetInfluences){let e=!1;for(let t=0;t{let n=e.match(t);if(!n)return null;let r=n[1]||n[2]||``,i=n[3].split(`?`)[0],a=parseInt(n[4],10),o=parseInt(n[5],10);return{fn:r,file:i.split(`/`).pop(),line:a,column:o}}).filter(e=>e&&!mD.some(t=>t.test(e.file)))}var gD=class{constructor(e=null){this.isStackTrace=!0,this.stack=hD(e||Error().stack)}getLocation(){if(this.stack.length===0)return`[Unknown location]`;let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:``}"${e.file}:${e.line}"`}getError(e){return this.stack.length===0?e:`${e}\n${this.stack.map(e=>{let t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join(` +`)}`}};function _D(e,t=0){let n=3735928559^t,r=1103547991^t;if(Array.isArray(e))for(let t=0,i;t>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}var vD=e=>_D(e),yD=e=>_D(e),bD=(...e)=>_D(e),Vee=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),xD=new WeakMap;function SD(e){return Vee.get(e)}function CD(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function wD(e){if(/float|int|uint|bool/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;z(`TSL: Unsupported type: ${e}`,new gD)}function TD(e){if(/float|int|uint|bool/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;z(`TSL: Unsupported type: ${e}`,new gD)}function ED(e){if(/float|int|uint|bool/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e)||/vec4/.test(e))return 4;if(/mat2/.test(e))return 2;if(/mat3/.test(e)||/mat4/.test(e))return 4;z(`TSL: Unsupported type: ${e}`,new gD)}function DD(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function OD(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new Ur(...t):n===`vec2`?new B(...t):n===`vec3`?new V(...t):n===`vec4`?new ir(...t):n===`mat2`?new pl(...t):n===`mat3`?new Hn(...t):n===`mat4`?new lr(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?jD(t[0]):null}function kD(e){let t=xD.get(e);return t===void 0&&(t={},xD.set(e,t)),t}function AD(e){let t=``,n=new Uint8Array(e);for(let e=0;ee.charCodeAt(0)).buffer}var MD={VERTEX:`vertex`,FRAGMENT:`fragment`},ND={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},PD={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},FD={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},ID=[`fragment`,`vertex`],LD=[`setup`,`analyze`,`generate`],RD=[...ID,`compute`],zD=[`x`,`y`,`z`,`w`],BD={analyze:`setup`,generate:`analyze`},VD=0,HD=class e extends dn{static get type(){return`Node`}constructor(t=null){super(),this.nodeType=t,this.updateType=ND.NONE,this.updateBeforeType=ND.NONE,this.updateAfterType=ND.NONE,this.version=0,this.name=``,this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=VD++,this.stackTrace=null,e.captureStackTrace===!0&&(this.stackTrace=new gD)}set needsUpdate(e){e===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=Rn.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,ND.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ND.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ND.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let n of Object.getOwnPropertyNames(this)){let r=this[n];if(!(n.startsWith(`_`)===!0||e.has(r))){if(Array.isArray(r)===!0)for(let e=0;e0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n])r[i]=t[e.inputNodes[n][i]];this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}};HD.captureStackTrace=!1;var UD=class extends HD{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`)} ]`}},WD=class extends HD{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},GD=class extends HD{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},KD=class extends GD{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){z(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;if(s+c>r&&(z(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i),e.getComponentType(i)!==a){let t=e.getTypeFromLength(c,a);l=e.format(l,i,t)}o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},qD=zD.join(``),JD=class extends HD{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(zD.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=n.build(e,a);i=this.components.length===r&&this.components===qD.slice(0,this.components.length)?e.format(o,a,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},YD=class extends GD{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;ee.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),iO=e=>rO(e).split(``).sort().join(``);HD.prototype.assign=function(...e){if(this.isStackNode!==!0)return tO===null?z(`TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().`,new gD):tO.assign(this,...e),this;{let t=nO.get(`assign`);return this.addToStack(t(...e))}},HD.prototype.toVarIntent=function(){return this},HD.prototype.get=function(e){return new eO(this,e)};var aO={};function oO(e,t,n){aO[e]=aO[t]=aO[n]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new JD(this,e),this._cache[e]=t),t},set(t){this[e].assign(FO(t))}};let r=e.toUpperCase(),i=t.toUpperCase(),a=n.toUpperCase();HD.prototype[`set`+r]=HD.prototype[`set`+i]=HD.prototype[`set`+a]=function(t){let n=iO(e);return new YD(this,n,FO(t))},HD.prototype[`flip`+r]=HD.prototype[`flip`+i]=HD.prototype[`flip`+a]=function(){let t=iO(e);return new XD(this,t)}}var sO=[`x`,`y`,`z`,`w`],cO=[`r`,`g`,`b`,`a`],lO=[`s`,`t`,`p`,`q`];for(let e=0;e<4;e++){let t=sO[e],n=cO[e],r=lO[e];oO(t,n,r);for(let i=0;i<4;i++){t=sO[e]+sO[i],n=cO[e]+cO[i],r=lO[e]+lO[i],oO(t,n,r);for(let a=0;a<4;a++){t=sO[e]+sO[i]+sO[a],n=cO[e]+cO[i]+cO[a],r=lO[e]+lO[i]+lO[a],oO(t,n,r);for(let o=0;o<4;o++)t=sO[e]+sO[i]+sO[a]+sO[o],n=cO[e]+cO[i]+cO[a]+cO[o],r=lO[e]+lO[i]+lO[a]+lO[o],oO(t,n,r)}}}for(let e=0;e<32;e++)aO[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new UD(this,new $D(e,`uint`)),this._cache[e]=t),t},set(t){this[e].assign(FO(t))}};Object.defineProperties(HD.prototype,aO);var uO=function(e,t=null){let n=DD(e);return n===`node`?e:t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`?FO(AO(e,t)):n===`shader`?e.isFn?e:G(e):e},dO=function(e,t=null){for(let n in e)e[n]=FO(e[n],t);return e},fO=function(e,t=null){let n=e.length;for(let r=0;rc?(z(`TSL: "${n}" parameter length exceeds limit.`,new gD),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...RO(l(t)))):n===null?a=(...n)=>i(new e(t,...RO(l(n)))):(n=FO(n),a=(...r)=>i(new e(t,...RO(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},mO=function(e,...t){return new e(...RO(t))},hO=class extends HD{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:n}=this,r=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||``,a=i||`default`;if(r[a])return r[a];let o=e.subBuildFn,s=e.fnCall;e.subBuildFn=i,e.fnCall=this;let c=null;if(t.layout){if(n){let r=t.layout.inputs;if(gO(n)){let t=n;for(let n=0;n{let r;return r=Symbol.iterator===t?function*(){yield void 0}:Reflect.get(e,t,n),r}}),i=n?vO(n):null,a=Array.isArray(n)?n.length>0:n!==null,o=t.jsFunc;c=FO(a||o.length>1?o(i,r):o(r))}return e.subBuildFn=o,e.fnCall=s,t.once&&(r[a]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),s=e.fnCall;if(e.fnCall=this,r===`setup`){let t=e.getSubBuildProperty(`initialized`,this);if(i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let n=e.getDataFromNode(t,`any`);n.subBuilds=n.subBuilds||new Set;for(let e of this.shaderNode.subBuilds)n.subBuilds.add(e)}n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return e.fnCall=s,n}};function gO(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}function _O(e){let t;return LO(e),t=gO(e)?[...e]:e[0],t}function vO(e){let t=0;return LO(e),new Proxy(e,{get:(n,r,i)=>{let a;if(r===`length`)return a=e.length,a;if(Symbol.iterator===r)a=function*(){for(let t of e)yield FO(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){let n=e[0];a=n[r]===void 0?n[t++]:Reflect.get(n,r,i)}else e[0]instanceof HD&&(a=e[r]===void 0?e[t++]:Reflect.get(e,r,i));else a=Reflect.get(n,r,i);a=FO(a)}return a}})}var yO=class extends HD{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new hO(this,e)}setup(){return this.call()}},bO=[!1,!0],xO=[0,1,2,3],SO=[-1,-2],CO=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],wO=new Map;for(let e of bO)wO.set(e,new $D(e));var TO=new Map;for(let e of xO)TO.set(e,new $D(e,`uint`));var EO=new Map([...TO].map(e=>new $D(e.value,`int`)));for(let e of SO)EO.set(e,new $D(e,`int`));var DO=new Map([...EO].map(e=>new $D(e.value)));for(let e of CO)DO.set(e,new $D(e));for(let e of CO)DO.set(-e,new $D(-e));var OO={bool:wO,uint:TO,ints:EO,float:DO},kO=new Map([...wO,...DO]),AO=(e,t)=>kO.has(e)?kO.get(e):e.isNode===!0?e:new $D(e,t),jO=function(e,t=null){return(...n)=>{for(let t of n)if(t===void 0)return z(`TSL: Invalid parameter for the type "${e}".`,new gD),new $D(0,e);if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>{let t=typeof e;return t!==`object`&&t!==`function`}))&&(n=[OD(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return IO(t.get(n[0]));if(n.length===1){let t=AO(n[0],e);return t.nodeType===e?IO(t):IO(new WD(t,e))}return IO(new KD(n.map(e=>AO(e)),e))}};function MO(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),!!e}var NO=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function PO(e,t){return new yO(e,t)}var FO=(e,t=null)=>uO(e,t),IO=(e,t=null)=>FO(e,t).toVarIntent(),LO=(e,t=null)=>new dO(e,t),RO=(e,t=null)=>new fO(e,t),zO=(e,t=null,n=null,r=null)=>new pO(e,t,n,r),BO=(e,...t)=>new mO(e,...t),VO=(e,t=null,n=null,r={})=>new pO(e,t,n,{...r,intent:!0}),HO=(e,t)=>new Proxy(e,{get(e,n,r){return Reflect.get(t,n,r)},set(e,n,r){return Reflect.set(t,n,r)}}),UO=0,WO=class extends HD{constructor(e,t=null){super();let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:z(`TSL: Invalid layout type.`,new gD),t=null)),this.shaderNode=new PO(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!=`object`){let n={name:`fn`+UO++,type:t,inputs:[]};for(let t in e)t!==`return`&&n.inputs.push({name:t,type:e[t]});e=n}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||`float`}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType===`void`&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return z(`TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".`,this.stackTrace),e.generateConst(t)}};function G(e,t=null){let n=new WO(e,t);return new Proxy(()=>{},{apply(e,t,r){return n.call(...r)},get(e,t,r){return Reflect.get(n,t,r)},set(e,t,r,i){return Reflect.set(n,t,r,i)}})}var GO=e=>{tO=e},KO=()=>tO,qO=(...e)=>tO.If(...e),JO=(...e)=>tO.Switch(...e);function YO(e){return tO&&tO.addToStack(e),e}W(`toStack`,YO);var XO=new jO(`color`),K=new jO(`float`,OO.float),q=new jO(`int`,OO.ints),J=new jO(`uint`,OO.uint),ZO=new jO(`bool`,OO.bool),QO=new jO(`vec2`),$O=new jO(`ivec2`),ek=new jO(`uvec2`),tk=new jO(`bvec2`),Y=new jO(`vec3`),nk=new jO(`ivec3`),rk=new jO(`uvec3`),ik=new jO(`bvec3`),ak=new jO(`vec4`),ok=new jO(`ivec4`),sk=new jO(`uvec4`),ck=new jO(`bvec4`),lk=new jO(`mat2`),uk=new jO(`mat3`),dk=new jO(`mat4`);W(`toColor`,XO),W(`toFloat`,K),W(`toInt`,q),W(`toUint`,J),W(`toBool`,ZO),W(`toVec2`,QO),W(`toIVec2`,$O),W(`toUVec2`,ek),W(`toBVec2`,tk),W(`toVec3`,Y),W(`toIVec3`,nk),W(`toUVec3`,rk),W(`toBVec3`,ik),W(`toVec4`,ak),W(`toIVec4`,ok),W(`toUVec4`,sk),W(`toBVec4`,ck),W(`toMat2`,lk),W(`toMat3`,uk),W(`toMat4`,dk);var fk=zO(UD).setParameterLength(2),pk=(e,t)=>new WD(FO(e),t),mk=(e,t)=>new JD(FO(e),t);W(`element`,fk),W(`convert`,pk);var hk=e=>(R(`TSL: append() has been renamed to Stack().`,new gD),YO(e));W(`append`,e=>(R(`TSL: .append() has been renamed to .toStack().`,new gD),YO(e)));var gk=class extends HD{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1,r=null){super(e),this.name=t,this.varying=n,this.placeholderNode=FO(r),this.isPropertyNode=!0,this.global=!0}getNodeType(e){let t=super.getNodeType(e);return t===`output`?e.getOutputType():t}customCacheKey(){return vD(this.type+`:`+(this.name||``)+`:`+(this.varying?`1`:`0`))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(this.varying===!0)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),this.placeholderNode!==null&&e.hasWriteUsage(this)===!1){let n=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${n}`,this)}return e.getPropertyName(t)}},_k=(e,t,n=null)=>new gk(e,t,!1,n),vk=(e,t,n=null)=>new gk(e,t,!0,n),yk=BO(gk,`vec4`,`DiffuseColor`),bk=BO(gk,`vec3`,`DiffuseContribution`),xk=BO(gk,`vec3`,`EmissiveColor`),Sk=BO(gk,`float`,`Roughness`),Ck=BO(gk,`float`,`Metalness`),wk=BO(gk,`float`,`Clearcoat`),Tk=BO(gk,`float`,`ClearcoatRoughness`),Ek=BO(gk,`vec3`,`Sheen`),Dk=BO(gk,`float`,`SheenRoughness`),Ok=BO(gk,`float`,`Iridescence`),kk=BO(gk,`float`,`IridescenceIOR`),Ak=BO(gk,`float`,`IridescenceThickness`),jk=BO(gk,`float`,`AlphaT`),Mk=BO(gk,`float`,`Anisotropy`),Nk=BO(gk,`vec3`,`AnisotropyT`),Pk=BO(gk,`vec3`,`AnisotropyB`),Fk=BO(gk,`color`,`SpecularColor`),Ik=BO(gk,`color`,`SpecularColorBlended`),Lk=BO(gk,`float`,`SpecularF90`),Rk=BO(gk,`float`,`Shininess`),zk=BO(gk,`output`,`Output`),Bk=BO(gk,`float`,`dashSize`),Vk=BO(gk,`float`,`gapSize`),Hk=BO(gk,`float`,`pointWidth`),Uk=BO(gk,`float`,`IOR`),Wk=BO(gk,`float`,`Transmission`),Gk=BO(gk,`float`,`Thickness`),Kk=BO(gk,`float`,`AttenuationDistance`),qk=BO(gk,`color`,`AttenuationColor`),Jk=BO(gk,`float`,`Dispersion`),Yk=BO(gk,`float`,`AmbientOcclusion`,!1,1),Xk=class extends HD{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1,r=null){super(`string`),this.name=e,this.shared=t,this.order=n,this.updateType=r,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},Zk=(e,t=1,n=null)=>new Xk(e,!1,t,n),Qk=(e,t=0,n=null)=>new Xk(e,!0,t,n),$k=Qk(`frame`,0,ND.FRAME),eA=Qk(`render`,0,ND.RENDER),tA=Zk(`object`,1,ND.OBJECT),nA=class extends ZD{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=tA}setName(e){return this.name=e,this}label(e){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new gD),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let n=e(t,this);n!==void 0&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t===`bool`&&(t=`uint`),t}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.nodeName),s=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=s;if(n===`bool`){let t=e.getDataFromNode(this),r=t.propertyName;if(r===void 0){let i=e.getVarFromNode(this,null,`bool`);r=e.getPropertyName(i),t.propertyName=r,c=e.format(s,a,n),e.addLineFlowCode(`${r} = ${c}`,this)}c=r}return e.format(c,n,t)}},rA=(e,t)=>{let n=NO(t||e);if(n===e&&(e=OD(n)),e&&e.isNode===!0){let t=e.value;e.traverse(e=>{e.isConstNode===!0&&(t=e.value)}),e=t}return new nA(e,n)},iA=class extends GD{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},aA=(...e)=>{let t;if(e.length===1){let n=e[0];t=new iA(null,n.length,n)}else{let n=e[0],r=e[1];t=new iA(n,r)}return FO(t)};W(`toArray`,(e,t)=>aA(Array(t).fill(e)));var oA=zO(class extends GD{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e));return zD.join(``).slice(0,n)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=t.getScope(),i=e.getDataFromNode(r);i.assign=!0;let a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.build(e),o=n.getNodeType(e),s=r.build(e,o),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=a);else if(i){let r=e.getVarFromNode(this,null,o),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}).build(e);for(let t=0;t{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)z(`TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length(t=t.length>1||t[0]&&t[0].isNode===!0?RO(t):LO(t[0]),new Hee(FO(e),t));W(`call`,sA);var Uee={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`},cA=class e extends GD{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n>`||n===`<<`)return e.getIntegerType(a);if(n===`&&`||n===`||`||n===`^^`)return`bool`;if(n===`!`){let t=e.getTypeLength(a);return t>1?`bvec${t}`:`bool`}else if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`){let t=Math.max(e.getTypeLength(a),e.getTypeLength(o));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(a)){if(o===`float`)return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a===`float`)return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e,t),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===Yt;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`)return r&&e.isVector(o)?e.format(`not( ${c} )`,t):e.format(`( ${n} ${c} )`,o,t);if(n===`~`)return e.format(`( ${n} ${c} )`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},lA=VO(cA,`+`).setParameterLength(2,1/0).setName(`add`),uA=VO(cA,`-`).setParameterLength(2,1/0).setName(`sub`),dA=VO(cA,`*`).setParameterLength(2,1/0).setName(`mul`),fA=VO(cA,`/`).setParameterLength(2,1/0).setName(`div`),pA=VO(cA,`%`).setParameterLength(2).setName(`mod`),mA=VO(cA,`==`).setParameterLength(2).setName(`equal`),hA=VO(cA,`!=`).setParameterLength(2).setName(`notEqual`),gA=VO(cA,`<`).setParameterLength(2).setName(`lessThan`),_A=VO(cA,`>`).setParameterLength(2).setName(`greaterThan`),vA=VO(cA,`<=`).setParameterLength(2).setName(`lessThanEqual`),yA=VO(cA,`>=`).setParameterLength(2).setName(`greaterThanEqual`),bA=VO(cA,`&&`).setParameterLength(2,1/0).setName(`and`),xA=VO(cA,`||`).setParameterLength(2,1/0).setName(`or`),SA=VO(cA,`!`).setParameterLength(1).setName(`not`),CA=VO(cA,`^^`).setParameterLength(2).setName(`xor`),wA=VO(cA,`&`).setParameterLength(2).setName(`bitAnd`),TA=VO(cA,`~`).setParameterLength(1).setName(`bitNot`),EA=VO(cA,`|`).setParameterLength(2).setName(`bitOr`),DA=VO(cA,`^`).setParameterLength(2).setName(`bitXor`),OA=VO(cA,`<<`).setParameterLength(2).setName(`shiftLeft`),kA=VO(cA,`>>`).setParameterLength(2).setName(`shiftRight`),AA=G(([e])=>(e.addAssign(1),e)),jA=G(([e])=>(e.subAssign(1),e)),MA=G(([e])=>{let t=q(e).toConst();return e.addAssign(1),t}),NA=G(([e])=>{let t=q(e).toConst();return e.subAssign(1),t});W(`add`,lA),W(`sub`,uA),W(`mul`,dA),W(`div`,fA),W(`mod`,pA),W(`equal`,mA),W(`notEqual`,hA),W(`lessThan`,gA),W(`greaterThan`,_A),W(`lessThanEqual`,vA),W(`greaterThanEqual`,yA),W(`and`,bA),W(`or`,xA),W(`not`,SA),W(`xor`,CA),W(`bitAnd`,wA),W(`bitNot`,TA),W(`bitOr`,EA),W(`bitXor`,DA),W(`shiftLeft`,OA),W(`shiftRight`,kA),W(`incrementBefore`,AA),W(`decrementBefore`,jA),W(`increment`,MA),W(`decrement`,NA);var X=class e extends GD{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=3;na&&i>o?t:a>o?n:o>i?r:t}generateNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=uA(1,n);else if(i===e.RECIPROCAL)a=fA(1,n);else if(i===e.DIFFERENCE)a=dj(uA(n,r));else if(i===e.TRANSFORM_DIRECTION){let e,i;t.isMatrix(n.getNodeType(t))?(e=n,i=r):(e=r,i=n),a=ZA(dA(e,ak(Y(i),0)).xyz)}return a===null?super.setup(t):a}generate(t,n){if(t.getNodeProperties(this).outputNode)return super.generate(t,n);let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=this.cNode,l=t.renderer.coordinateSystem;if(r===e.NEGATE)return t.format(`( - `+o.build(t,a)+` )`,i,n);{let u=[];return r===e.CROSS?u.push(o.build(t,i),s.build(t,i)):l===2e3&&r===e.STEP?u.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?`float`:a),s.build(t,a)):l===2e3&&(r===e.MIN||r===e.MAX)?u.push(o.build(t,a),s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:a)):r===e.REFRACT?u.push(o.build(t,a),s.build(t,a),c.build(t,`float`)):r===e.MIX?u.push(o.build(t,a),s.build(t,a),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:a)):(l===2001&&r===e.ATAN&&s!==null&&(r=`atan2`),t.shaderStage!==`fragment`&&(r===e.DFDX||r===e.DFDY)&&(R(`TSL: '${r}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),r=`/*`+r+`*/`),u.push(o.build(t,a)),s!==null&&u.push(s.build(t,a)),c!==null&&u.push(c.build(t,a))),t.format(`${t.getMethod(r,i)}( ${u.join(`, `)} )`,i,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};X.ALL=`all`,X.ANY=`any`,X.RADIANS=`radians`,X.DEGREES=`degrees`,X.EXP=`exp`,X.EXP2=`exp2`,X.LOG=`log`,X.LOG2=`log2`,X.SQRT=`sqrt`,X.INVERSE_SQRT=`inversesqrt`,X.FLOOR=`floor`,X.CEIL=`ceil`,X.NORMALIZE=`normalize`,X.FRACT=`fract`,X.SIN=`sin`,X.SINH=`sinh`,X.COS=`cos`,X.COSH=`cosh`,X.TAN=`tan`,X.TANH=`tanh`,X.ASIN=`asin`,X.ASINH=`asinh`,X.ACOS=`acos`,X.ACOSH=`acosh`,X.ATAN=`atan`,X.ATANH=`atanh`,X.ABS=`abs`,X.SIGN=`sign`,X.LENGTH=`length`,X.NEGATE=`negate`,X.ONE_MINUS=`oneMinus`,X.DFDX=`dFdx`,X.DFDY=`dFdy`,X.ROUND=`round`,X.RECIPROCAL=`reciprocal`,X.TRUNC=`trunc`,X.FWIDTH=`fwidth`,X.TRANSPOSE=`transpose`,X.DETERMINANT=`determinant`,X.INVERSE=`inverse`,X.EQUALS=`equals`,X.MIN=`min`,X.MAX=`max`,X.STEP=`step`,X.REFLECT=`reflect`,X.DISTANCE=`distance`,X.DIFFERENCE=`difference`,X.DOT=`dot`,X.CROSS=`cross`,X.POW=`pow`,X.TRANSFORM_DIRECTION=`transformDirection`,X.MIX=`mix`,X.CLAMP=`clamp`,X.REFRACT=`refract`,X.SMOOTHSTEP=`smoothstep`,X.FACEFORWARD=`faceforward`;var PA=K(1e-6),FA=K(1e6),IA=K(Math.PI),Wee=K(Math.PI*2),LA=K(Math.PI*2),RA=K(Math.PI*.5),zA=VO(X,X.ALL).setParameterLength(1),BA=VO(X,X.ANY).setParameterLength(1),VA=VO(X,X.RADIANS).setParameterLength(1),HA=VO(X,X.DEGREES).setParameterLength(1),UA=VO(X,X.EXP).setParameterLength(1),WA=VO(X,X.EXP2).setParameterLength(1),GA=VO(X,X.LOG).setParameterLength(1),KA=VO(X,X.LOG2).setParameterLength(1),qA=VO(X,X.SQRT).setParameterLength(1),JA=VO(X,X.INVERSE_SQRT).setParameterLength(1),YA=VO(X,X.FLOOR).setParameterLength(1),XA=VO(X,X.CEIL).setParameterLength(1),ZA=VO(X,X.NORMALIZE).setParameterLength(1),QA=VO(X,X.FRACT).setParameterLength(1),$A=VO(X,X.SIN).setParameterLength(1),ej=VO(X,X.SINH).setParameterLength(1),tj=VO(X,X.COS).setParameterLength(1),nj=VO(X,X.COSH).setParameterLength(1),rj=VO(X,X.TAN).setParameterLength(1),ij=VO(X,X.TANH).setParameterLength(1),aj=VO(X,X.ASIN).setParameterLength(1),oj=VO(X,X.ASINH).setParameterLength(1),sj=VO(X,X.ACOS).setParameterLength(1),cj=VO(X,X.ACOSH).setParameterLength(1),lj=VO(X,X.ATAN).setParameterLength(1,2),uj=VO(X,X.ATANH).setParameterLength(1),dj=VO(X,X.ABS).setParameterLength(1),fj=VO(X,X.SIGN).setParameterLength(1),pj=VO(X,X.LENGTH).setParameterLength(1),mj=VO(X,X.NEGATE).setParameterLength(1),hj=VO(X,X.ONE_MINUS).setParameterLength(1),gj=VO(X,X.DFDX).setParameterLength(1),_j=VO(X,X.DFDY).setParameterLength(1),vj=VO(X,X.ROUND).setParameterLength(1),yj=VO(X,X.RECIPROCAL).setParameterLength(1),bj=VO(X,X.TRUNC).setParameterLength(1),xj=VO(X,X.FWIDTH).setParameterLength(1),Sj=VO(X,X.TRANSPOSE).setParameterLength(1),Cj=VO(X,X.DETERMINANT).setParameterLength(1),wj=VO(X,X.INVERSE).setParameterLength(1),Tj=VO(X,X.MIN).setParameterLength(2,1/0),Ej=VO(X,X.MAX).setParameterLength(2,1/0),Dj=VO(X,X.STEP).setParameterLength(2),Oj=VO(X,X.REFLECT).setParameterLength(2),kj=VO(X,X.DISTANCE).setParameterLength(2),Aj=VO(X,X.DIFFERENCE).setParameterLength(2),jj=VO(X,X.DOT).setParameterLength(2),Mj=VO(X,X.CROSS).setParameterLength(2),Nj=VO(X,X.POW).setParameterLength(2),Pj=e=>dA(e,e),Fj=e=>dA(e,e,e),Ij=e=>dA(e,e,e,e),Lj=VO(X,X.TRANSFORM_DIRECTION).setParameterLength(2),Rj=(e,t)=>ZA(dA(t,ak(Y(e),0)).xyz),zj=(e,t)=>ZA(ak(Y(e),0).mul(t).xyz),Bj=e=>dA(fj(e),Nj(dj(e),1/3)),Vj=e=>jj(e,e),Hj=VO(X,X.MIX).setParameterLength(3),Uj=(e,t=0,n=1)=>new X(X.CLAMP,FO(e),FO(t),FO(n)),Wj=e=>Uj(e),Gj=VO(X,X.REFRACT).setParameterLength(3),Kj=VO(X,X.SMOOTHSTEP).setParameterLength(3),qj=VO(X,X.FACEFORWARD).setParameterLength(3),Jj=G(([e])=>QA($A(pA(jj(e.xy,QO(12.9898,78.233)),IA)).mul(43758.5453))),Yj=(e,t,n)=>Hj(t,n,e),Xj=(e,t,n)=>Kj(t,n,e),Zj=(e,t)=>Dj(t,e),Qj=qj,$j=JA;W(`all`,zA),W(`any`,BA),W(`radians`,VA),W(`degrees`,HA),W(`exp`,UA),W(`exp2`,WA),W(`log`,GA),W(`log2`,KA),W(`sqrt`,qA),W(`inverseSqrt`,JA),W(`floor`,YA),W(`ceil`,XA),W(`normalize`,ZA),W(`fract`,QA),W(`sin`,$A),W(`sinh`,ej),W(`cos`,tj),W(`cosh`,nj),W(`tan`,rj),W(`tanh`,ij),W(`asin`,aj),W(`asinh`,oj),W(`acos`,sj),W(`acosh`,cj),W(`atan`,lj),W(`atanh`,uj),W(`abs`,dj),W(`sign`,fj),W(`length`,pj),W(`lengthSq`,Vj),W(`negate`,mj),W(`oneMinus`,hj),W(`dFdx`,gj),W(`dFdy`,_j),W(`round`,vj),W(`reciprocal`,yj),W(`trunc`,bj),W(`fwidth`,xj),W(`min`,Tj),W(`max`,Ej),W(`step`,Zj),W(`reflect`,Oj),W(`distance`,kj),W(`dot`,jj),W(`cross`,Mj),W(`pow`,Nj),W(`pow2`,Pj),W(`pow3`,Fj),W(`pow4`,Ij),W(`transformDirection`,Lj),W(`transformNormalByViewMatrix`,Rj),W(`transformNormalByInverseViewMatrix`,zj),W(`mix`,Yj),W(`clamp`,Uj),W(`refract`,Gj),W(`smoothstep`,Xj),W(`faceForward`,qj),W(`difference`,Aj),W(`saturate`,Wj),W(`cbrt`,Bj),W(`transpose`,Sj),W(`determinant`,Cj),W(`inverse`,wj),W(`rand`,Jj);var eM=zO(class extends HD{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}generateNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,`setup`),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?n:n.context({nodeBlock:n}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?_k(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);if(e.context.uniformFlow&&o!==null){let r=a.build(e,n),i=o.build(e,n),s=e.getTernary(u,r,i);return e.format(s,n,t)}e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(R(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+` + +`+e.tab+`}`),o!==null){e.addFlowCode(` else { + +`).addFlowTab();let t=o.build(e,n);t&&(c?t=l+` = `+t+`;`:(t=`return `+t+`;`,s===null&&(R(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),t=`// `+t))),e.removeFlowTab().addFlowCode(e.tab+` `+t+` + +`+e.tab+`} + +`)}else e.addFlowCode(` + +`);return e.format(l,n,t)}}).setParameterLength(2,3);W(`select`,eM);var tM=class extends HD{static get type(){return`ContextNode`}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}},nM=(e=null,t={})=>{let n=e;return(n===null||n.isNode!==!0)&&(t=n||t,n=null),new tM(n,t)},rM=e=>nM(e,{uniformFlow:!0}),iM=(e,t)=>nM(e,{nodeName:t});function aM(e,t,n=null){return nM(n,{getShadow:({light:n,shadowColorNode:r})=>t===n?r.mul(e):r})}function oM(e,t=null){return nM(t,{getAO:(t,{material:n})=>n.transparent===!0?t:t===null?e:t.mul(e)})}function sM(e,t){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`),iM(e,t)}W(`context`,nM),W(`label`,sM),W(`uniformFlow`,rM),W(`setName`,iM),W(`builtinShadowContext`,(e,t,n)=>aM(t,n,e)),W(`builtinAOContext`,(e,t)=>oM(t,e));var cM=class extends HD{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration!==!0&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0],n=this.getShared(t);if(this!==n)return n.build(...e);if(this._hasStack(t)===!1&&t.buildStage===`setup`&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let n=t.getDataFromNode(this);n.forceDeclaration=!0,e=!0}let n=t.getBaseStack();e?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=this.getNodeType(e);if(c==`void`)return this.isIntent(e)!==!0&&z(`TSL: ".toVar()" can not be used with void type.`,this.stackTrace),t.build(e);let l=e.getVectorType(c),u=t.build(e,l),d=e.getVarFromNode(this,n,l,void 0,s),f=e.getPropertyName(d),p=f;if(s)if(a)p=o?`const ${f}`:`let ${f}`;else{let n=t.getArrayCount(e);p=`const ${e.getVar(d.type,f,n)}`}return e.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}},lM=zO(cM),uM=(e,t=null)=>lM(e,t).toStack(),dM=(e,t=null)=>lM(e,t,!0).toStack(),fM=e=>lM(e).setIntent(!0).toStack();W(`toVar`,uM),W(`toConst`,dM),W(`toVarIntent`,fM);var pM=class extends HD{static get type(){return`SubBuild`}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let n=this.node.build(e,...t);return e.removeSubBuild(),n}},mM=(e,t,n=null)=>new pM(FO(e),t,n),hM=zO(class extends HD{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=mM(e,`VERTEX`),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=mM(this.node,`VERTEX`)}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(MD.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(MD.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty(`property`,e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){let i=this.getNodeType(e),a=e.getPropertyName(r,MD.VERTEX);if(e.shaderStage===MD.VERTEX){let t=n.node.build(e,i);e.addLineFlowCode(`${a} = ${t}`,this)}else e.flowNodeFromShaderStage(MD.VERTEX,n.node,i,a);n[t]=a}return e.getPropertyName(r)}}).setParameterLength(1,2),gM=e=>hM(e);W(`toVarying`,hM),W(`toVertexStage`,gM);var _M=G(([e])=>Hj(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),vM=G(([e])=>Hj(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),yM=`WorkingColorSpace`,bM=`OutputColorSpace`,xM=class extends GD{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===yM?qn.workingColorSpace:t===bM?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return qn.enabled===!1||n===r||!n||!r?i:(qn.getTransfer(n)===`srgb`&&(i=ak(_M(i.rgb),i.a)),qn.getPrimaries(n)!==qn.getPrimaries(r)&&(i=ak(uk(qn._getMatrix(new Hn,n,r)).mul(i.rgb),i.a)),qn.getTransfer(r)===`srgb`&&(i=ak(vM(i.rgb),i.a)),i)}},SM=(e,t)=>new xM(FO(e),yM,t),CM=(e,t)=>new xM(FO(e),t,yM),wM=(e,t,n)=>new xM(FO(e),t,n);W(`workingToColorSpace`,SM),W(`colorSpaceToWorking`,CM);var TM=class extends UD{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},EM=class extends HD{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=ND.OBJECT}setGroup(e){return this.group=e,this}element(e){return new TM(this,FO(e))}setNodeType(e){let t=rA(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;enew EM(e,t,n),OM=class extends EM{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(eA)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},kM=(e,t,n=null)=>new OM(e,t,n),AM=class extends GD{static get type(){return`ToneMappingNode`}constructor(e,t=MM,n=null){super(`vec3`),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return bD(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,n=this._toneMapping;if(n===0)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(z(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=ak(i(t.rgb,this.exposureNode),t.a),r}},jM=(e,t,n)=>new AM(e,FO(t),FO(n)),MM=kM(`toneMappingExposure`,`float`);W(`toneMapping`,(e,t,n)=>jM(t,n,e));var NM=new WeakMap;function PM(e,t){let n=NM.get(e);return n===void 0&&(n=new Gi(e,t),NM.set(e,n)),n}var FM=class extends ZD{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=qt,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let n=e.globalCache.getData(this.value);n===void 0&&(n={node:this},e.globalCache.setData(this.value,n)),t=n.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=e.getTypeLength(t),r=this.value,i=this.bufferStride||n,a=this.bufferOffset,o;o=r.isInterleavedBuffer===!0?r:r.isBufferAttribute===!0?PM(r.array,i):PM(r,i);let s=new qi(o,n,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.context.nodeName;n!==void 0&&delete e.context.nodeName;let r=e.getBufferAttributeFromNode(this,t,n),i=e.getPropertyName(r),a=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=i,a=i;else{let r;n&&(r=n+`Varying`),a=hM(this,r).build(e,t)}return a}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};function IM(e,t=null,n=0,r=0,i=qt,a=!1){return t===`mat3`||t===null&&e.itemSize===9?uk(new FM(e,`vec3`,9,0).setUsage(i).setInstanced(a),new FM(e,`vec3`,9,3).setUsage(i).setInstanced(a),new FM(e,`vec3`,9,6).setUsage(i).setInstanced(a)):t===`mat4`||t===null&&e.itemSize===16?dk(new FM(e,`vec4`,16,0).setUsage(i).setInstanced(a),new FM(e,`vec4`,16,4).setUsage(i).setInstanced(a),new FM(e,`vec4`,16,8).setUsage(i).setInstanced(a),new FM(e,`vec4`,16,12).setUsage(i).setInstanced(a)):new FM(e,t,n,r).setUsage(i)}var LM=(e,t=null,n=0,r=0)=>IM(e,t,n,r),RM=(e,t=null,n=0,r=0)=>IM(e,t,n,r,Jt),zM=(e,t=null,n=0,r=0)=>IM(e,t,n,r,qt,!0),BM=(e,t=null,n=0,r=0)=>IM(e,t,n,r,Jt,!0);W(`toAttribute`,e=>LM(e.value));var VM=class e extends HD{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;return a=t.shaderStage===`vertex`||t.shaderStage===`compute`?i:hM(this).build(t,n),a}};VM.VERTEX=`vertex`,VM.INSTANCE=`instance`,VM.SUBGROUP=`subgroup`,VM.INVOCATION_LOCAL=`invocationLocal`,VM.INVOCATION_SUBGROUP=`invocationSubgroup`,VM.DRAW=`draw`;var HM=BO(VM,VM.VERTEX),UM=BO(VM,VM.INSTANCE),WM=BO(VM,VM.SUBGROUP),GM=BO(VM,VM.INVOCATION_SUBGROUP),KM=BO(VM,VM.INVOCATION_LOCAL),qM=BO(VM,VM.DRAW),JM=class extends HD{static get type(){return`ComputeNode`}constructor(e,t){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name=``,this.updateBeforeType=ND.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:`dispose`})}setName(e){return this.name=e,this}label(e){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new gD),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){this.count!==null&&this.countNode===null&&(this.countNode=rA(this.count,`uint`).onObjectUpdate(()=>this.count));let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);if(t!==``&&e.addLineFlowCode(t,this),this.count!==null&&e.allowEarlyReturns===!0){let t=this.countNode.build(e,`uint`),n=UM.build(e,`uint`);e.flow.code=`${e.tab}if ( ${n} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{let n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}},YM=(e,t=[64])=>{(t.length===0||t.length>3)&&z(`TSL: compute() workgroupSize must have 1, 2, or 3 elements`,new gD);for(let e=0;e{let r=YM(e,n);return typeof t==`number`?r.count=t:r.dispatchSize=t,r};W(`compute`,XM),W(`computeKernel`,YM);var Gee=class extends HD{static get type(){return`IsolateNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}},ZM=e=>new Gee(FO(e));function QM(e,t=!0){return R(`TSL: "cache()" has been deprecated. Use "isolate()" instead.`),ZM(e).setParent(t)}W(`cache`,QM),W(`isolate`,ZM);var $M=zO(class extends HD{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2);W(`bypass`,$M);var eN=G(([e,t,n,r=K(0),i=K(1),a=ZO(!1)])=>{let o=e.sub(t).div(n.sub(t));return MO(a)&&(o=o.clamp()),o.mul(i.sub(r)).add(r)});function tN(e,t,n,r=K(0),i=K(1)){return eN(e,t,n,r,i,!0)}W(`remap`,eN),W(`remapClamp`,tN);var nN=class extends HD{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}},rN=zO(nN).setParameterLength(1,2),iN=e=>(e?eM(e,rN(`discard`)):rN(`discard`)).toStack(),Kee=()=>rN(`return`).toStack();W(`discard`,iN);var aN=G(([e])=>ak(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),oN=G(([e])=>e.a.equal(0).select(ak(0),ak(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),sN=class extends GD{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=ak(t.rgb,t.a.clamp(0,1)),t=oN(t);let n=(this._toneMapping===null?e.toneMapping:this._toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||``;return n!==0&&(t=t.toneMapping(n)),r!==``&&r!==qn.workingColorSpace&&(t=t.workingToColorSpace(r)),t=aN(t),t}},cN=(e,t=null,n=null)=>new sN(FO(e),t,n);W(`renderOutput`,cN);var lN=class extends GD{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e);if(t!==null)t(e,n);else{let t=`--- TSL debug - `+e.shaderStage+` shader ---`,r=`-`.repeat(t.length),i=``;i+=`// #`+t+`# +`,i+=e.flow.code.replace(/^\t/gm,``)+` +`,i+=`/* ... */ `+n+` /* ... */ +`,i+=`// #`+r+`# +`,an(i)}return n}},uN=(e,t=null)=>new lN(FO(e),t).toStack();W(`debug`,uN);var dN=class extends dn{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},fN=class extends HD{static get type(){return`InspectorNode`}constructor(e,t=``,n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=ND.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==dN&&sn(`TSL: ".toInspector()" is only available with WebGPU.`),t}};function pN(e,t=``,n=null){return e=FO(e),e.before(new fN(e,t,n))}W(`toInspector`,pN);function mN(e){R(`TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var hN=class extends HD{static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage===`vertex`?e.format(a.name,i,n):hM(this).build(e,n)}else return R(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},gN=(e,t=null)=>new hN(e,t),_N=(e=0)=>gN(`uv`+(e>0?e:``),`vec2`),vN=zO(class extends HD{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),yN=zO(class extends nA{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=ND.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}}).setParameterLength(1),bN=class extends Error{constructor(e,t=null){super(e),this.name=`NodeError`,this.stackTrace=t}},xN=new rr,SN=class extends nA{static get type(){return`TextureNode`}constructor(e=xN,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ND.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?this.gatherNode===null?`float`:`vec4`:this.value.type===1014?`uvec4`:this.value.type===1013?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return _N(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=rA(this.value.matrix)),this._matrixUniform.mul(Y(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=rA(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(q(vN(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw new bN("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=G(()=>{let t=this.uvNode;return(t===null||e.context.forceUVContext===!0)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||=this.getDefaultUV(),this.updateMatrix===!0&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?ND.OBJECT:ND.NONE,t})(),i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(Qt.TEXTURE_COMPARE))a=this.compareNode;else{let e=n.compareFunction;e===null||e===513||e===515||e===516||e===518?o=this.compareNode:(a=this.compareNode,sn(`TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.`))}t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateOffset(e,t){return t.build(e,`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s,c,l,u){let d=this.value,f;return f=i?e.generateTextureBias(d,t,n,i,a,l):s?e.generateTextureGrad(d,t,n,s,a,l):c?o?e.generateTextureGatherCompare(d,t,n,o,a,l,u):e.generateTextureGather(d,t,n,c,a,l,u):o?e.generateTextureCompare(d,t,n,o,a,l):this.sampler===!1?e.generateTextureLoad(d,t,n,r,a,l):r?e.generateTextureLevel(d,t,n,r,a,l):e.generateTexture(d,t,n,a,l),f}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=this.getNodeType(e),s=a.propertyName;if(s===void 0){let{uvNode:t,levelNode:c,biasNode:l,compareNode:u,compareStepNode:d,depthNode:f,gradNode:p,gatherNode:m,offsetNode:h}=r,g=this.generateUV(e,t),_=c?c.build(e,`float`):null,v=l?l.build(e,`float`):null,y=f?f.build(e,`int`):null,b=u?u.build(e,`float`):null,x=d?d.build(e,`float`):null,S=p?[p[0].build(e,`vec2`),p[1].build(e,`vec2`)]:null,C=m?m.build(e,`int`):null,w=h?this.generateOffset(e,h):null,T=this._flipYUniform?this._flipYUniform.build(e,`bool`):null;C&&(o=`vec4`);let E=y;E===null&&n.isArrayTexture&&this.isTexture3DNode!==!0&&(E=`0`);let D=e.getVarFromNode(this);s=e.getPropertyName(D);let O=this.generateSnippet(e,i,g,_,v,E,b,S,C,w,T);if(x!==null){let t=n.compareFunction;O=t===516||t===518?Dj(rN(O,o),rN(x,`float`)).build(e,o):Dj(rN(x,`float`),rN(O,o)).build(e,o)}e.addLineFlowCode(`${s} = ${O}`,this),a.snippet=O,a.propertyName=s}let c=s;return e.needsToWorkingColorSpace(n)&&(c=CM(rN(c,o),n.colorSpace).setup(e).build(e,o)),e.format(c,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=FO(e),t.referenceNode=this.getBase(),FO(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=FO(e).mul(yN(t)),t.referenceNode=this.getBase();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===1003||n.magFilter===1003)&&(R(`TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),FO(t)}level(e){let t=this.clone();return t.levelNode=FO(e),t.referenceNode=this.getBase(),FO(t)}size(e){return vN(this,e)}bias(e){let t=this.clone();return t.biasNode=FO(e),t.referenceNode=this.getBase(),FO(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=FO(e),t.referenceNode=this.getBase(),FO(t)}grad(e,t){let n=this.clone();return n.gradNode=[FO(e),FO(t)],n.referenceNode=this.getBase(),FO(n)}gather(e=0){let t=this.clone();return t.gatherNode=FO(e),t.referenceNode=this.getBase(),FO(t)}depth(e){let t=this.clone();return t.depthNode=FO(e),t.referenceNode=this.getBase(),FO(t)}offset(e){let t=this.clone();return t.offsetNode=FO(e),t.referenceNode=this.getBase(),FO(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},CN=zO(SN).setParameterLength(1,4).setName(`texture`),wN=(e=xN,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=FO(e.clone()),i.referenceNode=e.getBase(),t!==null&&(i.uvNode=FO(t)),n!==null&&(i.levelNode=FO(n)),r!==null&&(i.biasNode=FO(r))):i=CN(e,t,n,r),i},TN=(e=xN)=>wN(e),EN=(...e)=>wN(...e).setSampler(!1),DN=(e,t,n)=>wN(e,t).level(n),ON=e=>(e.isNode===!0?e:wN(e)).convert(`sampler`),kN=e=>(e.isNode===!0?e:wN(e)).convert(`samplerComparison`),AN=class extends nA{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}},jN=(e,t,n)=>new AN(e,t,n),MN=class extends UD{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(e),r=this.node.getPaddedType();return e.format(t,r,n)}},NN=class extends AN{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?DD(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ND.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;nnew NN(e,t),FN=zO(class extends HD{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),IN,LN,RN=class e extends HD{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===e.DPR?`float`:this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=ND.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT||this.scope===e.DPR)&&(t=ND.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(LN),LN.multiplyScalar(t.getPixelRatio())):LN.copy(n.viewport):this.scope===e.DPR?this._output.value=t.getPixelRatio():n===null?t.getDrawingBufferSize(IN):(IN.width=n.width,IN.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?rA(IN||=new B):t===e.VIEWPORT?rA(LN||=new ir):t===e.DPR?rA(1):QO(HN.div(VN)),this._output=n,n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(VN).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};RN.COORDINATE=`coordinate`,RN.VIEWPORT=`viewport`,RN.SIZE=`size`,RN.UV=`uv`,RN.DPR=`dpr`;var zN=BO(RN,RN.DPR),BN=BO(RN,RN.UV),VN=BO(RN,RN.SIZE),HN=BO(RN,RN.COORDINATE),UN=BO(RN,RN.VIEWPORT),WN=UN.zw,GN=HN.sub(UN.xy),KN=GN.div(WN),qN=G(()=>(R(`TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`,new gD),VN),`vec2`).once()(),JN=null,YN=null,XN=null,ZN=null,QN=null,$N=null,eP=null,tP=null,nP=null,rP=null,iP=null,aP=null,oP=null,sP=null,cP=rA(0,`uint`).setName(`u_cameraIndex`).setGroup(Qk(`cameraIndex`)).toVarying(`v_cameraIndex`),lP=rA(`float`).setName(`cameraNear`).setGroup(eA).onRenderUpdate(({camera:e})=>e.near),uP=rA(`float`).setName(`cameraFar`).setGroup(eA).onRenderUpdate(({camera:e})=>e.far),dP=G(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);YN===null?YN=PN(n).setGroup(eA).setName(`cameraProjectionMatrices`):YN.array=n,t=YN.element(e.isMultiViewCamera?FN(`gl_ViewID_OVR`):cP)}else JN===null&&(JN=rA(e.projectionMatrix).setName(`cameraProjectionMatrix`).setGroup(eA).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=JN;return t}).once()(),fP=G(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);ZN===null?ZN=PN(n).setGroup(eA).setName(`cameraProjectionMatricesInverse`):ZN.array=n,t=ZN.element(e.isMultiViewCamera?FN(`gl_ViewID_OVR`):cP)}else XN===null&&(XN=rA(e.projectionMatrixInverse).setName(`cameraProjectionMatrixInverse`).setGroup(eA).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=XN;return t}).once()(),pP=G(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);$N===null?$N=PN(n).setGroup(eA).setName(`cameraViewMatrices`):$N.array=n,t=$N.element(e.isMultiViewCamera?FN(`gl_ViewID_OVR`):cP)}else QN===null&&(QN=rA(e.matrixWorldInverse).setName(`cameraViewMatrix`).setGroup(eA).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=QN;return t}).once()(),mP=G(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorld);tP===null?tP=PN(n).setGroup(eA).setName(`cameraWorldMatrices`):tP.array=n,t=tP.element(e.isMultiViewCamera?FN(`gl_ViewID_OVR`):cP)}else eP===null&&(eP=rA(e.matrixWorld).setName(`cameraWorldMatrix`).setGroup(eA).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=eP;return t}).once()(),hP=G(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.normalMatrix);rP===null?rP=PN(n).setGroup(eA).setName(`cameraNormalMatrices`):rP.array=n,t=rP.element(e.isMultiViewCamera?FN(`gl_ViewID_OVR`):cP)}else nP===null&&(nP=rA(e.normalMatrix).setName(`cameraNormalMatrix`).setGroup(eA).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=nP;return t}).once()(),gP=G(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t=0,r=e.cameras.length;t{let n=e.cameras,r=t.array;for(let e=0,t=n.length;et.value.setFromMatrixPosition(e.matrixWorld))),t=iP;return t}).once()(),_P=G(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.viewport);sP===null?sP=PN(n,`vec4`).setGroup(eA).setName(`cameraViewports`):sP.array=n,t=sP.element(cP)}else oP===null&&(oP=ak(0,0,VN.x,VN.y).toConst(`cameraViewport`)),t=oP;return t}).once()(),vP=new Ii,yP=class e extends HD{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ND.OBJECT,this.uniformNode=new nA(null)}generateNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new V,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new V,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),vP.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=vP.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};yP.WORLD_MATRIX=`worldMatrix`,yP.POSITION=`position`,yP.SCALE=`scale`,yP.VIEW_POSITION=`viewPosition`,yP.DIRECTION=`direction`,yP.RADIUS=`radius`;var bP=zO(yP,yP.DIRECTION).setParameterLength(1),xP=zO(yP,yP.WORLD_MATRIX).setParameterLength(1),SP=zO(yP,yP.POSITION).setParameterLength(1),CP=zO(yP,yP.SCALE).setParameterLength(1),wP=zO(yP,yP.VIEW_POSITION).setParameterLength(1),TP=zO(yP,yP.RADIUS).setParameterLength(1),EP=class extends yP{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},DP=BO(EP,EP.DIRECTION),OP=BO(EP,EP.WORLD_MATRIX),kP=BO(EP,EP.POSITION),AP=BO(EP,EP.SCALE),jP=BO(EP,EP.VIEW_POSITION),MP=BO(EP,EP.RADIUS),NP=rA(new Hn).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),PP=rA(new lr).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),FP=G(e=>e.context.modelViewMatrix||IP).once()().toVar(`modelViewMatrix`),IP=pP.mul(OP),LP=G(e=>(e.context.isHighPrecisionModelViewMatrix=!0,rA(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),RP=G(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return rA(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),zP=G(e=>e.shaderStage===`fragment`?e.context.clipSpace.toVarying(`v_clipSpace`):(sn("TSL: `clipSpace` is only available in fragment stage."),ak())).once()(),BP=gN(`position`,`vec3`),VP=BP.toVarying(`positionLocal`),HP=BP.toVarying(`positionPrevious`),UP=G(e=>OP.mul(VP).xyz.toVarying(e.getSubBuildProperty(`v_positionWorld`)),`vec3`).once([`POSITION`])(),WP=G(()=>VP.transformDirection(OP).toVarying(`v_positionWorldDirection`).normalize().toVar(`positionWorldDirection`),`vec3`).once([`POSITION`])(),GP=G(e=>{if(e.shaderStage===`fragment`&&e.material.vertexNode){let e=fP.mul(zP);return e.xyz.div(e.w).toVar(`positionView`)}return e.context.setupPositionView().toVarying(`v_positionView`)},`vec3`).once([`POSITION`,`VERTEX`])(),KP=G(e=>{let t;return t=e.camera.isOrthographicCamera?Y(0,0,1):GP.negate().toVarying(`v_positionViewDirection`).normalize(),t.toVar(`positionViewDirection`)},`vec3`).once([`POSITION`])(),qP=BO(class extends HD{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!==`fragment`)return`true`;let{material:t}=e;return t.side===1?`false`:e.getFrontFacing()}}),JP=K(qP).mul(2).sub(1),YP=G(([e],{material:t})=>{let n=t.side;return n===1?e=e.mul(-1):n===2&&(e=e.mul(JP)),e}),XP=e=>(sn(`TSL: "directionToFaceDirection()" has been renamed to "negateOnBackSide()".`),YP(e)),ZP=gN(`normal`,`vec3`),QP=G(e=>e.geometry.hasAttribute(`normal`)===!1?(R(`TSL: Vertex attribute "normal" not found on geometry.`),Y(0,1,0)):ZP,`vec3`).once()().toVar(`normalLocal`),$P=GP.dFdx().cross(GP.dFdy()).normalize().toVar(`normalFlat`),eF=G(e=>{let t;return t=e.isFlatShading()?$P:oF(QP).toVarying(`v_normalViewGeometry`).normalize(),t},`vec3`).once()().toVar(`normalViewGeometry`),tF=G(e=>{let t=eF.transformNormalByInverseViewMatrix(pP);return e.isFlatShading()!==!0&&(t=t.toVarying(`v_normalWorldGeometry`)),t.normalize().toVar(`normalWorldGeometry`)},`vec3`).once()(),nF=G(e=>{let t;return e.subBuildFn===`NORMAL`||e.subBuildFn===`VERTEX`?(t=eF,e.isFlatShading()!==!0&&(t=YP(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`normalView`),rF=nF.transformNormalByInverseViewMatrix(pP).toVar(`normalWorld`),iF=G(({subBuildFn:e,context:t})=>{let n;return n=e===`NORMAL`||e===`VERTEX`?nF:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),n},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`clearcoatNormalView`),aF=G(([e,t=OP])=>uk(t).inverse().transpose().mul(e).normalize());W(`transformNormal`,aF);var oF=G(([e],t)=>{let n=t.context.modelNormalViewMatrix;return n?e.transformNormalByViewMatrix(n):NP.mul(e).transformNormalByViewMatrix(pP)}),sF=G(()=>(R(`TSL: "transformedNormalView" is deprecated. Use "normalView" instead.`),nF)).once([`NORMAL`,`VERTEX`])(),cF=G(()=>(R(`TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.`),rF)).once([`NORMAL`,`VERTEX`])(),lF=G(()=>(R(`TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.`),iF)).once([`NORMAL`,`VERTEX`])(),uF=new lr,dF=rA(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),fF=rA(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),pF=rA(new lr).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=(t.environment!==null||t.environmentNode&&t.environmentNode.isNode)&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?uF.makeRotationFromEuler(n).transpose():uF.identity(),uF}),mF=KP.negate().reflect(nF),hF=KP.negate().refract(nF,dF),gF=mF.transformDirection(mP).toVar(`reflectVector`),_F=hF.transformDirection(mP).toVar(`refractVector`),vF=new $a,yF=zO(class extends SN{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?`cubeDepthTexture`:`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===301?gF:e.mapping===302?_F:(z(`CubeTextureNode: Mapping "%s" not supported.`,e.mapping),Y(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===2001?Y(t.x,t.y.negate(),t.z):t:(t=pF.mul(t),(e.renderer.coordinateSystem===2001||!n.isRenderTargetTexture)&&(t=Y(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}}).setParameterLength(1,4).setName(`cubeTexture`),bF=(e=vF,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=FO(e.clone()),i.referenceNode=e,t!==null&&(i.uvNode=FO(t)),n!==null&&(i.levelNode=FO(n)),r!==null&&(i.biasNode=FO(r))):i=yF(e,t,n,r),i},xF=(e=vF)=>yF(e),SF=class extends UD{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(e),r=this.getNodeType(e);return e.format(t,n,r)}},CF=class extends HD{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=ND.OBJECT}element(e){return new SF(this,FO(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`),this.setName(e)}setNodeType(e){let t=null;this.count===null?Array.isArray(this.getValueFromReference())?(t=PN(null,e),t.updateType=ND.OBJECT):t=e===`texture`?wN(null):e===`cubeTexture`?bF(null):rA(null,e):t=jN(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;enew CF(e,t,n),TF=(e,t,n,r)=>new CF(e,t,r,n),EF=class extends CF{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},DF=(e,t,n=null)=>new EF(e,t,n),OF=_N(),kF=GP.dFdx(),AF=GP.dFdy(),jF=OF.dFdx(),MF=OF.dFdy(),NF=nF,PF=AF.cross(NF),FF=NF.cross(kF),IF=PF.mul(jF.x).add(FF.mul(MF.x)),LF=PF.mul(jF.y).add(FF.mul(MF.y)),RF=IF.dot(IF).max(LF.dot(LF)),zF=RF.equal(0).select(0,RF.inverseSqrt()),qee=IF.mul(zF).toVar(`tangentViewFrame`),Jee=LF.mul(zF).toVar(`bitangentViewFrame`),BF=gN(`tangent`,`vec4`),VF=BF.xyz.toVar(`tangentLocal`),HF=G(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?FP.mul(ak(VF,0)).xyz.toVarying(`v_tangentView`).normalize():qee,e.isFlatShading()!==!0&&(t=YP(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`tangentView`),UF=HF.transformDirection(mP).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),WF=G(([e,t],n)=>{let r=e.mul(BF.w).xyz;return n.subBuildFn===`NORMAL`&&n.isFlatShading()!==!0&&(r=r.toVarying(t)),r}).once([`NORMAL`]),Yee=WF(ZP.cross(BF),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),Xee=WF(QP.cross(VF),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),GF=G(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?WF(nF.cross(HF),`v_bitangentView`).normalize():Jee,e.isFlatShading()!==!0&&(t=YP(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`bitangentView`),Zee=WF(rF.cross(UF),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),KF=uk(HF,GF,nF).toVar(`TBNViewMatrix`),qF=KP.mul(KF),Qee=(e,t)=>e.sub(qF.mul(t)),JF=G(()=>{let e=Pk.cross(KP);return e=e.cross(Pk).normalize(),e=Hj(e,nF,Mk.mul(Sk.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),YF=e=>FO(e).mul(.5).add(.5),XF=e=>FO(e).mul(2).sub(1),ZF=e=>Y(e,qA(Wj(K(1).sub(jj(e,e))))),$ee=e=>(sn(`TSL: "directionToColor()" has been renamed to "packNormalToRGB()".`),YF(e)),QF=e=>(sn(`TSL: "colorToDirection()" has been renamed to "unpackRGBToNormal()".`),XF(e)),$F=zO(class extends GD{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=``}setup(e){let{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this,i=this.node.mul(2).sub(1);if(t===0?r===`rg`?i=ZF(i.xy):r===`ga`?i=ZF(i.yw):r!==``&&z(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==``&&z(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let t=n;e.isFlatShading()===!0&&(t=YP(t)),i=Y(i.xy.mul(t),i.z)}let a=null;return t===1?a=oF(i):t===0?a=KF.mul(i).normalize():(z(`NodeMaterial: Unsupported normal map type: ${t}`),a=nF),a}}).setParameterLength(1,2),eI=G(({textureNode:e,bumpScale:t})=>{let n=t=>e.isolate().context({getUV:e=>t(e.uvNode||_N()),forceUVContext:!0}),r=K(n(e=>e));return QO(K(n(e=>e.add(e.dFdx()))).sub(r),K(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),tI=G(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(JP),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()}),nI=zO(class extends GD{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(e){if(e.material.wireframe===!0)return nF;let t=this.scaleNode===null?1:this.scaleNode;return tI({surf_pos:GP,surf_norm:nF,dHdxy:eI({textureNode:this.textureNode,bumpScale:t})})}}).setParameterLength(1,2),rI=new Map,iI=class e extends HD{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=rI.get(e);return n===void 0&&(n=DF(e,t),rI.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?Y():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:K(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=$F(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType,(n.normalMap.format==1030||n.normalMap.format==36285||n.normalMap.format==37490)&&(i.unpackNormalMode=`rg`)):i=n.bumpMap?nI(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):nF;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?$F(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):nF;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(1e-4,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r);i=lk(HI.x,HI.y,HI.y.negate(),HI.x).mul(e.rg.mul(2).sub(QO(1)).normalize().mul(e.b))}else i=HI;else if(r===e.IRIDESCENCE_THICKNESS){let e=wF(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=wF(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=n.lightMap?this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`)):Y(0);else if(r===e.AO)i=n.aoMap?this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1):K(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):K(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};iI.ALPHA_TEST=`alphaTest`,iI.COLOR=`color`,iI.OPACITY=`opacity`,iI.SHININESS=`shininess`,iI.SPECULAR=`specular`,iI.SPECULAR_STRENGTH=`specularStrength`,iI.SPECULAR_INTENSITY=`specularIntensity`,iI.SPECULAR_COLOR=`specularColor`,iI.REFLECTIVITY=`reflectivity`,iI.ROUGHNESS=`roughness`,iI.METALNESS=`metalness`,iI.NORMAL=`normal`,iI.CLEARCOAT=`clearcoat`,iI.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,iI.CLEARCOAT_NORMAL=`clearcoatNormal`,iI.EMISSIVE=`emissive`,iI.ROTATION=`rotation`,iI.SHEEN=`sheen`,iI.SHEEN_ROUGHNESS=`sheenRoughness`,iI.ANISOTROPY=`anisotropy`,iI.IRIDESCENCE=`iridescence`,iI.IRIDESCENCE_IOR=`iridescenceIOR`,iI.IRIDESCENCE_THICKNESS=`iridescenceThickness`,iI.IOR=`ior`,iI.TRANSMISSION=`transmission`,iI.THICKNESS=`thickness`,iI.ATTENUATION_DISTANCE=`attenuationDistance`,iI.ATTENUATION_COLOR=`attenuationColor`,iI.LINE_SCALE=`scale`,iI.LINE_DASH_SIZE=`dashSize`,iI.LINE_GAP_SIZE=`gapSize`,iI.LINE_WIDTH=`linewidth`,iI.LINE_DASH_OFFSET=`dashOffset`,iI.POINT_SIZE=`size`,iI.DISPERSION=`dispersion`,iI.LIGHT_MAP=`light`,iI.AO=`ao`;var aI=BO(iI,iI.ALPHA_TEST),oI=BO(iI,iI.COLOR),sI=BO(iI,iI.SHININESS),cI=BO(iI,iI.EMISSIVE),lI=BO(iI,iI.OPACITY),uI=BO(iI,iI.SPECULAR),dI=BO(iI,iI.SPECULAR_INTENSITY),fI=BO(iI,iI.SPECULAR_COLOR),pI=BO(iI,iI.SPECULAR_STRENGTH),mI=BO(iI,iI.REFLECTIVITY),hI=BO(iI,iI.ROUGHNESS),gI=BO(iI,iI.METALNESS),_I=BO(iI,iI.NORMAL),vI=BO(iI,iI.CLEARCOAT),yI=BO(iI,iI.CLEARCOAT_ROUGHNESS),bI=BO(iI,iI.CLEARCOAT_NORMAL),xI=BO(iI,iI.ROTATION),SI=BO(iI,iI.SHEEN),CI=BO(iI,iI.SHEEN_ROUGHNESS),wI=BO(iI,iI.ANISOTROPY),TI=BO(iI,iI.IRIDESCENCE),EI=BO(iI,iI.IRIDESCENCE_IOR),DI=BO(iI,iI.IRIDESCENCE_THICKNESS),OI=BO(iI,iI.TRANSMISSION),kI=BO(iI,iI.THICKNESS),AI=BO(iI,iI.IOR),jI=BO(iI,iI.ATTENUATION_DISTANCE),MI=BO(iI,iI.ATTENUATION_COLOR),NI=BO(iI,iI.LINE_SCALE),PI=BO(iI,iI.LINE_DASH_SIZE),FI=BO(iI,iI.LINE_GAP_SIZE),II=BO(iI,iI.LINE_WIDTH),LI=BO(iI,iI.LINE_DASH_OFFSET),RI=BO(iI,iI.POINT_SIZE),zI=BO(iI,iI.DISPERSION),BI=BO(iI,iI.LIGHT_MAP),VI=BO(iI,iI.AO),HI=rA(new B).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),UI=G(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`),WI=class e extends HD{static get type(){return`EventNode`}constructor(t,n){super(`void`),this.eventType=t,this.callback=n,t===e.OBJECT?this.updateType=ND.OBJECT:t===e.MATERIAL?this.updateType=ND.RENDER:t===e.FRAME?this.updateType=ND.FRAME:t===e.BEFORE_OBJECT?this.updateBeforeType=ND.OBJECT:t===e.BEFORE_MATERIAL?this.updateBeforeType=ND.RENDER:t===e.BEFORE_FRAME&&(this.updateBeforeType=ND.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}};WI.OBJECT=`object`,WI.MATERIAL=`material`,WI.FRAME=`frame`,WI.BEFORE_OBJECT=`beforeObject`,WI.BEFORE_MATERIAL=`beforeMaterial`,WI.BEFORE_FRAME=`beforeFrame`;var GI=(e,t)=>new WI(e,t).toStack(),KI=e=>GI(WI.OBJECT,e),qI=e=>GI(WI.MATERIAL,e),JI=e=>GI(WI.FRAME,e),YI=e=>GI(WI.BEFORE_OBJECT,e),XI=e=>GI(WI.BEFORE_MATERIAL,e),ZI=e=>GI(WI.BEFORE_FRAME,e),QI=zO(class extends UD{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.isContextAssign();if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}}).setParameterLength(2),$I=class extends AN{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStructTypeNode?(r=`struct`,i=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=SD(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=FD.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let n=e.globalCache.getData(this.value);n===void 0&&(n={node:this},e.globalCache.setData(this.value,n)),t=n.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return QI(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(FD.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=LM(this.value),this._varying=hM(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generateNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}},eL=(e,t=null,n=0)=>new $I(e,t,n),tL=new WeakMap,nL=new WeakMap,rL=new WeakMap;function iL(e,t){let n,r=Math.max(t.count,1);if(t.isStorageInstancedBufferAttribute===!0)n=eL(t,`mat4`,r).element(UM);else if(r*16*4<=e.getUniformBufferLimit())n=jN(t.array,`mat4`,r).element(UM);else{let e=tL.get(t);e||(e=new sl(t.array,16,1),tL.set(t,e));let r=t.usage===35048?BM:zM;n=dk(r(e,`vec4`,16,0),r(e,`vec4`,16,4),r(e,`vec4`,16,8),r(e,`vec4`,16,12))}return n}function aL(e,t,n){let r=rL.get(e);if(r===void 0){let i=t.clone();r={previousInstanceMatrix:i,node:iL(n,i)},rL.set(e,r)}return r.node}var oL=vk(`vec3`,`vInstanceColor`),sL=G(([e,t=null],n)=>{let r=e.isStorageInstancedBufferAttribute===!0,i=t&&t.isStorageInstancedBufferAttribute===!0,a=iL(n,e),o=null;r||Math.max(e.count,1)*16*4>n.getUniformBufferLimit()&&(o=tL.get(e));let s=null,c=null;if(t)if(i)s=eL(t,`vec3`,Math.max(t.count,1)).element(UM);else{let e=nL.get(t);e||(e=new xa(t.array,3),nL.set(t,e)),c=e,s=Y((t.usage===35048?BM:zM)(e,`vec3`,3,0))}(o!==null||c!==null)&&JI(()=>{o!==null&&(o.clearUpdateRanges(),o.updateRanges.push(...e.updateRanges),e.version!==o.version&&(o.version=e.version)),t&&c!==null&&(c.clearUpdateRanges(),c.updateRanges.push(...t.updateRanges),t.version!==c.version&&(c.version=t.version))});let l=a.mul(VP).xyz;if(VP.assign(l),n.needsPreviousData()){let t=n.object;KI(({object:t})=>{rL.get(t).previousInstanceMatrix.array.set(e.array)});let r=aL(t,e,n);HP.assign(r.mul(HP).xyz)}if(n.hasGeometryAttribute(`normal`)){let e=aF(QP,a);QP.assign(e)}s!==null&&oL.assign(s)},`void`),cL=G(([e])=>{let{instanceMatrix:t,instanceColor:n}=e;sL(t,n)},`void`),lL=G(([e,t])=>{let n=q(vN(EN(e),0).x).toConst(),r=q(t);return EN(e,$O(r.mod(n).toConst(),r.div(n).toConst()))}),uL=G(([e,t])=>{let n=q(vN(EN(e),0).x).toConst();return EN(e,$O(q(t).mod(n).toConst(),q(t).div(n).toConst())).x}),dL=vk(`vec4`,`vBatchColor`),fL=G(([e],t)=>{let n=t.getDrawIndex()===null?UM:qM,r=uL(e._indirectTexture,q(n)),i=e._matricesTexture,a=q(vN(EN(i),0).x).toConst(),o=K(r).mul(4).toInt().toConst(),s=o.mod(a).toConst(),c=o.div(a).toConst(),l=dk(EN(i,$O(s,c)),EN(i,$O(s.add(1),c)),EN(i,$O(s.add(2),c)),EN(i,$O(s.add(3),c))),u=e._colorsTexture;if(u!==null){let e=lL(u,r);dL.assign(e)}let d=uk(l);VP.assign(l.mul(VP));let f=QP.div(Y(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),p=d.mul(f).xyz;QP.assign(p),t.hasGeometryAttribute(`tangent`)&&VF.mulAssign(d)},`void`),pL=new WeakMap,mL=new WeakMap;function hL(e,t,n,r,i,a){let o=e.element(i.x),s=e.element(i.y),c=e.element(i.z),l=e.element(i.w),u=n.mul(t),d=lA(o.mul(a.x).mul(u),s.mul(a.y).mul(u),c.mul(a.z).mul(u),l.mul(a.w).mul(u));return r.mul(d).xyz}function gL(e,t,n,r,i,a,o){let s=e.element(a.x),c=e.element(a.y),l=e.element(a.z),u=e.element(a.w),d=lA(o.x.mul(s),o.y.mul(c),o.z.mul(l),o.w.mul(u));return d=i.mul(d).mul(r),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(n).xyz}}function _L(e,t,n,r,i){let a=e.skeleton,o=mL.get(a);if(o===void 0){a.update();let e=new Float32Array(a.boneMatrices);o={previousBoneMatrices:e,node:jN(e,`mat4`,a.bones.length)},mL.set(a,o)}return hL(o.node,HP,t,n,r,i)}var vL=G(([e],t)=>{let n=gN(`skinIndex`,`uvec4`),r=gN(`skinWeight`,`vec4`),i=wF(`bindMatrix`,`mat4`),a=wF(`bindMatrixInverse`,`mat4`),o=TF(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length);if(KI(({object:e,frameId:t})=>{let n=e.skeleton;if(pL.get(n)!==t){pL.set(n,t);let e=mL.get(n);e!==void 0&&e.previousBoneMatrices.set(n.boneMatrices),n.update()}}),t.needsPreviousData()){let t=_L(e,i,a,n,r);HP.assign(t)}let s=hL(o,VP,i,a,n,r);if(VP.assign(s),t.hasGeometryAttribute(`normal`)){let{skinNormal:e,skinTangent:s}=gL(o,QP,VF,i,a,n,r);QP.assign(e),t.hasGeometryAttribute(`tangent`)&&VF.assign(s)}},`void`),yL=G(([e,t=null],n)=>{let r=eL(new xa(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(UM).toVar(),i=eL(new xa(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(UM).toVar(),a=eL(new xa(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(UM).toVar(),o=rA(e.bindMatrix,`mat4`),s=rA(e.bindMatrixInverse,`mat4`),c=jN(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),l=e.skeleton;if(KI(({frameId:e})=>{if(pL.get(l)!==e){pL.set(l,e);let t=mL.get(l);t!==void 0&&t.previousBoneMatrices.set(l.boneMatrices),l.update()}}),n.needsPreviousData()){let t=_L(e,o,s,i,a);HP.assign(t)}let u=hL(c,r,o,s,i,a);if(t!==null&&t.assign(u),n.hasGeometryAttribute(`normal`)){let{skinNormal:e,skinTangent:t}=gL(c,QP,VF,o,s,i,a);QP.assign(e),n.hasGeometryAttribute(`tangent`)&&VF.assign(t)}return u}),bL=class extends HD{static get type(){return`LoopNode`}constructor(e=[]){super(`void`),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:a=e.flowStagesNode(t.updateNode,`void`).code.replace(/\t|;/g,``);break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(z(`TSL: 'Loop( { update: ... } )' is not a function, string or number.`,this.stackTrace),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;f=`for ( ${e.getVar(l,c)+` = `+r}; ${c+` `+u+` `+i}; ${a} )`}e.addFlowCode((r===0?` +`:``)+e.tab+f+` { + +`).addFlowTab()}let i=r.build(e,`void`);t.returnsNode.build(e,`void`),e.removeFlowTab().addFlowCode(` +`+e.tab+i);for(let t=0,n=this.params.length-1;tnew bL(RO(e,`int`)).toStack(),SL=()=>rN(`continue`).toStack(),CL=()=>rN(`break`).toStack(),wL=new WeakMap,TL=new ir,EL=new WeakMap,DL=G(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=q(HM).mul(n).add(a),s=o.div(r);return EN(e,$O(o.sub(s.mul(r)),s)).depth(i).xyz.mul(t)});function OL(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=wL.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new sr(p,u,d,a);m.type=ke,m.needsUpdate=!0;let h=l*4;for(let e=0;e{let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length;if(a===0)return;let o=EL.get(e);(o===void 0||o.count!==a)&&(o={base:rA(1),influences:e.morphTargetInfluences?PN(e.morphTargetInfluences,`float`):null,count:a},EL.set(e,o));let{base:s,influences:c}=o,{texture:l,stride:u,size:d}=OL(t);n===!0&&VP.mulAssign(s),r===!0&&QP.mulAssign(s);let f=q(d.width);xL(a,({i:t})=>{let i=K(0).toVar();e.count>1&&e.morphTexture!==null&&e.morphTexture!==void 0?i.assign(EN(e.morphTexture,$O(q(t).add(1),q(UM))).r):i.assign(c.element(t).toVar()),qO(i.notEqual(0),()=>{n===!0&&VP.addAssign(DL({bufferMap:l,influence:i,stride:u,width:f,depth:t,offset:q(0)})),r===!0&&QP.addAssign(DL({bufferMap:l,influence:i,stride:u,width:f,depth:t,offset:q(1)}))})}),KI(({object:e})=>{let{base:t,influences:n}=o;e.geometry.morphTargetsRelative?t.value=1:t.value=1-e.morphTargetInfluences.reduce((e,t)=>e+t,0),n&&(n.array=e.morphTargetInfluences,n.update())})},`void`),AL=class extends HD{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},jL=class extends AL{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},ML=zO(class extends tM{static get type(){return`LightingContextNode`}constructor(e,t=null,n=[],r=null,i=null){super(e),this.lightingModel=t,this.materialLightings=n,this.backdropNode=r,this.backdropAlphaNode=i,this._value=null}getContext(){let{materialLightings:e,backdropNode:t,backdropAlphaNode:n}=this,r={directDiffuse:Y().toVar(`directDiffuse`),directSpecular:Y().toVar(`directSpecular`),indirectDiffuse:Y().toVar(`indirectDiffuse`),indirectSpecular:Y().toVar(`indirectSpecular`)};return{radiance:Y().toVar(`radiance`),irradiance:Y().toVar(`irradiance`),iblIrradiance:Y().toVar(`iblIrradiance`),ambientOcclusion:K(1).toVar(`ambientOcclusion`),reflectedLight:r,materialLightings:e,backdrop:t,backdropAlpha:n}}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),NL=class extends AL{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},PL=new B,FL=class extends SN{static get type(){return`ViewportTextureNode`}constructor(e=BN,t=null,n=null){let r=null;n===null?(r=new Qa,r.minFilter=Se,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=ND.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){let r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){let t=e.renderer,n=t.getRenderTarget(),r=t.getCanvasTarget(),i=n||r;return this.value=this.getTextureForReference(i),this.value}updateBefore(e){let t=e.renderer,n=t.getRenderTarget(),r=t.getCanvasTarget(),i=n||r;i===null?t.getDrawingBufferSize(PL):i.getDrawingBufferSize?i.getDrawingBufferSize(PL):PL.set(i.width,i.height);let a=this.getTextureForReference(i);(a.image.width!==PL.width||a.image.height!==PL.height)&&(a.image.width=PL.width,a.image.height=PL.height,a.needsUpdate=!0);let o=a.generateMipmaps;a.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(a),a.generateMipmaps=o}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},IL=zO(FL).setParameterLength(0,3),LL=zO(FL,null,null,{generateMipmaps:!0}).setParameterLength(0,3),RL=LL(),zL=(e=BN,t=null)=>RL.sample(e,t),BL=null,VL=zO(class extends FL{static get type(){return`ViewportDepthTextureNode`}constructor(e=BN,t=null,n=null){n===null&&(BL===null&&(BL=new eo),n=BL),super(e,t,n)}}).setParameterLength(0,3),HL=class e extends HD{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;return n===e.DEPTH_BASE?r!==null&&(i=ZL().assign(r)):n===e.DEPTH?i=t.isPerspectiveCamera?KL(GP.z,lP,uP):UL(GP.z,lP,uP):n===e.LINEAR_DEPTH&&(i=r===null?UL(GP.z,lP,uP):t.isPerspectiveCamera?UL(JL(r,lP,uP),lP,uP):r),i}};HL.DEPTH_BASE=`depthBase`,HL.DEPTH=`depth`,HL.LINEAR_DEPTH=`linearDepth`;var UL=(e,t,n)=>e.add(t).div(t.sub(n)),WL=(e,t,n)=>e.add(n).div(n.sub(t)),GL=G(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?n.sub(t).mul(e).sub(n):t.sub(n).mul(e).sub(t)),KL=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),qL=(e,t,n)=>t.mul(e.add(n)).div(e.mul(t.sub(n))),JL=G(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?t.mul(n).div(t.sub(n).mul(e).sub(t)):t.mul(n).div(n.sub(t).mul(e).sub(n))),YL=(e,t,n)=>{t=t.max(1e-6).toVar();let r=KA(e.negate().div(t)),i=KA(n.div(t));return r.div(i)},XL=(e,t,n)=>{let r=e.mul(GA(n.div(t)));return K(Math.E).pow(r).mul(t).negate()},ZL=zO(HL,HL.DEPTH_BASE),QL=BO(HL,HL.DEPTH),$L=zO(HL,HL.LINEAR_DEPTH).setParameterLength(0,1),eR=$L(VL());QL.assign=e=>ZL(e);var tR=class e extends HD{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let{intersectionPlanes:n,unionPlanes:r}=t.clippingContext;return this.hardwareClipping=t.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===e.HARDWARE?this.setupHardwareClipping(r,t):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return G(()=>{let n=K().toVar(`distanceToPlane`),r=K().toVar(`distanceToGradient`),i=K(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=PN(t).setGroup(eA);xL(a,({i:t})=>{let a=e.element(t);n.assign(GP.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(Kj(r.negate(),r,n))})}let o=e.length;if(o>0){let t=PN(e).setGroup(eA),a=K(1).toVar(`intersectionClipOpacity`);xL(o,({i:e})=>{let i=t.element(e);n.assign(GP.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(Kj(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}yk.a.mulAssign(i),yk.a.equal(0).discard()})()}setupDefault(e,t){return G(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=PN(t).setGroup(eA);xL(n,({i:t})=>{let n=e.element(t);GP.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=PN(e).setGroup(eA),n=ZO(!0).toVar(`clipped`);xL(r,({i:e})=>{let r=t.element(e);n.assign(GP.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),G(()=>{let r=PN(e).setGroup(eA),i=FN(t.getClipDistance());xL(n,({i:e})=>{let t=r.element(e),n=GP.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};tR.ALPHA_TO_COVERAGE=`alphaToCoverage`,tR.DEFAULT=`default`,tR.HARDWARE=`hardware`;var nR=()=>new tR,rR=()=>new tR(tR.ALPHA_TO_COVERAGE),iR=()=>new tR(tR.HARDWARE),aR=.05,oR=G(([e])=>QA(dA(1e4,$A(dA(17,e.x).add(dA(.1,e.y)))).mul(lA(.1,dj($A(dA(13,e.y).add(e.x))))))),sR=G(([e])=>oR(QO(oR(e.xy),e.z))),cR=G(([e])=>{let t=Ej(pj(gj(e.xyz)),pj(_j(e.xyz))),n=K(1).div(K(aR).mul(t)).toVar(`pixScale`),r=QO(WA(YA(KA(n))),WA(XA(KA(n)))),i=QO(sR(YA(r.x.mul(e.xyz))),sR(YA(r.y.mul(e.xyz)))),a=QA(KA(n)),o=lA(dA(a.oneMinus(),i.x),dA(a,i.y)),s=Tj(a,a.oneMinus()),c=Y(o.mul(o).div(dA(2,s).mul(uA(1,s))),o.sub(dA(.5,s)).div(uA(1,s)),uA(1,uA(1,o).mul(uA(1,o)).div(dA(2,s).mul(uA(1,s)))));return Uj(o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z),1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]}),lR=class extends hN{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new ir(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},uR=(e=0)=>new lR(e),dR=class extends Yi{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith(`_`)===!0)continue;let n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:n}of this._getNodeChildren())e.push(vD(t.slice(0,-4)),n.getCacheKey());return this.type+yD(e)}build(e){this.setup(e)}setupObserver(e){return new pD(e)}setup(e){e.context.setupNormal=()=>mM(this.setupNormal(e),`NORMAL`,`vec3`),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=mM(this.vertexNode||r,`VERTEX`);e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.addToStack(o);let i=ak(r,yk.a).max(0);a=this.setupOutput(e,i),zk.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&zk.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=t.convert(e.getOutputType())),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?r=rR():e.stack.addToStack(nR())}return r}setupHardwareClipping(e){if(e.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.addToStack(iR()),e.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?YL(GP.z,lP,uP):UL(GP.z,lP,uP))}r!==null&&QL.assign(r).toStack()}setupPositionView(){return FP.mul(VP).xyz}setupModelViewProjection(){return dP.mul(GP)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),UI}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&kL(t),t.isSkinnedMesh===!0&&vL(t),this.displacementMap){let e=DF(`displacementMap`,`texture`),t=DF(`displacementScale`,`float`),n=DF(`displacementBias`,`float`);VP.addAssign(QP.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&fL(t),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&cL(t),this.positionNode!==null&&VP.assign(mM(this.positionNode,`POSITION`,`vec3`)),VP}setupDiffuseColor(e){let{object:t,geometry:n}=e;this.maskNode!==null&&ZO(this.maskNode).not().discard();let r=this.colorNode?ak(this.colorNode):oI;this.vertexColors===!0&&n.hasAttribute(`color`)&&(r=r.mul(uR())),t.instanceColor&&(r=oL.mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=dL.mul(r)),yk.assign(r);let i=this.opacityNode?K(this.opacityNode):lI;yk.a.assign(yk.a.mul(i));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode===null?aI:K(this.alphaTestNode),this.alphaToCoverage===!0?(yk.a=Kj(a,a.add(xj(yk.a)),yk.a),yk.a.lessThanEqual(0).discard()):yk.a.lessThanEqual(a).discard()),this.alphaHash===!0&&yk.a.lessThan(cR(VP)).discard(),e.isOpaque()&&yk.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Y(0):yk.rgb}setupNormal(){return this.normalNode?Y(this.normalNode):_I}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?DF(`envMap`,`cubeTexture`):DF(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new NL(BI)),t}setupMaterialLightings(e){let t=[];if(e.renderer.lighting.enabled===!1)return t;let n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);return r&&r.isLightingNode&&t.push(r),e.context.ambientOcclusion&&t.push(new jL(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;t===null&&e.material.aoMap&&(t=VI),e.context.getAO&&(t=e.context.getAO(t,e)),t!==null&&(Yk.assign(t),e.context.ambientOcclusion=Yk)}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=this.lights===!0?this.setupMaterialLightings(e):[],s=a?this.lightsNode||e.lightsNode:null,c=this.setupOutgoingLight(e);return s&&(o.length>0||s.getScope().hasLights)?c=ML(s,this.setupLightingModel(e)||null,o,n,r):n!==null&&(c=Y(r===null?n:Hj(c,n,r))),(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(xk.assign(Y(i||cI)),c=c.add(xk)),c}setupFog(e,t){let n=e.fogNode;return n&&(zk.assign(t),t=ak(n.toVar())),t}setupPremultipliedAlpha(e,t){return aN(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=Yi.prototype.toJSON.call(this,e);n.inputNodes={};for(let{property:t,childNode:r}of this._getNodeChildren())n.inputNodes[t]=r.toJSON(e).uuid;function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images),a=r(e.nodes);t.length>0&&(n.textures=t),i.length>0&&(n.images=i),a.length>0&&(n.nodes=a)}return n}copy(e){let t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(let n in t)if(t[n].set!==void 0&&e[n]!==void 0){let t=e[n];this[n]&&this[n].copy!==void 0?this[n].copy(t):this[n]=t}for(let t in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(t)&&this[t]!==void 0&&e[t]!==void 0){let n=e[t];this[t]&&this[t].copy!==void 0?this[t].copy(n):this[t]=n}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(e=>e.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}},fR=new Ma,pR=class extends dR{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(fR),this.setValues(e)}},mR=new Ys,hR=class extends dR{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(mR),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?K(this.offsetNode):LI,t=this.dashScaleNode?K(this.dashScaleNode):NI,n=this.dashSizeNode?K(this.dashSizeNode):PI,r=this.gapSizeNode?K(this.gapSizeNode):FI;Bk.assign(n),Vk.assign(r);let i=hM(gN(`lineDistance`).mul(t));(e?i.add(e):i).mod(Bk.add(Vk)).greaterThan(Bk).discard()}},gR=vk(`vec3`,`worldStart`),_R=vk(`vec3`,`worldEnd`),vR=vk(`float`,`lineDistance`),yR=vk(`vec4`,`worldPos`),bR=G(({start:e,end:t})=>{let n=dP.element(2).element(2),r=dP.element(3).element(2);return n.greaterThan(0).select(r.negate().div(n.add(1)),r.mul(-.5).div(n)).sub(e.z).div(t.z.sub(e.z))},{start:`vec4`,end:`vec4`,return:`float`}),xR=G(({p1:e,p2:t,p3:n,p4:r})=>{let i=e.sub(n),a=r.sub(n),o=t.sub(e),s=i.dot(a),c=a.dot(o),l=i.dot(o),u=a.dot(a),d=o.dot(o).mul(u).sub(c.mul(c)),f=s.mul(c).sub(l.mul(u)).div(d).clamp();return QO(f,s.add(c.mul(f)).div(u).clamp())},{p1:`vec3`,p2:`vec3`,p3:`vec3`,p4:`vec3`,return:`vec2`});G(({material:e})=>{let t=e._useDash,n=e._useWorldUnits,r=gN(`instanceStart`),i=gN(`instanceEnd`),a=ak(FP.mul(ak(r,1))).toVar(`start`),o=ak(FP.mul(ak(i,1))).toVar(`end`),s,c;t&&(s=K(gN(`instanceDistanceStart`)).toVar(`distanceStart`),c=K(gN(`instanceDistanceEnd`)).toVar(`distanceEnd`)),n&&(gR.assign(a.xyz),_R.assign(o.xyz));let l=UN.z.div(UN.w);if(qO(dP.element(2).element(3).equal(-1),()=>{qO(a.z.lessThan(0).and(o.z.greaterThan(0)),()=>{let e=bR({start:a,end:o});o.assign(ak(Hj(a.xyz,o.xyz,e),o.w)),t&&c.assign(Hj(s,c,e))}).ElseIf(o.z.lessThan(0).and(a.z.greaterThanEqual(0)),()=>{let e=bR({start:o,end:a});a.assign(ak(Hj(o.xyz,a.xyz,e),a.w)),t&&s.assign(Hj(c,s,e))})}),t){let t=e.dashScaleNode?K(e.dashScaleNode):NI,n=e.offsetNode?K(e.offsetNode):LI,r=BP.y.lessThan(.5).select(t.mul(s),t.mul(c));r=r.add(n),vR.assign(r)}let u=dP.mul(a),d=dP.mul(o),f=u.xyz.div(u.w),p=d.xyz.div(d.w),m=p.xy.sub(f.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());let h=ak().toVar();if(n){let e=o.xyz.sub(a.xyz).normalize(),n=Hj(a.xyz,o.xyz,.5).normalize(),r=e.cross(n).normalize(),i=e.cross(r);yR.assign(BP.y.lessThan(.5).select(a,o));let s=II.mul(.5);yR.addAssign(ak(BP.x.lessThan(0).select(r.mul(s),r.mul(s).negate()),0)),t||(yR.addAssign(ak(BP.y.lessThan(.5).select(e.mul(s).negate(),e.mul(s)),0)),yR.addAssign(ak(i.mul(s),0)),qO(BP.y.greaterThan(1).or(BP.y.lessThan(0)),()=>{yR.subAssign(ak(i.mul(2).mul(s),0))})),h.assign(dP.mul(yR));let c=Y().toVar();c.assign(BP.y.lessThan(.5).select(f,p)),h.z.assign(c.z.mul(h.w))}else{let e=QO(m.y,m.x.negate()).toVar(`offset`);m.x.assign(m.x.div(l)),e.x.assign(e.x.div(l)),e.assign(BP.x.lessThan(0).select(e.negate(),e)),qO(BP.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(BP.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul(II)),e.assign(e.div(UN.w.div(zN))),h.assign(BP.y.lessThan(.5).select(u,d)),e.assign(e.mul(h.w)),h.assign(h.add(ak(e,0,0)))}return h})(),G(({material:e,renderer:t})=>{let n=e._useAlphaToCoverage,r=e._useDash,i=e._useWorldUnits,a=_N();if(r){let t=e.dashSizeNode?K(e.dashSizeNode):PI,n=e.gapSizeNode?K(e.gapSizeNode):FI;Bk.assign(t),Vk.assign(n),a.y.lessThan(-1).or(a.y.greaterThan(1)).discard(),vR.mod(Bk.add(Vk)).greaterThan(Bk).discard()}let o=K(1).toVar(`alpha`);if(i){let e=yR.xyz.normalize().mul(1e5),i=_R.sub(gR),a=xR({p1:gR,p2:_R,p3:Y(0,0,0),p4:e}),s=gR.add(i.mul(a.x)),c=e.mul(a.y),l=s.sub(c).length().div(II);if(!r)if(n&&t.currentSamples>0){let e=l.fwidth();o.assign(Kj(e.negate().add(.5),e.add(.5),l).oneMinus())}else l.greaterThan(.5).discard()}else if(n&&t.currentSamples>0){let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1)),n=e.mul(e).add(t.mul(t)),r=K(n.fwidth()).toVar(`dlen`);qO(a.y.abs().greaterThan(1),()=>{o.assign(Kj(r.oneMinus(),r.add(1),n).oneMinus())})}else qO(a.y.abs().greaterThan(1),()=>{let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()});return o})();var SR=new Ws,CR=class extends dR{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(SR),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?K(this.opacityNode):lI;yk.assign(CM(ak(YF(nF),e),It))}},wR=G(([e=WP])=>QO(e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))),TR=G(([e=_N()])=>{let t=e.x.sub(.5).mul(Math.PI*2),n=e.y.sub(.5).mul(Math.PI),r=n.cos();return Y(r.mul(t.cos()),n.sin(),r.mul(t.sin()))}),ER=class extends ar{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new $a(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i=new ro(5,5,5),a=wR(WP),o=new dR;o.colorNode=wN(t,a,0),o.side=1,o.blending=0;let s=new _a(i,o),c=new Gr;c.add(s),t.minFilter===1008&&(t.minFilter=be);let l=new Gc(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,c),e.setMRT(u),t.minFilter=n,t.generateMipmaps=r,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},DR=new WeakMap,OR=class extends GD{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=bF(null);let t=new $a;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=ND.RENDER}updateBefore(e){let{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:n[r.property];if(e&&e.isTexture){let n=e.mapping;if(n===303||n===304){if(DR.has(e)){let t=DR.get(e);jR(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(kR(n)){let r=new ER(n.height);r.fromEquirectangularTexture(t,e),jR(r.texture,e.mapping),this._cubeTexture=r.texture,DR.set(e,r.texture),e.addEventListener(`dispose`,AR)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function kR(e){return e!=null&&e.height>0}function AR(e){let t=e.target;t.removeEventListener(`dispose`,AR);let n=DR.get(t);n!==void 0&&(DR.delete(t),n.dispose())}function jR(e,t){t===303?e.mapping=301:t===304&&(e.mapping=302)}var MR=zO(OR).setParameterLength(1),NR=class extends AL{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=MR(this.envNode)}},PR=class extends AL{static get type(){return`BasicLightMapNode`}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=K(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},FR=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},IR=class extends FR{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(ak(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(ak(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(yk.rgb)}finish(e){let{material:t,context:n}=e,r=n.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case 0:r.rgb.assign(Hj(r.rgb,r.rgb.mul(i.rgb),pI.mul(mI)));break;case 1:r.rgb.assign(Hj(r.rgb,i.rgb,pI.mul(mI)));break;case 2:r.rgb.addAssign(i.rgb.mul(pI.mul(mI)));break;default:R(`BasicLightingModel: Unsupported .combine value:`,t.combine);break}}},LR=new aa,RR=class extends dR{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(LR),this.setValues(e)}setupNormal(){return YP(eF)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new NR(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new PR(BI)),t}setupOutgoingLight(){return yk.rgb}setupLightingModel(){return new IR}},zR=G(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),BR=G(e=>e.diffuseColor.mul(1/Math.PI)),VR=()=>K(.25),HR=G(({dotNH:e})=>Rk.mul(K(.5)).add(1).mul(K(1/Math.PI)).mul(e.pow(Rk))),UR=G(({lightDirection:e})=>{let t=e.add(KP).normalize(),n=nF.dot(t).clamp(),r=zR({f0:Fk,f90:1,dotVH:KP.dot(t).clamp()}),i=VR(),a=HR({dotNH:n});return r.mul(i).mul(a)}),WR=class extends IR{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=nF.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(BR({diffuseColor:yk.rgb}))),this.specular===!0&&n.directSpecular.addAssign(r.mul(UR({lightDirection:e})).mul(pI))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(BR({diffuseColor:yk}))),r.indirectDiffuse.mulAssign(t)}},GR=new Gs,KR=class extends dR{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(GR),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new NR(t):null}setupLightingModel(){return new WR(!1)}},qR=new Hs,JR=class extends dR{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(qR),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new NR(t):null}setupLightingModel(){return new WR}setupVariants(){let e=(this.shininessNode?K(this.shininessNode):sI).max(1e-4);Rk.assign(e);let t=this.specularNode||uI;Fk.assign(t)}},YR=G(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return K(0);let t=eF.dFdx().abs().max(eF.dFdy().abs());return t.x.max(t.y).max(t.z)}),XR=G(e=>{let{roughness:t}=e,n=YR(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),ZR=G(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return fA(.5,i.add(a).max(PA))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),QR=G(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(Y(e.mul(n),t.mul(r),o).length()),l=o.mul(Y(e.mul(i),t.mul(a),s).length());return fA(.5,c.add(l).max(PA))}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),$R=G(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),ez=K(1/Math.PI),tz=G(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=Y(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return ez.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),nz=G(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,normalView:a=nF,USE_IRIDESCENCE:o,USE_ANISOTROPY:s})=>{let c=r.pow2(),l=e.add(KP).normalize(),u=a.dot(e).clamp(),d=a.dot(KP).clamp(),f=a.dot(l).clamp(),p=zR({f0:t,f90:n,dotVH:KP.dot(l).clamp()}),m,h;if(MO(o)&&(p=Ok.mix(p,i)),MO(s)){let t=Nk.dot(e),n=Nk.dot(KP),r=Nk.dot(l),i=Pk.dot(e),a=Pk.dot(KP),o=Pk.dot(l);m=QR({alphaT:jk,alphaB:c,dotTV:n,dotBV:a,dotTL:t,dotBL:i,dotNV:d,dotNL:u}),h=tz({alphaT:jk,alphaB:c,dotNH:f,dotTH:r,dotBH:o})}else m=ZR({alpha:c,dotNL:u,dotNV:d}),h=$R({alpha:c,dotNH:f});return p.mul(m).mul(h)}),rz=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]),iz=null,az=G(({roughness:e,dotNV:t})=>{iz===null&&(iz=new ba(rz,16,16,He,Ae),iz.name=`DFG_LUT`,iz.minFilter=be,iz.magFilter=be,iz.wrapS=he,iz.wrapT=he,iz.generateMipmaps=!1,iz.needsUpdate=!0);let n=QO(e,t);return wN(iz,n).rg}),oz=G(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{let s=nz({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}),c=nF.dot(e).clamp(),l=az({roughness:r,dotNV:nF.dot(KP).clamp()}),u=az({roughness:r,dotNV:c}),d=t.mul(l.x).add(n.mul(l.y)),f=t.mul(u.x).add(n.mul(u.y)),p=l.x.add(l.y),m=u.x.add(u.y),h=K(1).sub(p),g=K(1).sub(m),_=t.add(t.oneMinus().mul(.047619)),v=d.mul(f).mul(_).div(K(1).sub(h.mul(g).mul(_).mul(_)).add(PA)),y=h.mul(g),b=v.mul(y);return s.add(b)}),sz=G(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=az({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),cz=G(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(Y(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),lz=G(({roughness:e,dotNH:t})=>{let n=e.pow2(),r=K(1).div(n),i=t.pow2().oneMinus().max(.0078125);return K(2).add(r).mul(i.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:`D_Charlie`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`dotNH`,type:`float`}]}),uz=G(({dotNV:e,dotNL:t})=>K(1).div(K(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:`V_Neubelt`,type:`float`,inputs:[{name:`dotNV`,type:`float`},{name:`dotNL`,type:`float`}]}),dz=G(({lightDirection:e})=>{let t=e.add(KP).normalize(),n=nF.dot(e).clamp(),r=nF.dot(KP).clamp(),i=lz({roughness:Dk,dotNH:nF.dot(t).clamp()}),a=uz({dotNV:r,dotNL:n});return Ek.mul(i).mul(a)}),fz=G(({N:e,V:t,roughness:n})=>{let r=QO(n,e.dot(t).saturate().oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r}).setLayout({name:`LTC_Uv`,type:`vec2`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`roughness`,type:`float`}]}),pz=G(({f:e})=>{let t=e.length();return Ej(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),mz=G(({v1:e,v2:t})=>{let n=e.dot(t),r=n.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=i.div(a),s=n.greaterThan(0).select(o,Ej(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(s)}).setLayout({name:`LTC_EdgeVectorFormFactor`,type:`vec3`,inputs:[{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`}]}),hz=G(({N:e,V:t,P:n,mInv:r,p0:i,p1:a,p2:o,p3:s})=>{let c=a.sub(i).toVar(),l=s.sub(i).toVar(),u=c.cross(l),d=Y().toVar();return qO(u.dot(n.sub(i)).greaterThanEqual(0),()=>{let c=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(c).negate(),u=r.mul(uk(c,l,e).transpose()).toVar(),f=u.mul(i.sub(n)).normalize().toVar(),p=u.mul(a.sub(n)).normalize().toVar(),m=u.mul(o.sub(n)).normalize().toVar(),h=u.mul(s.sub(n)).normalize().toVar(),g=Y(0).toVar();g.addAssign(mz({v1:f,v2:p})),g.addAssign(mz({v1:p,v2:m})),g.addAssign(mz({v1:m,v2:h})),g.addAssign(mz({v1:h,v2:f})),d.assign(Y(pz({f:g})))}),d}).setLayout({name:`LTC_Evaluate`,type:`vec3`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`P`,type:`vec3`},{name:`mInv`,type:`mat3`},{name:`p0`,type:`vec3`},{name:`p1`,type:`vec3`},{name:`p2`,type:`vec3`},{name:`p3`,type:`vec3`}]}),gz=1/6,_z=e=>dA(gz,dA(e,dA(e,e.negate().add(3)).sub(3)).add(1)),vz=e=>dA(gz,dA(e,dA(e,dA(3,e).sub(6))).add(4)),yz=e=>dA(gz,dA(e,dA(e,dA(-3,e).add(3)).add(3)).add(1)),bz=e=>dA(gz,Nj(e,3)),xz=e=>_z(e).add(vz(e)),Sz=e=>yz(e).add(bz(e)),Cz=e=>lA(-1,vz(e).div(_z(e).add(vz(e)))),wz=e=>lA(1,bz(e).div(yz(e).add(bz(e)))),Tz=(e,t,n)=>{let r=e.uvNode,i=dA(r,t.zw).add(.5),a=YA(i),o=QA(i),s=xz(o.x),c=Sz(o.x),l=Cz(o.x),u=wz(o.x),d=Cz(o.y),f=wz(o.y),p=QO(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=QO(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=QO(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=QO(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=xz(o.y).mul(lA(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=Sz(o.y).mul(lA(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Ez=G(([e,t])=>{let n=QO(e.size(q(t))),r=QO(e.size(q(t.add(1)))),i=fA(1,n),a=fA(1,r),o=Tz(e,ak(i,n),YA(t)),s=Tz(e,ak(a,r),XA(t));return QA(t).mix(o,s)}),Dz=G(([e,t])=>Ez(e,t.mul(yN(e)))),Oz=G(([e,t,n,r,i])=>{let a=Y(Gj(t.negate(),ZA(e),fA(1,r))),o=Y(pj(i[0].xyz),pj(i[1].xyz),pj(i[2].xyz));return ZA(a).mul(n.mul(o))}).setLayout({name:`getVolumeTransmissionRay`,type:`vec3`,inputs:[{name:`n`,type:`vec3`},{name:`v`,type:`vec3`},{name:`thickness`,type:`float`},{name:`ior`,type:`float`},{name:`modelMatrix`,type:`mat4`}]}),kz=G(([e,t])=>e.mul(Uj(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),Az=LL(),jz=zL(),Mz=G(([e,t,n],{material:r})=>Ez((r.side===1?Az:jz).sample(e),KA(VN.x).mul(kz(t,n)))),Nz=G(([e,t,n])=>(qO(n.notEqual(0),()=>UA(GA(t).negate().div(n).negate().mul(e))),Y(1))).setLayout({name:`volumeAttenuation`,type:`vec3`,inputs:[{name:`transmissionDistance`,type:`float`},{name:`attenuationColor`,type:`vec3`},{name:`attenuationDistance`,type:`float`}]}),Pz=G(([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m])=>{let h,g;if(m){h=ak().toVar(),g=Y().toVar();let i=u.sub(1).mul(m.mul(.025)),a=Y(u.sub(i),u,u.add(i));xL({start:0,end:3},({i})=>{let u=a.element(i),m=Oz(e,t,d,u,s),_=o.add(m),v=l.mul(c.mul(ak(_,1))),y=QO(v.xy.div(v.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(QO(y.x,y.y.oneMinus()));let b=Mz(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(Nz(pj(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=Oz(e,t,d,u,s),a=o.add(i),m=l.mul(c.mul(ak(a,1))),_=QO(m.xy.div(m.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(QO(_.x,_.y.oneMinus())),h=Mz(_,n,u),g=r.mul(Nz(pj(i),f,p))}let _=g.rgb.mul(h.rgb),v=Y(sz({dotNV:e.dot(t).clamp(),specularColor:i,specularF90:a,roughness:n})),y=g.r.add(g.g,g.b).div(3);return ak(v.oneMinus().mul(_),h.a.oneMinus().mul(y).oneMinus())}),Fz=uk(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Iz=e=>{let t=e.sqrt();return Y(1).add(t).div(Y(1).sub(t))},Lz=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Rz=(e,t)=>{let n=e.mul(2*Math.PI*1e-9),r=Y(54856e-17,44201e-17,52481e-17),i=Y(1681e3,1795300,2208400),a=Y(43278e5,93046e5,66121e5),o=K(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(t.x).cos()).mul(n.pow2().mul(-45282e5).exp()),s=r.mul(a.mul(2*Math.PI).sqrt()).mul(i.mul(n).add(t).cos()).mul(n.pow2().negate().mul(a).exp());return s=Y(s.x.add(o),s.y,s.z).div(1.0685e-7),Fz.mul(s)},zz=G(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=Hj(e,t,Kj(0,.03,r)),o=e.div(a).pow2().mul(n.pow2().oneMinus()).oneMinus();qO(o.lessThan(0),()=>Y(1));let s=o.sqrt(),c=zR({f0:Lz(a,e),f90:1,dotVH:n}),l=c.oneMinus(),u=a.lessThan(e).select(Math.PI,0),d=K(Math.PI).sub(u),f=Iz(i.clamp(0,.9999)),p=zR({f0:Lz(f,a.toVec3()),f90:1,dotVH:s}),m=Y(f.x.lessThan(a).select(Math.PI,0),f.y.lessThan(a).select(Math.PI,0),f.z.lessThan(a).select(Math.PI,0)),h=a.mul(r,s,2),g=Y(d).add(m),_=c.mul(p).clamp(1e-5,.9999),v=_.sqrt(),y=l.pow2().mul(p).div(Y(1).sub(_)),b=c.add(y).toVar(),x=y.sub(l).toVar();return xL({start:1,end:2,condition:`<=`,name:`m`},({m:e})=>{x.mulAssign(v);let t=Rz(K(e).mul(h),K(e).mul(g)).mul(2);b.addAssign(x.mul(t))}),b.max(Y(0))}).setLayout({name:`evalIridescence`,type:`vec3`,inputs:[{name:`outsideIOR`,type:`float`},{name:`eta2`,type:`float`},{name:`cosTheta1`,type:`float`},{name:`thinFilmThickness`,type:`float`},{name:`baseF0`,type:`vec3`}]}),Bz=G(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.mul(n),a=n.add(.1).reciprocal(),o=K(-1.9362).add(n.mul(1.0678)).add(i.mul(.4573)).sub(a.mul(.8469)),s=K(-.6014).add(n.mul(.5538)).sub(i.mul(.467)).sub(a.mul(.1255));return o.mul(r).add(s).exp().saturate()}),Vz=Y(.04),Hz=K(1),Uz=class extends FR{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=i,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Y().toVar(`clearcoatRadiance`),this.clearcoatSpecularDirect=Y().toVar(`clearcoatSpecularDirect`),this.clearcoatSpecularIndirect=Y().toVar(`clearcoatSpecularIndirect`)),this.sheen===!0&&(this.sheenSpecularDirect=Y().toVar(`sheenSpecularDirect`),this.sheenSpecularIndirect=Y().toVar(`sheenSpecularIndirect`)),this.iridescence===!0){let e=nF.dot(KP).clamp(),t=zz({outsideIOR:K(1),eta2:kk,cosTheta1:e,thinFilmThickness:Ak,baseF0:Fk}),n=zz({outsideIOR:K(1),eta2:kk,cosTheta1:e,thinFilmThickness:Ak,baseF0:yk.rgb});this.iridescenceFresnel=Hj(t,n,Ck),this.iridescenceF0Dielectric=cz({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=cz({f:n,f90:1,dotVH:e}),this.iridescenceF0=Hj(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,Ck)}if(this.transmission===!0){let t=UP,n=gP.sub(UP).normalize(),r=rF,i=e.context;i.backdrop=Pz(r,n,Sk,bk,Ik,Lk,t,OP,pP,dP,Uk,Gk,qk,Kk,this.dispersion?Jk:null),i.backdropAlpha=Wk,yk.a.mulAssign(Hj(1,i.backdrop.a,Wk))}super.start(e)}computeMultiscattering(e,t,n,r,i=null){let a=az({roughness:Sk,dotNV:nF.dot(KP).clamp()}),o=i?Ok.mix(r,i):r,s=o.mul(a.x).add(n.mul(a.y)),c=a.x.add(a.y).oneMinus(),l=o.add(o.oneMinus().mul(.047619)),u=s.mul(l).div(c.mul(l).oneMinus());e.addAssign(s),t.addAssign(u.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=nF.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(r.mul(dz({lightDirection:e})));let t=Bz({normal:nF,viewDir:KP,roughness:Dk}),n=Bz({normal:nF,viewDir:e,roughness:Dk}),i=Ek.r.max(Ek.g).max(Ek.b).mul(t.max(n)).oneMinus();r.mulAssign(i)}if(this.clearcoat===!0){let n=iF.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(n.mul(nz({lightDirection:e,f0:Vz,f90:Hz,roughness:Tk,normalView:iF})))}n.directDiffuse.addAssign(r.mul(BR({diffuseColor:bk}))),n.directSpecular.addAssign(r.mul(oz({lightDirection:e,f0:Ik,f90:1,roughness:Sk,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:i,ltc_1:a,ltc_2:o}){let s=t.add(n).sub(r),c=t.sub(n).sub(r),l=t.sub(n).add(r),u=t.add(n).add(r),d=nF,f=KP,p=GP.toVar(),m=fz({N:d,V:f,roughness:Sk}),h=a.sample(m).toVar(),g=o.sample(m).toVar(),_=uk(Y(h.x,0,h.y),Y(0,1,0),Y(h.z,0,h.w)).toVar(),v=Ik.mul(g.x).add(Lk.sub(Ik).mul(g.y)).toVar();if(i.directSpecular.addAssign(e.mul(v).mul(hz({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(bk).mul(hz({N:d,V:f,P:p,mInv:uk(1,0,0,0,1,0,0,0,1),p0:s,p1:c,p2:l,p3:u}))),this.clearcoat===!0){let t=iF,n=fz({N:t,V:f,roughness:Tk}),r=a.sample(n),i=o.sample(n),d=uk(Y(r.x,0,r.y),Y(0,1,0),Y(r.z,0,r.w)),m=Vz.mul(i.x).add(Hz.sub(Vz).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(m).mul(hz({N:t,V:f,P:p,mInv:d,p0:s,p1:c,p2:l,p3:u})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:n}=e.context,r=t.mul(BR({diffuseColor:bk})).toVar();if(this.sheen===!0){let e=Bz({normal:nF,viewDir:KP,roughness:Dk}),t=Ek.r.max(Ek.g).max(Ek.b).mul(e).oneMinus();r.mulAssign(t)}n.indirectDiffuse.addAssign(r)}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(Ek,Bz({normal:nF,viewDir:KP,roughness:Dk}))),this.clearcoat===!0){let e=sz({dotNV:iF.dot(KP).clamp(),specularColor:Vz,specularF90:Hz,roughness:Tk});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let i=Y().toVar(`singleScatteringDielectric`),a=Y().toVar(`multiScatteringDielectric`),o=Y().toVar(`singleScatteringMetallic`),s=Y().toVar(`multiScatteringMetallic`);this.computeMultiscattering(i,a,Lk,Fk,this.iridescenceF0Dielectric),this.computeMultiscattering(o,s,Lk,yk.rgb,this.iridescenceF0Metallic);let c=Hj(i,o,Ck),l=Hj(a,s,Ck),u=i.add(a),d=bk.mul(u.oneMinus()),f=n.mul(1/Math.PI),p=t.mul(c).add(l.mul(f)).toVar(),m=d.mul(f).toVar();if(this.sheen===!0){let e=Bz({normal:nF,viewDir:KP,roughness:Dk}),t=Ek.r.max(Ek.g).max(Ek.b).mul(e).oneMinus();p.mulAssign(t),m.mulAssign(t)}r.indirectSpecular.addAssign(p),r.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:n}=e.context,r=nF.dot(KP).clamp().add(t),i=Sk.mul(-16).oneMinus().negate().exp2(),a=t.sub(r.pow(i).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(a)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let e=zR({dotVH:iF.dot(KP).clamp(),f0:Vz,f90:Hz}),n=t.mul(wk.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(wk));t.assign(n)}if(this.sheen===!0){let e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}},Wz=K(1),Gz=K(-2),Kz=K(.8),qz=K(-1),Jz=K(.4),Yz=K(2),Xz=K(.305),Zz=K(3),Qz=K(.21),$z=K(4),eB=K(4),tB=K(16),nB=G(([e])=>{let t=Y(dj(e)).toVar(),n=K(-1).toVar();return qO(t.x.greaterThan(t.z),()=>{qO(t.x.greaterThan(t.y),()=>{n.assign(eM(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(eM(e.y.greaterThan(0),1,4))})}).Else(()=>{qO(t.z.greaterThan(t.y),()=>{n.assign(eM(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(eM(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),rB=G(([e,t])=>{let n=QO().toVar();return qO(t.equal(0),()=>{n.assign(QO(e.z,e.y).div(dj(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(QO(e.x.negate(),e.z.negate()).div(dj(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(QO(e.x.negate(),e.y).div(dj(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(QO(e.z.negate(),e.y).div(dj(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(QO(e.x.negate(),e.z).div(dj(e.y)))}).Else(()=>{n.assign(QO(e.x,e.y).div(dj(e.z)))}),dA(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),iB=G(([e])=>{let t=K(0).toVar();return qO(e.greaterThanEqual(Kz),()=>{t.assign(Wz.sub(e).mul(qz.sub(Gz)).div(Wz.sub(Kz)).add(Gz))}).ElseIf(e.greaterThanEqual(Jz),()=>{t.assign(Kz.sub(e).mul(Yz.sub(qz)).div(Kz.sub(Jz)).add(qz))}).ElseIf(e.greaterThanEqual(Xz),()=>{t.assign(Jz.sub(e).mul(Zz.sub(Yz)).div(Jz.sub(Xz)).add(Yz))}).ElseIf(e.greaterThanEqual(Qz),()=>{t.assign(Xz.sub(e).mul($z.sub(Zz)).div(Xz.sub(Qz)).add(Zz))}).Else(()=>{t.assign(K(-2).mul(KA(dA(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),aB=G(([e,t])=>{let n=e.toVar();n.assign(dA(2,n).sub(1));let r=Y(n,1).toVar();return qO(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),oB=G(([e,t,n,r,i,a])=>{let o=K(n),s=Y(t),c=Uj(iB(o),Gz,a),l=QA(c),u=YA(c),d=Y(sB(e,s,u,r,i,a)).toVar();return qO(l.notEqual(0),()=>{let t=Y(sB(e,s,u.add(1),r,i,a)).toVar();d.assign(Hj(d,t,l))}),d}),sB=G(([e,t,n,r,i,a])=>{let o=K(n).toVar(),s=Y(t),c=K(nB(s)).toVar(),l=K(Ej(eB.sub(o),0)).toVar();o.assign(Ej(o,eB));let u=K(WA(o)).toVar(),d=QO(rB(s,c).mul(u.sub(2)).add(1)).toVar();return qO(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(dA(3,tB))),d.y.addAssign(dA(4,WA(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(QO(),QO())}),cB=G(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=tj(r);return sB(e,n.mul(c).add(i.cross(n).mul($A(r))).add(i.mul(i.dot(n).mul(c.oneMinus()))),t,a,o,s)}),lB=G(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=Y(eM(t,n,Mj(n,r))).toVar();qO(f.equal(Y(0)),()=>{f.assign(Y(r.z,0,r.x.negate()))}),f.assign(ZA(f));let p=Y().toVar();return p.addAssign(i.element(0).mul(cB({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),xL({start:q(1),end:e},({i:e})=>{qO(e.greaterThanEqual(a),()=>{CL()});let t=K(o.mul(K(e))).toVar();p.addAssign(i.element(e).mul(cB({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(cB({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),ak(p,1)}),uB=G(([e])=>{let t=J(e).toVar();return t.assign(t.shiftLeft(J(16)).bitOr(t.shiftRight(J(16)))),t.assign(t.bitAnd(J(1431655765)).shiftLeft(J(1)).bitOr(t.bitAnd(J(2863311530)).shiftRight(J(1)))),t.assign(t.bitAnd(J(858993459)).shiftLeft(J(2)).bitOr(t.bitAnd(J(3435973836)).shiftRight(J(2)))),t.assign(t.bitAnd(J(252645135)).shiftLeft(J(4)).bitOr(t.bitAnd(J(4042322160)).shiftRight(J(4)))),t.assign(t.bitAnd(J(16711935)).shiftLeft(J(8)).bitOr(t.bitAnd(J(4278255360)).shiftRight(J(8)))),K(t).mul(23283064365386963e-26)}),dB=G(([e,t])=>QO(K(e).div(K(t)),uB(e))),fB=G(([e,t,n])=>{let r=n.mul(n).toConst(),i=Y(1,0,0).toConst(),a=Mj(t,i).toConst(),o=qA(e.x).toConst(),s=dA(2,3.14159265359).mul(e.y).toConst(),c=o.mul(tj(s)).toConst(),l=o.mul($A(s)).toVar(),u=dA(.5,t.z.add(1)).toConst();l.assign(u.oneMinus().mul(qA(c.mul(c).oneMinus())).add(u.mul(l)));let d=i.mul(c).add(a.mul(l)).add(t.mul(qA(Ej(0,c.mul(c).add(l.mul(l)).oneMinus()))));return ZA(Y(r.mul(d.x),r.mul(d.y),Ej(0,d.z)))}),pB=G(({roughness:e,mipInt:t,envMap:n,N_immutable:r,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=Y(r).toVar(),l=Y(0).toVar(),u=K(0).toVar();return qO(e.lessThan(.001),()=>{l.assign(sB(n,c,t,a,o,s))}).Else(()=>{let r=ZA(Mj(eM(dj(c.z).lessThan(.999),Y(0,0,1),Y(1,0,0)),c)).toVar(),d=Mj(c,r).toVar();xL({start:J(0),end:i},({i:f})=>{let p=fB(dB(f,i),Y(0,0,1),e),m=ZA(r.mul(p.x).add(d.mul(p.y)).add(c.mul(p.z))),h=ZA(m.mul(jj(c,m).mul(2)).sub(c)),g=Ej(jj(c,h),0);qO(g.greaterThan(0),()=>{let e=sB(n,h,t,a,o,s);l.addAssign(e.mul(g)),u.addAssign(g)})}),qO(u.greaterThan(0),()=>{l.assign(l.div(u))})}),ak(l,1)}),mB=4,hB=[.125,.215,.35,.446,.526,.582],gB=20,_B=512,vB=new Fc(-1,1,1,-1,0,1),yB=new Ac(90,1),bB=new Ur,xB=null,SB=0,CB=0,wB=new V,TB=new WeakMap,EB=[3,1,5,0,4,2],DB=aB(_N(),gN(`faceIndex`)).normalize(),OB=Y(DB.x,DB.y,DB.z),kB=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=wB,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.`);xB=this._renderer.getRenderTarget(),SB=this._renderer.getActiveCubeFace(),CB=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget(!0);return this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return sn(`PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return sn(`PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return sn(`PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=FB(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=IB(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?this._cubemapMaterial===null&&(this._cubemapMaterial=FB(e)):this._equirectMaterial===null&&(this._equirectMaterial=IB(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;this._setViewport(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,vB)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-mB?n-d+mB:0),m=4*(this._cubeSize-f);e.texture.frame=(e.texture.frame||0)+1,s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,this._setViewport(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,vB),i.texture.frame=(i.texture.frame||0)+1,s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,this._setViewport(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,vB)}_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`&&z(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=TB.get(c),d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*gB-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):gB;m>gB&&R(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${gB}`);let h=[],g=0;for(let e=0;e_-mB?r-_+mB:0),b=4*(this._cubeSize-v);this._setViewport(t,y,b,3*v,2*v),s.setRenderTarget(t),s.render(l,vB)}_setViewport(e,t,n,r,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-n,r,i),e.scissor.set(t,e.height-i-n,r,i)):(e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i))}};function AB(e){let t=[],n=[],r=[],i=e,a=e-mB+1+hB.length;for(let o=0;oe-mB?s=hB[o-e+mB-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=EB[e];f.set(r,18*i),p.set(d,12*i);let a=[i,i,i,i,i,i];m.set(a,6*i)}let h=new Wi;h.setAttribute(`position`,new Oi(f,3)),h.setAttribute(`uv`,new Oi(p,2)),h.setAttribute(`faceIndex`,new Oi(m,1)),r.push(new _a(h,null)),i>mB&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function jB(e,t,n){let r=new ar(e,t,{magFilter:be,minFilter:be,generateMipmaps:!1,type:Ae,format:Re,colorSpace:Lt,depthBuffer:n});return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function MB(e){let t=new dR;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function NB(e,t,n){let r=PN(Array(gB).fill(0)),i=rA(new V(0,1,0)),a=rA(0),o=K(gB),s=rA(0),c={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:OB,dTheta:a,samples:rA(1),envMap:wN(),mipInt:rA(0),CUBEUV_TEXEL_WIDTH:K(1/t),CUBEUV_TEXEL_HEIGHT:K(1/n),CUBEUV_MAX_MIP:K(e)},l=MB(`blur`);return l.fragmentNode=lB({...c,latitudinal:s.equal(1)}),TB.set(l,c),l}function PB(e,t,n){let r={envMap:wN(),roughness:rA(0),mipInt:rA(0),CUBEUV_TEXEL_WIDTH:K(1/t),CUBEUV_TEXEL_HEIGHT:K(1/n),CUBEUV_MAX_MIP:K(e)},i=MB(`ggx`);return i.fragmentNode=pB({...r,N_immutable:OB,GGX_SAMPLES:J(_B)}),TB.set(i,r),i}function FB(e){let t=MB(`cubemap`);return t.fragmentNode=bF(e,OB),t}function IB(e){let t=MB(`equirect`);return t.fragmentNode=wN(e,wR(OB),0),t}var LB=new WeakMap;function RB(e){let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(2**t,112)),texelHeight:n,maxMip:t}}function zB(e,t,n){let r=BB(t),i=r.get(e);if((i===void 0?-1:i.pmremVersion)!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(HB(t))i=n.fromCubemap(e,i);else return null;else if(UB(t))i=n.fromEquirectangular(e,i);else return null;if(i.pmremVersion=e.pmremVersion,r.has(e)===!1){let t=()=>{e.removeEventListener(`dispose`,t);let n=r.get(e);n!==void 0&&(n.dispose(),r.delete(e))};e.addEventListener(`dispose`,t)}r.set(e,i)}return i.texture}function BB(e){let t=LB.get(e);return t===void 0&&(t=new WeakMap,LB.set(e,t)),t}var VB=class extends GD{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new rr;r.isRenderTargetTexture=!0,this._texture=wN(r),this._width=rA(0),this._height=rA(0),this._maxMip=rA(0),this.updateBeforeType=ND.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=RB(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0||r.mapping===306?r:zB(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new kB(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?pF.mul(Y(t.x,t.y.negate(),t.z)):pF.mul(t);let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),oB(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function HB(e){if(e==null)return!1;let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function UB(e){return e!=null&&e.height>0}var WB=zO(VB).setParameterLength(1,3),GB=new WeakMap,KB=class extends AL{static get type(){return`EnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){let r=n.isTextureNode?n.value:t[n.property],i=this._getPMREMNodeCache(e.renderer),a=i.get(r);a===void 0&&(a=WB(r),i.set(r,a)),n=a}let r=t.useAnisotropy===!0||t.anisotropy>0?JF:nF,i=n.context(qB(Sk,r)).mul(fF),a=n.context(JB(rF)).mul(Math.PI).mul(fF),o=ZM(i),s=ZM(a);e.context.radiance.addAssign(o),e.context.iblIrradiance.addAssign(s);let c=e.context.lightingModel.clearcoatRadiance;if(c){let e=ZM(n.context(qB(Tk,iF)).mul(fF));c.addAssign(e)}}_getPMREMNodeCache(e){let t=GB.get(e);return t===void 0&&(t=new WeakMap,GB.set(e,t)),t}},qB=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=KP.negate().reflect(t),n=Ij(e).mix(n,t).normalize(),n=n.transformDirection(mP)),n),getTextureLevel:()=>e}},JB=e=>({getUV:()=>e,getTextureLevel:()=>K(1)}),YB=new Bs,XB=class extends dR{static get type(){return`MeshStandardNodeMaterial`}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(YB),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new KB(t):null}setupLightingModel(){return new Uz}setupSpecular(){let e=Hj(Y(.04),yk.rgb,Ck);Fk.assign(Y(.04)),Ik.assign(e),Lk.assign(1)}setupVariants(){let e=this.metalnessNode?K(this.metalnessNode):gI;Ck.assign(e);let t=this.roughnessNode?K(this.roughnessNode):hI;t=XR({roughness:t}),Sk.assign(t),this.setupSpecular(),bk.assign(yk.rgb.mul(e.oneMinus()))}},ZB=new Vs,QB=class extends XB{static get type(){return`MeshPhysicalNodeMaterial`}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(ZB),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){let e=this.iorNode?K(this.iorNode):AI;Uk.assign(e),Fk.assign(Tj(Pj(Uk.sub(1).div(Uk.add(1))).mul(fI),Y(1)).mul(dI)),Ik.assign(Hj(Fk,yk.rgb,Ck)),Lk.assign(Hj(dI,1,Ck))}setupLightingModel(){return new Uz(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?K(this.clearcoatNode):vI,t=this.clearcoatRoughnessNode?K(this.clearcoatRoughnessNode):yI;wk.assign(e),Tk.assign(XR({roughness:t}))}if(this.useSheen){let e=this.sheenNode?Y(this.sheenNode):SI,t=this.sheenRoughnessNode?K(this.sheenRoughnessNode):CI;Ek.assign(e),Dk.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?K(this.iridescenceNode):TI,t=this.iridescenceIORNode?K(this.iridescenceIORNode):EI,n=this.iridescenceThicknessNode?K(this.iridescenceThicknessNode):DI;Ok.assign(e),kk.assign(t),Ak.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?QO(this.anisotropyNode):wI).toVar();Mk.assign(e.length()),qO(Mk.equal(0),()=>{e.assign(QO(1,0))}).Else(()=>{e.divAssign(QO(Mk)),Mk.assign(Mk.saturate())}),jk.assign(Mk.pow2().mix(Sk.pow2(),1)),Nk.assign(KF[0].mul(e.x).add(KF[1].mul(e.y))),Pk.assign(KF[1].mul(e.x).sub(KF[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?K(this.transmissionNode):OI,t=this.thicknessNode?K(this.thicknessNode):kI,n=this.attenuationDistanceNode?K(this.attenuationDistanceNode):jI,r=this.attenuationColorNode?Y(this.attenuationColorNode):MI;if(Wk.assign(e),Gk.assign(t),Kk.assign(n),qk.assign(r),this.useDispersion){let e=this.dispersionNode?K(this.dispersionNode):zI;Jk.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Y(this.clearcoatNormalNode):bI}setup(e){e.context.setupClearcoatNormal=()=>mM(this.setupClearcoatNormal(e),`NORMAL`,`vec3`),super.setup(e)}},$B=G(({normal:e,lightDirection:t,builder:n})=>{let r=QO(e.dot(t).mul(.5).add(.5),0);if(n.material.gradientMap)return Y(DF(`gradientMap`,`texture`).context({getUV:()=>r}).r);{let e=r.fwidth().mul(.5);return Hj(Y(.7),Y(1),Kj(K(.7).sub(e.x),K(.7).add(e.x),r.x))}}),eV=class extends FR{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){let i=$B({normal:ZP,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(i.mul(BR({diffuseColor:yk.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(BR({diffuseColor:yk}))),r.indirectDiffuse.mulAssign(t)}},tV=new Us,nV=class extends dR{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(tV),this.setValues(e)}setupLightingModel(){return new eV}},rV=G(()=>{let e=Y(KP.z,0,KP.x.negate()).normalize(),t=KP.cross(e);return QO(e.dot(nF),t.dot(nF)).mul(.495).add(.5)}).once([`NORMAL`,`VERTEX`])().toVar(`matcapUV`),iV=new Js,aV=class extends dR{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(iV),this.setValues(e)}setupVariants(e){let t=rV,n;n=e.material.matcap?DF(`matcap`,`texture`).context({getUV:()=>t}):Y(Hj(.2,.8,t.y)),yk.rgb.mulAssign(n.rgb)}},oV=zO(class extends GD{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)===`vec2`){let e=t.cos(),r=t.sin();return lk(e,r,r.negate(),e).mul(n)}else{let e=t,r=dk(ak(1,0,0,0),ak(0,tj(e.x),$A(e.x).negate(),0),ak(0,$A(e.x),tj(e.x),0),ak(0,0,0,1)),i=dk(ak(tj(e.y),0,$A(e.y),0),ak(0,1,0,0),ak($A(e.y).negate(),0,tj(e.y),0),ak(0,0,0,1)),a=dk(ak(tj(e.z),$A(e.z).negate(),0,0),ak($A(e.z),tj(e.z),0,0),ak(0,0,1,0),ak(0,0,0,1));return r.mul(i).mul(a).mul(ak(n,1)).xyz}}}).setParameterLength(2),sV=new Xi,cV=class extends dR{static get type(){return`SpriteNodeMaterial`}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(sV),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,{positionNode:r,rotationNode:i,scaleNode:a,sizeAttenuation:o}=this,s=FP.mul(Y(r||0)),c=QO(OP[0].xyz.length(),OP[1].xyz.length());a!==null&&(c=c.mul(QO(a))),n.isPerspectiveCamera&&o===!1&&(c=c.mul(s.z.negate()));let l=BP.xy;if(t.center&&t.center.isVector2===!0){let e=DM(`center`,`vec2`,t);l=l.sub(e.sub(.5))}l=l.mul(c);let u=K(i||xI),d=oV(l,u);return ak(s.xy.add(d),s.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},lV=new Ga,uV=new B,dV=class extends cV{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(lV),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return FP.mul(Y(e||VP)).xyz}setupVertexSprite(e){let{material:t,camera:n}=e,{rotationNode:r,scaleNode:i,sizeNode:a,sizeAttenuation:o}=this,s=super.setupVertex(e);if(t.isNodeMaterial!==!0)return s;let c=a===null?RI:QO(a);c=c.mul(zN),n.isPerspectiveCamera&&o===!0&&(c=c.mul(fV.div(GP.z.negate()))),i&&i.isNode&&(c=c.mul(QO(i)));let l=BP.xy;if(r&&r.isNode){let e=K(r);l=oV(l,e)}return l=l.mul(c),l=l.div(WN.div(2)),l=l.mul(s.w),s=s.add(ak(l,0,0)),s}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},fV=rA(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(uV);this.value=.5*t.y}),pV=class extends FR{constructor(){super(),this.shadowNode=K(1).toVar(`shadowMask`)}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yk.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yk.rgb)}},mV=new ks,hV=class extends dR{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(mV),this.setValues(e)}setupLightingModel(){return new pV}};_k(`vec3`),_k(`vec3`),_k(`vec3`);var gV=class{constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self<`u`?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,n),this.renderer._inspector.finish()};e()}stop(){this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},_V=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener(`dispose`,this.onMaterialDispose),this.geometry.addEventListener(`dispose`,this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.addEventListener(`dispose`,this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.getNodeBuilderState().hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||=this._nodes.getForRender(this)}getMonitor(){return this._monitor||=this.getNodeBuilderState().observer}getBindings(){return this._bindings||=this.getNodeBuilderState().createBindings()}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set,i={};for(let a of e){let e;if(a.node&&a.node.attribute?e=a.node.attribute:(e=t.getAttribute(a.name),e!==void 0&&(e.isInterleavedBufferAttribute?i[a.name]=e.data.uuid:i[a.name]=e.id)),e===void 0)continue;n.push(e);let o=e.isInterleavedBufferAttribute?e.data:e;r.add(o)}return this.attributes=n,this.attributesId=i,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:n,group:r,drawRange:i}=this,a=this.drawParams||={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0},o=this.getIndex(),s=o!==null,c=1;if(n.isInstancedBufferGeometry===!0?c=n.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(a.instanceCount=c,e.isBatchedMesh===!0)return a;let l=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(l=2);let u=i.start*l,d=(i.start+i.count)*l;r!==null&&(u=Math.max(u,r.start*l),d=Math.min(d,(r.start+r.count)*l));let f=n.attributes.position,p=1/0;s?p=o.count:f!=null&&(p=f.count),u=Math.max(u,0),d=Math.min(d,p);let m=d-u;return m<0||m===1/0?null:(a.vertexCount=m,a.firstVertex=u,a)}getGeometryCacheKey(){let{geometry:e}=this,t=``;for(let n of Object.keys(e.attributes).sort()){let r=e.attributes[n];t+=n+`,`,r.data&&(t+=r.data.stride+`,`),r.offset&&(t+=r.offset+`,`),r.itemSize&&(t+=r.itemSize+`,`),r.normalized&&(t+=`n,`)}for(let n of Object.keys(e.morphAttributes).sort()){let r=e.morphAttributes[n];t+=`morph-`+n+`,`;for(let e=0,n=r.length;e1)&&(r+=e.uuid+`,`),r+=this.context.id+`,`,r+=e.receiveShadow+`,`,vD(r)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){let e=this.attributesId;for(let t in e){let n=this.geometry.getAttribute(t);if(n===void 0)return!0;let r=n.isInterleavedBufferAttribute?n.data.uuid:n.id;if(e[t]!==r)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=bD(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=bD(e,1)),e=bD(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener(`dispose`,this.onMaterialDispose),this.geometry.removeEventListener(`dispose`,this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.removeEventListener(`dispose`,this.onMaterialDispose),this.onDispose()}},SV=[],CV=class{constructor(e,t,n,r,i,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=a,this.chainMaps={}}get(e,t,n,r,i,a,o,s){let c=this.getChainMap(s);SV[0]=e,SV[1]=t,SV[2]=a,SV[3]=i;let l=c.get(SV);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,o,s),c.set(SV,l)):(l.camera=r,l.updateClipping(o),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey===l.getCacheKey()?l.version=t.version:(l.dispose(),l=this.get(e,t,n,r,i,a,o,s)))),SV[0]=null,SV[1]=null,SV[2]=null,SV[3]=null,l}getChainMap(e=`default`){return this.chainMaps[e]||(this.chainMaps[e]=new _V)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,o,s,c,l,u){let d=this.getChainMap(u),f=new xV(e,t,n,r,i,a,o,s,c,l);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.deleteForRender(f),this.nodes.delete(f),d.delete(f.getChainArray())},f}},wV=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},TV={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},EV=16,DV=211,OV=212,kV=class extends wV{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){let t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){let n=this.get(e);if(n.version===void 0)t===TV.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===TV.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===TV.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===TV.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),n.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(n.version=65535?Ai:ki)(t,1);return i.version=AV(e),i.__id=jV(e),i}var ete=class extends wV{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){let t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;let r=()=>{this.info.memory.geometries--;let n=t.index,i=e.getAttributes();n!==null&&this.attributes.delete(n);for(let e of i)this.attributes.delete(e);let a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener(`dispose`,r),this._geometryDisposeListeners.delete(t)};t.addEventListener(`dispose`,r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){let t=e.getAttributes();for(let e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,TV.STORAGE):this.updateAttribute(e,TV.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,TV.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,TV.INDIRECT)}updateAttribute(e,t){let n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){let{geometry:t,material:n}=e,r=t.index;if(n.wireframe===!0){let e=this.wireframes,n=e.get(t);n===void 0?(n=MV(t),e.set(t,n)):(n.version!==AV(t)||n.__id!==jV(t))&&(this.attributes.delete(n),n=MV(t),e.set(t,n)),r=n}return r}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener(`dispose`,t);this._geometryDisposeListeners.clear()}},tte=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=t/3*n:e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=t/2*n:e.isLine?this.render.lines+=n*(t-1):z(`WebGPUInfo: Unknown object type.`)}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(let e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){let t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){let n=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:n,type:t}),this.memory[t]++,this.memory.total+=n,this.memory[t+`Size`]+=n}createAttribute(e){this._createAttribute(e,`attributes`)}createIndexAttribute(e){this._createAttribute(e,`indexAttributes`)}createStorageAttribute(e){this._createAttribute(e,`storageAttributes`)}createIndirectStorageAttribute(e){this._createAttribute(e,`indirectStorageAttributes`)}destroyAttribute(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+`Size`]-=t.size)}createReadbackBuffer(e){let t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:`readbackBuffers`}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){let{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){let t=e.byteLength;this.memoryMap.set(e,{size:t,type:`uniformBuffers`}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){let t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===1010||e.type===1009?t=1:e.type===1011||e.type===1012||e.type===1016?t=2:(e.type===1013||e.type===1014||e.type===1015)&&(t=4);let n=4;e.format===1021||e.format===1028||e.format===1029||e.format===1026||e.format===1027?n=1:e.format===1030||e.format===1031?n=2:(e.format===1022||e.format===1032)&&(n=3);let r=t*n;e.type===1017||e.type===1018?r=2:(e.type===1020||e.type===35902||e.type===35899)&&(r=4);let i=e.width||1,a=e.height||1,o=e.isCubeTexture?6:e.depth||1,s=i*a*o*r,c=e.mipmaps;if(c&&c.length>0){let e=0;for(let t=0;t>t),c=n.height||Math.max(1,a>>t);e+=s*c*o*r}}s+=e}else e.generateMipmaps&&(s*=1.333);return Math.round(s)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}},NV=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},nte=class extends NV{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},rte=class extends NV{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},ite=0,PV=class{constructor(e,t,n,r=null,i=null){this.id=ite++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}},ate=class extends wV{constructor(e,t,n){super(),this.backend=e,this.nodes=t,this.info=n,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);let a=this.nodes.getForCompute(e),o=this.programs.compute.get(a.computeShader);o===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),o=new PV(a.computeShader,`compute`,e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,o),n.createProgram(o),this.info.createProgram(o));let s=this._getComputeCacheKey(e,o),c=this.caches.get(s);c===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),c=this._getComputePipeline(e,o,s,t)),c.usedTimes++,o.usedTimes++,r.version=e.version,r.pipeline=c}return r.pipeline}getForRender(e,t=null){let{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);let a=e.getNodeBuilderState(),o=e.material?e.material.name:``,s=this.programs.vertex.get(a.vertexShader);s===void 0&&(i&&i.vertexProgram.usedTimes===0&&this._releaseProgram(i.vertexProgram),s=new PV(a.vertexShader,`vertex`,o),this.programs.vertex.set(a.vertexShader,s),n.createProgram(s),this.info.createProgram(s));let c=this.programs.fragment.get(a.fragmentShader);c===void 0&&(i&&i.fragmentProgram.usedTimes===0&&this._releaseProgram(i.fragmentProgram),c=new PV(a.fragmentShader,`fragment`,o),this.programs.fragment.set(a.fragmentShader,c),n.createProgram(c),this.info.createProgram(c));let l=this._getRenderCacheKey(e,s,c),u=this.caches.get(l);u===void 0?(i&&i.usedTimes===0&&this._releasePipeline(i),u=this._getRenderPipeline(e,s,c,l,t)):e.pipeline=u,u.usedTimes++,s.usedTimes++,c.usedTimes++,r.pipeline=u}return r.pipeline}isReady(e){let t=this.get(e).pipeline;if(t===void 0)return!1;let n=this.backend.get(t);return n.pipeline!==void 0&&n.pipeline!==null}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n||=this._getComputeCacheKey(e,t);let i=this.caches.get(n);return i===void 0&&(i=new rte(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r||=this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new nte(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,i)),a}_getComputeCacheKey(e,t){return e.id+`,`+t.id}_getRenderCacheKey(e,t,n){return t.id+`,`+n.id+`,`+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,n=e.stage;this.programs[n].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}},ote=class extends wV{constructor(e,t,n,r,i,a){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings(),n=this.get(e);return n.initialized!==!0&&(this._createBindings(t),n.initialized=!0),t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings,n=this.get(e);return(n.initialized!==!0||n.bindings!==t)&&(n.bindings!==void 0&&this._destroyBindings(n.bindings),this._createBindings(t),n.initialized=!0,n.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){let t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){let t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(let t of e){let n=this.get(t);if(n.bindGroup===void 0){for(let e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e);else if(e.isStorageBuffer){let t=e.attribute,n=t.isIndirectStorageBufferAttribute?TV.INDIRECT:TV.STORAGE;this.attributes.update(t,n)}this.backend.createBindings(t,e,0),n.bindGroup=t,n.usedTimes=1}else n.usedTimes++}}_destroyBindings(e){for(let t of e){let e=this.get(t);if(e.usedTimes--,e.usedTimes===0){for(let e of t.bindings)e.isUniformBuffer?(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release()):e.isSampler&&(e.isSampledTexture!==!0&&this.backend.destroySampler(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(let t of e)this._update(t,e)}_update(e,t){let{backend:n}=this,r=!1,i=!0,a=0,o=0;for(let t of e.bindings)if(this.nodes.updateGroup(t)!==!1){if(t.isStorageBuffer){let e=t.attribute,i=e.isIndirectStorageBufferAttribute?TV.INDIRECT:TV.STORAGE,a=n.get(t);this.attributes.update(e,i),a.attribute!==e&&(a.attribute=e,r=!0)}if(t.isUniformBuffer)t.update()&&n.updateBinding(t);else if(t.isSampledTexture){let s=t.update(),c=t.texture,l=this.textures.get(c);if(s&&(this.textures.updateTexture(c),t.generation!==l.generation&&(t.generation=l.generation,r=!0),l.bindGroups.add(e)),n.get(c).externalTexture!==void 0||l.isDefaultTexture?i=!1:(a=a*10+c.id,o+=c.version),c.isStorageTexture===!0&&c.mipmapsAutoUpdate===!0){let e=this.get(c);t.store===!0?e.needsMipmap=!0:this.textures.needsMipmaps(c)&&e.needsMipmap===!0&&(this.backend.generateMipmaps(c),e.needsMipmap=!1)}}else if(t.isSampler&&t.update()){let e=this.textures.updateSampler(t);t.samplerKey!==e&&(t.samplerKey=e,r=!0)}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}r===!0&&this.backend.updateBindings(e,t,i?a:0,o)}},ste=Object.freeze([]);function cte(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:e.z-t.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function FV(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 IV(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===2&&e.forceSinglePass===!1}var lte=class{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0,this._lastOcclusionObject=null}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,i,a,o){let s=this.renderItems[this.renderItemsIndex];return s===void 0?(s={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a,clippingContext:o},this.renderItems[this.renderItemsIndex]=s):(s.id=e.id,s.object=e,s.geometry=t,s.material=n,s.groupOrder=r,s.renderOrder=e.renderOrder,s.z=i,s.group=a,s.clippingContext=o),this.renderItemsIndex++,s}push(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);e.occlusionTest===!0&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(IV(n)&&this.transparentDoublePass.push(s),this.transparent.push(s)):this.opaque.push(s)}unshift(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(IV(n)&&this.transparentDoublePass.unshift(s),this.transparent.unshift(s)):this.opaque.unshift(s)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t,n){this.opaque.length>1&&this.opaque.sort(e||cte),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||FV),this.transparent.length>1&&this.transparent.sort(t||FV),n&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:ste);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,c=o.height>>t,l=e.depthTexture||i[t],u=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1,f=l!==void 0&&l.image!==void 0&&l.image.depth>1,p=o.depth>1&&(e.useArrayDepthTexture||e.multiview||f);l===void 0&&u&&(l=new eo,l.format=e.stencilBuffer?Be:ze,l.type=e.stencilBuffer?Ne:Oe,l.image.width=s,l.image.height=c,l.image.depth=o.depth,l.renderTarget=e,i[t]=l),l&&(l.isArrayTexture=p),(n.width!==o.width||o.height!==n.height)&&(d=!0,l&&(l.needsUpdate=!0,l.image.width=s,l.image.height=c,l.image.depth=p?o.depth:1)),n.width=o.width,n.height=o.height,n.textures=a,n.depthTexture=l||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(d=!0,l&&(l.needsUpdate=!0),n.sampleCount=r);let m={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let e=0;e{this._destroyRenderTarget(e)},e.addEventListener(`dispose`,n.onDispose))}updateTexture(e,t={}){let n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;let r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(r&&n.initialized===!0&&i.destroyTexture(e),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();t?e.type=t.texture.type:e.type=Ce}if(e.isHTMLTexture&&e.image){let t=this.renderer.domElement;if(`requestPaint`in t){if(t.hasAttribute(`layoutsubtree`)||t.setAttribute(`layoutsubtree`,`true`),e.image.parentNode!==t&&t.appendChild(e.image),this._htmlTextures.size===0){let e=this._htmlTextures;t.onpaint=t=>{let n=t&&t.changedElements;for(let t of e)(!n||n.includes(t.image))&&(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}let{width:a,height:o,depth:s}=this.getSize(e);if(t.width=a,t.height=o,t.depth=s,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,o):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)i.createTexture(e,t),n.generation=e.version;else if(e.version>0){let r=e.image;if(r===void 0)R(`Renderer: Texture marked for update but image is undefined.`);else if(r.complete===!1)R(`Renderer: Texture marked for update but image is incomplete.`);else{if(e.images){let n=[];for(let t of e.images)n.push(t);t.images=n}else t.image=r;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&i.updateTexture(e,t);let a=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!a&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,n.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&qn.enabled===!0&&qn.getTransfer(e.colorSpace)!==`srgb`&&R(`WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.`),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener(`dispose`,n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=mte){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),e.isHTMLTexture?(t.width=n.offsetWidth||1,t.height=n.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<`u`&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame<`u`&&n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return r=e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture===!0?1:Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){let t=this.get(e),n=t.textures,r=t.depthTexture;e.removeEventListener(`dispose`,t.onDispose);for(let e=0;e{t.isOverrideContextNode===!0&&e.push(t.value.overrideNodes)});let t=new Map(e.flatMap(e=>Array.from(e.entries()))),n=super.getFlowContextData();return n.overrideNodes=t,n}};function VV(e,t=null,n=null){if(t&&t.isNode){let e=t;t=()=>e}return new BV(new Map([[e,t]]),n)}W(`overrideNode`,(e,t,n)=>VV(t,n,e));function HV(e,t=null){let n=new Map;for(let[t,r]of e){let e=r===null?null:typeof r==`function`?r:()=>r;n.set(t,e)}return new BV(n,t)}W(`overrideNodes`,(e,t)=>HV(t,e));var UV=class extends gk{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let n=this.getNodeType(e),r=e.getStructTypeNode(n),i;return r===null?(z(`TSL: Member "${t}" not found in struct "${n}".`,new gD),i=`float`):i=r.getMemberType(e,t),i}getHash(){return String(this.id)}generate(){return this.name}},gte=(e,t)=>new UV(e,t),WV=zO(class extends HD{static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):`void`}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}addToStack(e,t=-1){if(e.isNode!==!0)return z(`TSL: Invalid node added to stack.`,new gD),this;if(t===-1)if(this._currentNode){let e=this._nodeDataLibrary.get(this._currentNode);e===void 0&&(e={delta:0},this._nodeDataLibrary.set(this._currentNode,e)),e.delta++,t=this.nodes.indexOf(this._currentNode)+e.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){let n=new PO(t);return this._currentCond=eM(e,n),this.addToStack(this._currentCond)}ElseIf(e,t){let n=eM(e,new PO(t));return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new PO(e),this}Switch(e){return this._expressionNode=FO(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;ntypeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var vte=class extends HD{static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=_te(e),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(let n of this.membersLayout){let r=n.type,i=TD(r),a=ED(r);e=Math.max(e,a);let o=t%e%a;o!==0&&(t+=a-o),t+=i}return Math.ceil(t/e)*e}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}},yte=class extends HD{static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){let e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}},bte=(e,t=null)=>{let n=new vte(e,t);return HO((...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;enew YV(e,`int`,`float`),ZV=e=>new YV(e,`uint`,`float`),Tte=e=>new YV(e,`float`,`int`),Ete=e=>new YV(e,`float`,`uint`),QV={},$V=class e extends X{static get type(){return`BitcountNode`}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n===`int`?t.assign(XV(e,`uint`)):t.assign(e)}_returnDataNode(e){switch(e){case`uint`:return J;case`int`:return q;case`uvec2`:return ek;case`uvec3`:return rk;case`uvec4`:return sk;case`ivec2`:return $O;case`ivec3`:return nk;case`ivec4`:return ok}}_createTrailingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return G(([e])=>{let r=J(0);this._resolveElementType(e,r,t);let i=ZV(K(r.bitAnd(mj(r)))).shiftRight(23).sub(127);return n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createLeadingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return G(([e])=>{qO(e.equal(J(0)),()=>J(32));let r=J(0),i=J(0);return this._resolveElementType(e,r,t),qO(r.shiftRight(16).equal(0),()=>{i.addAssign(16),r.shiftLeftAssign(16)}),qO(r.shiftRight(24).equal(0),()=>{i.addAssign(8),r.shiftLeftAssign(8)}),qO(r.shiftRight(28).equal(0),()=>{i.addAssign(4),r.shiftLeftAssign(4)}),qO(r.shiftRight(30).equal(0),()=>{i.addAssign(2),r.shiftLeftAssign(2)}),qO(r.shiftRight(31).equal(0),()=>{i.addAssign(1)}),n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createOneBitsBaseLayout(e,t){let n=this._returnDataNode(t);return G(([e])=>{let r=J(0);this._resolveElementType(e,r,t),r.assign(r.sub(r.shiftRight(J(1)).bitAnd(J(1431655765)))),r.assign(r.bitAnd(J(858993459)).add(r.shiftRight(J(2)).bitAnd(J(858993459))));let i=r.add(r.shiftRight(J(4))).bitAnd(J(252645135)).mul(J(16843009)).shiftRight(J(24));return n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createMainLayout(e,t,n,r){let i=this._returnDataNode(t);return G(([e])=>{if(n===1)return i(r(e));{let t=i(0),a=[`x`,`y`,`z`,`w`];for(let i=0;id(r))()}};$V.COUNT_TRAILING_ZEROS=`countTrailingZeros`,$V.COUNT_LEADING_ZEROS=`countLeadingZeros`,$V.COUNT_ONE_BITS=`countOneBits`;var Dte=VO($V,$V.COUNT_TRAILING_ZEROS).setParameterLength(1),Ote=VO($V,$V.COUNT_LEADING_ZEROS).setParameterLength(1),kte=VO($V,$V.COUNT_ONE_BITS).setParameterLength(1),Ate=G(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return n.shiftRight(22).bitXor(n).toFloat().mul(1/2**32)}),eH=(e,t)=>Nj(dA(4,e.mul(uA(1,e))),t),tH=(e,t)=>e.lessThan(.5)?eH(e.mul(2),t).div(2):uA(1,eH(dA(uA(1,e),2),t).div(2)),nH=(e,t,n)=>Nj(fA(Nj(e,t),lA(Nj(e,t),Nj(uA(1,e),n))),1/t),rH=(e,t)=>$A(IA.mul(t.mul(e).sub(1))).div(IA.mul(t.mul(e).sub(1))),iH=class extends GD{static get type(){return`PackFloatNode`}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return`uint`}generate(e){let t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}},aH=VO(iH,`snorm`).setParameterLength(1),oH=VO(iH,`unorm`).setParameterLength(1),sH=VO(iH,`float16`).setParameterLength(1),cH=class extends GD{static get type(){return`UnpackFloatNode`}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return`vec2`}generate(e){let t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}},lH=VO(cH,`snorm`).setParameterLength(1),uH=VO(cH,`unorm`).setParameterLength(1),dH=VO(cH,`float16`).setParameterLength(1),fH=G(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),pH=G(([e])=>Y(fH(e.z.add(fH(e.y.mul(1)))),fH(e.z.add(fH(e.x.mul(1)))),fH(e.y.add(fH(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),mH=G(([e,t,n])=>{let r=Y(e).toVar(),i=K(1.4).toVar(),a=K(0).toVar(),o=Y(r).toVar();return xL({start:K(0),end:K(3),type:`float`,condition:`<=`},()=>{let e=Y(pH(o.mul(2))).toVar();r.addAssign(e.add(n.mul(K(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=K(fH(r.z.add(fH(r.x.add(fH(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]}),hH=zO(class extends HD{static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){let t=this.parametersNodes,n=this._candidateFn;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode.layout;if(a===null)throw Error(`THREE.FunctionOverloadingNode: FunctionNode must be a layout.`);let o=a.inputs;if(t.length===o.length){let a=0;for(let n=0;ni&&(r=n,i=a)}}this._candidateFn=n=r}return n}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}),gH=e=>(...t)=>hH(e,...t),_H=rA(0).setGroup(eA).onRenderUpdate(e=>e.time),vH=rA(0).setGroup(eA).onRenderUpdate(e=>e.deltaTime),yH=rA(0,`uint`).setGroup(eA).onRenderUpdate(e=>e.frameId),bH=(e=_H)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),xH=(e=_H)=>e.fract().round(),SH=(e=_H)=>e.add(.5).fract().mul(2).sub(1).abs(),CH=(e=_H)=>e.fract();function wH(e,t=null){return nM(t,{getUV:typeof e==`function`?e:()=>e})}var TH=G(([e,t,n=QO(.5)])=>oV(e.sub(n),t).add(n)),EH=G(([e,t,n=QO(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i).mul(t);return e.add(r.mul(a))}),DH=G(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=OP:(r=OP.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=pP.mul(r);return MO(t)&&(i[0][0]=OP[0].length(),i[0][1]=0,i[0][2]=0),MO(n)&&(i[1][0]=0,i[1][1]=OP[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,dP.mul(i).mul(VP)}),OH=G(([e=null])=>{let t=$L();return $L(VL(e)).sub(t).lessThan(0).select(BN,e)}),kH=G(([e,t=_N(),n=K(0)])=>{let r=e.x,i=e.y,a=n.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=e.reciprocal(),l=QO(o,s);return t.add(l).mul(c)}),AH=G(([e,t=null,n=null,r=K(1),i=VP,a=QP])=>{let o=a.abs().normalize();o=o.div(o.dot(Y(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value;return lA(wN(u,s).mul(o.x),wN(d,c).mul(o.y),wN(f,l).mul(o.z))}),jH=(...e)=>AH(...e),MH=new Ta,NH=new V,PH=new V,FH=new V,IH=new lr,LH=new V(0,0,-1),RH=new ir,zH=new V,BH=new V,VH=new ir,HH=new B,UH=new ar,WH=BN.flipX();UH.depthTexture=new eo(1,1);var GH=!1,KH=class e extends SN{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||UH.texture,WH),this._reflectorBaseNode=e.reflector||new qH(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=new e({defaultTexture:UH.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},qH=class extends HD{static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new Fr,resolutionScale:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1,samples:s=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=r,t.resolution!==void 0&&(sn(`ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".`),this.resolutionScale=t.resolution),this.generateMipmaps=i,this.bounces=a,this.depth=o,this.samples=s,this.updateBeforeType=a?ND.RENDER:ND.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolutionScale;t.getDrawingBufferSize(HH),e.setSize(Math.round(HH.width*n),Math.round(HH.height*n))}setup(e){return this._updateResolution(UH,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new ar(0,0,{type:Ae,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=I,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new eo),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&GH)return!1;GH=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(HH),this._updateResolution(s,r),PH.setFromMatrixPosition(a.matrixWorld),FH.setFromMatrixPosition(n.matrixWorld),IH.extractRotation(a.matrixWorld),NH.set(0,0,1),NH.applyMatrix4(IH),zH.subVectors(PH,FH);let c=zH.dot(NH)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){GH=!1;return}l=!0}zH.reflect(NH).negate(),zH.add(PH),IH.extractRotation(n.matrixWorld),LH.set(0,0,-1),LH.applyMatrix4(IH),LH.add(FH),BH.subVectors(PH,LH),BH.reflect(NH).negate(),BH.add(PH),o.coordinateSystem=n.coordinateSystem,o.position.copy(zH),o.up.set(0,1,0),o.up.applyMatrix4(IH),o.up.reflect(NH),o.lookAt(BH),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),MH.setFromNormalAndCoplanarPoint(NH,PH),MH.applyMatrix4(o.matrixWorldInverse),RH.set(MH.normal.x,MH.normal.y,MH.normal.z,MH.constant);let u=o.projectionMatrix;VH.x=(Math.sign(RH.x)+u.elements[8])/u.elements[0],VH.y=(Math.sign(RH.y)+u.elements[9])/u.elements[5],VH.z=-1,VH.w=(1+u.elements[10])/u.elements[14],RH.multiplyScalar(1/RH.dot(VH)),u.elements[2]=RH.x,u.elements[6]=RH.y,u.elements[10]=r.coordinateSystem===2001?RH.z-0:RH.z+1-0,u.elements[14]=RH.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let d=r.getRenderTarget(),f=r.getMRT(),p=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0;let m=t.name;t.name=(t.name||`Scene`)+` [ Reflector ]`,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),t.name=m,r.setMRT(f),r.setRenderTarget(d),r.autoClear=p,i.visible=!0,GH=!1,this.forceUpdate=!1}get resolution(){return sn(`ReflectorNode: The "resolution" property has been renamed to "resolutionScale".`),this.resolutionScale}set resolution(e){sn(`ReflectorNode: The "resolution" property has been renamed to "resolutionScale".`),this.resolutionScale=e}},JH=e=>new KH(e),YH=new Fc(-1,1,1,-1,0,1),XH=new class extends Wi{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new Mi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Mi(t,2))}},ZH=class extends _a{constructor(e=null){super(XH,e),this.camera=YH,this.isQuadMesh=!0}async renderAsync(e){sn(`QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await e.init(),e.render(this,YH)}render(e){e.render(this,YH)}},QH=new B,$H=class extends SN{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:Ae}){let i=new ar(t,n,r);super(i.texture,_N()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new ZH(new dR),this.updateBeforeType=ND.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){let n=Math.floor(e*this._resolutionScale),r=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,this.autoResize===!1&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;this.textureNeedsUpdate=!1;let t=e.getRenderTarget();if(this.autoResize===!0){let t=e.getDrawingBufferSize(QH),n=Math.floor(t.width*this._resolutionScale),r=Math.floor(t.height*this._resolutionScale);(n!==this.renderTarget.width||r!==this.renderTarget.height)&&(this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0)}let n=`RTT`;this.node.name&&(n=this.node.name+` [ `+n+` ]`),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=n,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new SN(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}},eU=(e,...t)=>new $H(FO(e),...t),tU=(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():eU(e,...t),nU=G(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===2001?(e=QO(e.x,e.y.oneMinus()).mul(2).sub(1),i=ak(Y(e,t),1)):i=ak(Y(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=ak(n.mul(i));return a.xyz.div(a.w)}),rU=G(([e,t])=>{let n=t.mul(ak(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return QO(r.x,r.y.oneMinus())}),iU=G(([e,t,n])=>{let r=vN(EN(t)),i=$O(e.mul(r)).toVar(),a=EN(t,i).toVar(),o=EN(t,i.sub($O(2,0))).toVar(),s=EN(t,i.sub($O(1,0))).toVar(),c=EN(t,i.add($O(1,0))).toVar(),l=EN(t,i.add($O(2,0))).toVar(),u=EN(t,i.add($O(0,2))).toVar(),d=EN(t,i.add($O(0,1))).toVar(),f=EN(t,i.sub($O(0,1))).toVar(),p=EN(t,i.sub($O(0,2))).toVar(),m=dj(uA(K(2).mul(s).sub(o),a)).toVar(),h=dj(uA(K(2).mul(c).sub(l),a)).toVar(),g=dj(uA(K(2).mul(d).sub(u),a)).toVar(),_=dj(uA(K(2).mul(f).sub(p),a)).toVar(),v=nU(e,a,n).toVar();return ZA(Mj(m.lessThan(h).select(v.sub(nU(e.sub(QO(K(1).div(r.x),0)),s,n)),v.negate().add(nU(e.add(QO(K(1).div(r.x),0)),c,n))),g.lessThan(_).select(v.sub(nU(e.add(QO(0,K(1).div(r.y))),d,n)),v.negate().add(nU(e.sub(QO(0,K(1).div(r.y))),f,n)))))}),aU=G(([e])=>QA(K(52.9829189).mul(QA(jj(e,QO(.06711056,.00583715)))))).setLayout({name:`interleavedGradientNoise`,type:`float`,inputs:[{name:`position`,type:`vec2`}]}),oU=G(([e,t,n])=>{let r=K(2.399963229728653),i=qA(K(e).add(.5).div(K(t))),a=K(e).mul(r).add(n);return QO(tj(a),$A(a)).mul(i)}).setLayout({name:`vogelDiskSample`,type:`vec2`,inputs:[{name:`sampleIndex`,type:`int`},{name:`samplesCount`,type:`int`},{name:`phi`,type:`float`}]}),sU=class extends HD{static get type(){return`SampleNode`}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(_N())}sample(e){return this.callback(e)}},cU=(e,t=null)=>new sU(e,FO(t)),lU=class extends xa{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},uU=class extends Oi{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}},dU=(e,t=`float`)=>{let n,r;return t.isStructTypeNode===!0?(n=t.getLength(),r=CD(`float`)):(n=wD(t),r=CD(t)),eL(new uU(e,n,r),t,e)},fU=(e,t=`float`)=>{let n,r;t.isStructTypeNode===!0?(n=t.getLength(),r=CD(`float`)):(n=wD(t),r=CD(t));let i=new lU(e,n,r);return eL(i,t,i.count)},pU=BO(class extends HD{static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}}),mU=new lr,hU=rA(0).setGroup(eA).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),gU=rA(1).setGroup(eA).onRenderUpdate(({scene:e})=>e.backgroundIntensity),_U=rA(new lr).setGroup(eA).onRenderUpdate(({scene:e})=>{let t=e.background;return t!==null&&t.isTexture&&t.mapping!==300||e.backgroundNode&&e.backgroundNode.isNode?mU.makeRotationFromEuler(e.backgroundRotation).transpose():mU.identity(),mU}),vU=class extends SN{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=FD.WRITE_ONLY}getInputType(){return`storageTexture`}getTransformedUV(e){return e}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return this.storeNode===null?super.generate(e,t):(this.generateStore(e),``)}generateSnippet(e,t,n,r,i,a,o,s,c){let l=this.value;return e.generateStorageTextureLoad(l,t,n,r,a,c)}toReadWrite(){return this.setAccess(FD.READ_WRITE)}toReadOnly(){return this.setAccess(FD.READ_ONLY)}toWriteOnly(){return this.setAccess(FD.WRITE_ONLY)}store(e,t){let n=this.clone();return n.referenceNode=this.getBase(),n.uvNode=e,n.storeNode=t,t!==null&&n.toStack(),n}generateStore(e){let{uvNode:t,storeNode:n,depthNode:r}=e.getNodeProperties(this),i=super.generate(e,`property`),a=t.build(e,this.value.is3DTexture===!0?`uvec3`:`uvec2`),o=n.build(e,`vec4`),s=r?r.build(e,`int`):null,c=e.generateTextureStore(this.value,i,a,s,o);e.addLineFlowCode(c,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}},yU=zO(vU).setParameterLength(1,3),bU=(e,t,n)=>{let r;return e.isStorageTextureNode===!0?r=e.store(t,n):(r=yU(e,t,n),n!==null&&r.toStack()),r},xU=zO(class extends vU{static get type(){return`StorageTexture3DNode`}constructor(e,t,n=null){super(e,t,n),this.isStorageTexture3DNode=!0}getDefaultUV(){return Y(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}generateOffset(e,t){return t.build(e,`ivec3`)}}).setParameterLength(1,3),SU=G(({texture:e,uv:t})=>{let n=1e-4,r=Y().toVar();return qO(t.x.lessThan(n),()=>{r.assign(Y(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(Y(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(Y(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(Y(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(Y(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(Y(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(Y(-.01,0,0))).r.sub(e.sample(t.add(Y(n,0,0))).r),a=e.sample(t.add(Y(0,-.01,0))).r.sub(e.sample(t.add(Y(0,n,0))).r),o=e.sample(t.add(Y(0,0,-.01))).r.sub(e.sample(t.add(Y(0,0,n))).r);r.assign(Y(i,a,o))}),r.normalize()}),CU=zO(class extends SN{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return Y(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}generateOffset(e,t){return t.build(e,`ivec3`)}normal(e){return SU({texture:this,uv:e})}}).setParameterLength(1,3),wU=(...e)=>CU(...e).setSampler(!1),TU=(e,t,n)=>CU(e,t).level(n),EU=class extends CF{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}},DU=(e,t,n)=>new EU(e,t,n),OU=new WeakMap,kU=class extends GD{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=ND.OBJECT,this.updateAfterType=ND.OBJECT,this.previousModelWorldMatrix=rA(new lr),this.previousProjectionMatrix=rA(new lr).setGroup(eA),this.previousCameraViewMatrix=rA(new lr)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=jU(n);this.previousModelWorldMatrix.value.copy(r);let i=AU(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new lr,i.previousCameraViewMatrix=new lr,i.currentProjectionMatrix=new lr,i.currentCameraViewMatrix=new lr,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){jU(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?dP:rA(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(FP).mul(VP),r=this.previousProjectionMatrix.mul(t).mul(HP);return uA(n.xy.div(n.w),r.xy.div(r.w))}};function AU(e){let t=OU.get(e);return t===void 0&&(t={},OU.set(e,t)),t}function jU(e,t=0){let n=AU(e),r=n[t];return r===void 0&&(n[t]=r=new lr,n[t].copy(e.matrixWorld)),r}var MU=BO(kU),NU=G(([e,t])=>Tj(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),PU=G(([e,t])=>Tj(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),FU=G(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),IU=G(([e,t])=>Hj(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),Dj(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),LU=G(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return ak(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),RU=G(([e])=>HU(e.rgb)),zU=G(([e,t=K(1)])=>t.mix(HU(e.rgb),e.rgb).max(0)),BU=G(([e,t=K(0)])=>{let n=lA(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return Hj(e.rgb,r,i).max(0)}),VU=G(([e,t=K(1)])=>{let n=Y(.57735,.57735,.57735),r=t.cos();return Y(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(jj(n,e.rgb).mul(r.oneMinus()))))).max(0)}),HU=(e,t=Y(qn.getLuminanceCoefficients(new V)))=>jj(e,t),UU=G(([e,t=Y(1),n=Y(0),r=Y(1),i=K(1),a=Y(qn.getLuminanceCoefficients(new V,Lt))])=>{let o=e.rgb.dot(Y(a)),s=Ej(e.rgb.mul(t).add(n),0),c=s.pow(r);return qO(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),qO(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),qO(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i)).max(0)),ak(s.rgb,e.a)}),WU=G(([e,t])=>e.mul(t).floor().div(t)),GU=null,KU=zO(class extends FL{static get type(){return`ViewportSharedTextureNode`}constructor(e=BN,t=null){GU===null&&(GU=new Qa),super(e,t,GU)}getTextureForReference(){return GU}updateReference(){return this}}).setParameterLength(0,2),qU=new B,JU=class extends SN{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},YU=class extends JU{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},XU=class e extends GD{static get type(){return`PassNode`}constructor(t,n,r,i={}){super(`vec4`),this.scope=t,this.scene=n,this.camera=r,this.options=i,this._width=1,this._height=1;let a=new ar(this._width,this._height,{type:Ae,...i});a.texture.name=`output`;let o=null;(this.scope===e.DEPTH||i.depthBuffer!==!1)&&(o=new eo,o.isRenderTargetTexture=!0,o.name=`depth`,a.depthTexture=o),this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture},o!==null&&(this._textures.depth=o),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=rA(0),this._cameraFar=rA(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ND.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return R(`PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead.`),this.setResolutionScale(e)}getResolution(){return R(`PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead.`),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){if(e===`depth`)throw Error(`THREE.PassNode: Depth texture is not available for this pass.`);t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=new YU(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new YU(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=JL(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=UL(i,n,r)}return t}async compileAsync(e){let t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),t.reversedDepthBuffer===!0&&this.renderTarget.depthTexture!==null&&(this.renderTarget.depthTexture.type=ke),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i=t.getOutputRenderTarget();i&&i.isXRRenderTarget===!0?(r=t.xr.getCamera(),t.xr.updateCamera(r),qU.set(i.width,i.height)):(r=this.camera,t.getDrawingBufferSize(qU)),this.setSize(qU.width,qU.height);let a=t.getRenderTarget(),o=t.getMRT(),s=t.autoClear,c=t.transparent,l=t.opaque,u=r.layers.mask,d=t.contextNode,f=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(let e in this._previousTextures)this.toggleTexture(e);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:nM({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);let p=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=p,n.overrideMaterial=f,t.setRenderTarget(a),t.setMRT(o),t.autoClear=s,t.transparent=c,t.opaque=l,t.contextNode=d,r.layers.mask=u}setSize(e,t){this._width=e,this._height=t;let n=Math.floor(this._width*this._resolutionScale),r=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor===null?this.renderTarget.scissorTest=!1:(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new ir),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r))}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new ir),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r))}dispose(){this.renderTarget.dispose()}};XU.COLOR=`color`,XU.DEPTH=`depth`;var ZU=(e,t,n)=>new XU(XU.COLOR,e,t,n),QU=(e,t)=>new JU(e,t),$U=(e,t,n)=>new XU(XU.DEPTH,e,t,n),eW=class extends XU{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(XU.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap,this.name=`Outline Pass`}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new dR;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=1;let t=QP.negate(),n=dP.mul(FP),r=K(1),i=n.mul(ak(VP,1)),a=n.mul(ak(VP.add(t),1)),o=ZA(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=ak(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}},tW=(e,t,n=new Ur(0,0,0),r=.003,i=1)=>new eW(e,t,FO(n),FO(r),FO(i)),nW=G(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),rW=G(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),iW=G(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),aW=G(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),oW=G(([e,t])=>{let n=uk(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=uk(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=aW(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),sW=uk(Y(1.6605,-.1246,-.0182),Y(-.5876,1.1329,-.1006),Y(-.0728,-.0083,1.1187)),cW=uk(Y(.6274,.0691,.0164),Y(.3293,.9195,.088),Y(.0433,.0113,.8956)),lW=G(([e])=>{let t=Y(e).toVar(),n=Y(t.mul(t)).toVar(),r=Y(n.mul(n)).toVar();return K(15.5).mul(r.mul(n)).sub(dA(40.14,r.mul(t))).add(dA(31.96,r).sub(dA(6.868,n.mul(t))).add(dA(.4298,n).add(dA(.1191,t).sub(.00232))))}),uW=G(([e,t])=>{let n=Y(e).toVar(),r=uk(Y(.856627153315983,.137318972929847,.11189821299995),Y(.0951212405381588,.761241990602591,.0767994186031903),Y(.0482516061458583,.101439036467562,.811302368396859)),i=uk(Y(1.1271005818144368,-.1413297634984383,-.14132976349843826),Y(-.11060664309660323,1.157823702216272,-.11060664309660294),Y(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=K(-12.47393),o=K(4.026069);return n.mulAssign(t),n.assign(cW.mul(n)),n.assign(r.mul(n)),n.assign(Ej(n,1e-10)),n.assign(KA(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(Uj(n,0,1)),n.assign(lW(n)),n.assign(i.mul(n)),n.assign(Nj(Ej(Y(0),n),Y(2.2))),n.assign(sW.mul(n)),n.assign(Uj(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),dW=G(([e,t])=>{let n=K(.76),r=K(.15);e=e.mul(t);let i=Tj(e.r,Tj(e.g,e.b)),a=eM(i.lessThan(.08),i.sub(dA(6.25,i.mul(i))),.04);e.subAssign(a);let o=Ej(e.r,Ej(e.g,e.b));qO(o.lessThan(n),()=>e);let s=uA(1,n),c=uA(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=uA(1,fA(1,r.mul(o.sub(c)).add(1)));return Hj(e,Y(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),fW=class extends HD{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},pW=zO(fW).setParameterLength(1,3),mW=(e,t)=>pW(e,t,`js`),hW=(e,t)=>pW(e,t,`wgsl`),gW=(e,t)=>pW(e,t,`glsl`),_W=class extends fW{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a);return a.code=this.getNodeFunction(e).getCode(o)+` +`,t===`property`?o:e.format(`${o}()`,i,t)}},vW=(e,t=[],n=``)=>{let r=new _W(e,t,n);return HO((...e)=>r.call(...e),r)},yW=(e,t)=>vW(e,t,`glsl`),bW=(e,t)=>vW(e,t,`wgsl`);function xW(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||GP.z).negate()}var SW=G(([e,t],n)=>Kj(e,t,xW(n))),CW=G(([e],t)=>{let n=xW(t);return e.mul(e,n,n).negate().exp().oneMinus()}),wW=G(([e,t],n)=>{let r=xW(n),i=t.sub(UP.y).max(0).toConst().mul(r).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),TW=G(([e,t])=>ak(t.toFloat().mix(zk.rgb,e.toVec3()),zk.a)),EW=null,DW=null,OW=zO(class extends HD{static get type(){return`RangeNode`}constructor(e=K(),t=K()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),r=e.getTypeLength(DD(t.value)),i=e.getTypeLength(DD(n.value));return r>i?r:i}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}getConstNode(e){let t=null;if(e.traverse(e=>{e.isConstNode===!0&&(t=e)}),t===null)throw new bN(`THREE.TSL: No "ConstNode" found in node graph.`,this.stackTrace);return t}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.getConstNode(this.minNode),i=this.getConstNode(this.maxNode),a=r.value,o=i.value,s=e.getTypeLength(DD(a)),c=e.getTypeLength(DD(o));EW||=new ir,DW||=new ir,EW.setScalar(0),DW.setScalar(0),s===1?EW.setScalar(a):a.isColor?EW.set(a.r,a.g,a.b,1):EW.set(a.x,a.y,a.z||0,a.w||0),c===1?DW.setScalar(o):o.isColor?DW.set(o.r,o.g,o.b,1):DW.set(o.x,o.y,o.z||0,o.w||0);let l=4*t.count,u=new Float32Array(l);for(let e=0;enew kW(e,t),jW=AW(`numWorkgroups`,`uvec3`),MW=AW(`workgroupId`,`uvec3`),NW=AW(`globalId`,`uvec3`),PW=AW(`localId`,`uvec3`),FW=AW(`subgroupSize`,`uint`),IW=zO(class extends HD{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}),LW=()=>IW(`workgroup`).toStack(),RW=()=>IW(`storage`).toStack(),zW=()=>IW(`texture`).toStack(),BW=class extends UD{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.isContextAssign();if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},VW=class extends HD{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=``}setName(e){return this.name=e,this}label(e){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new gD),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new BW(this,e)}generate(e){let t=this.name===``?`${this.scope}Array_${this.id}`:this.name;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},HW=(e,t)=>new VW(`Workgroup`,e,t),UW=class extends HD{static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`;if(n&&n.length===1&&n[0].isStackNode===!0)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=rN(l,i).toConst()),t.constNode.build(e)}};UW.ATOMIC_LOAD=`atomicLoad`,UW.ATOMIC_STORE=`atomicStore`,UW.ATOMIC_ADD=`atomicAdd`,UW.ATOMIC_SUB=`atomicSub`,UW.ATOMIC_MAX=`atomicMax`,UW.ATOMIC_MIN=`atomicMin`,UW.ATOMIC_AND=`atomicAnd`,UW.ATOMIC_OR=`atomicOr`,UW.ATOMIC_XOR=`atomicXor`;var WW=zO(UW),GW=(e,t,n)=>WW(e,t,n).toStack(),KW=e=>GW(UW.ATOMIC_LOAD,e,null),qW=(e,t)=>GW(UW.ATOMIC_STORE,e,t),JW=(e,t)=>GW(UW.ATOMIC_ADD,e,t),YW=(e,t)=>GW(UW.ATOMIC_SUB,e,t),XW=(e,t)=>GW(UW.ATOMIC_MAX,e,t),ZW=(e,t)=>GW(UW.ATOMIC_MIN,e,t),QW=(e,t)=>GW(UW.ATOMIC_AND,e,t),$W=(e,t)=>GW(UW.ATOMIC_OR,e,t),eG=(e,t)=>GW(UW.ATOMIC_XOR,e,t),tG=class e extends GD{static get type(){return`SubgroupFunctionNode`}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(n)?0:e.getTypeLength(n))?t:n}generateNodeType(t){let n=this.method;return n===e.SUBGROUP_ELECT?`bool`:n===e.SUBGROUP_BALLOT?`uvec4`:this.getInputType(t)}generate(t,n){let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=[];if(r===e.SUBGROUP_BROADCAST||r===e.SUBGROUP_SHUFFLE||r===e.QUAD_BROADCAST){let e=s.getNodeType(t);c.push(o.build(t,i),s.build(t,e===`float`?`int`:i))}else r===e.SUBGROUP_SHUFFLE_XOR||r===e.SUBGROUP_SHUFFLE_DOWN||r===e.SUBGROUP_SHUFFLE_UP?c.push(o.build(t,i),s.build(t,`uint`)):(o!==null&&c.push(o.build(t,a)),s!==null&&c.push(s.build(t,a)));let l=c.length===0?`()`:`( ${c.join(`, `)} )`;return t.format(`${t.getMethod(r,i)}${l}`,i,n)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};tG.SUBGROUP_ELECT=`subgroupElect`,tG.SUBGROUP_BALLOT=`subgroupBallot`,tG.SUBGROUP_ADD=`subgroupAdd`,tG.SUBGROUP_INCLUSIVE_ADD=`subgroupInclusiveAdd`,tG.SUBGROUP_EXCLUSIVE_AND=`subgroupExclusiveAdd`,tG.SUBGROUP_MUL=`subgroupMul`,tG.SUBGROUP_INCLUSIVE_MUL=`subgroupInclusiveMul`,tG.SUBGROUP_EXCLUSIVE_MUL=`subgroupExclusiveMul`,tG.SUBGROUP_AND=`subgroupAnd`,tG.SUBGROUP_OR=`subgroupOr`,tG.SUBGROUP_XOR=`subgroupXor`,tG.SUBGROUP_MIN=`subgroupMin`,tG.SUBGROUP_MAX=`subgroupMax`,tG.SUBGROUP_ALL=`subgroupAll`,tG.SUBGROUP_ANY=`subgroupAny`,tG.SUBGROUP_BROADCAST_FIRST=`subgroupBroadcastFirst`,tG.QUAD_SWAP_X=`quadSwapX`,tG.QUAD_SWAP_Y=`quadSwapY`,tG.QUAD_SWAP_DIAGONAL=`quadSwapDiagonal`,tG.SUBGROUP_BROADCAST=`subgroupBroadcast`,tG.SUBGROUP_SHUFFLE=`subgroupShuffle`,tG.SUBGROUP_SHUFFLE_XOR=`subgroupShuffleXor`,tG.SUBGROUP_SHUFFLE_UP=`subgroupShuffleUp`,tG.SUBGROUP_SHUFFLE_DOWN=`subgroupShuffleDown`,tG.QUAD_BROADCAST=`quadBroadcast`;var nG=VO(tG,tG.SUBGROUP_ELECT).setParameterLength(0),rG=VO(tG,tG.SUBGROUP_BALLOT).setParameterLength(1),iG=VO(tG,tG.SUBGROUP_ADD).setParameterLength(1),aG=VO(tG,tG.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),oG=VO(tG,tG.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),sG=VO(tG,tG.SUBGROUP_MUL).setParameterLength(1),cG=VO(tG,tG.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),lG=VO(tG,tG.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),uG=VO(tG,tG.SUBGROUP_AND).setParameterLength(1),dG=VO(tG,tG.SUBGROUP_OR).setParameterLength(1),fG=VO(tG,tG.SUBGROUP_XOR).setParameterLength(1),pG=VO(tG,tG.SUBGROUP_MIN).setParameterLength(1),mG=VO(tG,tG.SUBGROUP_MAX).setParameterLength(1),hG=VO(tG,tG.SUBGROUP_ALL).setParameterLength(0),gG=VO(tG,tG.SUBGROUP_ANY).setParameterLength(0),_G=VO(tG,tG.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),vG=VO(tG,tG.QUAD_SWAP_X).setParameterLength(1),yG=VO(tG,tG.QUAD_SWAP_Y).setParameterLength(1),bG=VO(tG,tG.QUAD_SWAP_DIAGONAL).setParameterLength(1),xG=VO(tG,tG.SUBGROUP_BROADCAST).setParameterLength(2),SG=VO(tG,tG.SUBGROUP_SHUFFLE).setParameterLength(2),CG=VO(tG,tG.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),wG=VO(tG,tG.SUBGROUP_SHUFFLE_UP).setParameterLength(2),TG=VO(tG,tG.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),EG=VO(tG,tG.QUAD_BROADCAST).setParameterLength(1),DG;function OG(e){DG||=new WeakMap;let t=DG.get(e);return t===void 0&&DG.set(e,t={}),t}function kG(e){let t=OG(e);return t.shadowMatrix||=rA(`mat4`).setGroup(eA).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix))}function AG(e,t=UP){let n=kG(e).mul(t);return n.xyz.div(n.w)}function jG(e){let t=OG(e);return t.position||=rA(new V).setGroup(eA).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function MG(e){let t=OG(e);return t.targetPosition||=rA(new V).setGroup(eA).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function NG(e){let t=OG(e);return t.viewPosition||=rA(new V).setGroup(eA).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new V,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}var PG=e=>pP.transformDirection(jG(e).sub(MG(e))),FG=_k(`vec3`,`totalDiffuse`),IG=_k(`vec3`,`totalSpecular`),LG=_k(`vec3`,`outgoingLight`),RG=e=>e.sort((e,t)=>e.id-t.id),zG=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},BG=new WeakMap,VG=[],HG=class extends HD{static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=FG,this.totalSpecularNode=IG,this.outgoingLightNode=LG,this._lights=[],this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t0}},UG=(e=[])=>new HG().setLights(e),WG=class extends HD{static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=ND.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){GG.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||UP)}},GG=_k(`vec3`,`shadowPositionWorld`);function KG(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new Ur),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function qG(e,t){return t=KG(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function JG(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function YG(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function XG(e,t){return t=YG(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function ZG(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function QG(e,t,n){return n=qG(e,n),n=XG(t,n),n}function $G(e,t,n){JG(e,n),ZG(t,n)}var eK=new WeakMap,tK=G(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=wN(e,t.xy).setName(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),nK=G(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=wN(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=wF(`mapSize`,`vec2`,n).setGroup(eA),o=wF(`radius`,`float`,n).setGroup(eA),s=QO(1).div(a),c=o.mul(s.x),l=aU(HN.xy).mul(6.28318530718);return lA(i(t.xy.add(oU(0,5,l).mul(c)),t.z),i(t.xy.add(oU(1,5,l).mul(c)),t.z),i(t.xy.add(oU(2,5,l).mul(c)),t.z),i(t.xy.add(oU(3,5,l).mul(c)),t.z),i(t.xy.add(oU(4,5,l).mul(c)),t.z)).mul(1/5)}),rK=G(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=wF(`mapSize`,`vec2`,n).setGroup(eA),a=QO(1).div(i),o=t.xy,s=QA(o.mul(i).add(.5)).toConst();o.subAssign(s.sub(.5).mul(a));let c=n=>{let i=wN(e,o).offset(n).gather();return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)},l=c($O(-1,1)).toConst(),u=c($O(1,1)).toConst(),d=c($O(-1,-1)).toConst(),f=c($O(1,-1)).toConst();return lA(Hj(l.x,u.y,s.x).add(l.y).add(u.x).mul(s.y),Hj(l.w,u.z,s.x).add(l.z).add(u.w),Hj(d.x,f.y,s.x).add(d.y).add(f.x),Hj(d.w,f.z,s.x).add(d.z).add(f.w).mul(s.y.oneMinus())).mul(1/9)}),iK=G(({depthTexture:e,shadowCoord:t,depthLayer:n},r)=>{let i=wN(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=i.x,o=Ej(1e-7,i.y.mul(i.y)),s=r.renderer.reversedDepthBuffer?Dj(a,t.z):Dj(t.z,a),c=K(1).toVar();return qO(s.notEqual(1),()=>{let e=t.z.sub(a),n=o.div(o.add(e.mul(e)));n=Uj(uA(n,.3).div(.65)),c.assign(Ej(s,n))}),c}),aK=e=>{let t=eK.get(e);return t===void 0&&(t=new dR,t.colorNode=ak(0,0,0,1),t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.blending=0,t.fog=!1,eK.set(e,t)),t},oK=e=>{let t=eK.get(e);t!==void 0&&(t.dispose(),eK.delete(e))},sK=new _V,cK=[],lK=(e,t,n,r)=>{cK[0]=e,cK[1]=t;let i=sK.get(cK);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,u,d,f)=>{(i.castShadow===!0||i.receiveShadow&&n===3)&&(r&&(kD(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,u,d,f),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,sK.set(cK,i)),cK[0]=null,cK[1]=null,i},uK=G(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=K(0).toVar(`meanVertical`),o=K(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(K(1)).select(K(0),K(2).div(e.sub(1))),c=e.lessThanEqual(K(1)).select(K(0),K(-1));return xL({start:q(0),end:q(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(K(e).mul(s)),u=r.sample(lA(HN.xy,QO(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e),QO(a,qA(o.sub(a.mul(a)).max(0)))}),dK=G(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=K(0).toVar(`meanHorizontal`),o=K(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(K(1)).select(K(0),K(2).div(e.sub(1))),c=e.lessThanEqual(K(1)).select(K(0),K(-1));return xL({start:q(0),end:q(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(K(e).mul(s)),u=r.sample(lA(HN.xy,QO(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(lA(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e),QO(a,qA(o.sub(a.mul(a)).max(0)))}),fK=[tK,nK,rK,iK],pK,mK=new ZH,hK=class extends WG{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,K(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=n.biasNode||wF(`bias`,`float`,n).setGroup(eA),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{let e=a.w;a=a.xy.div(e);let t=wF(`near`,`float`,n.camera).setGroup(eA),r=wF(`far`,`float`,n.camera).setGroup(eA);o=YL(e.negate(),t,r)}return a=Y(a.x,a.y.oneMinus(),r.reversedDepthBuffer?o.sub(i):o.add(i)),a}getShadowFilterFn(e){return fK[e]}setupRenderTarget(e,t){let n=new eo(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t,camera:n}=e,{light:r,shadow:i}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(i,e),s=t.shadowMap.type,c=t.hasCompatibility(Qt.TEXTURE_COMPARE);if((s===1||s===2)&&c?(a.minFilter=be,a.magFilter=be):(a.minFilter=_e,a.magFilter=_e),i.camera.coordinateSystem=n.coordinateSystem,i.camera.updateProjectionMatrix(),s===3&&i.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:He,type:Ae,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:He,type:Ae,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:He,type:Ae,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:He,type:Ae,depthBuffer:!1}));let t=wN(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=wN(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let r=wF(`blurSamples`,`float`,i).setGroup(eA),s=wF(`radius`,`float`,i).setGroup(eA),c=wF(`mapSize`,`vec2`,i).setGroup(eA),l=this.vsmMaterialVertical||=new dR;l.fragmentNode=uK({samples:r,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new dR,l.fragmentNode=dK({samples:r,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let l=wF(`intensity`,`float`,i).setGroup(eA),u=wF(`normalBias`,`float`,i).setGroup(eA),d=kG(r),f=rF.mul(u),p;p=!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?d.mul(GG.add(f)):rA(`mat4`).onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(d.value,e.matrixWorld)).mul(VP).add(d.mul(ak(f,0)));let m=this.setupShadowCoord(e,p),h=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(h===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let g=s===3&&i.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,_=this.setupShadowFilter(e,{filterFn:h,shadowTexture:o.texture,depthTexture:g,shadowCoord:m,shadow:i,depthLayer:this.depthLayer}),v;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?v=bF(o.texture,m.xyz):(v=wN(o.texture,m),a.isArrayTexture&&(v=v.depth(this.depthLayer))));let y;y=v?Hj(1,_.rgb.mix(v,1),l.mul(v.a)).toVar():Hj(1,_,l).toVar(),this.shadowMap=o,this.shadow.map=o;let b=`${this.light.type} Shadow [ ${this.light.name||`ID: `+this.light.id} ]`;return v&&y.toInspector(`${b} / Color`,()=>this.shadowMap.texture.isCubeTexture?bF(this.shadowMap.texture,TR()):wN(this.shadowMap.texture)),y.toInspector(`${b} / Depth`,()=>{let e=wF(`near`,`float`,this.shadow.camera),t=wF(`far`,`float`,this.shadow.camera),n;n=this.shadowMap.texture.isCubeTexture?bF(this.shadowMap.depthTexture,TR()).r:wN(this.shadowMap.depthTexture).r;let r;return r=this.shadow.camera.isPerspectiveCamera?JL(n,e,t):GL(n,e,t),r=UL(r,e,t),r.oneMinus()})}setup(e){if(e.renderer.shadowMap.enabled!==!1)return G(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);let o=a.name;a.name=`Shadow Map [ ${r.name||`ID: `+r.id} ]`,i.render(a,t.camera),a.name=o}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;pK=QG(i,a,pK),a.overrideMaterial=aK(n),i.setRenderObjectFunction(lK(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===3&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,$G(i,a,pK)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),mK.material=this.vsmMaterialVertical,mK.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),mK.material=this.vsmMaterialHorizontal,mK.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,oK(this.light),this.shadowMap&&=(this.shadowMap.dispose(),null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},gK=(e,t)=>new hK(e,t),_K=new Ur,vK=new lr,yK=new V,bK=new V,xK=[new V(1,0,0),new V(-1,0,0),new V(0,-1,0),new V(0,1,0),new V(0,0,1),new V(0,0,-1)],SK=[new V(0,-1,0),new V(0,-1,0),new V(0,0,-1),new V(0,0,1),new V(0,-1,0),new V(0,-1,0)],CK=[new V(1,0,0),new V(-1,0,0),new V(0,1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1)],wK=[new V(0,-1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1),new V(0,-1,0),new V(0,-1,0)],TK=G(({depthTexture:e,bd3D:t,dp:n})=>bF(e,t).compare(n)),EK=G(({depthTexture:e,bd3D:t,dp:n,shadow:r})=>{let i=wF(`radius`,`float`,r).setGroup(eA),a=wF(`mapSize`,`vec2`,r).setGroup(eA),o=i.div(a.x),s=dj(t),c=ZA(Mj(t,s.x.greaterThan(s.z).select(Y(0,1,0),Y(1,0,0)))),l=Mj(t,c),u=aU(HN.xy).mul(6.28318530718),d=oU(0,5,u),f=oU(1,5,u),p=oU(2,5,u),m=oU(3,5,u),h=oU(4,5,u);return bF(e,t.add(c.mul(d.x).add(l.mul(d.y)).mul(o))).compare(n).add(bF(e,t.add(c.mul(f.x).add(l.mul(f.y)).mul(o))).compare(n)).add(bF(e,t.add(c.mul(p.x).add(l.mul(p.y)).mul(o))).compare(n)).add(bF(e,t.add(c.mul(m.x).add(l.mul(m.y)).mul(o))).compare(n)).add(bF(e,t.add(c.mul(h.x).add(l.mul(h.y)).mul(o))).compare(n)).mul(1/5)}),DK=G(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r},i)=>{let a=n.xyz.toConst(),o=a.abs().toConst(),s=o.x.max(o.y).max(o.z),c=rA(`float`).setGroup(eA).onRenderUpdate(()=>r.camera.near),l=rA(`float`).setGroup(eA).onRenderUpdate(()=>r.camera.far),u=wF(`bias`,`float`,r).setGroup(eA),d=K(1).toVar();return qO(s.sub(l).lessThanEqual(0).and(s.sub(c).greaterThanEqual(0)),()=>{let n;i.renderer.reversedDepthBuffer?(n=qL(s.negate(),c,l),n.subAssign(u)):i.renderer.logarithmicDepthBuffer?(n=YL(s.negate(),c,l),n.addAssign(u)):(n=KL(s.negate(),c,l),n.addAssign(u));let o=a.normalize();d.assign(e({depthTexture:t,bd3D:o,dp:n,shadow:r}))}),d}),OK=class extends hK{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===0?TK:EK}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i}){return DK({filterFn:t,depthTexture:n,shadowCoord:r,shadow:i})}setupRenderTarget(e,t){let n=new to(e.mapSize.width);n.name=`PointShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name=`PointShadowMap`,r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.camera,s=t.matrix,c=i.coordinateSystem===Xt,l=c?xK:CK,u=c?SK:wK;n.setSize(t.mapSize.width,t.mapSize.width);let d=i.autoClear,f=i.getClearColor(_K),p=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(n,e),i.clear();let c=r.distance||o.far;c!==o.far&&(o.far=c,o.updateProjectionMatrix()),yK.setFromMatrixPosition(r.matrixWorld),o.position.copy(yK),bK.copy(o.position),bK.add(l[e]),o.up.copy(u[e]),o.lookAt(bK),o.updateMatrixWorld(),s.makeTranslation(-yK.x,-yK.y,-yK.z),vK.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(vK,o.coordinateSystem,o.reversedDepth);let d=a.name;a.name=`Point Light Shadow [ ${r.name||`ID: `+r.id} ] - Face ${e+1}`,i.render(a,o),a.name=d}i.autoClear=d,i.setClearColor(f,p)}},kK=(e,t)=>new OK(e,t),AK=class extends AL{static get type(){return`AnalyticLightNode`}constructor(e=null){super(),this.light=e,this.color=new Ur,this.colorNode=e&&e.colorNode||rA(this.color).setGroup(eA),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ND.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener(`dispose`,this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener(`dispose`,this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return NG(this.light).sub(e.context.positionView||GP)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return gK(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){let e=this.light.shadow.shadowNode,t;t=e===void 0?this.setupShadowNode():FO(e),this.shadowNode=t,this.shadowColorNode=n=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(n=e.context.getShadow(this,e)),this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},jK=G(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),MK=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=jK({lightDistance:t.length(),cutoffDistance:n,decayExponent:r});return{lightDirection:i,lightColor:e.mul(a)}},NK=class extends AK{static get type(){return`PointLightNode`}constructor(e=null){super(e),this.cutoffDistanceNode=rA(0).setGroup(eA),this.decayExponentNode=rA(2).setGroup(eA)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return kK(this.light)}setupDirect(e){return MK({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}},PK=G(([e=_N()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor();return n.add(r).mod(2).sign()}),FK=G(([e=_N()],{renderer:t,material:n})=>{let r=Vj(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.currentSamples>0){let e=K(r.fwidth()).toVar();i=Kj(e.oneMinus(),e.add(1),r).oneMinus()}else i=eM(r.greaterThan(1),0,1);return i}),IK=G(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar();return eM(ZO(e).toVar(),i,r).uniformFlow()}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),LK=G(([e,t])=>{let n=ZO(t).toVar(),r=K(e).toVar();return eM(n,r.negate(),r).uniformFlow()}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),RK=G(([e])=>q(YA(K(e).toVar()))).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),zK=G(([e,t])=>{let n=K(e).toVar();return t.assign(RK(n)),n.sub(K(t))}),BK=gH([G(([e,t,n,r,i,a])=>{let o=K(a).toVar(),s=K(i).toVar(),c=K(r).toVar(),l=K(n).toVar(),u=K(t).toVar(),d=K(e).toVar(),f=K(uA(1,s)).toVar();return uA(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),G(([e,t,n,r,i,a])=>{let o=K(a).toVar(),s=K(i).toVar(),c=Y(r).toVar(),l=Y(n).toVar(),u=Y(t).toVar(),d=Y(e).toVar(),f=K(uA(1,s)).toVar();return uA(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]})]),VK=gH([G(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=K(u).toVar(),f=K(l).toVar(),p=K(c).toVar(),m=K(s).toVar(),h=K(o).toVar(),g=K(a).toVar(),_=K(i).toVar(),v=K(r).toVar(),y=K(n).toVar(),b=K(t).toVar(),x=K(e).toVar(),S=K(uA(1,p)).toVar(),C=K(uA(1,f)).toVar();return K(uA(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),G(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=K(u).toVar(),f=K(l).toVar(),p=K(c).toVar(),m=Y(s).toVar(),h=Y(o).toVar(),g=Y(a).toVar(),_=Y(i).toVar(),v=Y(r).toVar(),y=Y(n).toVar(),b=Y(t).toVar(),x=Y(e).toVar(),S=K(uA(1,p)).toVar(),C=K(uA(1,f)).toVar();return K(uA(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]})]),HK=gH([G(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar(),a=J(J(e).toVar().bitAnd(J(7))).toVar(),o=K(IK(a.lessThan(J(4)),i,r)).toVar(),s=K(dA(2,IK(a.lessThan(J(4)),r,i))).toVar();return LK(o,ZO(a.bitAnd(J(1)))).add(LK(s,ZO(a.bitAnd(J(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),G(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=K(t).toVar(),s=J(J(e).toVar().bitAnd(J(15))).toVar(),c=K(IK(s.lessThan(J(8)),o,a)).toVar(),l=K(IK(s.lessThan(J(4)),a,IK(s.equal(J(12)).or(s.equal(J(14))),o,i))).toVar();return LK(c,ZO(s.bitAnd(J(1)))).add(LK(l,ZO(s.bitAnd(J(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),UK=gH([G(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar(),a=rk(e).toVar();return Y(HK(a.x,i,r),HK(a.y,i,r),HK(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),G(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=K(t).toVar(),s=rk(e).toVar();return Y(HK(s.x,o,a,i),HK(s.y,o,a,i),HK(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),WK=G(([e])=>dA(.6616,K(e).toVar())).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),GK=G(([e])=>dA(.982,K(e).toVar())).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),KK=gH([WK,G(([e])=>dA(.6616,Y(e).toVar())).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),qK=gH([GK,G(([e])=>dA(.982,Y(e).toVar())).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),JK=G(([e,t])=>{let n=q(t).toVar(),r=J(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(q(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),YK=G(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(JK(n,q(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(JK(e,q(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(JK(t,q(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(JK(n,q(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(JK(e,q(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(JK(t,q(4))),t.addAssign(e)}),XK=G(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar();return r.bitXorAssign(i),r.subAssign(JK(i,q(14))),a.bitXorAssign(r),a.subAssign(JK(r,q(11))),i.bitXorAssign(a),i.subAssign(JK(a,q(25))),r.bitXorAssign(i),r.subAssign(JK(i,q(16))),a.bitXorAssign(r),a.subAssign(JK(r,q(4))),i.bitXorAssign(a),i.subAssign(JK(a,q(14))),r.bitXorAssign(i),r.subAssign(JK(i,q(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),ZK=G(([e])=>K(J(e).toVar()).div(K(J(q(4294967295))))).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),QK=G(([e])=>{let t=K(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),$K=gH([G(([e])=>{let t=q(e).toVar(),n=J(J(1)).toVar(),r=J(J(q(3735928559)).add(n.shiftLeft(J(2))).add(J(13))).toVar();return XK(r.add(J(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),G(([e,t])=>{let n=q(t).toVar(),r=q(e).toVar(),i=J(J(2)).toVar(),a=J().toVar(),o=J().toVar(),s=J().toVar();return a.assign(o.assign(s.assign(J(q(3735928559)).add(i.shiftLeft(J(2))).add(J(13))))),a.addAssign(J(r)),o.addAssign(J(n)),XK(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),G(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=q(e).toVar(),o=J(J(3)).toVar(),s=J().toVar(),c=J().toVar(),l=J().toVar();return s.assign(c.assign(l.assign(J(q(3735928559)).add(o.shiftLeft(J(2))).add(J(13))))),s.addAssign(J(a)),c.addAssign(J(i)),l.addAssign(J(r)),XK(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),G(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=q(e).toVar(),c=J(J(4)).toVar(),l=J().toVar(),u=J().toVar(),d=J().toVar();return l.assign(u.assign(d.assign(J(q(3735928559)).add(c.shiftLeft(J(2))).add(J(13))))),l.addAssign(J(s)),u.addAssign(J(o)),d.addAssign(J(a)),YK(l,u,d),l.addAssign(J(i)),XK(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),G(([e,t,n,r,i])=>{let a=q(i).toVar(),o=q(r).toVar(),s=q(n).toVar(),c=q(t).toVar(),l=q(e).toVar(),u=J(J(5)).toVar(),d=J().toVar(),f=J().toVar(),p=J().toVar();return d.assign(f.assign(p.assign(J(q(3735928559)).add(u.shiftLeft(J(2))).add(J(13))))),d.addAssign(J(l)),f.addAssign(J(c)),p.addAssign(J(s)),YK(d,f,p),d.addAssign(J(o)),f.addAssign(J(a)),XK(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]})]),eq=gH([G(([e,t])=>{let n=q(t).toVar(),r=J($K(q(e).toVar(),n)).toVar(),i=rk().toVar();return i.x.assign(r.bitAnd(q(255))),i.y.assign(r.shiftRight(q(8)).bitAnd(q(255))),i.z.assign(r.shiftRight(q(16)).bitAnd(q(255))),i}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),G(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=J($K(q(e).toVar(),i,r)).toVar(),o=rk().toVar();return o.x.assign(a.bitAnd(q(255))),o.y.assign(a.shiftRight(q(8)).bitAnd(q(255))),o.z.assign(a.shiftRight(q(16)).bitAnd(q(255))),o}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]})]),tq=gH([G(([e])=>{let t=QO(e).toVar(),n=q().toVar(),r=q().toVar(),i=K(zK(t.x,n)).toVar(),a=K(zK(t.y,r)).toVar(),o=K(QK(i)).toVar(),s=K(QK(a)).toVar();return KK(K(BK(HK($K(n,r),i,a),HK($K(n.add(q(1)),r),i.sub(1),a),HK($K(n,r.add(q(1))),i,a.sub(1)),HK($K(n.add(q(1)),r.add(q(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),G(([e])=>{let t=Y(e).toVar(),n=q().toVar(),r=q().toVar(),i=q().toVar(),a=K(zK(t.x,n)).toVar(),o=K(zK(t.y,r)).toVar(),s=K(zK(t.z,i)).toVar(),c=K(QK(a)).toVar(),l=K(QK(o)).toVar(),u=K(QK(s)).toVar();return qK(K(VK(HK($K(n,r,i),a,o,s),HK($K(n.add(q(1)),r,i),a.sub(1),o,s),HK($K(n,r.add(q(1)),i),a,o.sub(1),s),HK($K(n.add(q(1)),r.add(q(1)),i),a.sub(1),o.sub(1),s),HK($K(n,r,i.add(q(1))),a,o,s.sub(1)),HK($K(n.add(q(1)),r,i.add(q(1))),a.sub(1),o,s.sub(1)),HK($K(n,r.add(q(1)),i.add(q(1))),a,o.sub(1),s.sub(1)),HK($K(n.add(q(1)),r.add(q(1)),i.add(q(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]})]),nq=gH([G(([e])=>{let t=QO(e).toVar(),n=q().toVar(),r=q().toVar(),i=K(zK(t.x,n)).toVar(),a=K(zK(t.y,r)).toVar(),o=K(QK(i)).toVar(),s=K(QK(a)).toVar();return KK(Y(BK(UK(eq(n,r),i,a),UK(eq(n.add(q(1)),r),i.sub(1),a),UK(eq(n,r.add(q(1))),i,a.sub(1)),UK(eq(n.add(q(1)),r.add(q(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),G(([e])=>{let t=Y(e).toVar(),n=q().toVar(),r=q().toVar(),i=q().toVar(),a=K(zK(t.x,n)).toVar(),o=K(zK(t.y,r)).toVar(),s=K(zK(t.z,i)).toVar(),c=K(QK(a)).toVar(),l=K(QK(o)).toVar(),u=K(QK(s)).toVar();return qK(Y(VK(UK(eq(n,r,i),a,o,s),UK(eq(n.add(q(1)),r,i),a.sub(1),o,s),UK(eq(n,r.add(q(1)),i),a,o.sub(1),s),UK(eq(n.add(q(1)),r.add(q(1)),i),a.sub(1),o.sub(1),s),UK(eq(n,r,i.add(q(1))),a,o,s.sub(1)),UK(eq(n.add(q(1)),r,i.add(q(1))),a.sub(1),o,s.sub(1)),UK(eq(n,r.add(q(1)),i.add(q(1))),a,o.sub(1),s.sub(1)),UK(eq(n.add(q(1)),r.add(q(1)),i.add(q(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]})]),rq=gH([G(([e])=>ZK($K(q(RK(K(e).toVar())).toVar()))).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),G(([e])=>{let t=QO(e).toVar();return ZK($K(q(RK(t.x)).toVar(),q(RK(t.y)).toVar()))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),G(([e])=>{let t=Y(e).toVar();return ZK($K(q(RK(t.x)).toVar(),q(RK(t.y)).toVar(),q(RK(t.z)).toVar()))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),G(([e])=>{let t=ak(e).toVar();return ZK($K(q(RK(t.x)).toVar(),q(RK(t.y)).toVar(),q(RK(t.z)).toVar(),q(RK(t.w)).toVar()))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]})]),iq=gH([G(([e])=>{let t=q(RK(K(e).toVar())).toVar();return Y(ZK($K(t,q(0))),ZK($K(t,q(1))),ZK($K(t,q(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),G(([e])=>{let t=QO(e).toVar(),n=q(RK(t.x)).toVar(),r=q(RK(t.y)).toVar();return Y(ZK($K(n,r,q(0))),ZK($K(n,r,q(1))),ZK($K(n,r,q(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),G(([e])=>{let t=Y(e).toVar(),n=q(RK(t.x)).toVar(),r=q(RK(t.y)).toVar(),i=q(RK(t.z)).toVar();return Y(ZK($K(n,r,i,q(0))),ZK($K(n,r,i,q(1))),ZK($K(n,r,i,q(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),G(([e])=>{let t=ak(e).toVar(),n=q(RK(t.x)).toVar(),r=q(RK(t.y)).toVar(),i=q(RK(t.z)).toVar(),a=q(RK(t.w)).toVar();return Y(ZK($K(n,r,i,a,q(0))),ZK($K(n,r,i,a,q(1))),ZK($K(n,r,i,a,q(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]})]),aq=G(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=q(t).toVar(),s=Y(e).toVar(),c=K(0).toVar(),l=K(1).toVar();return xL(o,()=>{c.addAssign(l.mul(tq(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),oq=G(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=q(t).toVar(),s=Y(e).toVar(),c=Y(0).toVar(),l=K(1).toVar();return xL(o,()=>{c.addAssign(l.mul(nq(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),sq=G(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=q(t).toVar(),s=Y(e).toVar();return QO(aq(s,o,a,i),aq(s.add(Y(q(19),q(193),q(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),cq=G(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=q(t).toVar(),s=Y(e).toVar();return ak(Y(oq(s,o,a,i)).toVar(),K(aq(s.add(Y(q(19),q(193),q(17))),o,a,i)).toVar())}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),lq=gH([G(([e,t,n,r,i,a,o])=>{let s=q(o).toVar(),c=K(a).toVar(),l=q(i).toVar(),u=q(r).toVar(),d=q(n).toVar(),f=q(t).toVar(),p=QO(e).toVar(),m=Y(iq(QO(f.add(u),d.add(l)))).toVar(),h=QO(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=QO(QO(QO(K(f),K(d)).add(h)).toVar().sub(p)).toVar();return qO(s.equal(q(2)),()=>dj(g.x).add(dj(g.y))),qO(s.equal(q(3)),()=>Ej(dj(g.x),dj(g.y))),jj(g,g)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),G(([e,t,n,r,i,a,o,s,c])=>{let l=q(c).toVar(),u=K(s).toVar(),d=q(o).toVar(),f=q(a).toVar(),p=q(i).toVar(),m=q(r).toVar(),h=q(n).toVar(),g=q(t).toVar(),_=Y(e).toVar(),v=Y(iq(Y(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=Y(Y(Y(K(g),K(h),K(m)).add(v)).toVar().sub(_)).toVar();return qO(l.equal(q(2)),()=>dj(y.x).add(dj(y.y)).add(dj(y.z))),qO(l.equal(q(3)),()=>Ej(dj(y.x),dj(y.y),dj(y.z))),jj(y,y)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),uq=G(([e,t,n])=>{let r=q(n).toVar(),i=K(t).toVar(),a=QO(e).toVar(),o=q().toVar(),s=q().toVar(),c=QO(zK(a.x,o),zK(a.y,s)).toVar(),l=K(1e6).toVar();return xL({start:-1,end:q(1),name:`x`,condition:`<=`},({x:e})=>{xL({start:-1,end:q(1),name:`y`,condition:`<=`},({y:t})=>{let n=K(lq(c,e,t,o,s,i,r)).toVar();l.assign(Tj(l,n))})}),qO(r.equal(q(0)),()=>{l.assign(qA(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),dq=G(([e,t,n])=>{let r=q(n).toVar(),i=K(t).toVar(),a=QO(e).toVar(),o=q().toVar(),s=q().toVar(),c=QO(zK(a.x,o),zK(a.y,s)).toVar(),l=QO(1e6,1e6).toVar();return xL({start:-1,end:q(1),name:`x`,condition:`<=`},({x:e})=>{xL({start:-1,end:q(1),name:`y`,condition:`<=`},({y:t})=>{let n=K(lq(c,e,t,o,s,i,r)).toVar();qO(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),qO(r.equal(q(0)),()=>{l.assign(qA(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),fq=G(([e,t,n])=>{let r=q(n).toVar(),i=K(t).toVar(),a=QO(e).toVar(),o=q().toVar(),s=q().toVar(),c=QO(zK(a.x,o),zK(a.y,s)).toVar(),l=Y(1e6,1e6,1e6).toVar();return xL({start:-1,end:q(1),name:`x`,condition:`<=`},({x:e})=>{xL({start:-1,end:q(1),name:`y`,condition:`<=`},({y:t})=>{let n=K(lq(c,e,t,o,s,i,r)).toVar();qO(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),qO(r.equal(q(0)),()=>{l.assign(qA(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),pq=gH([uq,G(([e,t,n])=>{let r=q(n).toVar(),i=K(t).toVar(),a=Y(e).toVar(),o=q().toVar(),s=q().toVar(),c=q().toVar(),l=Y(zK(a.x,o),zK(a.y,s),zK(a.z,c)).toVar(),u=K(1e6).toVar();return xL({start:-1,end:q(1),name:`x`,condition:`<=`},({x:e})=>{xL({start:-1,end:q(1),name:`y`,condition:`<=`},({y:t})=>{xL({start:-1,end:q(1),name:`z`,condition:`<=`},({z:n})=>{let a=K(lq(l,e,t,n,o,s,c,i,r)).toVar();u.assign(Tj(u,a))})})}),qO(r.equal(q(0)),()=>{u.assign(qA(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),mq=gH([dq,G(([e,t,n])=>{let r=q(n).toVar(),i=K(t).toVar(),a=Y(e).toVar(),o=q().toVar(),s=q().toVar(),c=q().toVar(),l=Y(zK(a.x,o),zK(a.y,s),zK(a.z,c)).toVar(),u=QO(1e6,1e6).toVar();return xL({start:-1,end:q(1),name:`x`,condition:`<=`},({x:e})=>{xL({start:-1,end:q(1),name:`y`,condition:`<=`},({y:t})=>{xL({start:-1,end:q(1),name:`z`,condition:`<=`},({z:n})=>{let a=K(lq(l,e,t,n,o,s,c,i,r)).toVar();qO(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),qO(r.equal(q(0)),()=>{u.assign(qA(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),hq=gH([fq,G(([e,t,n])=>{let r=q(n).toVar(),i=K(t).toVar(),a=Y(e).toVar(),o=q().toVar(),s=q().toVar(),c=q().toVar(),l=Y(zK(a.x,o),zK(a.y,s),zK(a.z,c)).toVar(),u=Y(1e6,1e6,1e6).toVar();return xL({start:-1,end:q(1),name:`x`,condition:`<=`},({x:e})=>{xL({start:-1,end:q(1),name:`y`,condition:`<=`},({y:t})=>{xL({start:-1,end:q(1),name:`z`,condition:`<=`},({z:n})=>{let a=K(lq(l,e,t,n,o,s,c,i,r)).toVar();qO(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),qO(r.equal(q(0)),()=>{u.assign(qA(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),gq=G(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(e).toVar(),f=QO(t).toVar(),p=QO(n).toVar(),m=QO(r).toVar(),h=K(i).toVar(),g=K(a).toVar(),_=K(o).toVar(),v=ZO(s).toVar(),y=q(c).toVar(),b=K(l).toVar(),x=K(u).toVar(),S=f.mul(p).add(m),C=K(0).toVar();return qO(d.equal(q(0)),()=>{C.assign(nq(S))}),qO(d.equal(q(1)),()=>{C.assign(iq(S))}),qO(d.equal(q(2)),()=>{C.assign(hq(S,h,q(0)))}),qO(d.equal(q(3)),()=>{C.assign(oq(Y(S,0),y,b,x))}),C.assign(C.mul(_.sub(g)).add(g)),qO(v,()=>{C.assign(Uj(C,g,_))}),C}).setLayout({name:`mx_unifiednoise2d`,type:`float`,inputs:[{name:`noiseType`,type:`int`},{name:`texcoord`,type:`vec2`},{name:`freq`,type:`vec2`},{name:`offset`,type:`vec2`},{name:`jitter`,type:`float`},{name:`outmin`,type:`float`},{name:`outmax`,type:`float`},{name:`clampoutput`,type:`bool`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),_q=G(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(e).toVar(),f=Y(t).toVar(),p=Y(n).toVar(),m=Y(r).toVar(),h=K(i).toVar(),g=K(a).toVar(),_=K(o).toVar(),v=ZO(s).toVar(),y=q(c).toVar(),b=K(l).toVar(),x=K(u).toVar(),S=f.mul(p).add(m),C=K(0).toVar();return qO(d.equal(q(0)),()=>{C.assign(nq(S))}),qO(d.equal(q(1)),()=>{C.assign(iq(S))}),qO(d.equal(q(2)),()=>{C.assign(hq(S,h,q(0)))}),qO(d.equal(q(3)),()=>{C.assign(oq(S,y,b,x))}),C.assign(C.mul(_.sub(g)).add(g)),qO(v,()=>{C.assign(Uj(C,g,_))}),C}).setLayout({name:`mx_unifiednoise3d`,type:`float`,inputs:[{name:`noiseType`,type:`int`},{name:`position`,type:`vec3`},{name:`freq`,type:`vec3`},{name:`offset`,type:`vec3`},{name:`jitter`,type:`float`},{name:`outmin`,type:`float`},{name:`outmax`,type:`float`},{name:`clampoutput`,type:`bool`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),vq=G(([e])=>{let t=e.y,n=e.z,r=Y().toVar();return qO(t.lessThan(1e-4),()=>{r.assign(Y(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(YA(i)).mul(6).toVar();let a=q(bj(i)),o=i.sub(K(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());qO(a.equal(q(0)),()=>{r.assign(Y(n,l,s))}).ElseIf(a.equal(q(1)),()=>{r.assign(Y(c,n,s))}).ElseIf(a.equal(q(2)),()=>{r.assign(Y(s,n,l))}).ElseIf(a.equal(q(3)),()=>{r.assign(Y(s,c,n))}).ElseIf(a.equal(q(4)),()=>{r.assign(Y(l,s,n))}).Else(()=>{r.assign(Y(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),yq=G(([e])=>{let t=Y(e).toVar(),n=K(t.x).toVar(),r=K(t.y).toVar(),i=K(t.z).toVar(),a=K(Tj(n,Tj(r,i))).toVar(),o=K(Ej(n,Ej(r,i))).toVar(),s=K(o.sub(a)).toVar(),c=K().toVar(),l=K().toVar(),u=K().toVar();return u.assign(o),qO(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),qO(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{qO(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(lA(2,i.sub(n).div(s)))}).Else(()=>{c.assign(lA(4,n.sub(r).div(s)))}),c.mulAssign(1/6),qO(c.lessThan(0),()=>{c.addAssign(1)})}),Y(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),bq=G(([e])=>{let t=Y(e).toVar(),n=ik(_A(t,Y(.04045))).toVar();return Hj(Y(t.div(12.92)).toVar(),Y(Nj(Ej(t.add(Y(.055)),Y(0)).div(1.055),Y(2.4))).toVar(),n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),xq=(e,t)=>{e=K(e),t=K(t);let n=QO(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Kj(e.sub(n),e.add(n),t)},Sq=(e,t,n,r)=>Hj(e,t,n[r].clamp()),Cq=(e,t,n=_N())=>Sq(e,t,n,`x`),wq=(e,t,n=_N())=>Sq(e,t,n,`y`),Tq=(e,t,n,r,i=_N())=>{let a=i.x.clamp(),o=i.y.clamp();return Hj(Hj(e,t,a),Hj(n,r,a),o)},Eq=(e,t,n,r,i)=>Hj(e,t,xq(n,r[i])),Dq=(e,t,n,r=_N())=>Eq(e,t,n,r,`x`),Oq=(e,t,n,r=_N())=>Eq(e,t,n,r,`y`),kq=(e=1,t=0,n=_N())=>n.mul(e).add(t),Aq=(e,t=1)=>(e=K(e),e.abs().pow(t).mul(e.sign())),jq=(e,t=1,n=.5)=>K(e).sub(n).mul(t).add(n),Mq=(e=_N(),t=1,n=0)=>tq(e.convert(`vec2|vec3`)).mul(t).add(n),Nq=(e=_N(),t=1,n=0)=>nq(e.convert(`vec2|vec3`)).mul(t).add(n),Pq=(e=_N(),t=1,n=0)=>(e=e.convert(`vec2|vec3`),ak(nq(e),tq(e.add(QO(19,73)))).mul(t).add(n)),Fq=(e,t=_N(),n=QO(1,1),r=QO(0,0),i=1,a=0,o=1,s=!1,c=1,l=2,u=.5)=>gq(e,t.convert(`vec2|vec3`),n,r,i,a,o,s,c,l,u),Iq=(e,t=_N(),n=QO(1,1),r=QO(0,0),i=1,a=0,o=1,s=!1,c=1,l=2,u=.5)=>_q(e,t.convert(`vec2|vec3`),n,r,i,a,o,s,c,l,u),Lq=(e=_N(),t=1)=>pq(e.convert(`vec2|vec3`),t,q(1)),Rq=(e=_N(),t=1)=>mq(e.convert(`vec2|vec3`),t,q(1)),zq=(e=_N(),t=1)=>hq(e.convert(`vec2|vec3`),t,q(1)),Bq=(e=_N())=>rq(e.convert(`vec2|vec3`)),Vq=(e=_N(),t=3,n=2,r=.5,i=1)=>aq(e,q(t),n,r).mul(i),Hq=(e=_N(),t=3,n=2,r=.5,i=1)=>sq(e,q(t),n,r).mul(i),Uq=(e=_N(),t=3,n=2,r=.5,i=1)=>oq(e,q(t),n,r).mul(i),Wq=(e=_N(),t=3,n=2,r=.5,i=1)=>cq(e,q(t),n,r).mul(i),Gq=(e,t=K(0))=>lA(e,t),Kq=(e,t=K(0))=>uA(e,t),qq=(e,t=K(1))=>dA(e,t),Jq=(e,t=K(1))=>fA(e,t),Yq=(e,t=K(1))=>pA(e,t),Xq=(e,t=K(1))=>Nj(e,t),Zq=(e=K(0),t=K(1))=>lj(e,t),Qq=()=>_H,$q=()=>yH,eJ=(e,t=K(1))=>uA(t,e),tJ=(e,t,n,r)=>e.greaterThan(t).mix(n,r),nJ=(e,t,n,r)=>e.greaterThanEqual(t).mix(n,r),rJ=(e,t,n,r)=>e.equal(t).mix(n,r),iJ=(e,t=null)=>{if(typeof t==`string`){let n={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},r=t.replace(/^out/,``).toLowerCase();if(n[r]!==void 0)return e.element(n[r])}if(typeof t==`number`)return e.element(t);if(typeof t==`string`&&t.length===1){let n={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(n[t]!==void 0)return e.element(n[t])}return e},aJ=(e,t=QO(.5,.5),n=QO(1,1),r=K(0),i=QO(0,0))=>{let a=e;if(t&&(a=a.sub(t)),n&&(a=a.mul(n)),r){let e=r.mul(Math.PI/180),t=e.cos(),n=e.sin();a=QO(a.x.mul(t).sub(a.y.mul(n)),a.x.mul(n).add(a.y.mul(t)))}return t&&(a=a.add(t)),i&&(a=a.add(i)),a},oJ=(e,t)=>{e=QO(e),t=K(t);let n=t.mul(Math.PI/180);return oV(e,n)},sJ=(e,t,n)=>{e=Y(e),t=K(t),n=Y(n);let r=t.mul(Math.PI/180),i=n.normalize(),a=r.cos(),o=r.sin(),s=K(1).sub(a);return e.mul(a).add(i.cross(e).mul(o)).add(i.mul(i.dot(e)).mul(s))},cJ=(e,t)=>(e=Y(e),t=K(t),nI(e,t)),lJ=G(([e,t,n])=>{let r=ZA(e).toVar(),i=uA(K(.5).mul(t.sub(n)),UP).div(r).toVar(),a=uA(K(-.5).mul(t.sub(n)),UP).div(r).toVar(),o=Y().toVar();o.x=r.x.greaterThan(K(0)).select(i.x,a.x),o.y=r.y.greaterThan(K(0)).select(i.y,a.y),o.z=r.z.greaterThan(K(0)).select(i.z,a.z);let s=Tj(o.x,o.y,o.z).toVar();return UP.add(r.mul(s)).toVar().sub(n)}),uJ=G(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(dA(n,n).sub(dA(r,r)))),a}),Z=Object.freeze({__proto__:null,BRDF_GGX:nz,BRDF_Lambert:BR,BasicPointShadowFilter:TK,BasicShadowFilter:tK,Break:CL,Const:dM,Continue:SL,DFGLUT:az,D_GGX:$R,Discard:iN,EPSILON:PA,F_Schlick:zR,Fn:G,HALF_PI:RA,INFINITY:FA,If:qO,Loop:xL,NodeAccess:FD,NodeShaderStage:MD,NodeType:PD,NodeUpdateType:ND,OnBeforeFrameUpdate:ZI,OnBeforeMaterialUpdate:XI,OnBeforeObjectUpdate:YI,OnFrameUpdate:JI,OnMaterialUpdate:qI,OnObjectUpdate:KI,PCFShadowFilter:nK,PCFSoftShadowFilter:rK,PI:IA,PI2:Wee,PointShadowFilter:EK,Return:Kee,Schlick_to_F0:cz,ShaderNode:PO,Stack:YO,Switch:JO,TBNViewMatrix:KF,TWO_PI:LA,VSMShadowFilter:iK,V_GGX_SmithCorrelated:ZR,Var:uM,VarIntent:fM,abs:dj,acesFilmicToneMapping:oW,acos:sj,acosh:cj,add:lA,addMethodChaining:W,addNodeElement:mN,agxToneMapping:uW,all:zA,alphaT:jk,ambientOcclusion:Yk,and:bA,anisotropy:Mk,anisotropyB:Pk,anisotropyT:Nk,any:BA,append:hk,array:aA,asin:aj,asinh:oj,assign:oA,atan:lj,atanh:uj,atomicAdd:JW,atomicAnd:QW,atomicFunc:GW,atomicLoad:KW,atomicMax:XW,atomicMin:ZW,atomicOr:$W,atomicStore:qW,atomicSub:YW,atomicXor:eG,attenuationColor:qk,attenuationDistance:Kk,attribute:gN,attributeArray:dU,backgroundBlurriness:hU,backgroundIntensity:gU,backgroundRotation:_U,batch:fL,batchColor:dL,bentNormalView:JF,billboarding:DH,bitAnd:wA,bitNot:TA,bitOr:EA,bitXor:DA,bitangentGeometry:Yee,bitangentLocal:Xee,bitangentView:GF,bitangentWorld:Zee,bitcast:XV,blendBurn:NU,blendColor:LU,blendDodge:PU,blendOverlay:IU,blendScreen:FU,blur:lB,bool:ZO,buffer:jN,bufferAttribute:LM,builtin:FN,builtinAOContext:oM,builtinShadowContext:aM,bumpMap:nI,bvec2:tk,bvec3:ik,bvec4:ck,bypass:$M,cache:QM,call:sA,cameraFar:uP,cameraIndex:cP,cameraNear:lP,cameraNormalMatrix:hP,cameraPosition:gP,cameraProjectionMatrix:dP,cameraProjectionMatrixInverse:fP,cameraViewMatrix:pP,cameraViewport:_P,cameraWorldMatrix:mP,cbrt:Bj,cdl:UU,ceil:XA,checker:PK,cineonToneMapping:iW,clamp:Uj,clearcoat:wk,clearcoatNormalView:iF,clearcoatRoughness:Tk,clipSpace:zP,code:pW,color:XO,colorSpaceToWorking:CM,colorToDirection:QF,compute:XM,computeKernel:YM,computeSkinning:yL,context:nM,convert:pk,convertColorSpace:wM,convertToTexture:tU,cos:tj,cosh:nj,countLeadingZeros:Ote,countOneBits:kte,countTrailingZeros:Dte,cross:Mj,cubeTexture:bF,cubeTextureBase:yF,dFdx:gj,dFdy:_j,dashSize:Bk,debug:uN,decrement:NA,decrementBefore:jA,defaultBuildStages:LD,defaultShaderStages:ID,defined:MO,degrees:HA,deltaTime:vH,densityFogFactor:CW,depth:QL,depthPass:$U,determinant:Cj,difference:Aj,diffuseColor:yk,diffuseContribution:bk,directPointLight:MK,directionToColor:$ee,directionToFaceDirection:XP,dispersion:Jk,disposeShadowMaterial:oK,distance:kj,div:fA,dot:jj,drawIndex:qM,dynamicBufferAttribute:RM,element:fk,emissive:xk,equal:mA,equirectDirection:TR,equirectUV:wR,exp:UA,exp2:WA,exponentialHeightFogFactor:wW,expression:rN,faceDirection:JP,faceForward:qj,faceforward:Qj,float:K,floatBitsToInt:wte,floatBitsToUint:ZV,floor:YA,fog:TW,fract:QA,frameGroup:$k,frameId:yH,frontFacing:qP,fwidth:xj,gain:tH,gapSize:Vk,getConstNodeType:NO,getCurrentStack:KO,getDirection:aB,getDistanceAttenuation:jK,getGeometryRoughness:YR,getNormalFromDepth:iU,getParallaxCorrectNormal:lJ,getRoughness:XR,getScreenPosition:rU,getShIrradianceAt:uJ,getShadowMaterial:aK,getShadowRenderObjectFunction:lK,getTextureIndex:qV,getViewPosition:nU,ggxConvolution:pB,globalId:NW,glsl:gW,glslFn:yW,grayscale:RU,greaterThan:_A,greaterThanEqual:yA,hash:Ate,highpModelNormalViewMatrix:RP,highpModelViewMatrix:LP,hue:VU,increment:MA,incrementBefore:AA,inspector:pN,instance:sL,instanceColor:oL,instanceIndex:UM,instancedArray:fU,instancedBufferAttribute:zM,instancedDynamicBufferAttribute:BM,instancedMesh:cL,int:q,intBitsToFloat:Tte,interleavedGradientNoise:aU,inverse:wj,inverseSqrt:JA,inversesqrt:$j,invocationLocalIndex:KM,invocationSubgroupIndex:GM,ior:Uk,iridescence:Ok,iridescenceIOR:kk,iridescenceThickness:Ak,isolate:ZM,ivec2:$O,ivec3:nk,ivec4:ok,js:mW,label:sM,length:pj,lengthSq:Vj,lessThan:gA,lessThanEqual:vA,lightPosition:jG,lightProjectionUV:AG,lightShadowMatrix:kG,lightTargetDirection:PG,lightTargetPosition:MG,lightViewPosition:NG,lightingContext:ML,lights:UG,linearDepth:$L,linearToneMapping:nW,localId:PW,log:GA,log2:KA,logarithmicDepthToViewZ:XL,luminance:HU,mat2:lk,mat3:uk,mat4:dk,matcapUV:rV,materialAO:VI,materialAlphaTest:aI,materialAnisotropy:wI,materialAnisotropyVector:HI,materialAttenuationColor:MI,materialAttenuationDistance:jI,materialClearcoat:vI,materialClearcoatNormal:bI,materialClearcoatRoughness:yI,materialColor:oI,materialDispersion:zI,materialEmissive:cI,materialEnvIntensity:fF,materialEnvRotation:pF,materialIOR:AI,materialIridescence:TI,materialIridescenceIOR:EI,materialIridescenceThickness:DI,materialLightMap:BI,materialLineDashOffset:LI,materialLineDashSize:PI,materialLineGapSize:FI,materialLineScale:NI,materialLineWidth:II,materialMetalness:gI,materialNormal:_I,materialOpacity:lI,materialPointSize:RI,materialReference:DF,materialReflectivity:mI,materialRefractionRatio:dF,materialRotation:xI,materialRoughness:hI,materialSheen:SI,materialSheenRoughness:CI,materialShininess:sI,materialSpecular:uI,materialSpecularColor:fI,materialSpecularIntensity:dI,materialSpecularStrength:pI,materialThickness:kI,materialTransmission:OI,max:Ej,maxMipLevel:yN,mediumpModelViewMatrix:IP,metalness:Ck,min:Tj,mix:Hj,mixElement:Yj,mod:pA,modelDirection:DP,modelNormalMatrix:NP,modelPosition:kP,modelRadius:MP,modelScale:AP,modelViewMatrix:FP,modelViewPosition:jP,modelViewProjection:UI,modelWorldMatrix:OP,modelWorldMatrixInverse:PP,morphReference:kL,mrt:JV,mul:dA,mx_aastep:xq,mx_add:Gq,mx_atan2:Zq,mx_cell_noise_float:Bq,mx_contrast:jq,mx_divide:Jq,mx_fractal_noise_float:Vq,mx_fractal_noise_vec2:Hq,mx_fractal_noise_vec3:Uq,mx_fractal_noise_vec4:Wq,mx_frame:$q,mx_heighttonormal:cJ,mx_hsvtorgb:vq,mx_ifequal:rJ,mx_ifgreater:tJ,mx_ifgreatereq:nJ,mx_invert:eJ,mx_modulo:Yq,mx_multiply:qq,mx_noise_float:Mq,mx_noise_vec3:Nq,mx_noise_vec4:Pq,mx_place2d:aJ,mx_power:Xq,mx_ramp4:Tq,mx_ramplr:Cq,mx_ramptb:wq,mx_rgbtohsv:yq,mx_rotate2d:oJ,mx_rotate3d:sJ,mx_safepower:Aq,mx_separate:iJ,mx_splitlr:Dq,mx_splittb:Oq,mx_srgb_texture_to_lin_rec709:bq,mx_subtract:Kq,mx_timer:Qq,mx_transform_uv:kq,mx_unifiednoise2d:Fq,mx_unifiednoise3d:Iq,mx_worley_noise_float:Lq,mx_worley_noise_vec2:Rq,mx_worley_noise_vec3:zq,negate:mj,negateOnBackSide:YP,neutralToneMapping:dW,nodeArray:RO,nodeImmutable:BO,nodeObject:FO,nodeObjectIntent:IO,nodeObjects:LO,nodeProxy:zO,nodeProxyConstructor:HO,nodeProxyIntent:VO,normalFlat:$P,normalGeometry:ZP,normalLocal:QP,normalMap:$F,normalView:nF,normalViewGeometry:eF,normalWorld:rF,normalWorldGeometry:tF,normalize:ZA,not:SA,notEqual:hA,numWorkgroups:jW,objectDirection:bP,objectGroup:tA,objectPosition:SP,objectRadius:TP,objectScale:CP,objectViewPosition:wP,objectWorldMatrix:xP,oneMinus:hj,or:xA,orthographicDepthToViewZ:GL,oscSawtooth:CH,oscSine:bH,oscSquare:xH,oscTriangle:SH,output:zk,outputStruct:xte,overloadingFn:gH,overrideNode:VV,overrideNodes:HV,packHalf2x16:sH,packNormalToRGB:YF,packSnorm2x16:aH,packUnorm2x16:oH,parabola:eH,parallaxDirection:qF,parallaxUV:Qee,parameter:gte,pass:ZU,passTexture:QU,pcurve:nH,perspectiveDepthToViewZ:JL,pmremTexture:WB,pointShadow:kK,pointUV:pU,pointWidth:Hk,positionGeometry:BP,positionLocal:VP,positionPrevious:HP,positionView:GP,positionViewDirection:KP,positionWorld:UP,positionWorldDirection:WP,posterize:WU,pow:Nj,pow2:Pj,pow3:Fj,pow4:Ij,premultiplyAlpha:aN,property:_k,quadBroadcast:EG,quadSwapDiagonal:bG,quadSwapX:vG,quadSwapY:yG,radians:VA,rand:Jj,range:OW,rangeFogFactor:SW,reciprocal:yj,reference:wF,referenceBuffer:TF,reflect:Oj,reflectVector:gF,reflectView:mF,reflector:JH,refract:Gj,refractVector:_F,refractView:hF,reinhardToneMapping:rW,remap:eN,remapClamp:tN,renderGroup:eA,renderOutput:cN,rendererReference:kM,replaceDefaultUV:wH,rotate:oV,rotateUV:TH,roughness:Sk,round:vj,rtt:eU,sRGBTransferEOTF:_M,sRGBTransferOETF:vM,sample:cU,sampler:ON,samplerComparison:kN,saturate:Wj,saturation:zU,screenCoordinate:HN,screenDPR:zN,screenSize:VN,screenUV:BN,select:eM,setCurrentStack:GO,setName:iM,shaderStages:RD,shadow:gK,shadowPositionWorld:GG,shapeCircle:FK,sharedUniformGroup:Qk,sheen:Ek,sheenRoughness:Dk,shiftLeft:OA,shiftRight:kA,shininess:Rk,sign:fj,sin:$A,sinc:rH,sinh:ej,skinning:vL,smoothstep:Kj,smoothstepElement:Xj,specularColor:Fk,specularColorBlended:Ik,specularF90:Lk,spherizeUV:EH,split:mk,spritesheetUV:kH,sqrt:qA,stack:WV,step:Dj,stepElement:Zj,storage:eL,storageBarrier:RW,storageTexture:yU,storageTexture3D:xU,struct:bte,sub:uA,subBuild:mM,subgroupAdd:iG,subgroupAll:hG,subgroupAnd:uG,subgroupAny:gG,subgroupBallot:rG,subgroupBroadcast:xG,subgroupBroadcastFirst:_G,subgroupElect:nG,subgroupExclusiveAdd:oG,subgroupExclusiveMul:lG,subgroupInclusiveAdd:aG,subgroupInclusiveMul:cG,subgroupIndex:WM,subgroupMax:mG,subgroupMin:pG,subgroupMul:sG,subgroupOr:dG,subgroupShuffle:SG,subgroupShuffleDown:TG,subgroupShuffleUp:wG,subgroupShuffleXor:CG,subgroupSize:FW,subgroupXor:fG,tan:rj,tangentGeometry:BF,tangentLocal:VF,tangentView:HF,tangentWorld:UF,tanh:ij,texture:wN,texture3D:CU,texture3DLevel:TU,texture3DLoad:wU,textureBarrier:zW,textureBicubic:Dz,textureBicubicLevel:Ez,textureCubeUV:oB,textureLevel:DN,textureLoad:EN,textureSize:vN,textureStore:bU,thickness:Gk,time:_H,toneMapping:jM,toneMappingExposure:MM,toonOutlinePass:tW,transformDirection:Lj,transformNormal:aF,transformNormalByInverseViewMatrix:zj,transformNormalByViewMatrix:Rj,transformNormalToView:oF,transformedClearcoatNormalView:lF,transformedNormalView:sF,transformedNormalWorld:cF,transmission:Wk,transpose:Sj,triNoise3D:mH,triplanarTexture:jH,triplanarTextures:AH,trunc:bj,uint:J,uintBitsToFloat:Ete,uniform:rA,uniformArray:PN,uniformCubeTexture:xF,uniformFlow:rM,uniformGroup:Zk,uniformTexture:TN,unpackHalf2x16:dH,unpackNormal:ZF,unpackRGBToNormal:XF,unpackSnorm2x16:lH,unpackUnorm2x16:uH,unpremultiplyAlpha:oN,userData:DU,uv:_N,uvec2:ek,uvec3:rk,uvec4:sk,varying:hM,varyingProperty:vk,vec2:QO,vec3:Y,vec4:ak,vectorComponents:zD,velocity:MU,vertexColor:uR,vertexIndex:HM,vertexStage:gM,vibrance:BU,viewZToLogarithmicDepth:YL,viewZToOrthographicDepth:UL,viewZToPerspectiveDepth:KL,viewZToReversedOrthographicDepth:WL,viewZToReversedPerspectiveDepth:qL,viewport:UN,viewportCoordinate:GN,viewportDepthTexture:VL,viewportLinearDepth:eR,viewportMipTexture:LL,viewportOpaqueMipTexture:zL,viewportResolution:qN,viewportSafeUV:OH,viewportSharedTexture:KU,viewportSize:WN,viewportTexture:IL,viewportUV:KN,vogelDiskSample:oU,wgsl:hW,wgslFn:bW,workgroupArray:HW,workgroupBarrier:LW,workgroupId:MW,workingToColorSpace:SM,xor:CA}),dJ=new zV,fJ=class extends wV{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){let r=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(i===null)r._clearColor.getRGB(dJ),dJ.a=r._clearColor.a;else if(i.isColor===!0)i.getRGB(dJ),dJ.a=1,a=!0;else if(i.isNode===!0){let n=this.get(e),a=i;dJ.copy(r._clearColor);let o=n.backgroundMesh;if(o===void 0){let e=ak(a).mul(gU).context({getUV:()=>_U.mul(tF),getTextureLevel:()=>hU}),t=dP.element(3).element(3).equal(1),r=fA(1,dP.element(1).element(1)).mul(3),s=t.select(VP.mul(r),VP),c=FP.mul(ak(s,0)),l=dP.mul(ak(c.xyz,1));l=l.setZ(l.w);let u=new dR;u.name=`Background.material`,u.side=1,u.depthTest=!1,u.depthWrite=!1,u.allowOverride=!1,u.fog=!1,u.lights=!1,u.vertexNode=l,u.colorNode=e,n.backgroundMeshNode=e,n.backgroundMesh=o=new _a(new Ts(1,32,32),u),o.frustumCulled=!1,o.name=`Background.mesh`;function d(){i.removeEventListener(`dispose`,d),o.material.dispose(),o.geometry.dispose()}i.addEventListener(`dispose`,d)}let s=a.getCacheKey();n.backgroundCacheKey!==s&&(n.backgroundMeshNode.node=ak(a).mul(gU),n.backgroundMeshNode.needsUpdate=!0,o.material.needsUpdate=!0,n.backgroundCacheKey=s),t.unshift(o,o.geometry,o.material,0,0,null,null)}else z(`Renderer: Unsupported background configuration.`,i);let o=r.xr.getEnvironmentBlendMode();if(o===`additive`?dJ.set(0,0,0,1):o===`alpha-blend`&&dJ.set(0,0,0,0),r.autoClear===!0||a===!0){let e=n.clearColorValue;e.r=dJ.r,e.g=dJ.g,e.b=dJ.b,e.a=dJ.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),n.depthClearValue=r.getClearDepth(),n.stencilClearValue=r.getClearStencil(),n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}},pJ=0,mJ=class{constructor(e=``,t=[]){this.name=e,this.bindings=t,this.id=pJ++}},hJ=class{constructor(e,t,n,r,i,a,o,s,c,l,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=u,this.nodeAttributes=r,this.bindings=i,this.updateNodes=a,this.updateBeforeNodes=o,this.updateAfterNodes=s,this.observer=c,this.hardwareClipping=l,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){let n=new mJ(t.name,[]);e.push(n);for(let e of t.bindings)n.bindings.push(e.clone())}else e.push(t);return e}},gJ=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},_J=class{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},vJ=class{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}},yJ=class extends vJ{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}},bJ=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}},xJ=0,SJ=class{constructor(e=null){this.id=xJ++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},CJ=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},wJ=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}},TJ=class extends wJ{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},EJ=class extends wJ{constructor(e,t=new B){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},DJ=class extends wJ{constructor(e,t=new V){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},OJ=class extends wJ{constructor(e,t=new ir){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},kJ=class extends wJ{constructor(e,t=new Ur){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},AJ=class extends wJ{constructor(e,t=new pl){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},jJ=class extends wJ{constructor(e,t=new Hn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},MJ=class extends wJ{constructor(e,t=new lr){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},NJ=class extends TJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},PJ=class extends EJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},FJ=class extends DJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},IJ=class extends OJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},LJ=class extends kJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},RJ=class extends AJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},zJ=class extends jJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},BJ=class extends MJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},VJ=0,HJ=new WeakMap,UJ=new WeakMap,WJ=new WeakMap,GJ=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),KJ=e=>/e/g.test(e)?String(e).replace(/\+/g,``):(e=Number(e),e+(e%1?``:`.0`)),qJ=e=>{if(e.writeUsageCount>0)return!0;if(e.subBuildsCache!==void 0){for(let t in e.subBuildsCache)if(qJ(e.subBuildsCache[t]))return!0}return!1},JJ=class{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:``,fragment:``,compute:``},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:``},this.chaining=[],this.stack=WV(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new SJ,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:VJ++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute(`normal`)===!1}isOpaque(){let e=this.material;return e.transparent===!1&&e.blending===1&&e.alphaToCoverage===!1}createRenderTarget(e,t,n){return new ar(e,t,n)}createCubeRenderTarget(e,t){return new ER(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t=`vec4`,n=this.renderer.getRenderTarget();if(n!==null){let r=n.textures[e].type,i=n.textures[e].format,a=`vec`;r===1013?a=`ivec`:r===1014&&(a=`uvec`),t=i===1028||i===1029?r===1013?`int`:r===1014?`uint`:`float`:i===1030||i===1031?`${a}2`:i===1022||i===1032?`${a}3`:`${a}4`}return t}getOutputStructName(){}_getBindGroup(e,t){let n=t[0].groupNode,r=n.shared;if(r)for(let e=1;ee.nodeUniform.node.id-t.nodeUniform.node.id);for(let t of e.uniforms)n+=t.nodeUniform.node.id}else n+=e.nodeUniform.id;let r=this.renderer._currentRenderContext||this.renderer,a=HJ.get(r);a===void 0&&(a=new Map,HJ.set(r,a));let o=vD(n);i=a.get(o),i===void 0&&(i=new mJ(e,t),a.set(o,i))}else i=new mJ(e,t);return i}getBindGroupArray(e,t){let n=this.bindings[t],r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){let t={},n=this.bindings;for(let e of RD)for(let r in n[e]){let i=n[e][r],a=t[r]||(t[r]=[]);for(let e of i)a.includes(e)===!1&&a.push(e)}e=[];for(let n in t){let r=t[n],i=this._getBindGroup(n,r);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:`0u`;if(e===`bool`)return t?`true`:`false`;if(e===`color`)return`${this.getType(`vec3`)}( ${KJ(t.r)}, ${KJ(t.g)}, ${KJ(t.b)} )`;let n=this.getTypeLength(e),r=this.getComponentType(e),i=e=>this.generateConst(r,e);if(n===2)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)} )`;if(n===3)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)} )`;if(n===4&&e!==`mat2`)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)}, ${i(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(i).join(`, `)} )`;if(n>4)return`${this.getType(e)}()`;throw Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e===`color`?`vec3`:e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){let n=this.attributes;for(let t of n)if(t.name===e)return t;let r=new gJ(e,t);return this.registerDeclaration(r),n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e===`void`||e===`property`||e===`sampler`||e===`samplerComparison`||e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`depthTexture`||e===`texture3D`}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;return e.isDepthTexture===!0?`float`:t===1013?`int`:t===1014?`uint`:`float`}getElementType(e){return e===`mat2`?`vec2`:e===`mat3`?`vec3`:e===`mat4`?`vec4`:this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e===`float`||e===`bool`||e===`int`||e===`uint`)return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]===`b`?`bool`:t[1]===`i`?`int`:t[1]===`u`?`uint`:`float`}getVectorType(e){return e===`color`?`vec3`:e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`texture3D`?`vec4`:e}getTypeFromLength(e,t=`float`){if(e===1)return t;let n=SD(e),r=t===`float`?``:t[0];return/mat2/.test(t)===!0&&(n=n.replace(`vec`,`mat`)),r+n}getTypeFromArray(e){return GJ.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let n=t.array,r=e.itemSize,i=e.normalized,a;return!(e instanceof ji)&&i!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){let t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n===null?t===`float`||t===`bool`||t===`int`||t===`uint`?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0:Number(n[1])}getVectorFromMatrix(e){return e.replace(`mat`,`vec`)}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t===`int`||t===`uint`?e:this.changeComponentType(e,`int`)}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw Error(`THREE.NodeBuilder: Invalid active stack removal.`)}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=WV(this.stack);let e=KO();return this.stacks.push(e),GO(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes){let n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,GO(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={});let i=r[t];if(this.subBuildLayers.length===0)return i;let a=r.any?r.any.subBuilds:null,o=this.getClosestSubBuild(a);return o&&(i.subBuildsCache===void 0&&(i.subBuildsCache={}),i=i.subBuildsCache[o]||(i.subBuildsCache[o]={}),i.subBuilds=a),i}getNodeProperties(e,t=`any`){let n=this.getDataFromNode(e,t);return n.properties||={outputNode:null}}getBufferAttributeFromNode(e,t,n=null){let r=this.getDataFromNode(e,`vertex`),i=r.bufferAttribute;if(i===void 0){let a=this.uniforms.index++;n===null&&(n=`nodeAttribute`+a),i=new gJ(n,t,e),this.bufferAttributes.push(i),r.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){let i=this.getDataFromNode(e,r,this.globalCache),a=i.structType;if(a===void 0){let o=this.structs.index++;n===null&&(n=`StructType`+o),a=new CJ(n,t),this.structs[r].push(a),this.types[r][n]=e,i.structType=a}return a}getOutputStructTypeFromNode(e,t){let n=this.getStructTypeFromNode(e,t,`OutputType`,`fragment`);return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){let i=this.getDataFromNode(e,n,this.globalCache),a=i.uniform;if(a===void 0){let o=this.uniforms.index++;a=new _J(r||`nodeUniform`+o,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),i.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,i=!1){let a=this.getDataFromNode(e,r),o=this.getSubBuildProperty(`variable`,a.subBuilds),s=a[o];if(s===void 0){let c=i?`_const`:`_var`,l=this.vars[r]||(this.vars[r]=[]),u=this.vars[c]||(this.vars[c]=0);t===null&&(t=(i?`nodeConst`:`nodeVar`)+u,this.vars[c]++),o!==`variable`&&(t=this.getSubBuildProperty(t,a.subBuilds));let d=e.getArrayCount(this);s=new vJ(t,n,i,d),i||l.push(s),this.registerDeclaration(s),a[o]=s}return s}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,n=e.getNodeType(this),r=null,i=null){let a=this.getDataFromNode(e,`any`),o=this.getSubBuildProperty(`varying`,a.subBuilds),s=a[o];if(s===void 0){let e=this.varyings,c=e.length;t===null&&(t=`nodeVarying`+c),o!==`varying`&&(t=this.getSubBuildProperty(t,a.subBuilds)),s=new yJ(t,n,r,i),e.push(s),this.registerDeclaration(s),a[o]=s}return s}registerDeclaration(e){let t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=e.name,i=r,a=this.getPropertyName(e),o=1;for(;n[a]!==void 0;)i=r+`_`+o++,e.name=i,a=this.getPropertyName(e);i!==r&&R(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${i}'.`),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){let r=this.getDataFromNode(e),i=r.code;if(i===void 0){let e=this.codes[n]||(this.codes[n]=[]),a=e.length;i=new bJ(`nodeCode`+a,t),e.push(i),r.code=i}return i}addFlowCodeHierarchy(e,t){let{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e),i=!0,a=t;for(;a;){if(r.get(a)===!0){i=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(i)for(let e of n)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){let r=this.getDataFromNode(e),i=r.flowCodes||=[],a=r.flowCodeBlock||=new WeakMap;i.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===``?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=`; +`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=` `,this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=this.renderer.backend,n=UJ.get(t);n===void 0&&(n=new WeakMap,UJ.set(t,n));let r=n.get(e);if(r===void 0){r=new _W;let t=this.currentFunctionNode;this.currentFunctionNode=r,r.code=this.buildFunctionCode(e),this.currentFunctionNode=t,n.set(e,r)}return r}flowShaderNode(e){let t=e.layout,n={[Symbol.iterator](){let e=0,t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(let e of t.inputs)n[e.name]=new UV(e.type,e.name);e.layout=null;let r=e.call(n),i=this.flowStagesNode(r,t.type);return e.layout=t,i}flowBuildStage(e,t,n=null){let r=this.getBuildStage();this.setBuildStage(t);let i=e.build(this,n);return this.setBuildStage(r),i}flowStagesNode(e,t=null){let n=this.flow,r=this.vars,i=this.declarations,a=this.cache,o=this.buildStage,s=this.stack,c={code:``};this.flow=c,this.vars={},this.declarations={},this.cache=new SJ,this.stack=WV();for(let n of LD)this.setBuildStage(n),c.result=e.build(this,t);return c.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.declarations=i,this.cache=a,this.stack=s,this.setBuildStage(o),c}getFunctionOperator(){return null}buildFunctionCode(){R(`Abstract function.`)}flowChildNode(e,t=null){let n=this.flow,r={code:``};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){let i=this.tab,a=this.cache,o=this.shaderStage,s=this.context;this.setShaderStage(e);let c={...this.context};delete c.nodeBlock,this.cache=this.globalCache,this.tab=` `,this.context=c;let l=null;if(this.buildStage===`generate`){let i=this.flowChildNode(t,n);r!==null&&(i.code+=`${this.tab+r} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(o),this.cache=a,this.tab=i,this.context=s,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){R(`Abstract function.`)}getVaryings(){R(`Abstract function.`)}getVar(e,t,n=null){return`${n===null?this.getType(e):this.generateArrayDeclaration(e,n)} ${t}`}getVars(e,t=!1){let n=[],r=this.vars[e];if(r!==void 0)for(let e of r)n.push(`${this.getVar(e.type,e.name,e.count)};`);return n.join(t?` +`:` + `)}getUniforms(){R(`Abstract function.`)}getCodes(e){let t=this.codes[e],n=``;if(t!==void 0)for(let e of t)n+=e.code+` +`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){R(`Abstract function.`)}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,`any`).subBuilds:e instanceof Set?[...e]:e,!t)return null;let n=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){let r=t[e];if(n.includes(r))return r}return null}getSubBuildOutput(e){return this.getSubBuildProperty(`outputNode`,e)}getSubBuildProperty(e=``,t=null){let n;n=t===null?this.subBuildFn:this.getClosestSubBuild(t);let r;return r=n?e?n+`_`+e:n:e,r}prebuild(){let{object:e,renderer:t,material:n}=this;if(t.contextNode.isContextNode===!0?this.context={...this.context,...t.contextNode.getFlowContextData()}:z('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),n&&n.contextNode&&(n.contextNode.isContextNode===!0?this.context={...this.context,...n.contextNode.getFlowContextData()}:z('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),n!==null){let e=t.library.fromMaterial(n);e===null&&(z(`NodeBuilder: Material "${n.type}" is not compatible.`),e=new dR),e.build(this)}else this.addFlow(`compute`,e)}build(){this.prebuild();for(let e of LD){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.position);for(let t of RD){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(let e of LD){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.position);for(let t of RD){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.build(this);await cn()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=WJ.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){let n=this.getSharedDataFromNode(e),r=n.cache;if(r===void 0){if(t===`float`||t===`int`||t===`uint`)r=new NJ(e);else if(t===`vec2`||t===`ivec2`||t===`uvec2`)r=new PJ(e);else if(t===`vec3`||t===`ivec3`||t===`uvec3`)r=new FJ(e);else if(t===`vec4`||t===`ivec4`||t===`uvec4`)r=new IJ(e);else if(t===`color`)r=new LJ(e);else if(t===`mat2`)r=new RJ(e);else if(t===`mat3`)r=new zJ(e);else if(t===`mat4`)r=new BJ(e);else throw Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);n.cache=r}return r}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;let r=this.getTypeLength(t),i=this.getTypeLength(n);return r===16&&i===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&i===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||i>4||i===0?e:r===i?`${this.getType(n)}( ${e} )`:r>i?(e=n===`bool`?`all( ${e} )`:`${e}.${`xyz`.slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),n)):i===4&&r>1?`${this.getType(n)}( ${this.format(e,t,`vec3`)}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,`vec2`)}, 0.0 )`:(r===1&&i>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r185 - Node System +`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has(`velocity`)||kD(this.object).useVelocity===!0}},YJ=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){let t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===ND.FRAME){let t=this._getMaps(this.updateBeforeMap,n);if(t.frameId!==this.frameId){let n=t.frameId;t.frameId=this.frameId,e.updateBefore(this)===!1&&(t.frameId=n)}}else if(t===ND.RENDER){let t=this._getMaps(this.updateBeforeMap,n);if(t.renderId!==this.renderId){let n=t.renderId;t.renderId=this.renderId,e.updateBefore(this)===!1&&(t.renderId=n)}}else t===ND.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===ND.FRAME){let t=this._getMaps(this.updateAfterMap,n);t.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(t.frameId=this.frameId)}else if(t===ND.RENDER){let t=this._getMaps(this.updateAfterMap,n);t.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(t.renderId=this.renderId)}else t===ND.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===ND.FRAME){let t=this._getMaps(this.updateMap,n);t.frameId!==this.frameId&&e.update(this)!==!1&&(t.frameId=this.frameId)}else if(t===ND.RENDER){let t=this._getMaps(this.updateMap,n);t.renderId!==this.renderId&&e.update(this)!==!1&&(t.renderId=this.renderId)}else t===ND.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},XJ=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};XJ.isNodeFunctionInput=!0;var ZJ=class extends AK{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},QJ=class extends AK{static get type(){return`DirectionalLightNode`}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:PG(this.light),lightColor:e}}},$J=class extends AK{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=jG(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=rA(new Ur).setGroup(eA)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,i=Hj(n,t,rF.dot(r).mul(.5).add(.5));e.context.irradiance.addAssign(i)}},eY=class extends AK{static get type(){return`SpotLightNode`}constructor(e=null){super(e),this.coneCosNode=rA(0).setGroup(eA),this.penumbraCosNode=rA(0).setGroup(eA),this.cutoffDistanceNode=rA(0).setGroup(eA),this.decayExponentNode=rA(0).setGroup(eA),this.colorNode=rA(this.color).setGroup(eA)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:n,penumbraCosNode:r}=this;return Kj(n,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),n=t.projectionUV;return n===void 0&&(n=AG(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){let{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,a=this.getLightVector(e),o=a.normalize(),s=o.dot(PG(i)),c=this.getSpotAttenuation(e,s),l=jK({lightDistance:a.length(),cutoffDistance:n,decayExponent:r}),u=t.mul(c).mul(l),d,f;return i.colorNode?(f=this.getLightCoord(e),d=i.colorNode(f)):i.map&&(f=this.getLightCoord(e),d=wN(i.map,f.xy).onRenderUpdate(()=>i.map)),d&&(u=f.mul(2).sub(1).abs().lessThan(1).all().select(u.mul(d),u)),{lightColor:u,lightDirection:o}}},tY=class extends eY{static get type(){return`IESSpotLightNode`}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){let n=this.light.iesMap,r=null;if(n&&n.isTexture===!0){let e=t.acos().mul(1/Math.PI);this._iesTextureNode=wN(n,QO(e,0),0),r=this._iesTextureNode.r}else r=super.getSpotAttenuation(e,t);return r}update(e){super.update(e),this._iesTextureNode!==null&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}},nY=class extends AK{static get type(){return`LightProbeNode`}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new V);this.lightProbe=PN(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=uJ(rF,this.lightProbe);e.context.irradiance.addAssign(t)}},rY=G(([e,t])=>{let n=e.abs().sub(t);return pj(Ej(n,0)).add(Tj(Ej(n.x,n.y),0))}),iY=class extends eY{static get type(){return`ProjectorLightNode`}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let e=1;t.map!==null&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=K(0),n=this.penumbraCosNode,r=kG(this.light).mul(e.context.positionWorld||UP);return qO(r.w.greaterThan(0),()=>{let e=rY(r.xyz.div(r.w).xy.sub(QO(.5)),QO(.5)),i=fA(-1,uA(1,sj(n)).sub(1));t.assign(Wj(e.mul(-2).mul(i)))}),t}},aY=new lr,oY=new lr,sY=null,cY=class extends AK{static get type(){return`RectAreaLightNode`}constructor(e=null){super(e),this.halfHeight=rA(new V).setGroup(eA),this.halfWidth=rA(new V).setGroup(eA),this.updateType=ND.RENDER}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;oY.identity(),aY.copy(t.matrixWorld),aY.premultiply(n),oY.extractRotation(aY),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(oY),this.halfHeight.value.applyMatrix4(oY)}setupDirectRectArea(e){let t,n;e.isAvailable(`float32Filterable`)?(t=wN(sY.LTC_FLOAT_1),n=wN(sY.LTC_FLOAT_2)):(t=wN(sY.LTC_HALF_1),n=wN(sY.LTC_HALF_2));let{colorNode:r,light:i}=this;return{lightColor:r,lightPosition:NG(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){sY=e}},lY=class{parseFunction(){R(`Abstract function.`)}},uY=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){R(`Abstract function.`)}};uY.isNodeFunction=!0;var dY=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,fY=/[a-z_0-9]+/gi,pY=`#pragma main`,mY=e=>{e=e.trim();let t=e.indexOf(pY),n=t===-1?e:e.slice(t+12),r=n.match(dY);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=fY.exec(i))!==null;)a.push(o);let s=[],c=0;for(;c{let n=this._createNodeBuilder(e,e.material);try{t?await n.buildAsync():n.build()}catch(r){n=this._createNodeBuilder(e,new dR),t?await n.buildAsync():n.build(),z(`TSL: `+r)}return n};if(t)return o().then(e=>(r=this._createNodeBuilderState(e),i.set(a,r),r.usedTimes++,n.nodeBuilderState=r,r));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(n){t=this._createNodeBuilder(e,new dR),t.build();let r=n.stackTrace;!r&&n.stack&&(r=new gD(n.stack)),z(`TSL: `+n,r)}r=this._createNodeBuilderState(t),i.set(a,r)}}r.usedTimes++,n.nodeBuilderState=r}return r}getForRenderAsync(e){let t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){let t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;let n=this.getForRenderCacheKey(e),r=this.nodeBuilderCache.get(n);return r===void 0?(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null):(r.usedTimes++,t.nodeBuilderState=r,r)}_processBuildQueue(){this._buildInProgress||this._buildQueue.length===0||(this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()}))}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){let t=this.get(e),n=t.nodeBuilderState;if(n===void 0||t.version!==e.version){let r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n,t.version=e.version}return n}_createNodeBuilderState(e){return new hJ(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(this.renderer.lighting.enabled===!1)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){_Y[0]=e,_Y[1]=t;let n=this.renderer.info.calls,r=this.callHashCache.get(_Y)||{};if(r.callId!==n){if(vY.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),vY.push(+!!this.renderer.lighting.enabled),this.renderer.lighting.enabled){vY.push(t.getCacheKey(!0)),vY.push(+!!this.renderer.shadowMap.enabled),vY.push(this.renderer.shadowMap.type);let n=this.getEnvironmentNode(e);n&&vY.push(n.getCacheKey())}let i=this.getFogNode(e);i&&vY.push(i.getCacheKey()),r.callId=n,r.cacheKey=yD(vY),this.callHashCache.set(_Y,r),vY.length=0}return _Y[0]=null,_Y[1]=null,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),n=e.background;if(n){let r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;(t.background!==n||r)&&(t.backgroundNode=this.getCacheNode(`background`,n,()=>{if(n.isCubeTexture===!0||n.mapping===303||n.mapping===304||n.mapping===306){if(e.backgroundBlurriness>0||n.mapping===306)return WB(n);{let e;return e=n.isCubeTexture===!0?bF(n):wN(n),MR(e)}}else if(n.isTexture===!0)return wN(n,BN.flipY()).setUpdateMatrix(!0);else n.isColor!==!0&&z(`WebGPUNodes: Unsupported background configuration.`,n)},r),t.background=n,t.backgroundBlurriness=e.backgroundBlurriness)}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){let i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),a=i.get(t);return(a===void 0||r)&&(a=n(),i.set(t,a)),a}updateFog(e){let t=this.get(e),n=e.fog;n?t.fog!==n&&(t.fogNode=this.getCacheNode(`fog`,n,()=>{if(n.isFogExp2)return TW(wF(`color`,`color`,n).setGroup(eA),CW(wF(`density`,`float`,n).setGroup(eA)));if(n.isFog)return TW(wF(`color`,`color`,n).setGroup(eA),SW(wF(`near`,`float`,n).setGroup(eA),wF(`far`,`float`,n).setGroup(eA)));z(`Renderer: Unsupported fog configuration.`,n)}),t.fog=n):(delete t.fogNode,delete t.fog)}updateEnvironment(e){let t=this.get(e),n=e.environment;n?t.environment!==n&&(t.environmentNode=this.getCacheNode(`environment`,n,()=>{if(n.isCubeTexture===!0)return bF(n);if(n.isTexture===!0)return wN(n);z(`Nodes: Unsupported environment configuration.`,n)}),t.environment=n):t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,i=null){let a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=i,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+`,`+e.currentColorSpace+`,`+e.xr.isPresenting}getOutputNode(e){let t=this.renderer,n;return n=e.isArrayTexture?this.backend.isWebGLBackend?wN(e,BN).depth(FN(`gl_ViewID_OVR`)).renderOutput(t.toneMapping,t.currentColorSpace):wN(e,BN).depth(yY).renderOutput(t.toneMapping,t.currentColorSpace):wN(e,BN).renderOutput(t.toneMapping,t.currentColorSpace),n}setOutputLayerIndex(e){yY.value=e}updateBefore(e){let t=e.getNodeBuilderState();for(let n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){let t=e.getNodeBuilderState();for(let n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){let t=this.getNodeFrame(),n=this.getForCompute(e);for(let e of n.updateNodes)t.updateNode(e)}updateForRender(e){let t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(let e of n.updateNodes)t.updateNode(e)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new YJ,this.nodeBuilderCache=new Map,this.cacheLib={}}},xY=new Ta,SY=class e{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey=``,this.shadowPass=!1,this.viewMatrix=new lr,this.viewNormalMatrix=new Hn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,n){let r=e.length;for(let i=0;i0&&(sn(`THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session.`),this._currentSamples===null&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){let t=this.getWebGPUBinding(),n=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:`depth24plus`});this._glProjLayer=n,e.updateRenderState({layers:[n]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new ar(n.textureWidth,n.textureHeight,{depth:2,minFilter:be,magFilter:be,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,this._useMultiviewIfPossible===!0&&sn(`THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session.`),this._useMultiview=!1}_disposeWebGPUSession(){let e=this._renderer,t=this._xrRenderTarget;if(t===null||e.backend.isWebGPUBackend!==!0)return;let n=e.backend,r=e._textures,i=n.get?n.get(t):null;i&&(i.descriptors=void 0);let a=e=>{e!=null&&(n.delete&&n.delete(e),r.delete&&r.delete(e))};for(let e=0;ecN(e,n.toneMapping,n.outputColorSpace)}),NY.set(i,a))}else a=i;n.contextNode=a,n.setRenderTarget(r.renderTarget),r.rendercall(),n.contextNode=i}n.setRenderTarget(a),n._setXRLayerSize(i.x,i.y),this.isPresenting=r}getSession(){return this._session}async setSession(e){let t=this._renderer;t.initialized===!1&&await t.init(),this._gl=t.getContext();let n=this._gl;if(this._session=e,e!==null){if(e.addEventListener(`select`,this._onSessionEvent),e.addEventListener(`selectstart`,this._onSessionEvent),e.addEventListener(`selectend`,this._onSessionEvent),e.addEventListener(`squeeze`,this._onSessionEvent),e.addEventListener(`squeezestart`,this._onSessionEvent),e.addEventListener(`squeezeend`,this._onSessionEvent),e.addEventListener(`end`,this._onSessionEnd),e.addEventListener(`inputsourceschange`,this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(this._supportsLayers===!0){let r=null,i=null,a=null,o=n.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(a=t.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,r=t.stencil?Be:ze,i=t.stencil?Ne:Oe);let s={colorFormat:n.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature(`OVR_multiview2`)&&(s.textureType=`texture-array`,this._useMultiview=!0),this._glBinding=this.getBinding();let c=this._glBinding.createProjectionLayer(s),l=[c];this._glProjLayer=c,t.setPixelRatio(1),t._setXRLayerSize(c.textureWidth,c.textureHeight);let u=this._useMultiview?2:1,d=new eo(c.textureWidth,c.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,r,u);if(this._xrRenderTarget=new AY(c.textureWidth,c.textureHeight,{format:Re,type:Ce,colorSpace:t.outputColorSpace,depthTexture:d,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes(`layers`),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let e of this._layers)e.plane.material=new aa({color:16777215,side:+(e.type===`cylinder`)}),e.plane.material.blending=5,e.plane.material.blendEquation=100,e.plane.material.blendSrc=200,e.plane.material.blendDst=200,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());let r={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,n,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new AY(i.framebufferWidth,i.framebufferHeight,{format:Re,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:i.ignoreDepthValues===!1,resolveStencilBuffer:i.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:`sessionstart`})}}updateCamera(e){let t=this._session;if(t===null)return;let n=e.near,r=e.far,i=this._cameraXR,a=this._cameraL,o=this._cameraR;i.near=o.near=a.near=n,i.far=o.far=a.far=r,i.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==i.near||this._currentDepthFar!==i.far)&&(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=e.layers.mask|6,a.layers.mask=i.layers.mask&-5,o.layers.mask=i.layers.mask&-3;let s=e.parent,c=i.cameras;IY(i,s);for(let e=0;e=0&&(n[a]=null,t[a].disconnect(i))}for(let r=0;r=n.length){n.push(i),a=e;break}else if(n[e]===null){n[e]=i,a=e;break}if(a===-1)break}let o=t[a];o&&o.connect(i)}}function VY(e){return e.type===`quad`?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function HY(e,t){if(t===void 0)return;let n=this._cameraXR,r=this._renderer,i=r.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),s=t.getViewerPose(o);if(this._xrFrame=t,s!==null){let e=s.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;this._glBaseLayer!==null&&t===null&&i.setXRTarget(a.framebuffer);let o=!1;e.length!==n.cameras.length&&(n.cameras.length=0,o=!0);for(let r=0;r{await this.compileAsync(n,t,e);let r=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,i=this._renderLists.get(e,t),a=this._renderContexts.get(r,this._mrt),o=e.overrideMaterial||n.material,{fragmentShader:s,vertexShader:c}=this._objects.get(n,o,e,t,i.lightsNode,a,a.clippingContext).getNodeBuilderState();return{fragmentShader:s,vertexShader:c}}}}async init(){return this._initPromise===null&&(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(e){if(this._getFallback!==null)try{this.backend=n=this._getFallback(e),await n.init(this)}catch(e){t(e);return}else{t(e);return}}this._nodes=new bY(this,n),this._animation=new gV(this,this._nodes,this.info),this._attributes=new kV(n,this.info),this._background=new fJ(this,this._nodes),this._geometries=new ete(this._attributes,this.info),this._textures=new hte(this,n,this.info),this._pipelines=new ate(n,this._nodes,this.info),this._bindings=new ote(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new CV(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new ute(this.lighting),this._bundles=new TY,this._renderContexts=new pte(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let r=this._nodes.nodeFrame,i=r.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,s=this._handleObjectFunction,c=this._compilationPromises;n===null&&(n=e);let l=e.isScene===!0?e:n.isScene===!0?n:WY,u=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,d=this._renderContexts.get(u,this._mrt),f=this._activeMipmapLevel,p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,r.renderId++,r.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||=new SY,d.clippingContext.updateGlobal(l,t),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t),l.onBeforeRender(this,e,t,u);let m=t.isArrayCamera?JY:qY;t.isArrayCamera?m.setFromArrayCamera(t):(YY.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),m.setFromProjectionMatrix(YY,t.coordinateSystem,t.reversedDepth));let h=this._renderLists.get(l,t);if(h.begin(),this._projectObject(e,t,0,h,d.clippingContext),n!==e&&n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&h.pushLight(e)}),h.finish(),u!==null){this._textures.updateRenderTarget(u,f);let e=this._textures.get(u);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;n===e?this._background.update(l,h,d):this._background.update(n,h,d);let g=h.opaque,_=h.transparent,v=h.transparentDoublePass,y=h.lightsNode;this.opaque===!0&&g.length>0&&this._renderObjects(g,t,l,y),this.transparent===!0&&_.length>0&&this._renderTransparents(_,v,t,l,y),r.renderId=i,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=s,this._compilationPromises=c;for(let e of p){let t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._geometries.updateForRender(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);let n=[];this._pipelines.getForRender(t,n),n.length>0&&await Promise.all(n),this._nodes.updateAfter(t),await cn()}}async renderAsync(e,t){sn(`Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.render(e,t)}async waitForGPU(){z(`Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.`)}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;e===!0?(t.modelViewMatrix=LP,t.modelNormalViewMatrix=RP):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===LP&&e.modelNormalViewMatrix===RP}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return sn(`Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".`),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),z(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),z(t)}_bundleNeedsUpdate(e,t){return t.bundleGPU===void 0||e.version!==t.version}_renderBundle(e,t,n){let{bundleGroup:r,camera:i,renderList:a}=e,o=this._currentRenderContext,s=this._bundles.get(r,i,o),c=this.backend.get(s);if(this._bundleNeedsUpdate(r,c)){this.backend.beginBundle(o),this._currentRenderBundle=s;let{transparentDoublePass:e,transparent:l,opaque:u}=a;this.opaque===!0&&u.length>0&&this._renderObjects(u,i,t,n),this.transparent===!0&&l.length>0&&this._renderTransparents(l,e,i,t,n),this._currentRenderBundle=null,this.backend.finishBundle(o,s),c.version=r.version}else{let{renderObjects:e}=c;for(let t=0,n=e.length;t{c.removeEventListener(`dispose`,e),l.dispose(),this._frameBufferTargets.delete(c)};c.addEventListener(`dispose`,e),this._frameBufferTargets.set(c,l)}let u=this.getOutputRenderTarget();l.depthBuffer=o,l.stencilBuffer=s,u===null?l.setSize(i,a,1):l.setSize(u.width,u.height,u.depth);let d=this._outputRenderTarget?this._outputRenderTarget.viewport:c._viewport,f=this._outputRenderTarget?this._outputRenderTarget.scissor:c._scissor,p=this._outputRenderTarget?1:c._pixelRatio,m=this._outputRenderTarget?this._outputRenderTarget.scissorTest:c._scissorTest;return l.viewport.copy(d),l.scissor.copy(f),l.viewport.multiplyScalar(p),l.scissor.multiplyScalar(p),l.scissorTest=m,l.multiview=u!==null&&u.multiview,l.useArrayDepthTexture=u!==null&&u.useArrayDepthTexture,l.resolveDepthBuffer=u===null||u.resolveDepthBuffer,l._autoAllocateDepthBuffer=u!==null&&u._autoAllocateDepthBuffer,l}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;let r=n?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,a=i.renderId,o=this._currentRenderContext,s=this._currentRenderObjectFunction,c=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;let l=e.isScene===!0?e:WY,u=this._renderTarget||this._outputRenderTarget,d=this._activeCubeFace,f=this._activeMipmapLevel,p;if(r===null?p=u:(p=r,this.setRenderTarget(p)),p!==null&&p.depthBuffer===!0){let e=this._textures.get(p);e.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),e.depthInitialized=!0)}let m=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=m,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(m),this.inspector.beginRender(this.backend.getTimestampUID(m),e,t,p),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t);let h=this._canvasTarget,g=h._viewport,_=h._scissor,v=h._pixelRatio;p!==null&&(g=p.viewport,_=p.scissor,v=1),this.getDrawingBufferSize(GY),KY.set(0,0,GY.width,GY.height);let y=g.minDepth===void 0?0:g.minDepth,b=g.maxDepth===void 0?1:g.maxDepth;m.viewportValue.copy(g).multiplyScalar(v).floor(),m.viewportValue.width>>=f,m.viewportValue.height>>=f,m.viewportValue.minDepth=y,m.viewportValue.maxDepth=b,m.viewport=m.viewportValue.equals(KY)===!1,m.scissorValue.copy(_).multiplyScalar(v).floor(),m.scissor=h._scissorTest&&m.scissorValue.equals(KY)===!1,m.scissorValue.width>>=f,m.scissorValue.height>>=f,m.clippingContext||=new SY,m.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);let x=t.isArrayCamera?JY:qY;t.isArrayCamera?x.setFromArrayCamera(t):(YY.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),x.setFromProjectionMatrix(YY,t.coordinateSystem,t.reversedDepth));let S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,m.clippingContext),S.finish(),this.sortObjects===!0&&S.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),p!==null){this._textures.updateRenderTarget(p,f);let e=this._textures.get(p);m.textures=e.textures,m.depthTexture=e.depthTexture,m.width=e.width,m.height=e.height,m.renderTarget=p,m.depth=p.depthBuffer,m.stencil=p.stencilBuffer}else m.textures=null,m.depthTexture=null,m.width=GY.width,m.height=GY.height,m.depth=this.depth,m.stencil=this.stencil;m.width>>=f,m.height>>=f,m.activeCubeFace=d,m.activeMipmapLevel=f,m.occlusionQueryCount=S.occlusionQueryCount,m.scissorValue.max(XY.set(0,0,0,0)),m.scissorValue.x+m.scissorValue.width>m.width&&(m.scissorValue.width=Math.max(m.width-m.scissorValue.x,0)),m.scissorValue.y+m.scissorValue.height>m.height&&(m.scissorValue.height=Math.max(m.height-m.scissorValue.y,0)),this._background.update(l,S,m),m.camera=t,this.backend.beginRender(m);let{bundles:C,lightsNode:w,transparentDoublePass:T,transparent:E,opaque:D}=S;return C.length>0&&this._renderBundles(C,l,w),this.opaque===!0&&D.length>0&&this._renderObjects(D,t,l,w),this.transparent===!0&&E.length>0&&this._renderTransparents(E,T,t,l,w),this.backend.finishRender(m),i.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=s,this._handleObjectFunction=c,this.lighting.finishRender(e),this._callDepth--,r!==null&&(this.setRenderTarget(u,d,f),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(m)),m}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._nodes.getOutputCacheKey(),n=this._quadCache.get(e.texture),r;if(n===void 0){r=new ZH(new dR),r.name=`Output Color Transform`,r.material.name=`outputColorTransform`,r.material.fragmentNode=this._nodes.getOutputNode(e.texture),n={quad:r,cacheKey:t},this._quadCache.set(e.texture,n);let i=()=>{r.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener(`dispose`,i)};e.texture.addEventListener(`dispose`,i)}else r=n.quad,n.cacheKey!==t&&(r.material.fragmentNode=this._nodes.getOutputNode(e.texture),r.material.needsUpdate=!0,n.cacheKey=t);let i=this.autoClear,a=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(r,e),this.autoClear=i,this.xr.enabled=a}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,n=0,r=-1){if(t!==null&&t.isReadbackBuffer&&this.info.memoryMap.has(t)===!1){this.info.createReadbackBuffer(t);let e=()=>{t.removeEventListener(`dispose`,e),this.info.destroyReadbackBuffer(t)};t.addEventListener(`dispose`,e)}if(n%4!=0||r>0&&r%4!=0)throw Error(`THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.`);return await this.backend.getArrayBufferAsync(e,t,n,r)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,r){this._canvasTarget.setScissor(e,t,n,r)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,n,r,i=0,a=1){this._canvasTarget.setViewport(e,t,n,r,i,a)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)throw Error(`THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.`);let r=this._renderTarget||this._getFrameBufferTarget(),i=null;if(r!==null){this._textures.updateRenderTarget(r);let e=this._textures.get(r);i=this._renderContexts.get(r,null,-1),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=r,i.depth=r.depthBuffer,i.stencil=r.stencilBuffer;let t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),r.depthBuffer===!0&&(e.depthInitialized=!0)}this.backend.clear(e,t,n,i),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){sn(`Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.clear(e,t,n)}async clearColorAsync(){sn(`Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.`),this.clear(!0,!1,!1)}async clearDepthAsync(){sn(`Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!0,!1)}async clearStencilAsync(){sn(`Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==0,t=this.currentColorSpace!==qn.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget===null?this.needsFrameBufferTarget&&(e=0):e=this._renderTarget.samples,e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:0}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:qn.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){if(this._initialized===!0){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(let e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener(`resize`,this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener(`resize`,this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(let e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return R(`Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.`),this.computeAsync(e,t);let n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let i=this.backend,a=this._pipelines,o=this._bindings,s=this._nodes,c=Array.isArray(e)?e:[e];if(c[0]===void 0||c[0].isComputeNode!==!0)throw Error(`THREE.Renderer: .compute() expects a ComputeNode.`);i.beginCompute(e);for(let n of c){if(a.has(n)===!1){let e=()=>{n.removeEventListener(`dispose`,e),a.delete(n),o.deleteForCompute(n),s.delete(n)};n.addEventListener(`dispose`,e);let t=n.onInitFunction;t!==null&&t.call(n,{renderer:this})}s.updateForCompute(n),o.updateForCompute(n);let r=o.getForCompute(n),c=a.getForCompute(n,r);i.compute(e,n,r,c,t)}i.finishCompute(e),n.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return sn(`Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e=`render`){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){sn(`Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.`);this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.`);this._textures.updateRenderTarget(e);let t=this._textures.get(e),n=this._renderContexts.get(e);n.textures=t.textures,n.depthTexture=t.depthTexture,n.width=t.width,n.height=t.height,n.renderTarget=e,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,this.backend.initRenderTarget(n)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=XY.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=XY.copy(t).floor();else{z(`Renderer.copyFramebufferToTexture: Invalid rectangle.`);return}else t=XY.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n===null?(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))):r=n.renderTarget,this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,i,a),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,n,r,i,a=0,o=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,i,o)}_projectObject(e,t,n,r,i){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){let a=t.isArrayCamera?JY:qY;if(!e.frustumCulled||a.intersectsSprite(e)){this.sortObjects===!0&&XY.setFromMatrixPosition(e.matrixWorld).applyMatrix4(YY);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,n,XY.z,null,i)}}else if(e.isLineLoop)z(`Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.`);else if(e.isMesh||e.isLine||e.isPoints){let a=t.isArrayCamera?JY:qY;if(!e.frustumCulled||a.intersectsObject(e)){let{geometry:t,material:a}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),XY.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(YY)),Array.isArray(a)){let o=t.groups;for(let s=0,c=o.length;s0){for(let{material:e}of t)e.side=1;this._renderObjects(t,n,r,i,`backSide`);for(let{material:e}of t)e.side=0;this._renderObjects(e,n,r,i);for(let{material:e}of t)e.side=2}else this._renderObjects(e,n,r,i)}_renderObjects(e,t,n,r,i=null){for(let a=0,o=e.length;a(t.not().discard(),e))(c)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?s=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(s=e.positionNode),n={version:t,colorNode:c,depthNode:l,positionNode:s},this._cacheShadowNodes.set(e,n)}return n}_updateCamera(e){let t=this.xr;if(t.isPresenting===!1){let t=!1;if(this.reversedDepthBuffer===!0&&e.reversedDepth!==!0){if(e._reversedDepth=!0,e.isArrayCamera)for(let t of e.cameras)t._reversedDepth=!0;t=!0}let n=this.coordinateSystem;if(e.coordinateSystem!==n){if(e.coordinateSystem=n,e.isArrayCamera)for(let t of e.cameras)t.coordinateSystem=n;t=!0}if(t===!0&&(e.updateProjectionMatrix(),e.isArrayCamera))for(let t of e.cameras)t.updateProjectionMatrix()}return e.parent===null&&e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.enabled===!0&&t.isPresenting===!0&&(t.cameraAutoUpdate===!0&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,n,r,i,a,o,s=null,c=null){let l=!1,u,d,f,p,m,h,g,_=this._currentSourceMaterial;if(e.onBeforeRender(this,t,n,r,i,a),i.allowOverride===!0&&t.overrideMaterial!==null){this._currentSourceMaterial=i;let e=t.overrideMaterial;if(l=!0,u=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,f=e.isNodeMaterial?e.positionNode:null,p=t.overrideMaterial.side,m=e.displacementMap,h=e.displacementScale,g=e.displacementBias,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.displacementMap=i.displacementMap,e.displacementScale=i.displacementScale,e.displacementBias=i.displacementBias,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){let{colorNode:t,depthNode:n,positionNode:r}=this._getShadowNodes(i);this.shadowMap.type===3?e.side=i.shadowSide===null?i.side:i.shadowSide:e.side=i.shadowSide===null?ZY[i.side]:i.shadowSide,t!==null&&(e.colorNode=t),n!==null&&(e.depthNode=n),r!==null&&(e.positionNode=r)}i=e}i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,this._handleObjectFunction(e,i,t,n,o,a,s,`backSide`),i.side=0,this._handleObjectFunction(e,i,t,n,o,a,s,c),i.side=2):this._handleObjectFunction(e,i,t,n,o,a,s,c),l&&(t.overrideMaterial.colorNode=u,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=f,t.overrideMaterial.side=p,t.overrideMaterial.displacementMap=m,t.overrideMaterial.displacementScale=h,t.overrideMaterial.displacementBias=g),this._currentSourceMaterial=_,e.onAfterRender(this,t,n,r,i,a)}hasCompatibility(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,n,r,i,a,o,s){let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup);let l=this._nodes.needsRefresh(c);l&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._pipelines.isReady(c)&&(this.backend.draw(c,this.info),l&&this._nodes.updateAfter(c))}_createObjectPipeline(e,t,n,r,i,a,o,s){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:n,camera:r,lightsNode:i,group:a,clippingContext:o,passId:s,renderContext:this._currentRenderContext});return}let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}},$Y=class{constructor(e=``){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}};function eX(e){return e+(EV-e%EV)%EV}var tX=class extends $Y{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return eX(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}},nX=class extends tX{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},rX=0,iX=class extends nX{constructor(e,t){super(`UniformBuffer_`+rX++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return eX(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}},aX=class extends nX{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){let t=e.index;if(this._addedIndices.has(t))return;let n=this._updateRangeCache.get(t);n===void 0&&(n={start:0,count:0},this._updateRangeCache.set(t,n)),n.start=e.offset,n.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(n)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let n=0,r=this.uniforms.length;n0?i:``;t=`${n.name} {\n\t${r} ${e.name}[${a}];\n};\n`}else{let t=e.groupNode.name;if(r[t]===void 0){let e=this.uniformGroups[t];if(e!==void 0){let n=[];for(let t of e.uniforms){let e=t.getType(),r=this.getVectorType(e),i=t.nodeUniform.node.precision,a=`${r} ${t.name};`;i!==null&&(a=vX[i]+` `+a),n.push(` `+a)}r[t]=n}}i=!0}if(!i){let r=e.node.precision;r!==null&&(t=vX[r]+` `+t),t=`uniform `+t,n.push(t)}}let i=``;for(let e in r){let t=r[e];i+=this._getGLSLUniformStruct(e,t.join(` +`))+` +`}return i+=n.join(` +`),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==1013){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);let r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t=``;if(e===`vertex`||e===`compute`){let e=this.getAttributesArray(),n=0;for(let r of e)t+=`layout( location = ${n++} ) in ${r.type} ${r.name};\n`}return t}getStructMembers(e){let t=[];for(let n of e.members)t.push(`\t${n.type} ${n.name};`);return t.join(` +`)}getStructs(e){let t=[],n=this.structs[e],r=[];for(let e of n)if(e.output)for(let t of e.members)r.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let n=`struct `+e.name+` { +`;n+=this.getStructMembers(e),n+=` +}; +`,t.push(n)}return e===`fragment`&&r.length===0&&r.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),` +`+r.join(` +`)+` + +`+t.join(` +`)}getVaryings(e){let t=``,n=this.varyings;if(e===`vertex`||e===`compute`)for(let r of n){e===`compute`&&(r.needsInterpolation=!0);let n=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){let e=bX[r.interpolationType]||r.interpolationType,i=xX[r.interpolationSampling]||``;t+=`${e} ${i} out ${n} ${r.name};\n`}else{let e=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${e}out ${n} ${r.name};\n`}else t+=`${n} ${r.name};\n`}else if(e===`fragment`){for(let e of n)if(e.needsInterpolation){let n=this.getType(e.type);if(e.interpolationType){let r=bX[e.interpolationType]||e.interpolationType,i=xX[e.interpolationSampling]||``;t+=`${r} ${i} in ${n} ${e.name};\n`}else{let r=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${r}in ${n} ${e.name};\n`}}}for(let n of this.builtins[e])t+=`${n};\n`;return t}getVertexIndex(){return`uint( gl_VertexID )`}getInstanceIndex(){return`uint( gl_InstanceID )`}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){z(`GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node`)}getInvocationSubgroupIndex(){z(`GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node`)}getSubgroupIndex(){z(`GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node`)}getDrawIndex(){return this.renderer.backend.extensions.has(`WEBGL_multi_draw`)?`uint( gl_DrawID )`:`nodeUniformDrawId`}getFrontFacing(){return`gl_FrontFacing`}getFragCoord(){return`gl_FragCoord.xy`}getFragDepth(){return`gl_FragDepth`}enableExtension(e,t,n=this.shaderStage){let r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if(e===`vertex`){let t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has(`WEBGL_multi_draw`)&&this.enableExtension(`GL_ANGLE_multi_draw`,`require`,e)}let n=this.extensions[e];if(n!==void 0)for(let{name:e,behavior:r}of n.values())t.push(`#extension ${e} : ${r}`);return t.join(` +`)}getClipDistance(){return`gl_ClipDistance`}isAvailable(e){let t=yX[e];if(t===void 0){let n;switch(t=!1,e){case`float32Filterable`:n=`OES_texture_float_linear`;break;case`clipDistance`:n=`WEBGL_clip_cull_distance`;break}if(n!==void 0){let e=this.renderer.backend.extensions;e.has(n)&&(e.get(n),t=!0)}yX[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension(`GL_ANGLE_clip_cull_distance`,`require`),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension(`GL_OVR_multiview2`,`require`,`fragment`),this.enableExtension(`GL_OVR_multiview2`,`require`,`vertex`),this.builtins.vertex.push(`layout(num_views = 2) in`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t=``;for(let n=0;n0&&(n+=` +`),n+=`\t// flow -> ${a}\n\t`),n+=`${r.code}\n\t`,e===i&&t!==`compute`&&(n+=`// result + `,t===`vertex`?(n+=`gl_Position = `,n+=`${this.format(r.result,i.getNodeType(this),`vec4`)};`):t===`fragment`&&(e.outputNode.isOutputStructNode||(n+=`fragColor = `,n+=`${this.format(r.result,i.getNodeType(this),this.getOutputType())};`)))}let a=e[t];if(a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t,!0),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n,t===`vertex`){let e=this.renderer.backend.extensions;this.object.isBatchedMesh&&e.has(`WEBGL_multi_draw`)===!1&&(a.uniforms+=` +uniform uint nodeUniformDrawId; +`)}}this.material===null?this.computeShader=this._getGLSLVertexCode(e.compute):(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment))}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache),o=a.uniformGPU;if(o===void 0){let r=e.groupNode,s=r.name,c=this.getBindGroupArray(s,n);if(t===`texture`)o=new pX(i.name,i.node,r),c.push(o);else if(t===`cubeTexture`||t===`cubeDepthTexture`)o=new mX(i.name,i.node,r),c.push(o);else if(t===`texture3D`)o=new hX(i.name,i.node,r),c.push(o);else if(t===`buffer`){i.name=`buffer${e.id}`;let t=this.getSharedDataFromNode(e),n=t.buffer;n===void 0&&(e.name=`NodeBuffer_${e.id}`,n=new iX(e,r),n.name=e.name,t.buffer=n),c.push(n),o=n}else{let e=this.uniformGroups[s];e===void 0?(e=new lX(s,r),this.uniformGroups[s]=e,c.push(e)):c.indexOf(e)===-1&&c.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}},wX=null,TX=null,EX=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Zt.RENDER]:null,[Zt.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t=this.get(e),n=this.renderer.info.frame,r;r=e.isComputeNode===!0?`c:`+this.renderer.info.compute.frameCalls:`r:`+this.renderer.info.render.frameCalls,t.timestampUID=r+`:`+e.id+`:f`+n}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith(`c:`)?Zt.COMPUTE:Zt.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e=`render`){if(!this.trackTimestamp){sn(`WebGPURenderer: Timestamp tracking is disabled.`);return}let t=this.timestampQueryPool[e];if(!t)return;let n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return wX||=new B,this.renderer.getDrawingBufferSize(wX)}setScissorTest(){}getClearColor(){let e=this.renderer;return TX||=new zV,e.getClearColor(TX),TX.getRGB(TX),TX}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas===void 0?nn():this.parameters.canvas,`setAttribute`in e&&e.setAttribute(`data-engine`,`three.js r185 webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}},DX=0,OX=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},kX=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this.backend,{gl:r}=n,i=e.array,a=e.usage||r.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,s=n.get(o),c=s.bufferGPU;c===void 0&&(c=this._createBuffer(r,t,i,a),s.bufferGPU=c,s.bufferType=t,s.version=o.version);let l;if(i instanceof Float32Array)l=r.FLOAT;else if(typeof Float16Array<`u`&&i instanceof Float16Array)l=r.HALF_FLOAT;else if(i instanceof Uint16Array)l=e.isFloat16BufferAttribute?r.HALF_FLOAT:r.UNSIGNED_SHORT;else if(i instanceof Int16Array)l=r.SHORT;else if(i instanceof Uint32Array)l=r.UNSIGNED_INT;else if(i instanceof Int32Array)l=r.INT;else if(i instanceof Int8Array)l=r.BYTE;else if(i instanceof Uint8Array)l=r.UNSIGNED_BYTE;else if(i instanceof Uint8ClampedArray)l=r.UNSIGNED_BYTE;else throw Error(`THREE.WebGLBackend: Unsupported buffer data format: `+i);let u={bufferGPU:c,bufferType:t,type:l,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===r.INT||l===r.UNSIGNED_INT||e.gpuType===1013,id:DX++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let e=this._createBuffer(r,t,i,a);u=new OX(u,e)}n.set(e,u)}updateAttribute(e){let t=this.backend,{gl:n}=t,r=e.array,i=e.isInterleavedBufferAttribute?e.data:e,a=t.get(i),o=a.bufferType,s=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(o,a.bufferGPU),s.length===0)n.bufferSubData(o,0,r);else{for(let e=0,t=s.length;e{t.buffer=null,t._mapped=!1,t.removeEventListener(`release`,e),t.removeEventListener(`dispose`,e)};t.addEventListener(`release`,e),t.addEventListener(`dispose`,e),u=new Uint8Array(new ArrayBuffer(l)),t.buffer=u.buffer}else u=new Uint8Array(t);return a.bindBuffer(a.COPY_READ_BUFFER,c),a.getBufferSubData(a.COPY_READ_BUFFER,n,u),a.bindBuffer(a.COPY_READ_BUFFER,null),a.bindBuffer(a.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:u.buffer}_createBuffer(e,t,n,r){let i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,n,r),e.bindBuffer(t,null),i}},AX,jX,MX=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;AX={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT},jX={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new ir().fromArray(t),this.currentViewport=new ir().fromArray(n),this._tempVec4=new ir}enable(e){let{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e===0?this.disable(t.CULL_FACE):(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===1?t.cullFace(t.BACK):e===2?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,n){let r=this.gl,i=this.backend.drawBuffersIndexedExt;if(!i){sn(`WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.`);return}for(let a=0;a0?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n){let e=12288;for(let t=0;t<8;t++)t{function i(){let a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(i);return}e.deleteSync(t),n()}i()})}},PX=!1,FX,IX,LX,RX=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,PX===!1&&(this._init(),PX=!0)}_init(){let e=this.gl;FX={[me]:e.REPEAT,[he]:e.CLAMP_TO_EDGE,[ge]:e.MIRRORED_REPEAT},IX={[_e]:e.NEAREST,[ve]:e.NEAREST_MIPMAP_NEAREST,[ye]:e.NEAREST_MIPMAP_LINEAR,[be]:e.LINEAR,[xe]:e.LINEAR_MIPMAP_NEAREST,[Se]:e.LINEAR_MIPMAP_LINEAR},LX={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,n;return n=e.isCubeTexture===!0?t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?t.TEXTURE_3D:t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,i,a=!1){let{gl:o,extensions:s}=this;if(e!==null){if(o[e]!==void 0)return o[e];R(`WebGLBackend: Attempt to use non-existing WebGL internal format '`+e+`'`)}let c=null;r&&(c=s.get(`EXT_texture_norm16`),c||R(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=t;if(t===o.RED&&(n===o.FLOAT&&(l=o.R32F),n===o.HALF_FLOAT&&(l=o.R16F),n===o.UNSIGNED_BYTE&&(l=o.R8),n===o.BYTE&&(l=o.R8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),n===o.SHORT&&c&&(l=c.R16_SNORM_EXT)),t===o.RED_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.R8UI),n===o.UNSIGNED_SHORT&&(l=o.R16UI),n===o.UNSIGNED_INT&&(l=o.R32UI),n===o.BYTE&&(l=o.R8I),n===o.SHORT&&(l=o.R16I),n===o.INT&&(l=o.R32I)),t===o.RG&&(n===o.FLOAT&&(l=o.RG32F),n===o.HALF_FLOAT&&(l=o.RG16F),n===o.UNSIGNED_BYTE&&(l=o.RG8),n===o.BYTE&&(l=o.RG8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),n===o.SHORT&&c&&(l=c.RG16_SNORM_EXT)),t===o.RG_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RG8UI),n===o.UNSIGNED_SHORT&&(l=o.RG16UI),n===o.UNSIGNED_INT&&(l=o.RG32UI),n===o.BYTE&&(l=o.RG8I),n===o.SHORT&&(l=o.RG16I),n===o.INT&&(l=o.RG32I)),t===o.RGB){let e=a?Rt:qn.getTransfer(i);n===o.FLOAT&&(l=o.RGB32F),n===o.HALF_FLOAT&&(l=o.RGB16F),n===o.UNSIGNED_BYTE&&(l=e===`srgb`?o.SRGB8:o.RGB8),n===o.BYTE&&(l=o.RGB8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),n===o.SHORT&&c&&(l=c.RGB16_SNORM_EXT),n===o.UNSIGNED_SHORT_5_6_5&&(l=o.RGB565),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGB4),n===o.UNSIGNED_INT_5_9_9_9_REV&&(l=o.RGB9_E5),n===o.UNSIGNED_INT_10F_11F_11F_REV&&(l=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGB8UI),n===o.UNSIGNED_SHORT&&(l=o.RGB16UI),n===o.UNSIGNED_INT&&(l=o.RGB32UI),n===o.BYTE&&(l=o.RGB8I),n===o.SHORT&&(l=o.RGB16I),n===o.INT&&(l=o.RGB32I)),t===o.RGBA){let e=a?Rt:qn.getTransfer(i);n===o.FLOAT&&(l=o.RGBA32F),n===o.HALF_FLOAT&&(l=o.RGBA16F),n===o.UNSIGNED_BYTE&&(l=e===`srgb`?o.SRGB8_ALPHA8:o.RGBA8),n===o.BYTE&&(l=o.RGBA8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),n===o.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGBA4),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGBA8UI),n===o.UNSIGNED_SHORT&&(l=o.RGBA16UI),n===o.UNSIGNED_INT&&(l=o.RGBA32UI),n===o.BYTE&&(l=o.RGBA8I),n===o.SHORT&&(l=o.RGBA16I),n===o.INT&&(l=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(n===o.UNSIGNED_SHORT&&(l=o.DEPTH_COMPONENT16),n===o.UNSIGNED_INT&&(l=o.DEPTH_COMPONENT24),n===o.FLOAT&&(l=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&n===o.UNSIGNED_INT_24_8&&(l=o.DEPTH24_STENCIL8),(l===o.R16F||l===o.R32F||l===o.RG16F||l===o.RG32F||l===o.RGBA16F||l===o.RGBA32F)&&s.get(`EXT_color_buffer_float`),l}setTextureParameters(e,t){let{gl:n,extensions:r,backend:i}=this,{state:a}=this.backend,o=qn.getPrimaries(qn.workingColorSpace),s=t.colorSpace===``?null:qn.getPrimaries(t.colorSpace),c=t.colorSpace===``||o===s?n.NONE:n.BROWSER_DEFAULT_WEBGL;a.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),a.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,c),n.texParameteri(e,n.TEXTURE_WRAP_S,FX[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,FX[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,FX[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,IX[t.magFilter]);let l=t.mipmaps!==void 0&&t.mipmaps.length>0,u=t.minFilter===1006&&l?Se:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,IX[u]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,LX[t.compareFunction])),r.has(`EXT_texture_filter_anisotropic`)===!0){if(t.magFilter===1003||t.minFilter!==1005&&t.minFilter!==1008||t.type===1015&&r.has(`OES_texture_float_linear`)===!1)return;if(t.anisotropy>1){let a=r.get(`EXT_texture_filter_anisotropic`);n.texParameterf(e,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:n,defaultTextures:r}=this,i=this.getGLTextureType(e),a=r[i];a===void 0&&(a=t.createTexture(),n.state.bindTexture(i,a),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),r[i]=a),n.set(e,{textureGPU:a,glTextureType:i})}createTexture(e,t){let{gl:n,backend:r}=this,i,a,o,s,c;if(e.isExternalTexture===!0)i=e.sourceTexture,a=this.getGLTextureType(e);else{let{levels:l,width:u,height:d,depth:f}=t;o=r.utils.convert(e.format,e.colorSpace),s=r.utils.convert(e.type),c=this.getInternalFormat(e.internalFormat,o,s,e.normalized,e.colorSpace,e.isVideoTexture),i=n.createTexture(),a=this.getGLTextureType(e),r.state.bindTexture(a,i),this.setTextureParameters(a,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,l,c,u,d,f):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,l,c,u,d,f):e.isVideoTexture||n.texStorage2D(a,l,c,u,d)}r.set(e,{textureGPU:i,glTextureType:a,glFormat:o,glType:s,glInternalFormat:c})}copyBufferToTexture(e,t){let{gl:n,backend:r}=this,{state:i}=r,{textureGPU:a,glTextureType:o,glFormat:s,glType:c}=r.get(t),{width:l,height:u}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(o,a),i.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(o,0,0,0,l,u,s,c,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){let{gl:n}=this,{width:r,height:i}=t,{textureGPU:a,glTextureType:o,glFormat:s,glType:c,glInternalFormat:l}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0))if(this.backend.state.bindTexture(o,a),this.setTextureParameters(o,e),e.isCompressedTexture){let r=e.mipmaps,i=t.image;for(let t=0;t0){let t=El(r.width,r.height,e.format,e.type);for(let i of e.layerUpdates){let e=r.data.subarray(i*t/r.data.BYTES_PER_ELEMENT,(i+1)*t/r.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,i,r.width,r.height,1,s,c,e)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,r.width,r.height,r.depth,s,c,r.data)}else if(e.isData3DTexture){let e=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(o,0,l,s,c,t.image);else if(e.isHTMLTexture)typeof n.texElementImage2D==`function`&&(n.texElementImage2D.length===3?n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,t.image):n.texElementImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t.image));else{let a=e.mipmaps;if(a.length>0)for(let e=0,t=a.length;e0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){let n=o!==0||s!==0,u,f;if(e.isDepthTexture===!0?(u=r.DEPTH_BUFFER_BIT,f=r.DEPTH_ATTACHMENT,t.stencil&&(u|=r.STENCIL_BUFFER_BIT)):(u=r.COLOR_BUFFER_BIT,f=r.COLOR_ATTACHMENT0),n){let e=this.backend.get(t.renderTarget),n=e.framebuffers[t.getCacheKey()],f=e.msaaFrameBuffer;i.bindFramebuffer(r.DRAW_FRAMEBUFFER,n),i.bindFramebuffer(r.READ_FRAMEBUFFER,f);let p=d-s-l;r.blitFramebuffer(o,p,o+c,p+l,o,p,o+c,p+l,u,r.NEAREST),i.bindFramebuffer(r.READ_FRAMEBUFFER,n),i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,p,c,l),i.unbindTexture()}else{let e=r.createFramebuffer();i.bindFramebuffer(r.DRAW_FRAMEBUFFER,e),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,f,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,c,l,0,0,c,l,u,r.NEAREST),r.deleteFramebuffer(e)}}else i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,d-l-s,c,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){let{gl:i}=this,a=t.renderTarget,{depthTexture:o,depthBuffer:s,stencilBuffer:c,width:l,height:u}=a;if(i.bindRenderbuffer(i.RENDERBUFFER,e),s&&!c){let t=i.DEPTH_COMPONENT24;r===!0?this.extensions.get(`WEBGL_multisampled_render_to_texture`).renderbufferStorageMultisampleEXT(i.RENDERBUFFER,a.samples,t,l,u):n>0?(o&&o.isDepthTexture&&o.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,n,t,l,u)):i.renderbufferStorage(i.RENDERBUFFER,t,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else s&&c&&(n>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,n,i.DEPTH24_STENCIL8,l,u):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,r,i,a){let{backend:o,gl:s}=this,{textureGPU:c,glFormat:l,glType:u}=this.backend.get(e),d=s.createFramebuffer();o.state.bindFramebuffer(s.READ_FRAMEBUFFER,d);let f=e.isCubeTexture?s.TEXTURE_CUBE_MAP_POSITIVE_X+a:s.TEXTURE_2D;s.framebufferTexture2D(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,f,c,0);let p=this._getTypedArrayType(u),m=this._getBytesPerTexel(u,l),h=r*i*m,g=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.bufferData(s.PIXEL_PACK_BUFFER,h,s.STREAM_READ),s.readPixels(t,n,r,i,l,u,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),await o.utils._clientWaitAsync();let _=new p(h/p.BYTES_PER_ELEMENT);return s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,_),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),o.state.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.deleteFramebuffer(d),_}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:n}=this,r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}dispose(){let{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}};function zX(e){return e.isDataTexture?e.image.data:typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?e:e.data}var BX=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},VX=class{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;let e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}},HX={WEBGL_multi_draw:`WEBGL_multi_draw`,WEBGL_compressed_texture_astc:`texture-compression-astc`,WEBGL_compressed_texture_etc:`texture-compression-etc2`,WEBGL_compressed_texture_etc1:`texture-compression-etc1`,WEBGL_compressed_texture_pvrtc:`texture-compression-pvrtc`,WEBGL_compressed_texture_s3tc:`texture-compression-s3tc`,EXT_texture_compression_bptc:`texture-compression-bc`,EXT_disjoint_timer_query_webgl2:`timestamp-query`,OVR_multiview2:`OVR_multiview2`},UX=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:n,mode:r,object:i,type:a,info:o,index:s}=this;s===0?n.drawArrays(r,e,t):n.drawElements(r,t,a,e),o.update(i,t,1)}renderInstances(e,t,n){let{gl:r,mode:i,type:a,index:o,object:s,info:c}=this;n!==0&&(o===0?r.drawArraysInstanced(i,e,t,n):r.drawElementsInstanced(i,t,a,e,n),c.update(s,t,n))}renderMultiDraw(e,t,n){let{extensions:r,mode:i,object:a,info:o}=this;if(n===0)return;let s=r.get(`WEBGL_multi_draw`);if(s===null)for(let r=0;rthis.maxQueries)return sn(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,`inactive`),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;let n=this.queries[t];if(n)try{this.queryStates.get(t)===`inactive`&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,`started`))}catch(e){z(`Error in beginQuery:`,e),this.activeQuery=null,this.queryStates.set(t,`inactive`)}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,`ended`),this.activeQuery=null}catch(e){z(`Error in endQuery:`,e),this.queryStates.set(t,`inactive`),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=new Map;for(let[t,n]of this.queryOffsets)if(this.queryStates.get(n)===`ended`){let r=this.queries[n];e.set(t,this.resolveQuery(r))}if(e.size===0)return this.lastValue;let t={},n=[];for(let[r,i]of e){let e=r.match(/^(.*):f(\d+)$/),a=parseInt(e[2]);n.includes(a)===!1&&n.push(a),t[a]===void 0&&(t[a]=0);let o=await i;this.timestamps.set(r,o),t[a]+=o}let r=t[n[n.length-1]];return this.lastValue=r,this.frames=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return z(`Error resolving queries:`,e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,r=!1,i=()=>{n&&=(clearTimeout(n),null)},a=e=>{r||(r=!0,i(),t(e))},o=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(o,1);return}let r=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(r)/1e6)}catch(e){z(`Error checking query:`,e),t(this.lastValue)}};o()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}},KX=class extends EX{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context===void 0?e.domElement.getContext(`webgl2`,n):t.context;function i(t){t.preventDefault();let n={api:`WebGL`,message:t.statusMessage||`Unknown reason`,reason:null,originalEvent:t};e.onDeviceLost(n)}this._onContextLost=i,e.domElement.addEventListener(`webglcontextlost`,i,!1),this.gl=r,this.extensions=new BX(this),this.capabilities=new VX(this),this.attributeUtils=new kX(this),this.textureUtils=new RX(this),this.bufferRenderer=new UX(this),this.state=new MX(this),this.utils=new NX(this),this.extensions.get(`EXT_color_buffer_float`),this.extensions.get(`WEBGL_clip_cull_distance`),this.extensions.get(`OES_texture_float_linear`),this.extensions.get(`EXT_color_buffer_half_float`),this.extensions.get(`WEBGL_multisampled_render_to_texture`),this.extensions.get(`WEBGL_render_shared_exponent`),this.extensions.get(`WEBGL_multi_draw`),this.extensions.get(`OVR_multiview2`),this.extensions.get(`EXT_clip_control`),this.disjoint=this.extensions.get(`EXT_disjoint_timer_query_webgl2`),this.parallel=this.extensions.get(`KHR_parallel_shader_compile`),this.drawBuffersIndexedExt=this.extensions.get(`OES_draw_buffers_indexed`),t.reversedDepthBuffer&&(this.extensions.has(`EXT_clip_control`)?e.reversedDepthBuffer=!0:(R(`WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return Yt}get hasTimestamp(){return this.disjoint!==null}async getArrayBufferAsync(e,t=null,n=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,n,r)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){let r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){let t=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:t}),this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&R(`WebGLBackend: Render-to-texture extension was disabled because an external texture was provided`),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new GX(this.gl,e,2048));let n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){!this.disjoint||!this.trackTimestamp||this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,n=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.viewport(0,0,e,n)}if(e.scissor)this.updateScissor(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.scissor(0,0,e,n)}this.initTimestampQuery(Zt.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=Array(r),n.occlusionQueryObjects=Array(r),n.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:n}=this,r=this.get(e),i=r.previousContext;n.resetVertexState();let a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let o=e.textures;if(o!==null)for(let e=0;e{let o=0;for(let t=0;t1?t.renderInstances(n,r,i):t.render(n,r)}draw(e){let{object:t,pipeline:n,material:r,context:i,hardwareClippingPlanes:a}=e,{programGPU:o}=this.get(n),{gl:s,state:c}=this,l=this.get(i),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&t.matrixWorld.determinantAffine()<0;c.setMaterial(r,d,a),i.mrt!==null&&i.textures!==null&&c.setMRTBlending(i.textures,i.mrt,r),c.useProgram(o);let f=e.getAttributes(),p=this.get(f),m=p.vaoGPU;if(m===void 0){let e=this._getVaoKey(f);m=this.vaoCache[e],m===void 0&&(m=this._createVao(f),this.vaoCache[e]=m,p.vaoGPU=m)}let h=e.getIndex(),g=h===null?null:this.get(h).bufferGPU;c.setVertexState(m,g);let _=l.lastOcclusionObject;if(_!==t&&_!==void 0){if(_!==null&&_.occlusionTest===!0&&(s.endQuery(s.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),t.occlusionTest===!0){let e=s.createQuery();s.beginQuery(s.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}let v=this.bufferRenderer;t.isPoints?v.mode=s.POINTS:t.isLineSegments?v.mode=s.LINES:t.isLine?v.mode=s.LINE_STRIP:t.isLineLoop?v.mode=s.LINE_LOOP:r.wireframe===!0?(c.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),v.mode=s.LINES):v.mode=s.TRIANGLES;let{vertexCount:y,instanceCount:b}=u,{firstVertex:x}=u;if(v.object=t,h!==null){x*=h.array.BYTES_PER_ELEMENT;let e=this.get(h);v.index=h.count,v.type=e.type}else v.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let n=this.get(e.camera),r=e.camera.cameras,i=e.getBindingGroup(`cameraIndex`).bindings[0];if(n.indexesGPU===void 0||n.indexesGPU.length!==r.length){let e=new Uint32Array([0,0,0,0]),t=[];for(let n=0,i=r.length;n{let i=this.parallel,a=()=>{n.getProgramParameter(o,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),t()):requestAnimationFrame(a)};a()});t.push(i);return}this._completeCompile(e,r)}_handleSource(e,t){let n=e.split(` +`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` +`)}_getShaderErrors(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` + +`+i+` + +`+this._handleSource(e.getShaderSource(t),r)}else return i}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){let r=this.gl,i=(r.getProgramInfoLog(e)||``).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError==`function`)this.renderer.debug.onShaderError(r,e,n,t);else{let a=this._getShaderErrors(r,n,`vertex`),o=this._getShaderErrors(r,t,`fragment`);z(`WebGLProgram: Shader Error `+r.getError()+` - VALIDATE_STATUS `+r.getProgramParameter(e,r.VALIDATE_STATUS)+` + +Program Info Log: `+i+` +`+a+` +`+o)}else i!==``&&R(`WebGLProgram: Program Info Log:`,i)}}_completeCompile(e,t){let{state:n,gl:r}=this,{programGPU:i,fragmentShader:a,vertexShader:o}=this.get(t);r.getProgramParameter(i,r.LINK_STATUS)===!1&&this._logProgramError(i,a,o),n.useProgram(i);let s=e.getBindings();this._setupBindings(s,i),this.set(t,{programGPU:i,pipeline:i})}createComputePipeline(e,t){let{state:n,gl:r}=this,i={stage:`fragment`,code:`#version 300 es +precision highp float; +void main() {}`};this.createProgram(i);let{computeProgram:a}=e,o=r.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU,l=a.transforms,u=[],d=[];for(let e=0;eHX[t]===e),n=this.extensions;for(let e=0;e1,f=i.isXRRenderTarget===!0,p=f===!0&&i._hasExternalTextures===!0,m=a.msaaFrameBuffer,h=a.depthRenderbuffer,g=this.extensions.get(`WEBGL_multisampled_render_to_texture`),_=this.extensions.get(`OVR_multiview2`),v=this._useMultisampledExtension(i),y=RV(e),b;if(l?(a.cubeFramebuffers||={},b=a.cubeFramebuffers[y]):f&&p===!1?b=this._xrFramebuffer:(a.framebuffers||={},b=a.framebuffers[y]),b===void 0){b=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,b);let r=e.textures,s=[];if(l){a.cubeFramebuffers[y]=b;let{textureGPU:e}=this.get(r[0]),n=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,e,i)}else{a.framebuffers[y]=b;for(let n=0;n0&&v===!1&&!i.multiview){if(m===void 0){let r=[];m=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,m);let i=[],l=e.textures;for(let n=0;n0&&this._useMultisampledExtension(r)===!1){let a=i.framebuffers[e.getCacheKey()],o=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT));let s=i.msaaFrameBuffer,c=i.msaaRenderbuffers,l=e.textures,u=l.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,s),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),u)for(let e=0;e0&&this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();let e=this.extensions.get(`WEBGL_lose_context`);e&&e.loseContext(),this.renderer.domElement.removeEventListener(`webglcontextlost`,this._onContextLost)}},qX={PointList:`point-list`,LineList:`line-list`,LineStrip:`line-strip`,TriangleList:`triangle-list`},JX=typeof self<`u`&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},YX={Never:`never`,Less:`less`,Equal:`equal`,LessEqual:`less-equal`,Greater:`greater`,NotEqual:`not-equal`,GreaterEqual:`greater-equal`,Always:`always`},XX={Store:`store`},ZX={Load:`load`,Clear:`clear`},QX={CCW:`ccw`,CW:`cw`},$X={None:`none`,Back:`back`},eZ={Uint16:`uint16`,Uint32:`uint32`},Q={R8Unorm:`r8unorm`,R8Snorm:`r8snorm`,R8Uint:`r8uint`,R8Sint:`r8sint`,R16Uint:`r16uint`,R16Sint:`r16sint`,R16Float:`r16float`,RG8Unorm:`rg8unorm`,RG8Snorm:`rg8snorm`,RG8Uint:`rg8uint`,RG8Sint:`rg8sint`,R16Unorm:`r16unorm`,R16Snorm:`r16snorm`,R32Uint:`r32uint`,R32Sint:`r32sint`,R32Float:`r32float`,RG16Uint:`rg16uint`,RG16Sint:`rg16sint`,RG16Float:`rg16float`,RGBA8Unorm:`rgba8unorm`,RGBA8UnormSRGB:`rgba8unorm-srgb`,RGBA8Snorm:`rgba8snorm`,RGBA8Uint:`rgba8uint`,RGBA8Sint:`rgba8sint`,BGRA8Unorm:`bgra8unorm`,BGRA8UnormSRGB:`bgra8unorm-srgb`,RG16Unorm:`rg16unorm`,RG16Snorm:`rg16snorm`,RGB9E5UFloat:`rgb9e5ufloat`,RGB10A2Unorm:`rgb10a2unorm`,RG11B10UFloat:`rg11b10ufloat`,RG32Uint:`rg32uint`,RG32Sint:`rg32sint`,RG32Float:`rg32float`,RGBA16Uint:`rgba16uint`,RGBA16Sint:`rgba16sint`,RGBA16Float:`rgba16float`,RGBA16Unorm:`rgba16unorm`,RGBA16Snorm:`rgba16snorm`,RGBA32Uint:`rgba32uint`,RGBA32Sint:`rgba32sint`,RGBA32Float:`rgba32float`,Depth16Unorm:`depth16unorm`,Depth24Plus:`depth24plus`,Depth24PlusStencil8:`depth24plus-stencil8`,Depth32Float:`depth32float`,Depth32FloatStencil8:`depth32float-stencil8`,BC1RGBAUnorm:`bc1-rgba-unorm`,BC1RGBAUnormSRGB:`bc1-rgba-unorm-srgb`,BC2RGBAUnorm:`bc2-rgba-unorm`,BC2RGBAUnormSRGB:`bc2-rgba-unorm-srgb`,BC3RGBAUnorm:`bc3-rgba-unorm`,BC3RGBAUnormSRGB:`bc3-rgba-unorm-srgb`,BC4RUnorm:`bc4-r-unorm`,BC4RSnorm:`bc4-r-snorm`,BC5RGUnorm:`bc5-rg-unorm`,BC5RGSnorm:`bc5-rg-snorm`,BC6HRGBUFloat:`bc6h-rgb-ufloat`,BC6HRGBFloat:`bc6h-rgb-float`,BC7RGBAUnorm:`bc7-rgba-unorm`,BC7RGBAUnormSRGB:`bc7-rgba-unorm-srgb`,ETC2RGB8Unorm:`etc2-rgb8unorm`,ETC2RGB8UnormSRGB:`etc2-rgb8unorm-srgb`,ETC2RGB8A1Unorm:`etc2-rgb8a1unorm`,ETC2RGB8A1UnormSRGB:`etc2-rgb8a1unorm-srgb`,ETC2RGBA8Unorm:`etc2-rgba8unorm`,ETC2RGBA8UnormSRGB:`etc2-rgba8unorm-srgb`,EACR11Unorm:`eac-r11unorm`,EACR11Snorm:`eac-r11snorm`,EACRG11Unorm:`eac-rg11unorm`,EACRG11Snorm:`eac-rg11snorm`,ASTC4x4Unorm:`astc-4x4-unorm`,ASTC4x4UnormSRGB:`astc-4x4-unorm-srgb`,ASTC5x4Unorm:`astc-5x4-unorm`,ASTC5x4UnormSRGB:`astc-5x4-unorm-srgb`,ASTC5x5Unorm:`astc-5x5-unorm`,ASTC5x5UnormSRGB:`astc-5x5-unorm-srgb`,ASTC6x5Unorm:`astc-6x5-unorm`,ASTC6x5UnormSRGB:`astc-6x5-unorm-srgb`,ASTC6x6Unorm:`astc-6x6-unorm`,ASTC6x6UnormSRGB:`astc-6x6-unorm-srgb`,ASTC8x5Unorm:`astc-8x5-unorm`,ASTC8x5UnormSRGB:`astc-8x5-unorm-srgb`,ASTC8x6Unorm:`astc-8x6-unorm`,ASTC8x6UnormSRGB:`astc-8x6-unorm-srgb`,ASTC8x8Unorm:`astc-8x8-unorm`,ASTC8x8UnormSRGB:`astc-8x8-unorm-srgb`,ASTC10x5Unorm:`astc-10x5-unorm`,ASTC10x5UnormSRGB:`astc-10x5-unorm-srgb`,ASTC10x6Unorm:`astc-10x6-unorm`,ASTC10x6UnormSRGB:`astc-10x6-unorm-srgb`,ASTC10x8Unorm:`astc-10x8-unorm`,ASTC10x8UnormSRGB:`astc-10x8-unorm-srgb`,ASTC10x10Unorm:`astc-10x10-unorm`,ASTC10x10UnormSRGB:`astc-10x10-unorm-srgb`,ASTC12x10Unorm:`astc-12x10-unorm`,ASTC12x10UnormSRGB:`astc-12x10-unorm-srgb`,ASTC12x12Unorm:`astc-12x12-unorm`,ASTC12x12UnormSRGB:`astc-12x12-unorm-srgb`},tZ={ClampToEdge:`clamp-to-edge`,Repeat:`repeat`,MirrorRepeat:`mirror-repeat`},nZ={Linear:`linear`,Nearest:`nearest`},rZ={Zero:`zero`,One:`one`,Src:`src`,OneMinusSrc:`one-minus-src`,SrcAlpha:`src-alpha`,OneMinusSrcAlpha:`one-minus-src-alpha`,Dst:`dst`,OneMinusDst:`one-minus-dst`,DstAlpha:`dst-alpha`,OneMinusDstAlpha:`one-minus-dst-alpha`,SrcAlphaSaturated:`src-alpha-saturated`,Constant:`constant`,OneMinusConstant:`one-minus-constant`},iZ={Add:`add`,Subtract:`subtract`,ReverseSubtract:`reverse-subtract`,Min:`min`,Max:`max`},aZ={None:0,All:15},oZ={Keep:`keep`,Zero:`zero`,Replace:`replace`,Invert:`invert`,IncrementClamp:`increment-clamp`,DecrementClamp:`decrement-clamp`,IncrementWrap:`increment-wrap`,DecrementWrap:`decrement-wrap`},sZ={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},cZ={WriteOnly:`write-only`,ReadOnly:`read-only`,ReadWrite:`read-write`},lZ={NonFiltering:`non-filtering`,Comparison:`comparison`},uZ={Float:`float`,UnfilterableFloat:`unfilterable-float`,Depth:`depth`,SInt:`sint`,UInt:`uint`},dZ={TwoD:`2d`,ThreeD:`3d`},fZ={TwoD:`2d`,TwoDArray:`2d-array`,Cube:`cube`,ThreeD:`3d`},pZ={All:`all`},mZ={Vertex:`vertex`,Instance:`instance`},hZ={CoreFeaturesAndLimits:`core-features-and-limits`,DepthClipControl:`depth-clip-control`,Depth32FloatStencil8:`depth32float-stencil8`,TextureCompressionBC:`texture-compression-bc`,TextureCompressionBCSliced3D:`texture-compression-bc-sliced-3d`,TextureCompressionETC2:`texture-compression-etc2`,TextureCompressionASTC:`texture-compression-astc`,TextureCompressionASTCSliced3D:`texture-compression-astc-sliced-3d`,TimestampQuery:`timestamp-query`,IndirectFirstInstance:`indirect-first-instance`,ShaderF16:`shader-f16`,RG11B10UFloat:`rg11b10ufloat-renderable`,BGRA8UNormStorage:`bgra8unorm-storage`,Float32Filterable:`float32-filterable`,Float32Blendable:`float32-blendable`,ClipDistances:`clip-distances`,DualSourceBlending:`dual-source-blending`,Subgroups:`subgroups`,TextureFormatsTier1:`texture-formats-tier1`,TextureFormatsTier2:`texture-formats-tier2`},gZ={"texture-compression-s3tc":`texture-compression-bc`,"texture-compression-etc1":`texture-compression-etc2`},_Z=class extends uX{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},vZ=class extends tX{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}},yZ=0,bZ=class extends vZ{constructor(e,t){super(`StorageBuffer_`+yZ++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:FD.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}},xZ=[null],SZ=class{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=e.depthTexture===null?e.stencil?this.backend.renderer.reversedDepthBuffer===!0?Q.Depth32FloatStencil8:Q.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?Q.Depth32Float:Q.Depth24Plus:this.getTextureFormatGPU(e.depthTexture)),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorFormats(e){return e.textures===null?[this.getPreferredCanvasFormat()]:e.textures.map(e=>this.getTextureFormatGPU(e))}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return qX.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return qX.LineList;if(e.isLine)return qX.LineStrip;if(e.isMesh)return qX.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.currentSamples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return this._preferredCanvasFormat===null&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(e===1009)return Q.BGRA8Unorm;if(e===1016)return Q.RGBA16Float;throw Error(`THREE.WebGPUUtils: Unsupported output buffer type.`)}};function CZ(e,t){xZ[0]=t,e.queue.submit(xZ),xZ[0]=null}var wZ=class{constructor(){this.label=``,this.layout=null,this.entries=[]}reset(){this.label=``,this.layout=null,this.entries.length=0}},TZ=class{constructor(){this.label=``,this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label=``,this.size=0,this.usage=0,this.mappedAtCreation=!1}},EZ=class{constructor(){this.label=``}reset(){this.label=``}},DZ=class{constructor(){this.label=``,this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label=``,this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}},OZ=class{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}},kZ=class{constructor(){this.label=``,this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label=``,this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}},AZ=class{constructor(){this.label=``,this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new jZ,this.fragment=null}reset(){this.label=``,this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}},jZ=class{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}},MZ=class{constructor(){this.label=``,this.code=``,this.compilationHints=[]}reset(){this.label=``,this.code=``,this.compilationHints.length=0}},NZ=class{constructor(){this.label=``,this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension=`2d`,this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label=``,this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension=`2d`,this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}},PZ=class{constructor(){this.label=``,this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect=`all`,this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=`rgba`}reset(){this.label=``,this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect=`all`,this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=`rgba`}},FZ=new wZ,IZ=new TZ,LZ=new EZ,RZ=new DZ,zZ=new kZ,BZ=new AZ,VZ=new OZ,HZ=new MZ,UZ=new NZ,WZ=new PZ,GZ=class extends wV{constructor(e){super(),this.device=e,this.mipmapSampler=e.createSampler({minFilter:nZ.Linear}),this.flipYSampler=e.createSampler({minFilter:nZ.Nearest}),IZ.size=4,IZ.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(IZ),IZ.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),IZ.size=4,IZ.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(IZ),IZ.reset(),this.transferPipelines={},HZ.label=`mipmap`,HZ.code=` +struct VarysStruct { + @builtin( position ) Position: vec4f, + @location( 0 ) vTex : vec2f, + @location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32, +}; + +@group( 0 ) @binding ( 2 ) +var flipY: u32; + +@vertex +fn mainVS( + @builtin( vertex_index ) vertexIndex : u32, + @builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct { + + var Varys : VarysStruct; + + var pos = array( + vec2f( -1, -1 ), + vec2f( -1, 3 ), + vec2f( 3, -1 ), + ); + + let p = pos[ vertexIndex ]; + let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 ); + Varys.vTex = p * mult + vec2f( 0.5 ); + Varys.Position = vec4f( p, 0, 1 ); + Varys.vBaseArrayLayer = instanceIndex; + + return Varys; + +} + +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img2d : texture_2d; + +@fragment +fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( img2d, imgSampler, Varys.vTex ); + +} + +@group( 0 ) @binding( 1 ) +var img2dArray : texture_2d_array; + +@fragment +fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer ); + +} + +const faceMat = array( + mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x + mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x + mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y + mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y + mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z + mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z +); + +@group( 0 ) @binding( 1 ) +var imgCube : texture_cube; + +@fragment +fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) ); + +} +`,this.mipmapShaderModule=e.createShaderModule(HZ),HZ.reset()}getTransferPipeline(e,t){t||=`2d-array`;let n=`${e}-${t}`,r=this.transferPipelines[n];return r===void 0&&(BZ.label=`mipmap-${e}-${t}`,BZ.vertex={module:this.mipmapShaderModule},BZ.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace(`-`,`_`)}`,targets:[{format:e}]},BZ.layout=`auto`,r=this.device.createRenderPipeline(BZ),BZ.reset(),this.transferPipelines[n]=r),r}flipY(e,t,n=0){let r=t.format,{width:i,height:a}=t.size;UZ.size.width=i,UZ.size.height=a,UZ.format=r,UZ.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;let o=this.device.createTexture(UZ);UZ.reset();let s=this.getTransferPipeline(r,e.textureBindingViewDimension),c=this.getTransferPipeline(r,o.textureBindingViewDimension),l=this.device.createCommandEncoder(LZ),u=(e,t,n,r,i,a)=>{let o=e.getBindGroupLayout(0);WZ.dimension=t.textureBindingViewDimension||`2d-array`,WZ.mipLevelCount=1;let s=t.createView(WZ);WZ.reset(),FZ.layout=o,FZ.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:s},{binding:2,resource:{buffer:a?this.flipUniformBuffer:this.noFlipUniformBuffer}});let c=this.device.createBindGroup(FZ);FZ.reset(),WZ.dimension=`2d`,WZ.mipLevelCount=1,WZ.baseArrayLayer=i,WZ.arrayLayerCount=1;let u=r.createView(WZ);WZ.reset(),VZ.view=u,VZ.loadOp=ZX.Clear,VZ.storeOp=XX.Store,zZ.colorAttachments.push(VZ);let d=l.beginRenderPass(zZ);zZ.reset(),VZ.reset(),d.setPipeline(e),d.setBindGroup(0,c),d.draw(3,1,0,n),d.end()};u(s,e,n,o,0,!1),u(c,o,0,e,n,!0),CZ(this.device,l.finish()),o.destroy()}generateMipmaps(e,t=null){let n=this.get(e),r=n.layers||this._mipmapCreateBundles(e),i=t;i===null&&(LZ.label=`mipmapEncoder`,i=this.device.createCommandEncoder(LZ),LZ.reset()),this._mipmapRunBundles(i,r),t===null&&CZ(this.device,i.finish()),n.layers=r}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||`2d-array`,n=this.getTransferPipeline(e.format,t),r=n.getBindGroupLayout(0),i=[];for(let a=1;a0)for(let t=0,a=r.length;t0){for(let r of e.layerUpdates)this._copyBufferToTexture(t.image,n.texture,i,r,e.flipY,r);e.clearLayerUpdates()}else for(let r=0;r0?(this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,i);else if(e.isHTMLTexture){let t=this.backend.device,r=this.backend.renderer.domElement,a=e.image;if(typeof t.queue.copyElementImageToTexture!=`function`)return;if(!n.hasPaintCallback){n.hasPaintCallback=!0,r.requestPaint();return}let o=i.size.width,s=i.size.height;t.queue.copyElementImageToTexture.length===2?t.queue.copyElementImageToTexture({source:a},{destination:{texture:n.texture},width:o,height:s}):t.queue.copyElementImageToTexture(a,o,s,{texture:n.texture}),e.flipY&&this._flipY(n.texture,i)}else if(r.length>0)for(let t=0,a=r.length;t0?e.width:n.size.width,l=o>0?e.height:n.size.height;aQ.source=e,aQ.flipY=i,oQ.texture=t,oQ.mipLevel=o,oQ.origin.z=r,oQ.premultipliedAlpha=a,cQ.width=c,cQ.height=l;try{s.queue.copyExternalImageToTexture(aQ,oQ,cQ)}catch{}finally{aQ.reset(),oQ.reset(),cQ.reset()}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new GZ(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,i,a=0,o=0){let s=this.backend.device,c=e.data,l=this._getBytesPerTexel(n.format),u=e.width*l;nQ.texture=t,nQ.mipLevel=o,nQ.origin.z=r,iQ.offset=e.width*e.height*l*a,iQ.bytesPerRow=u,cQ.width=e.width,cQ.height=e.height,s.queue.writeTexture(nQ,c,iQ,cQ),nQ.reset(),iQ.reset(),cQ.reset(),i===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n,r=null){let i=this.backend.device,a=this._getBlockData(n.format),o=n.size.depthOrArrayLayers>1,s=r&&r.size>0?r:null;for(let r=0;r]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,hQ=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,gQ={f32:`float`,i32:`int`,u32:`uint`,bool:`bool`,"vec2":`vec2`,"vec2":`ivec2`,"vec2":`uvec2`,"vec2":`bvec2`,vec2f:`vec2`,vec2i:`ivec2`,vec2u:`uvec2`,vec2b:`bvec2`,"vec3":`vec3`,"vec3":`ivec3`,"vec3":`uvec3`,"vec3":`bvec3`,vec3f:`vec3`,vec3i:`ivec3`,vec3u:`uvec3`,vec3b:`bvec3`,"vec4":`vec4`,"vec4":`ivec4`,"vec4":`uvec4`,"vec4":`bvec4`,vec4f:`vec4`,vec4i:`ivec4`,vec4u:`uvec4`,vec4b:`bvec4`,"mat2x2":`mat2`,mat2x2f:`mat2`,"mat3x3":`mat3`,mat3x3f:`mat3`,"mat4x4":`mat4`,mat4x4f:`mat4`,sampler:`sampler`,texture_1d:`texture`,texture_2d:`texture`,texture_2d_array:`texture`,texture_multisampled_2d:`cubeTexture`,texture_depth_2d:`depthTexture`,texture_depth_2d_array:`depthTexture`,texture_depth_multisampled_2d:`depthTexture`,texture_depth_cube:`depthTexture`,texture_depth_cube_array:`depthTexture`,texture_3d:`texture3D`,texture_cube:`cubeTexture`,texture_cube_array:`cubeTexture`,texture_storage_1d:`storageTexture`,texture_storage_2d:`storageTexture`,texture_storage_2d_array:`storageTexture`,texture_storage_3d:`storageTexture`},_Q=e=>{e=e.trim();let t=e.match(mQ);if(t!==null&&t.length===4){let n=t[2],r=[],i=null;for(;(i=hQ.exec(n))!==null;)r.push({name:i[1],type:i[2]});let a=[];for(let e=0;e `+this.outputType;return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},yQ=class extends lY{parseFunction(e){return new vQ(e)}},bQ={[FD.READ_ONLY]:`read`,[FD.WRITE_ONLY]:`write`,[FD.READ_WRITE]:`read_write`},xQ={[me]:`repeat`,[he]:`clamp`,[ge]:`mirror`},SQ={vertex:JX.VERTEX,fragment:JX.FRAGMENT,compute:JX.COMPUTE},CQ={instance:!0,swizzleAssign:!1,storageBuffer:!0},wQ={"^^":`tsl_xor`},TQ={float:`f32`,int:`i32`,uint:`u32`,bool:`bool`,color:`vec3`,vec2:`vec2`,ivec2:`vec2`,uvec2:`vec2`,bvec2:`vec2`,vec3:`vec3`,ivec3:`vec3`,uvec3:`vec3`,bvec3:`vec3`,vec4:`vec4`,ivec4:`vec4`,uvec4:`vec4`,bvec4:`vec4`,mat2:`mat2x2`,mat3:`mat3x3`,mat4:`mat4x4`},EQ={},DQ={tsl_xor:new fW(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new fW(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new fW(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new fW(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new fW(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new fW(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new fW(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new fW(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new fW(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new fW(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new fW(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new fW(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),inverse_mat2:new fW(` +fn tsl_inverse_mat2( m : mat2x2 ) -> mat2x2 { + + let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ]; + + return mat2x2( + m[ 1 ][ 1 ], - m[ 0 ][ 1 ], + - m[ 1 ][ 0 ], m[ 0 ][ 0 ] + ) * ( 1.0 / det ); + +} +`),inverse_mat3:new fW(` +fn tsl_inverse_mat3( m : mat3x3 ) -> mat3x3 { + + let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; + let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; + let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; + + let b01 = a22 * a11 - a12 * a21; + let b11 = - a22 * a10 + a12 * a20; + let b21 = a21 * a10 - a11 * a20; + + let det = a00 * b01 + a01 * b11 + a02 * b21; + + return mat3x3( + b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ), + b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ), + b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 ) + ) * ( 1.0 / det ); + +} +`),inverse_mat4:new fW(` +fn tsl_inverse_mat4( m : mat4x4 ) -> mat4x4 { + + let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ]; + let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ]; + let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ]; + let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ]; + + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + + let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + return mat4x4( + a11 * b11 - a12 * b10 + a13 * b09, + a02 * b10 - a01 * b11 - a03 * b09, + a31 * b05 - a32 * b04 + a33 * b03, + a22 * b04 - a21 * b05 - a23 * b03, + a12 * b08 - a10 * b11 - a13 * b07, + a00 * b11 - a02 * b08 + a03 * b07, + a32 * b02 - a30 * b05 - a33 * b01, + a20 * b05 - a22 * b02 + a23 * b01, + a10 * b10 - a11 * b08 + a13 * b06, + a01 * b08 - a00 * b10 - a03 * b06, + a30 * b04 - a31 * b02 + a33 * b00, + a21 * b02 - a20 * b04 - a23 * b00, + a11 * b07 - a10 * b09 - a12 * b06, + a00 * b09 - a01 * b07 + a02 * b06, + a31 * b01 - a30 * b03 - a32 * b00, + a20 * b03 - a21 * b01 + a22 * b00 + ) * ( 1.0 / det ); + +} +`),biquadraticTexture:new fW(` +fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { + + let res = vec2f( iRes ); + + let uvScaled = coord * res; + let uvWrapping = ( ( uvScaled % res ) + res ) % res; + + // https://www.shadertoy.com/view/WtyXRy + + let uv = uvWrapping - 0.5; + let iuv = floor( uv ); + let f = fract( uv ); + + let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); + let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); + let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); + let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); + + return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); + +} +`),biquadraticTextureArray:new fW(` +fn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f { + + let res = vec2f( iRes ); + + let uvScaled = coord * res; + let uvWrapping = ( ( uvScaled % res ) + res ) % res; + + // https://www.shadertoy.com/view/WtyXRy + + let uv = uvWrapping - 0.5; + let iuv = floor( uv ); + let f = fract( uv ); + + let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level ); + let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level ); + let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level ); + let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level ); + + return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); + +} +`)},OQ={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inverse_mat2:`tsl_inverse_mat2`,inverse_mat3:`tsl_inverse_mat3`,inverse_mat4:`tsl_inverse_mat4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast`,floatpack_snorm_2x16:`pack2x16snorm`,floatpack_unorm_2x16:`pack2x16unorm`,floatpack_float16_2x16:`pack2x16float`,floatunpack_snorm_2x16:`unpack2x16snorm`,floatunpack_unorm_2x16:`unpack2x16unorm`,floatunpack_float16_2x16:`unpack2x16float`},kQ=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(kQ+=`diagnostic( off, derivative_uniformity ); +`);var AQ=class extends JJ{constructor(e,t){super(e,t,new yQ),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,n,r,i,a=this.shaderStage){return a===`fragment`?r?i?`textureSample( ${t}, ${t}_sampler, ${n}, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:i?`textureSample( ${t}, ${t}_sampler, ${n}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,`0`,r)}generateTextureSampleLevel(e,t,n,r,i,a){return this.isUnfilterable(e)===!1?i?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r,i):this.generateTextureLod(e,t,n,i,a,r)}generateWrapFunction(e){let t=`tsl_coord_${xQ[e.wrapS]}S_${xQ[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?`3d`:`2d`}`,n=EQ[t];if(n===void 0){let r=[],i=e.is3DTexture||e.isData3DTexture?`vec3f`:`vec2f`,a=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`,o=(e,t)=>{e===1e3?(r.push(DQ.repeatWrapping_float),a+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===1001?(r.push(DQ.clampWrapping_float),a+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===1002?(r.push(DQ.mirrorWrapping_float),a+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(a+=`\t\tcoord.${t}`,R(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};o(e.wrapS,`x`),a+=`, +`,o(e.wrapT,`y`),(e.is3DTexture||e.isData3DTexture)&&(a+=`, +`,o(e.wrapR,`z`)),a+=` + ); + +} +`,EQ[t]=n=new fW(a,r)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){let r=this.getDataFromNode(e,this.shaderStage,this.cache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let i=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,o,{primarySamples:s}=this.renderer.backend.utils.getTextureSampleData(e),c=s>1;o=e.is3DTexture||e.isData3DTexture?`vec3`:`vec2`,a=c||e.isStorageTexture?t:`${t}${n?`, u32( ${n} )`:``}`,i=new cM(new nN(`textureDimensions( ${a} )`,o)),r.dimensionsSnippet[n]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new cM(new nN(`textureNumLayers(${t})`,`u32`))),e.isTextureCube&&(r.cubeFaceCount=new cM(new nN(`6u`,`u32`)))}return i.build(this)}generateFilteredTexture(e,t,n,r,i=`0u`,a){let o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,i);return r&&(n=`${n} + vec2(${r}) / ${s}`),a?(this._include(`biquadraticTextureArray`),`tsl_biquadraticTexture_array( ${t}, ${o}( ${n} ), ${s}, u32( ${a} ), u32( ${i} ) )`):(this._include(`biquadraticTexture`),`tsl_biquadraticTexture( ${t}, ${o}( ${n} ), ${s}, u32( ${i} ) )`)}generateTextureLod(e,t,n,r,i,a=`0u`){if(e.isCubeTexture===!0){i&&(n=`${n} + vec3(${i})`);let r=e.isDepthTexture?`u32`:`f32`;return`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}( ${a} ) )`}let o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,a),c=e.is3DTexture||e.isData3DTexture?`vec3`:`vec2`,l=c===`vec3`?`vec3( 1, 1, 1 )`:`vec2( 1, 1 )`;i&&(n=`${n} + ${c}(${i}) / ${c}( ${s} )`);let u=`${c}( 0 )`,d=`${c}( ${s} - ${l} )`;return n=`${c}( clamp( floor( ${o}( ${n} ) * ${c}( ${s} ) ), ${u}, ${d} ) )`,this.generateTextureLoad(e,t,n,a,r,null)}generateStorageTextureLoad(e,t,n,r,i,a){a&&(n=`${n} + ${a}`);let o;return o=i?`textureLoad( ${t}, ${n}, ${i} )`:`textureLoad( ${t}, ${n} )`,o}generateTextureLoad(e,t,n,r,i,a){r===null&&(r=`0u`),a&&(n=`${n} + ${a}`);let o;return i?o=`textureLoad( ${t}, ${n}, ${i}, u32( ${r} ) )`:(o=`textureLoad( ${t}, ${n}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(o+=`.x`)),o}generateTextureStore(e,t,n,r,i){let a;return a=r?`textureStore( ${t}, ${n}, ${r}, ${i} )`:`textureStore( ${t}, ${n}, ${i} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(Qt.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!==`float`||!this.isAvailable(`float32Filterable`)&&e.type===1015||this.isSampleCompare(e)===!1&&e.minFilter===1003&&e.magFilter===1003||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,i,a=this.shaderStage){let o=null;return o=this.isUnfilterable(e)?this.generateTextureLod(e,t,n,r,i,`0`,a):this._generateTextureSample(e,t,n,r,i,a),o}generateTextureGrad(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return i?a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i}, ${r[0]}, ${r[1]} )`:a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;z(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${o} shader.`)}generateTextureCompare(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return e.isDepthTexture===!0&&e.isArrayTexture===!0?a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;z(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}generateTextureGather(e,t,n,r,i,a){let o=e.isDepthTexture===!0?``:`${r}, `;return i?a?`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${i}, ${a} )`:`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${i} )`:a?`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${a} )`:`textureGather( ${o}${t}, ${t}_sampler, ${n})`}generateTextureGatherCompare(e,t,n,r,i,a){return i?a?`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r})`:a?`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${r})`}generateTextureLevel(e,t,n,r,i,a){return this.isUnfilterable(e)===!1?i?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r,i):this.generateTextureLod(e,t,n,i,a,r)}generateTextureBias(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return i?a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;z(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${o} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t===`vertex`)return`varyings.${e.name}`}else if(e.isNodeUniform===!0){let t=e.name,n=e.type;return n===`texture`||n===`cubeTexture`||n===`cubeDepthTexture`||n===`storageTexture`||n===`texture3D`?t:n===`buffer`||n===`storageBuffer`||n===`indirectStorageBuffer`?this.isCustomStruct(e)?t:t+`.value`:e.groupNode.name+`.`+t}return super.getPropertyName(e)}getOutputStructName(){return`output`}getFunctionOperator(e){let t=wQ[e];return t===void 0?null:(this._include(t),t)}getNodeAccess(e,t){return t===`compute`?e.access:e.isAtomic===!0?(R(`WebGPURenderer: Atomic operations are only supported in compute shaders.`),FD.READ_WRITE):FD.READ_ONLY}getStorageAccess(e,t){return bQ[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let o,s=e.groupNode,c=s.name,l=this.getBindGroupArray(c,n);if(t===`texture`||t===`cubeTexture`||t===`cubeDepthTexture`||t===`storageTexture`||t===`texture3D`){let r=null,a=this.getNodeAccess(e,n);if(t===`texture`||t===`storageTexture`?r=e.value.is3DTexture===!0?new hX(i.name,i.node,s,a):new pX(i.name,i.node,s,a):t===`cubeTexture`||t===`cubeDepthTexture`?r=new mX(i.name,i.node,s,a):t===`texture3D`&&(r=new hX(i.name,i.node,s,a)),r.store=e.isStorageTextureNode===!0,r.mipLevel=r.store?e.mipLevel:0,r.setVisibility(SQ[n]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&r.store===!1||e.gatherNode!==null){let e=new _Z(`${i.name}_sampler`,i.node,s);e.setVisibility(SQ[n]),l.push(e,r),o=[e,r]}else l.push(r),o=[r]}else if(t===`buffer`||t===`storageBuffer`||t===`indirectStorageBuffer`){let a=this.getSharedDataFromNode(e),c=a.buffer;c===void 0&&(c=new(t===`buffer`?iX:bZ)(e,s),a.buffer=c),c.setVisibility(c.getVisibility()|SQ[n]),l.push(c),o=c,i.name=r||`NodeBuffer_`+i.id}else{let e=this.uniformGroups[c];e===void 0&&(e=new lX(c,s),e.setVisibility(JX.VERTEX|JX.FRAGMENT|JX.COMPUTE),this.uniformGroups[c]=e),l.indexOf(e)===-1&&l.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}getBuiltin(e,t,n,r=this.shaderStage){let i=this.builtins[r]||(this.builtins[r]=new Map);return i.has(e)===!1&&i.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`vertex_index`,`vertexIndex`,`u32`,`attribute`):`vertexIndex`}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(e.name+` : `+this.getType(e.type));let i=`fn ${t.name}( ${r.join(`, `)} ) -> ${this.getType(t.type)} { +${n.vars} +${n.code} +`;return n.result&&(i+=`\treturn ${n.result};\n`),i+=` +} +`,i}getInstanceIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`instance_index`,`instanceIndex`,`u32`,`attribute`):`instanceIndex`}getInvocationLocalIndex(){return this.getBuiltin(`local_invocation_index`,`invocationLocalIndex`,`u32`,`attribute`)}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin(`subgroup_size`,`subgroupSize`,`u32`,`attribute`)}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin(`subgroup_invocation_id`,`invocationSubgroupIndex`,`u32`,`attribute`)}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin(`subgroup_id`,`subgroupIndex`,`u32`,`attribute`)}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin(`front_facing`,`isFront`,`bool`)}getFragCoord(){return this.getBuiltin(`position`,`fragCoord`,`vec4`)+`.xy`}getFragDepth(){return`output.`+this.getBuiltin(`frag_depth`,`depth`,`f32`,`output`)}getClipDistance(){return`varyings.hw_clip_distances`}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){let t=[],n=this.directives[e];if(n!==void 0)for(let e of n)t.push(`enable ${e};`);return t.join(` +`)}enableSubGroups(){this.enableDirective(`subgroups`)}enableSubgroupsF16(){this.enableDirective(`subgroups-f16`)}enableClipDistances(){this.enableDirective(`clip_distances`)}enableShaderF16(){this.enableDirective(`f16`)}enableDualSourceBlending(){this.enableDirective(`dual_source_blending`)}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin(`clip_distances`,`hw_clip_distances`,`array`,`vertex`)}getBuiltins(e){let t=[],n=this.builtins[e];if(n!==void 0)for(let{name:e,property:r,type:i}of n.values())t.push(`@builtin( ${e} ) ${r} : ${i}`);return t.join(`, + `)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!==`compute`)return;let t=[];for(let{name:e,scope:n,bufferType:r,bufferCount:i}of this.scopedArrays.values()){let a=this.getType(r);t.push(`var<${n}> ${e}: array< ${a}, ${i} >;`)}return t.join(` +`)}getAttributes(e){let t=[];if(e===`compute`&&(this.getBuiltin(`global_invocation_id`,`globalId`,`vec3`,`attribute`),this.getBuiltin(`workgroup_id`,`workgroupId`,`vec3`,`attribute`),this.getBuiltin(`local_invocation_id`,`localId`,`vec3`,`attribute`),this.getBuiltin(`num_workgroups`,`numWorkgroups`,`vec3`,`attribute`),this.renderer.hasFeature(`subgroups`)&&(this.enableDirective(`subgroups`,e),this.getBuiltin(`subgroup_size`,`subgroupSize`,`u32`,`attribute`))),e===`vertex`||e===`compute`){let e=this.getBuiltins(`attribute`);e&&t.push(e);let n=this.getAttributesArray();for(let e=0,r=n.length;e`),t.push(`\t${r+n.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins(`output`)}`),t.join(`, +`)}getStructs(e){let t=``,n=this.structs[e];if(n.length>0){let e=[];for(let t of n){let n=`struct ${t.name} {\n`;n+=this.getStructMembers(t),n+=` +};`,e.push(n)}t=` +`+e.join(` + +`)+` +`}return t}getVar(e,t,n=null,r=``){let i=`var${r} ${t} : `;return n===null?i+=this.getType(e):i+=this.generateArrayDeclaration(e,n),i}getVars(e,t=!1){let n=``;t&&(n=``);let r=[],i=this.vars[e];if(i!==void 0)for(let e of i)r.push(`${this.getVar(e.type,e.name,e.count,n)};`);return t?r.join(` +`):`\n\t${r.join(` + `)}\n`}getVaryings(e){let t=[];if(e===`vertex`&&this.getBuiltin(`position`,`builtinClipSpace`,`vec4`,`vertex`),e===`vertex`||e===`fragment`){let n=this.varyings,r=this.vars[e],i=0;for(let a=0;an.value.itemSize;return r&&!i}getUniforms(e){let t=this.renderer.backend,n=this.uniforms[e],r=[],i=[],a=[],o={};for(let a of n){let n=a.groupNode.name,s=this.bindingsIndexes[n];if(a.type===`texture`||a.type===`cubeTexture`||a.type===`cubeDepthTexture`||a.type===`storageTexture`||a.type===`texture3D`){let n=a.node,i=n.value;(i.isCubeTexture===!0||this.isUnfilterable(i)===!1&&n.isStorageTextureNode!==!0||n.gatherNode!==null)&&(this.isSampleCompare(i)&&n.compareNode!==null?r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name}_sampler : sampler_comparison;`):r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name}_sampler : sampler;`));let o,c=``,{primarySamples:l}=t.utils.getTextureSampleData(i);if(l>1&&(c=`_multisampled`),i.isCubeTexture===!0&&i.isDepthTexture===!0)o=`texture_depth_cube`;else if(i.isCubeTexture===!0)o=`texture_cube`;else if(i.isDepthTexture===!0)o=t.compatibilityMode&&i.compareFunction===null?`texture${c}_2d`:`texture_depth${c}_2d${i.isArrayTexture===!0?`_array`:``}`;else if(a.node.isStorageTextureNode===!0){let n=pQ(i,t.device),r=this.getStorageAccess(a.node,e),s=a.node.value.is3DTexture,c=a.node.value.isArrayTexture;o=`texture_storage_${s?`3d`:`2d${c?`_array`:``}`}<${n}, ${r}>`}else if(i.isArrayTexture===!0||i.isDataArrayTexture===!0||i.isCompressedArrayTexture===!0)o=`texture_2d_array`;else if(i.is3DTexture===!0||i.isData3DTexture===!0)o=`texture_3d`;else{let e=this.getComponentTypeFromTexture(i).charAt(0);o=`texture${c}_2d<${e}32>`}r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name} : ${o};`)}else if(a.type===`buffer`||a.type===`storageBuffer`||a.type===`indirectStorageBuffer`){let t=a.node,n=this.getType(t.getNodeType(this)),r=t.bufferCount,o=r>0&&a.type===`buffer`?`, `+r:``,c=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:`uniform`;if(this.isCustomStruct(a))i.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var<${c}> ${a.name} : ${n};`);else{let e=`\tvalue : array< ${t.isAtomic?`atomic<${n}>`:`${n}`}${o} >`;i.push(this._getWGSLStructBinding(a.name,e,c,s.binding++,s.group))}}else{let e=a.groupNode.name;if(o[e]===void 0){let t=this.uniformGroups[e];if(t!==void 0){let n=[];for(let e of t.uniforms){let t=e.getType(),r=this.getType(this.getVectorType(t));n.push(`\t${e.name} : ${r}`)}let r=this.uniformGroupsBindings[e];r===void 0&&(r={index:s.binding++,id:s.group},this.uniformGroupsBindings[e]=r),o[e]={index:r.index,id:r.id,snippets:n}}}}}for(let e in o){let t=o[e];a.push(this._getWGSLStructBinding(e,t.snippets.join(`, +`),`uniform`,t.index,t.id))}return[...r,...i,...a].join(` +`)}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};this.sortBindingGroups();for(let t in e){this.shaderStage=t;let n=this.allowGlobalVariables,r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t,n),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let i=`// code + +`;i+=this.flowCode[t];let a=this.flowNodes[t],o=a[a.length-1],s=o.outputNode,c=s!==void 0&&s.isOutputStructNode===!0;for(let e of a){let n=this.getFlowData(e),a=e.name;if(a&&(i.length>0&&(i+=` +`),i+=`\t// flow -> ${a}\n`),i+=`${n.code}\n\t`,e===o&&t!==`compute`){if(i+=`// result + + `,t===`vertex`)i+=`varyings.builtinClipSpace = ${n.result};`;else if(t===`fragment`)if(c)r.returnType=s.getNodeType(this),r.structs+=`var output : `+r.returnType+`;`,i+=`return ${n.result};`;else{let e=`\t@location( 0 ) color: ${this.getType(this.getOutputType())}`,t=this.getBuiltins(`output`);t&&(e+=`, + `+t),r.returnType=`OutputStruct`,r.structs+=this._getWGSLStruct(`OutputStruct`,e),r.structs+=` +var output : OutputStruct;`,i+=`output.color = ${this.format(n.result,o.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}}r.flow=i}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+`_`+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return TQ[e]||e}isAvailable(e){let t=CQ[e];return t===void 0&&(e===`float32Filterable`?t=this.renderer.hasFeature(`float32-filterable`):e===`clipDistance`&&(t=this.renderer.hasFeature(`clip-distances`)),CQ[e]=t),t}_getWGSLMethod(e){return DQ[e]!==void 0&&this._include(e),OQ[e]}_include(e){let t=DQ[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} +// directives +${e.directives} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// varyings +${e.varyings} +var varyings : VaryingsStruct; + +// vars +${e.vars} + +// codes +${e.codes} + +@vertex +fn main( ${e.attributes} ) -> VaryingsStruct { + + // flow + ${e.flow} + + return varyings; + +} +`}_getWGSLFragmentCode(e){return`${this.getSignature()} +// global +${kQ} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// vars +${e.vars} + +// codes +${e.codes} + +@fragment +fn main( ${e.varyings} ) -> ${e.returnType} { + + // flow + ${e.flow} + +} +`}_getWGSLComputeCode(e,t){let[n,r,i]=t;return`${this.getSignature()} +// directives +${e.directives} + +// system +var instanceIndex : u32; + +// locals +${e.scopedArrays} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// vars +${this.allowGlobalVariables?e.vars:``} + +// codes +${e.codes} + +@compute @workgroup_size( ${n}, ${r}, ${i} ) +fn main( ${e.attributes} ) { + + // local vars + ${this.allowGlobalVariables?``:e.vars} + + // system + instanceIndex = globalId.x + + globalId.y * ( ${n} * numWorkgroups.x ) + + globalId.z * ( ${n} * numWorkgroups.x ) * ( ${r} * numWorkgroups.y ); + + // flow + ${e.flow} + +} +`}_getWGSLStruct(e,t){return` +struct ${e} { +${t} +};`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`;return`${this._getWGSLStruct(a,t)} +@binding( ${r} ) @group( ${i} ) +var<${n}> ${e} : ${a};`}},jQ=new TZ,MQ=new EZ,NQ=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]);typeof Float16Array<`u`&&NQ.set(Float16Array,[`float16`]);var PQ=new Map([[ji,[`float16`]]]),FQ=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]),IQ=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e1&&n.itemSize*s.BYTES_PER_ELEMENT%4!=0){let e=n.itemSize*s.BYTES_PER_ELEMENT;c=Math.floor((e+3)/4)*4/s.BYTES_PER_ELEMENT}if(c!==void 0){let e=n.itemSize,t=new s.constructor(n.count*c);for(let r=0;r1&&e%4!=0&&(e=Math.floor((e+3)/4)*4)),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,n=0,r=-1){let i=this.backend,a=i.device,o=i.get(this._getBufferAttribute(e)).buffer,s=r===-1?o.size-n:r,c;if(t!==null&&t.isReadbackBuffer){let e=i.get(t);if(t._mapped===!0)throw Error(`THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.`);if(t._mapped=!0,e.readBufferGPU===void 0){jQ.label=`${t.name}_readback`,jQ.size=t.maxByteLength,jQ.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=a.createBuffer(jQ),jQ.reset();let n=()=>{t.buffer=null,t._mapped=!1,c.unmap()},r=()=>{t.buffer=null,t._mapped=!1,c.destroy(),i.delete(t),t.removeEventListener(`release`,n),t.removeEventListener(`dispose`,r)};t.addEventListener(`release`,n),t.addEventListener(`dispose`,r),e.readBufferGPU=c}else c=e.readBufferGPU}else jQ.label=`${e.name}_readback`,jQ.size=s,jQ.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=a.createBuffer(jQ),jQ.reset();MQ.label=`readback_encoder_${e.name}`;let l=a.createCommandEncoder(MQ);if(MQ.reset(),l.copyBufferToBuffer(o,n,c,0,s),CZ(a,l.finish()),await c.mapAsync(GPUMapMode.READ,0,s),t===null){let e=c.getMappedRange(0,s).slice();return c.destroy(),e}else if(t.isReadbackBuffer)return t.buffer=c.getMappedRange(0,s),t;else{let e=c.getMappedRange(0,s);return new Uint8Array(t).set(new Uint8Array(e)),c.destroy(),t}}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=FQ.get(r);else{let e=(PQ.get(i)||NQ.get(r))[+!!n];if(e){let n=r.BYTES_PER_ELEMENT*t,i=Math.floor((n+3)/4)*4/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${e}x${i}`}}return a||z(`WebGPUAttributeUtils: Vertex format not supported yet.`),a}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},LQ=new wZ,RQ=new TZ,zQ=new PZ,BQ=class{constructor(e){this.layoutGPU=e,this.usedTimes=0}},VQ=class{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,n=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;let i=this._createLayoutEntries(e),a=vD(JSON.stringify(i)),o=this._bindGroupLayoutCache.get(a);return o===void 0&&(o=new BQ(n.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(a,o)),o.usedTimes++,r.layout=o,r.layoutKey=a,o.layoutGPU}createBindings(e,t,n,r=0){let{backend:i}=this,a=i.get(e),o=this.createBindingsLayout(e),s;n>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[n]===r&&(s=a.groups[n])),s===void 0&&(s=this.createBindGroup(e,o),n>0&&(a.groups[n]=s,a.versions[n]=r)),a.group=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer,a=e.updateRanges;if(a.length===0)n.queue.writeBuffer(i,0,r,0);else{let e=en(r),t=e?1:r.BYTES_PER_ELEMENT,o=a[0].start;for(let s=0,c=a.length;s1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${n}-${r}`,a=e[i],a===void 0){let o=pZ.All,s;s=t.isSampledCubeTexture?fZ.Cube:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?fZ.TwoDArray:t.isSampledTexture3D?fZ.ThreeD:fZ.TwoD,zQ.aspect=o,zQ.dimension=s,zQ.mipLevelCount=n,zQ.baseMipLevel=r,a=e[i]=e.texture.createView(zQ),zQ.reset()}}LQ.entries.push({binding:i,resource:a})}else if(t.isSampler){let e=n.get(t);LQ.entries.push({binding:i,resource:e.sampler})}i++}let a=r.createBindGroup(LQ);return LQ.reset(),a}_createLayoutEntries(e){let t=[],n=0;for(let r of e.bindings){let e=this.backend,i={binding:n,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){let e={};r.isStorageBuffer&&(r.visibility&JX.COMPUTE&&(r.access===FD.READ_WRITE||r.access===FD.WRITE_ONLY)?e.type=sZ.Storage:e.type=sZ.ReadOnlyStorage),i.buffer=e}else if(r.isSampledTexture&&r.store){let e={};e.format=this.backend.get(r.texture).texture.format;let t=r.access;t===FD.READ_WRITE?e.access=cZ.ReadWrite:t===FD.WRITE_ONLY?e.access=cZ.WriteOnly:e.access=cZ.ReadOnly,r.texture.isArrayTexture?e.viewDimension=fZ.TwoDArray:r.texture.is3DTexture&&(e.viewDimension=fZ.ThreeD),i.storageTexture=e}else if(r.isSampledTexture){let t={},{primarySamples:n}=e.utils.getTextureSampleData(r.texture);if(n>1&&(t.multisampled=!0,r.texture.isDepthTexture||(t.sampleType=uZ.UnfilterableFloat)),r.texture.isDepthTexture)e.compatibilityMode&&r.texture.compareFunction===null?t.sampleType=uZ.UnfilterableFloat:t.sampleType=uZ.Depth;else{let e=r.texture.type;e===1013?t.sampleType=uZ.SInt:e===1014?t.sampleType=uZ.UInt:e===1015&&(this.backend.hasFeature(`float32-filterable`)?t.sampleType=uZ.Float:t.sampleType=uZ.UnfilterableFloat)}r.isSampledCubeTexture?t.viewDimension=fZ.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?t.viewDimension=fZ.TwoDArray:r.isSampledTexture3D&&(t.viewDimension=fZ.ThreeD),i.texture=t}else if(r.isSampler){let t={};r.texture.isDepthTexture&&(r.texture.compareFunction!==null&&r.textureNode.compareNode!==null&&e.hasCompatibility(Qt.TEXTURE_COMPARE)?t.type=lZ.Comparison:t.type=lZ.NonFiltering),i.sampler=t}else z(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(i),n++}return t}deleteBindGroupData(e){let{backend:t}=this,n=t.get(e);n.layout&&(n.layout.usedTimes--,n.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(n.layoutKey),n.layout=void 0,n.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}},HQ=class{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}},UQ=class{constructor(){this.label=``,this.layout=null,this.compute=null}reset(){this.label=``,this.layout=null,this.compute=null}},WQ=class{constructor(){this.label=``,this.bindGroupLayouts=null}reset(){this.label=``,this.bindGroupLayouts=null}},GQ=new UQ,KQ=new WQ,qQ=new DZ,JQ=new AZ,YQ=class{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let{layoutGPU:e}=c.get(t).layout;f.push(e)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==0&&(r.blending!==1||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures,n=e.context.mrt;for(let e=0;e1,JQ.layout=w;let T={},E=e.context.depth,D=e.context.stencil;(E===!0||D===!0)&&(E===!0&&(T.format=S,T.depthWriteEnabled=r.depthWrite,T.depthCompare=x),D===!0&&(T.stencilFront=h,T.stencilBack=h,T.stencilReadMask=r.stencilFuncMask,T.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&b.topology===qX.TriangleList&&(T.depthBias=r.polygonOffsetUnits,T.depthBiasSlopeScale=r.polygonOffsetFactor,T.depthBiasClamp=0),JQ.depthStencil=T),l.pushErrorScope(`validation`);let O=[{program:o,module:v.module},{program:s,module:y.module}],k=JQ.label;if(t===null)d.pipeline=l.createRenderPipeline(JQ),JQ.reset(),l.popErrorScope().then(e=>{e!==null&&(d.error=!0,z(`WebGPURenderer: Render pipeline creation failed (${k}): ${e.message}`),this._reportShaderDiagnostics(O,k))});else{let e=new Promise(async e=>{try{let e=null,t=null;try{t=l.createRenderPipelineAsync(JQ)}catch(t){e=t}if(JQ.reset(),t!==null)try{d.pipeline=await t}catch(t){e=t}let n=await l.popErrorScope();if(n!==null||e!==null){d.error=!0;let t=n&&n.message||e&&e.message||`unknown`;z(`WebGPURenderer: Async render pipeline creation failed (${k}): ${t}`),await this._reportShaderDiagnostics(O,k)}}finally{e()}});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let{utils:n,device:r}=this.backend,i=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormats(e),o=this._getSampleCount(e);qQ.label=t,qQ.colorFormats=a,qQ.depthStencilFormat=i,qQ.sampleCount=o;let s=r.createRenderBundleEncoder(qQ);return qQ.reset(),s}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let{layoutGPU:t}=n.get(e).layout;o.push(t)}let s=e.computeProgram,c=`computePipeline_${s.stage}${s.name?`_${s.name}`:``}`;r.pushErrorScope(`validation`),KQ.bindGroupLayouts=o;let l=r.createPipelineLayout(KQ);KQ.reset(),GQ.label=c,GQ.compute=i,GQ.layout=l,a.pipeline=r.createComputePipeline(GQ),GQ.reset(),r.popErrorScope().then(e=>{e!==null&&(a.error=!0,z(`WebGPURenderer: Compute pipeline creation failed (${c}): ${e.message}`),this._reportShaderDiagnostics([{program:s,module:i.module}],c))})}async _reportShaderDiagnostics(e,t){for(let{program:n,module:r}of e){let e=await r.getCompilationInfo();if(e.messages.length===0)continue;let i=n.code.split(` +`);for(let r of e.messages){let e=r.lineNum>0?` at line ${r.lineNum}${r.linePos>0?`:${r.linePos}`:``}`:``,a=`WebGPURenderer [${t} / ${n.stage} ${r.type}]${e}: ${r.message}`,o=``;r.lineNum>0&&r.lineNum<=i.length&&(o=`\n ${i[r.lineNum-1]}`,r.linePos>0&&(o+=`\n ${` `.repeat(r.linePos-1)}^`)),(r.type===`error`?z:R)(a+o)}}}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===5){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:iZ.Add},n={srcFactor:i,dstFactor:a,operation:iZ.Add}};if(i)switch(r){case 1:a(rZ.One,rZ.OneMinusSrcAlpha,rZ.One,rZ.OneMinusSrcAlpha);break;case 2:a(rZ.One,rZ.One,rZ.One,rZ.One);break;case 3:a(rZ.Zero,rZ.OneMinusSrc,rZ.Zero,rZ.One);break;case 4:a(rZ.Dst,rZ.OneMinusSrcAlpha,rZ.Zero,rZ.One);break}else switch(r){case 1:a(rZ.SrcAlpha,rZ.OneMinusSrcAlpha,rZ.One,rZ.OneMinusSrcAlpha);break;case 2:a(rZ.SrcAlpha,rZ.One,rZ.One,rZ.One);break;case 3:z(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`);break;case 4:z(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};z(`WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case 200:t=rZ.Zero;break;case 201:t=rZ.One;break;case 202:t=rZ.Src;break;case 203:t=rZ.OneMinusSrc;break;case 204:t=rZ.SrcAlpha;break;case 205:t=rZ.OneMinusSrcAlpha;break;case 208:t=rZ.Dst;break;case 209:t=rZ.OneMinusDst;break;case 206:t=rZ.DstAlpha;break;case 207:t=rZ.OneMinusDstAlpha;break;case 210:t=rZ.SrcAlphaSaturated;break;case DV:t=rZ.Constant;break;case OV:t=rZ.OneMinusConstant;break;default:z(`WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case 512:t=YX.Never;break;case 519:t=YX.Always;break;case 513:t=YX.Less;break;case 515:t=YX.LessEqual;break;case 514:t=YX.Equal;break;case 518:t=YX.GreaterEqual;break;case 516:t=YX.Greater;break;case 517:t=YX.NotEqual;break;default:z(`WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case Bt:t=oZ.Keep;break;case 0:t=oZ.Zero;break;case Vt:t=oZ.Replace;break;case Kt:t=oZ.Invert;break;case Ht:t=oZ.IncrementClamp;break;case Ut:t=oZ.DecrementClamp;break;case Wt:t=oZ.IncrementWrap;break;case Gt:t=oZ.DecrementWrap;break;default:z(`WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case 100:t=iZ.Add;break;case 101:t=iZ.Subtract;break;case 102:t=iZ.ReverseSubtract;break;case 103:t=iZ.Min;break;case 104:t=iZ.Max;break;default:z(`WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={};r.topology=this.backend.utils.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?eZ.Uint16:eZ.Uint32);let i=n.side===1;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(i=!i),r.frontFace=i===!0?QX.CW:QX.CCW,r.cullMode=n.side===2?$X.None:$X.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?aZ.All:aZ.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=YX.Always;else{let n=this.backend.parameters.reversedDepthBuffer?un[e.depthFunc]:e.depthFunc;switch(n){case 0:t=YX.Never;break;case 1:t=YX.Always;break;case 2:t=YX.Less;break;case 3:t=YX.LessEqual;break;case 4:t=YX.Equal;break;case 5:t=YX.GreaterEqual;break;case 6:t=YX.Greater;break;case 7:t=YX.NotEqual;break;default:z(`WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},XQ=class{constructor(){this.label=``,this.type=void 0,this.count=0}reset(){this.label=``,this.type=void 0,this.count=0}},ZQ=new TZ,QQ=new EZ,$Q=new XQ,e$=class extends WX{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,$Q.label=`queryset_global_timestamp_${t}`,$Q.type=`timestamp`,$Q.count=this.maxQueries,this.querySet=this.device.createQuerySet($Q),$Q.reset();let r=this.maxQueries*8;ZQ.label=`buffer_timestamp_resolve_${t}`,ZQ.size=r,ZQ.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(ZQ),ZQ.reset(),ZQ.label=`buffer_timestamp_result_${t}`,ZQ.size=r,ZQ.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(ZQ),ZQ.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return sn(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder(QQ);r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(CZ(this.device,i),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o={},s=[];for(let[t,n]of e){let e=t.match(/^(.*):f(\d+)$/),r=parseInt(e[2]);s.includes(r)===!1&&s.push(r),o[r]===void 0&&(o[r]=0);let i=a[n],c=a[n+1],l=Number(c-i)/1e6;this.timestamps.set(t,l),o[r]+=l}let c=o[s[s.length-1]];return this.resultBuffer.unmap(),this.lastValue=c,this.frames=s,c}catch(e){return z(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){z(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){z(`Error unmapping buffer:`,e)}this.querySet&&=(this.querySet.destroy(),null),this.resolveBuffer&&=(this.resolveBuffer.destroy(),null),this.resultBuffer&&=(this.resultBuffer.destroy(),null),this.queryOffsets.clear(),this.pendingResolve=null}}},t$=class{constructor(){this.label=``,this.timestampWrites=void 0}reset(){this.label=``,this.timestampWrites=void 0}},n$=class{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}},r$=class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},i$={r:0,g:0,b:0,a:1},a$=new TZ,o$=new EZ,s$=new t$,c$=new XQ,l$=new MZ,u$=new r$,d$=new qZ,f$=new qZ,p$=new PZ,m$=new QZ,h$=class extends EX{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0||e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new SZ(this),this.attributeUtils=new IQ(this),this.bindingUtils=new VQ(this),this.capabilities=new HQ(this),this.pipelineUtils=new YQ(this),this.textureUtils=new fQ(this),this.occludedResolveCache=new Map;let t=typeof navigator>`u`||/Android/.test(navigator.userAgent)===!1;this._compatibility={[Qt.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let r={powerPreference:t.powerPreference,featureLevel:`compatibility`,xrCompatible:e.xr.enabled},i=typeof navigator<`u`?await navigator.gpu.requestAdapter(r):null;if(i===null)throw Error(`THREE.WebGPUBackend: Unable to create WebGPU adapter.`);let a=Object.values(hZ),o=[];for(let e of a)i.features.has(e)&&o.push(e);let s={requiredFeatures:o,requiredLimits:t.requiredLimits};n=await i.requestDevice(s)}else n=t.device;this.compatibilityMode=!n.features.has(`core-features-and-limits`),this.compatibilityMode&&(e._samples=0),n.lost.then(t=>{if(t.reason===`destroyed`)return;let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)}),n.onuncapturederror=t=>{let n=t.error,r=n&&n.constructor?n.constructor.name:`GPUError`,i=n&&n.message||`Unknown uncaptured GPU error`;e.onError({api:`WebGPU`,type:r,message:i,originalEvent:t})},this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(hZ.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,n=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:n,initialized:!0})}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),n=t.context;if(n===void 0){let r=this.parameters;n=e.isDefaultCanvasTarget===!0&&r.context!==void 0?r.context:e.domElement.getContext(`webgpu`),`setAttribute`in e.domElement&&e.domElement.setAttribute(`data-engine`,`three.js r185 webgpu`);let i=r.alpha?`premultiplied`:`opaque`,a=r.outputType===1016?`extended`:`standard`;n.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:a}}),t.context=n}return n}get coordinateSystem(){return Xt}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,n=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,n,r)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),n=this.get(t),r=e.currentSamples,i=n.descriptor;if(i===void 0||n.samples!==r){if(i=new kZ,i.colorAttachments.push(new OZ),e.depth===!0||e.stencil===!0){let t=new n$;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=t}let t=i.colorAttachments[0];r>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,n.descriptor=i,n.samples=r}let a=i.colorAttachments[0];return r>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){let t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){let t=e.textures;if(t===null)return!1;for(let e=0;e1)if(l===!0){let t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,c$.label=`occlusionQuerySet_${e.id}`,c$.type=`occlusion`,c$.count=r,i=n.createQuerySet(c$),c$.reset(),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:ZX.Load}),this.initTimestampQuery(Zt.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(a$.size=r,a$.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,i=this.device.createBuffer(a$),a$.reset(),this.occludedResolveCache.set(r,i)),a$.size=r,a$.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer(a$);a$.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(CZ(this.device,t.encoder.finish()),e.textures!==null){let t=e.textures;for(let e=0;es&&(i[0]=Math.min(o,s),i[1]=Math.ceil(o/s)),a.dispatchSize=i}i=a.dispatchSize}s.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),CZ(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,n,r,i,a,o,s,c){let{object:l,material:u,context:d}=e,f=e.getIndex(),p=f!==null;c.pipeline!==r&&(s.setPipeline(r),c.pipeline=r);let m=c.bindingGroups;for(let e=0,t=i.length;e65535?4:2);for(let a=0;a0){let i=this.get(e.camera),o=e.camera.cameras,d=e.getBindingGroup(`cameraIndex`);if(i.indexesGPU===void 0||i.indexesGPU.length!==o.length){let e=this.get(d),t=[],n=new Uint32Array([0,0,0,0]);for(let r=0,i=o.length;r(R(`WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new KX(e)));let n=new t(e);super(n,e),this.library=new v$,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}};Z.BRDF_GGX,Z.BRDF_Lambert,Z.BasicPointShadowFilter,Z.BasicShadowFilter,Z.Break,Z.Const,Z.Continue,Z.DFGLUT,Z.D_GGX,Z.Discard,Z.EPSILON,Z.F_Schlick;var b$=Z.Fn;Z.INFINITY;var x$=Z.If,S$=Z.Loop;Z.NodeAccess,Z.NodeShaderStage,Z.NodeType,Z.NodeUpdateType,Z.PCFShadowFilter,Z.PCFSoftShadowFilter,Z.PI,Z.PI2,Z.TWO_PI,Z.HALF_PI,Z.PointShadowFilter,Z.Return,Z.Schlick_to_F0,Z.ShaderNode,Z.Stack,Z.Switch,Z.TBNViewMatrix,Z.VSMShadowFilter,Z.V_GGX_SmithCorrelated,Z.Var,Z.VarIntent,Z.abs,Z.acesFilmicToneMapping,Z.acos,Z.acosh,Z.add,Z.addMethodChaining,Z.addNodeElement,Z.agxToneMapping,Z.all,Z.alphaT,Z.ambientOcclusion,Z.and,Z.anisotropy,Z.anisotropyB,Z.anisotropyT,Z.any,Z.append,Z.array;var C$=Z.asin;Z.asinh,Z.assign,Z.atan,Z.atanh,Z.atomicAdd,Z.atomicAnd,Z.atomicFunc,Z.atomicLoad,Z.atomicMax,Z.atomicMin,Z.atomicOr,Z.atomicStore,Z.atomicSub,Z.atomicXor,Z.attenuationColor,Z.attenuationDistance,Z.attribute,Z.attributeArray,Z.backgroundBlurriness,Z.backgroundIntensity,Z.backgroundRotation,Z.batch,Z.bentNormalView,Z.billboarding,Z.bitAnd,Z.bitNot,Z.bitOr,Z.bitXor,Z.bitangentGeometry,Z.bitangentLocal,Z.bitangentView,Z.bitangentWorld,Z.bitcast,Z.blendBurn,Z.blendColor,Z.blendDodge,Z.blendOverlay,Z.blendScreen,Z.blur,Z.bool,Z.buffer,Z.bufferAttribute,Z.bumpMap,Z.builtin,Z.builtinAOContext,Z.builtinShadowContext,Z.bvec2,Z.bvec3,Z.bvec4,Z.bypass,Z.cache,Z.call,Z.cameraFar,Z.cameraIndex,Z.cameraNear,Z.cameraNormalMatrix,Z.cameraPosition,Z.cameraProjectionMatrix,Z.cameraProjectionMatrixInverse,Z.cameraViewMatrix,Z.cameraViewport,Z.cameraWorldMatrix,Z.cbrt,Z.cdl,Z.ceil,Z.checker,Z.cineonToneMapping,Z.clamp,Z.clearcoat,Z.clearcoatNormalView,Z.clearcoatRoughness,Z.clipSpace,Z.code,Z.color,Z.colorSpaceToWorking,Z.colorToDirection,Z.compute,Z.computeKernel,Z.computeSkinning,Z.context,Z.convert,Z.convertColorSpace,Z.convertToTexture,Z.countLeadingZeros,Z.countOneBits,Z.countTrailingZeros;var w$=Z.cos;Z.cosh,Z.cross,Z.cubeTexture,Z.cubeTextureBase,Z.dFdx,Z.dFdy,Z.dashSize,Z.debug,Z.decrement,Z.decrementBefore,Z.defaultBuildStages,Z.defaultShaderStages,Z.defined,Z.degrees,Z.deltaTime,Z.densityFog,Z.densityFogFactor,Z.depth,Z.depthPass,Z.determinant,Z.difference,Z.diffuseColor,Z.directPointLight,Z.directionToColor,Z.directionToFaceDirection,Z.dispersion,Z.distance,Z.div,Z.dot,Z.drawIndex,Z.dynamicBufferAttribute,Z.element,Z.emissive,Z.equal,Z.equirectDirection,Z.equirectUV;var T$=Z.exp;Z.exp2,Z.exponentialHeightFogFactor,Z.expression,Z.faceDirection,Z.faceForward,Z.faceforward;var E$=Z.float;Z.floatBitsToInt,Z.floatBitsToUint,Z.floor,Z.fog,Z.fract,Z.frameGroup,Z.frameId,Z.frontFacing,Z.fwidth,Z.gain,Z.gapSize,Z.getConstNodeType,Z.getCurrentStack,Z.getDirection,Z.getDistanceAttenuation,Z.getGeometryRoughness,Z.getNormalFromDepth,Z.interleavedGradientNoise,Z.vogelDiskSample,Z.getParallaxCorrectNormal,Z.getRoughness,Z.getScreenPosition,Z.getShIrradianceAt,Z.getShadowMaterial,Z.getShadowRenderObjectFunction,Z.getTextureIndex,Z.getViewPosition,Z.globalId,Z.glsl,Z.glslFn,Z.grayscale,Z.greaterThan,Z.greaterThanEqual,Z.hash,Z.highpModelNormalViewMatrix,Z.highpModelViewMatrix,Z.hue,Z.increment,Z.incrementBefore,Z.instance;var D$=Z.instanceIndex;Z.instancedArray,Z.instancedBufferAttribute,Z.instancedDynamicBufferAttribute,Z.instancedMesh,Z.int,Z.intBitsToFloat,Z.inverse,Z.inverseSqrt,Z.inversesqrt,Z.invocationLocalIndex,Z.invocationSubgroupIndex,Z.ior,Z.iridescence,Z.iridescenceIOR,Z.iridescenceThickness,Z.ivec2,Z.ivec3,Z.ivec4,Z.js,Z.label,Z.length,Z.lengthSq,Z.lessThan,Z.lessThanEqual,Z.lightPosition,Z.lightProjectionUV,Z.lightShadowMatrix,Z.lightTargetDirection,Z.lightTargetPosition,Z.lightViewPosition,Z.lightingContext,Z.lights,Z.linearDepth,Z.linearToneMapping,Z.localId,Z.log,Z.log2,Z.logarithmicDepthToViewZ,Z.luminance,Z.mat2,Z.mat3,Z.mat4,Z.matcapUV,Z.materialAO,Z.materialAlphaTest,Z.materialAnisotropy,Z.materialAnisotropyVector,Z.materialAttenuationColor,Z.materialAttenuationDistance,Z.materialClearcoat,Z.materialClearcoatNormal,Z.materialClearcoatRoughness,Z.materialColor,Z.materialDispersion,Z.materialEmissive,Z.materialEnvIntensity,Z.materialEnvRotation,Z.materialIOR,Z.materialIridescence,Z.materialIridescenceIOR,Z.materialIridescenceThickness,Z.materialLightMap,Z.materialLineDashOffset,Z.materialLineDashSize,Z.materialLineGapSize,Z.materialLineScale,Z.materialLineWidth,Z.materialMetalness,Z.materialNormal,Z.materialOpacity,Z.materialPointSize,Z.materialReference,Z.materialReflectivity,Z.materialRefractionRatio,Z.materialRotation,Z.materialRoughness,Z.materialSheen,Z.materialSheenRoughness,Z.materialShininess,Z.materialSpecular,Z.materialSpecularColor,Z.materialSpecularIntensity,Z.materialSpecularStrength,Z.materialThickness,Z.materialTransmission,Z.max,Z.maxMipLevel,Z.mediumpModelViewMatrix,Z.metalness,Z.min,Z.mix,Z.mixElement,Z.mod,Z.modelDirection,Z.modelNormalMatrix,Z.modelPosition,Z.modelRadius,Z.modelScale,Z.modelViewMatrix,Z.modelViewPosition,Z.modelViewProjection,Z.modelWorldMatrix,Z.modelWorldMatrixInverse,Z.morphReference,Z.mrt,Z.mul,Z.mx_aastep,Z.mx_add,Z.mx_atan2,Z.mx_cell_noise_float,Z.mx_contrast,Z.mx_divide,Z.mx_fractal_noise_float,Z.mx_fractal_noise_vec2,Z.mx_fractal_noise_vec3,Z.mx_fractal_noise_vec4,Z.mx_frame,Z.mx_heighttonormal,Z.mx_hsvtorgb,Z.mx_ifequal,Z.mx_ifgreater,Z.mx_ifgreatereq,Z.mx_invert,Z.mx_modulo,Z.mx_multiply,Z.mx_noise_float,Z.mx_noise_vec3,Z.mx_noise_vec4,Z.mx_place2d,Z.mx_power,Z.mx_ramp4,Z.mx_ramplr,Z.mx_ramptb,Z.mx_rgbtohsv,Z.mx_rotate2d,Z.mx_rotate3d,Z.mx_safepower,Z.mx_separate,Z.mx_splitlr,Z.mx_splittb,Z.mx_srgb_texture_to_lin_rec709,Z.mx_subtract,Z.mx_timer,Z.mx_transform_uv,Z.mx_unifiednoise2d,Z.mx_unifiednoise3d,Z.mx_worley_noise_float,Z.mx_worley_noise_vec2,Z.mx_worley_noise_vec3;var O$=Z.negate;Z.negateOnBackSide,Z.neutralToneMapping,Z.nodeArray,Z.nodeImmutable,Z.nodeObject,Z.nodeObjectIntent,Z.nodeObjects,Z.nodeProxy,Z.nodeProxyIntent,Z.normalFlat,Z.normalGeometry,Z.normalLocal,Z.normalMap,Z.normalView,Z.normalViewGeometry,Z.normalWorld,Z.normalWorldGeometry,Z.normalize,Z.not,Z.notEqual,Z.numWorkgroups,Z.objectDirection,Z.objectGroup,Z.objectPosition,Z.objectRadius,Z.objectScale,Z.objectViewPosition,Z.objectWorldMatrix,Z.OnBeforeObjectUpdate,Z.OnBeforeMaterialUpdate,Z.OnObjectUpdate,Z.OnMaterialUpdate,Z.oneMinus,Z.or,Z.orthographicDepthToViewZ,Z.oscSawtooth,Z.oscSine,Z.oscSquare,Z.oscTriangle,Z.output,Z.outputStruct,Z.overloadingFn,Z.overrideNode,Z.overrideNodes,Z.packHalf2x16,Z.packSnorm2x16,Z.packUnorm2x16,Z.packNormalToRGB,Z.parabola,Z.parallaxDirection,Z.parallaxUV,Z.parameter,Z.pass,Z.passTexture,Z.pcurve,Z.perspectiveDepthToViewZ,Z.pmremTexture,Z.pointShadow,Z.pointUV,Z.pointWidth,Z.positionGeometry,Z.positionLocal,Z.positionPrevious,Z.positionView,Z.positionViewDirection,Z.positionWorld,Z.positionWorldDirection,Z.posterize,Z.pow,Z.pow2,Z.pow3,Z.pow4,Z.premultiplyAlpha,Z.property,Z.radians,Z.rand,Z.range,Z.rangeFog,Z.rangeFogFactor,Z.reciprocal,Z.reference,Z.referenceBuffer,Z.reflect,Z.reflectVector,Z.reflectView,Z.reflector,Z.refract,Z.refractVector,Z.refractView,Z.reinhardToneMapping,Z.remap,Z.remapClamp,Z.renderGroup,Z.renderOutput,Z.rendererReference,Z.replaceDefaultUV,Z.rotate,Z.rotateUV,Z.roughness,Z.round,Z.rtt,Z.sRGBTransferEOTF,Z.sRGBTransferOETF,Z.sample,Z.sampler,Z.samplerComparison,Z.saturate,Z.saturation,Z.screen,Z.screenCoordinate,Z.screenDPR,Z.screenSize,Z.screenUV,Z.select,Z.setCurrentStack,Z.setName,Z.shaderStages,Z.shadow,Z.shadowPositionWorld,Z.shapeCircle,Z.sharedUniformGroup,Z.sheen,Z.sheenRoughness,Z.shiftLeft,Z.shiftRight,Z.shininess,Z.sign;var k$=Z.sin;Z.sinh,Z.sinc,Z.skinning,Z.smoothstep,Z.smoothstepElement,Z.specularColor,Z.specularF90,Z.spherizeUV,Z.split,Z.spritesheetUV;var A$=Z.sqrt;Z.stack,Z.step,Z.stepElement;var j$=Z.storage;Z.storageBarrier,Z.storageTexture,Z.storageTexture3D,Z.struct,Z.sub,Z.subgroupAdd,Z.subgroupAll,Z.subgroupAnd,Z.subgroupAny,Z.subgroupBallot,Z.subgroupBroadcast,Z.subgroupBroadcastFirst,Z.subBuild,Z.subgroupElect,Z.subgroupExclusiveAdd,Z.subgroupExclusiveMul,Z.subgroupInclusiveAdd,Z.subgroupInclusiveMul,Z.subgroupIndex,Z.subgroupMax,Z.subgroupMin,Z.subgroupMul,Z.subgroupOr,Z.subgroupShuffle,Z.subgroupShuffleDown,Z.subgroupShuffleUp,Z.subgroupShuffleXor,Z.subgroupSize,Z.subgroupXor,Z.tan,Z.tanh,Z.tangentGeometry,Z.tangentLocal,Z.tangentView,Z.tangentWorld,Z.texture,Z.texture3D,Z.textureBarrier,Z.textureBicubic,Z.textureBicubicLevel,Z.textureCubeUV,Z.textureLoad,Z.textureSize,Z.textureLevel,Z.textureStore,Z.thickness,Z.time,Z.toneMapping,Z.toneMappingExposure,Z.toonOutlinePass,Z.transformDirection,Z.transformNormal,Z.transformNormalByInverseViewMatrix,Z.transformNormalByViewMatrix,Z.transformNormalToView,Z.transformedClearcoatNormalView,Z.transformedNormalView,Z.transformedNormalWorld,Z.transmission,Z.transpose,Z.triNoise3D,Z.triplanarTexture,Z.triplanarTextures,Z.trunc,Z.uint,Z.uintBitsToFloat;var M$=Z.uniform;Z.uniformArray,Z.uniformCubeTexture,Z.uniformGroup,Z.uniformFlow,Z.uniformTexture,Z.unpackHalf2x16,Z.unpackSnorm2x16,Z.unpackUnorm2x16,Z.unpackRGBToNormal,Z.unpremultiplyAlpha,Z.userData,Z.uv,Z.uvec2,Z.uvec3,Z.uvec4,Z.varying,Z.varyingProperty,Z.vec2,Z.vec3,Z.vec4,Z.vectorComponents,Z.velocity,Z.vertexColor,Z.vertexIndex,Z.vertexStage,Z.vibrance,Z.viewZToLogarithmicDepth,Z.viewZToOrthographicDepth,Z.viewZToPerspectiveDepth,Z.viewZToReversedOrthographicDepth,Z.viewZToReversedPerspectiveDepth,Z.viewport,Z.viewportCoordinate,Z.viewportDepthTexture,Z.viewportLinearDepth,Z.viewportMipTexture,Z.viewportOpaqueMipTexture,Z.viewportResolution,Z.viewportSafeUV,Z.viewportSharedTexture,Z.viewportSize,Z.viewportTexture,Z.viewportUV,Z.wgsl,Z.wgslFn,Z.workgroupArray,Z.workgroupBarrier,Z.workgroupId,Z.workingToColorSpace,Z.xor;var N$=new oi,P$=new V,F$=class extends Hc{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 Mi([-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 Mi([-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 sl(t,6,1);return this.setAttribute(`instanceStart`,new qi(n,3,0)),this.setAttribute(`instanceEnd`,new qi(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new sl(t,6,1);return this.setAttribute(`instanceColorStart`,new qi(n,3,0)),this.setAttribute(`instanceColorEnd`,new qi(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Ds(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new oi);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),N$.setFromBufferAttribute(t),this.boundingBox.union(N$))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ii),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 + #include + #include + #include + #include + + uniform float linewidth; + uniform vec2 resolution; + + attribute vec3 instanceStart; + attribute vec3 instanceEnd; + + attribute vec3 instanceColorStart; + attribute vec3 instanceColorEnd; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #ifdef USE_DASH + + uniform float dashScale; + attribute float instanceDistanceStart; + attribute float instanceDistanceEnd; + varying float vLineDistance; + + #endif + + float trimSegmentAlpha( const in vec4 start, const in vec4 end ) { + + // compute the interpolation factor needed to trim the 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 + + // we need different nearEstimate formula for reversed and default depth buffer + // a is positive with a reversed depth buffer so it can be used for controlling the code flow + float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a ); + + return ( nearEstimate - start.z ) / ( end.z - start.z ); + + } + + void main() { + + #ifdef USE_COLOR + + vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; + + #endif + + float aspect = resolution.x / resolution.y; + + // camera space + vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); + vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); + + #ifdef USE_DASH + + float lineDistanceStart = dashScale * instanceDistanceStart; + float lineDistanceEnd = dashScale * instanceDistanceEnd; + + #endif + + #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 ) { + + float alpha = trimSegmentAlpha( start, end ); + end.xyz = mix( start.xyz, end.xyz, alpha ); + + #ifdef USE_DASH + + lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha ); + + #endif + + } else if ( end.z < 0.0 && start.z >= 0.0 ) { + + float alpha = trimSegmentAlpha( end, start ); + start.xyz = mix( end.xyz, start.xyz, alpha ); + + #ifdef USE_DASH + + lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha ); + + #endif + + } + + } + + #ifdef USE_DASH + + vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd; + vUv = uv; + + #endif + + // clip space + vec4 clipStart = projectionMatrix * start; + vec4 clipEnd = projectionMatrix * end; + + // ndc space + vec3 ndcStart = clipStart.xyz / clipStart.w; + vec3 ndcEnd = clipEnd.xyz / clipEnd.w; + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize( dir ); + + #ifdef WORLD_UNITS + + vec3 worldDir = normalize( end.xyz - start.xyz ); + vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); + vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); + vec3 worldFwd = cross( worldDir, worldUp ); + worldPos = position.y < 0.5 ? start: end; + + // height offset + float hw = linewidth * 0.5; + worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; + + // don't extend the line if we're rendering dashes because we + // won't be rendering the endcaps + #ifndef USE_DASH + + // cap extension + worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; + + // add width to the box + worldPos.xyz += worldFwd * hw; + + // endcaps + if ( position.y > 1.0 || position.y < 0.0 ) { + + worldPos.xyz -= worldFwd * 2.0 * hw; + + } + + #endif + + // project the worldpos + vec4 clip = projectionMatrix * worldPos; + + // shift the depth of the projected points so the line + // segments overlap neatly + vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; + clip.z = clipPose.z * clip.w; + + #else + + vec2 offset = vec2( dir.y, - dir.x ); + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if ( position.x < 0.0 ) offset *= - 1.0; + + // endcaps + if ( position.y < 0.0 ) { + + offset += - dir; + + } else if ( position.y > 1.0 ) { + + offset += dir; + + } + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... + offset /= resolution.y; + + // select end + vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; + + // back to clip space + offset *= clip.w; + + clip.xy += offset; + + #endif + + gl_Position = clip; + + vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation + + #include + #include + #include + + } + `,fragmentShader:` + uniform vec3 diffuse; + uniform float opacity; + uniform float linewidth; + + #ifdef USE_DASH + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + #endif + + varying float vLineDistance; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #include + #include + #include + #include + #include + + vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { + + float mua; + float mub; + + vec3 p13 = p1 - p3; + vec3 p43 = p4 - p3; + + vec3 p21 = p2 - p1; + + float d1343 = dot( p13, p43 ); + float d4321 = dot( p43, p21 ); + float d1321 = dot( p13, p21 ); + float d4343 = dot( p43, p43 ); + float d2121 = dot( p21, p21 ); + + float denom = d2121 * d4343 - d4321 * d4321; + + float numer = d1343 * d4321 - d1321 * d4343; + + mua = numer / denom; + mua = clamp( mua, 0.0, 1.0 ); + mub = ( d1343 + d4321 * ( mua ) ) / d4343; + mub = clamp( mub, 0.0, 1.0 ); + + return vec2( mua, mub ); + + } + + void main() { + + float alpha = opacity; + vec4 diffuseColor = vec4( diffuse, alpha ); + + #include + + #ifdef USE_DASH + + if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps + + if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX + + #endif + + #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 + + #include + #include + + gl_FragColor = vec4( diffuseColor.rgb, alpha ); + + #include + #include + #include + #include + + } + `};var I$=class extends Rs{constructor(e){super({type:`LineMaterial`,uniforms:Fs.clone(Ml.line.uniforms),vertexShader:Ml.line.vertexShader,fragmentShader:Ml.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},L$=new ir,R$=new V,z$=new V,B$=new ir,V$=new ir,H$=new ir,U$=new V,W$=new lr,G$=new Cl,K$=new V,q$=new oi,J$=new Ii,Y$=new ir,X$,Z$;function Q$(e,t,n){return Y$.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),Y$.multiplyScalar(1/Y$.w),Y$.x=Z$/n.width,Y$.y=Z$/n.height,Y$.applyMatrix4(e.projectionMatrixInverse),Y$.multiplyScalar(1/Y$.w),Math.abs(Math.max(Y$.x,Y$.y))}function $$(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;ru&&V$.z>u)continue;if(B$.z>u){let e=B$.z-V$.z,t=(B$.z-u)/e;B$.lerp(V$,t)}else if(V$.z>u){let e=V$.z-B$.z,t=(V$.z-u)/e;V$.lerp(B$,t)}B$.applyMatrix4(r),V$.applyMatrix4(r),B$.multiplyScalar(1/B$.w),V$.multiplyScalar(1/V$.w),B$.x*=i.x/2,B$.y*=i.y/2,V$.x*=i.x/2,V$.y*=i.y/2,G$.start.copy(B$),G$.start.z=0,G$.end.copy(V$),G$.end.z=0;let o=G$.closestPointToPointParameter(U$,!0);G$.at(o,K$);let l=Rn.lerp(B$.z,V$.z,o),d=l>=-1&&l<=1,f=U$.distanceTo(K$)e.length)&&(t=e.length);for(var n=0,r=Array(t);n3?(i=m===r)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=n<2&&pr||r>m)&&(a[4]=n,a[5]=r,f.n=m,s=0))}if(i||n>1)return o;throw d=!0,r}return function(i,u,m){if(l>1)throw TypeError(`Generator is already running`);for(d&&u===1&&p(u,m),s=u,c=m;(t=s<2?e:c)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,c)):f.n=c:f.v=c);try{if(l=2,a){if(s||(i=`next`),t=a[i]){if(!(t=t.call(a,c)))throw TypeError(`iterator result is not an object`);if(!t.done)return t;c=t.value,s<2&&(s=0)}else s===1&&(t=a.return)&&t.call(a),s<2&&(c=TypeError(`The iterator does not provide a '`+i+`' method`),s=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==o)break}catch(t){a=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,i,a),!0),l}var o={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(z1(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,z1(e,i,`GeneratorFunction`)),e.prototype=Object.create(d),e}return c.prototype=l,z1(d,`constructor`,l),z1(l,`constructor`,c),c.displayName=`GeneratorFunction`,z1(l,i,`GeneratorFunction`),z1(d),z1(d,i,`Generator`),z1(d,r,function(){return this}),z1(d,`toString`,function(){return`[object Generator]`}),(R1=function(){return{w:a,m:f}})()}function z1(e,t,n,r){var i=Object.defineProperty;try{i({},``,{})}catch{i=0}z1=function(e,t,n,r){function a(t,n){z1(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a(`next`,0),a(`throw`,1),a(`return`,2))},z1(e,t,n,r)}function B1(e,t){return B1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},B1(e,t)}function V1(e,t){return l1(e)||A1(e,t)||q1(e,t)||j1()}function H1(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=E1(e))!==null;);return e}function U1(e,t,n,r){var i=T1(E1(e.prototype),t,n);return typeof i==`function`?function(e){return i.apply(n,e)}:i}function W1(e){return u1(e)||k1(e)||q1(e)||M1()}function G1(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function K1(e){var t=G1(e,`string`);return typeof t==`symbol`?t:t+``}function q1(e,t){if(e){if(typeof e==`string`)return c1(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)?c1(e,t):void 0}}var J1=function(e){e instanceof Array?e.forEach(J1):(e.map&&e.map.dispose(),e.dispose())},Y1=function(e){e.geometry&&e.geometry.dispose(),e.material&&J1(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(Y1)},X1=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),Y1(t)}};function Z1(e,t){var n=new t;return{linkProp:function(t){return{default:n[t](),onChange:function(n,r){r[e][t](n)},triggerUpdate:!1}},linkMethod:function(t){return function(n){var r=n[e],i=[...arguments].slice(1),a=r[t].apply(r,i);return a===r?this:a}}}}var Q1=100;function $1(){return Q1}function e0(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180,a=Q1*(1+n),o=Math.sin(r);return{x:a*o*Math.cos(i),y:a*Math.cos(r),z:a*o*Math.sin(i)}}function t0(e){var t=e.x,n=e.y,r=e.z,i=Math.sqrt(t*t+n*n+r*r),a=Math.acos(n/i),o=Math.atan2(r,t);return{lat:90-a*180/Math.PI,lng:90-o*180/Math.PI-(o<-Math.PI/2?360:0),altitude:i/Q1-1}}function n0(e){return e*Math.PI/180}var r0=window.THREE?window.THREE:{BackSide:1,BufferAttribute:Oi,Color:Ur,Mesh:_a,ShaderMaterial:Rs},i0=` +uniform float hollowRadius; + +varying vec3 vVertexWorldPosition; +varying vec3 vVertexNormal; +varying float vCameraDistanceToObjCenter; +varying float vVertexAngularDistanceToHollowRadius; + +void main() { + vVertexNormal = normalize(normalMatrix * normal); + vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; + + vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); + vCameraDistanceToObjCenter = length(objCenterViewPosition); + + float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter); + float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition))); + vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle; + + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +}`,a0=` +uniform vec3 color; +uniform float coefficient; +uniform float power; +uniform float hollowRadius; + +varying vec3 vVertexNormal; +varying vec3 vVertexWorldPosition; +varying float vCameraDistanceToObjCenter; +varying float vVertexAngularDistanceToHollowRadius; + +void main() { + if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius + if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius + + vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition; + vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz; + viewCameraToVertex = normalize(viewCameraToVertex); + float intensity = pow( + coefficient + dot(vVertexNormal, viewCameraToVertex), + power + ); + gl_FragColor = vec4(color, intensity); +}`;function o0(e,t,n,r){return new r0.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:i0,fragmentShader:a0,uniforms:{coefficient:{value:e},color:{value:new r0.Color(t)},power:{value:n},hollowRadius:{value:r}}})}function s0(e,t){for(var n=e.clone(),r=new Float32Array(e.attributes.position.count*3),i=0,a=r.length;i1&&arguments[1]!==void 0?arguments[1]:{},i=r.color,a=i===void 0?`gold`:i,o=r.size,s=o===void 0?2:o,c=r.coefficient,l=c===void 0?.5:c,u=r.power,d=u===void 0?1:u,f=r.hollowRadius,p=f===void 0?0:f,m=r.backside,h=m===void 0||m;_1(this,t),n=h1(this,t);var g=s0(e,s),_=o0(l,a,d,p);return h&&(_.side=r0.BackSide),n.geometry=g,n.material=_,n}return D1(t,e),C1(t)}(r0.Mesh),l0=window.THREE?window.THREE:{Color:Ur,Group:Ir,LineBasicMaterial:Ma,LineSegments:Wa,Mesh:_a,MeshPhongMaterial:Hs,SphereGeometry:Ts,SRGBColorSpace:It,TextureLoader:gc},u0=Up({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:`lightskyblue`},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t===void 0?e.globeObj.material:(e.globeObj.material=t||e.defaultGlobeMaterial,this)},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){Y1(e.globeObj),Y1(e.tileEngine),Y1(e.graticulesObj)}},stateInit:function(){var e=new l0.MeshPhongMaterial({color:0}),t=new l0.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new $b(Q1),r=new l0.Group;return r.__globeObjType=`globe`,r.add(t),r.add(n),{globeGroup:r,globeObj:t,graticulesObj:new l0.LineSegments(new SS(Cy(),Q1,2),new l0.LineBasicMaterial({color:`lightgrey`,transparent:!0,opacity:.1})),defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){X1(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty(`globeCurvatureResolution`)){var r;(r=e.globeObj.geometry)==null||r.dispose();var i=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new l0.SphereGeometry(Q1,i,i/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty(`globeImageUrl`)&&(e.globeImageUrl?new l0.TextureLoader().load(e.globeImageUrl,function(t){var r;t.colorSpace=l0.SRGBColorSpace,(r=n.map)==null||r.dispose(),n.map=t,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new l0.Color(0))),t.hasOwnProperty(`bumpImageUrl`)&&(e.bumpImageUrl?e.bumpImageUrl&&new l0.TextureLoader().load(e.bumpImageUrl,function(e){var t;(t=n.bumpMap)==null||t.dispose(),n.bumpMap=e,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty(`atmosphereColor`)||t.hasOwnProperty(`atmosphereAltitude`))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),Y1(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new c0(e.globeObj.geometry,{color:e.atmosphereColor,size:Q1*e.atmosphereAltitude,hollowRadius:Q1,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType=`atmosphere`,e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),d0=function(e){return isNaN(e)?parseInt(US(e).toHex(),16):e},f0=function(e){return e&&isNaN(e)?dh(e).opacity:1},p0=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r,i=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var o=V1(a.slice(1),4),s=o[0],c=o[1],l=o[2],u=o[3];r=new Ur(`rgb(${+s},${+c},${+l})`),i=Math.min(+u,1)}else r=new Ur(e);n&&r.convertLinearToSRGB();var d=r.toArray();return t?[].concat(W1(d),[i]):d};function m0(e,t,n){return e.opacity=t,e.transparent=t<1,e.depthWrite=t>=1,e}var h0=window.THREE?window.THREE:{BufferAttribute:Oi};function g0(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(t===1)return new h0.BufferAttribute(new n(e),t);for(var r=new h0.BufferAttribute(new n(e.length*t),t),i=0,a=e.length;i1&&arguments[1]!==void 0?arguments[1]:{},i=r.dataBindAttr,a=i===void 0?`__data`:i,o=r.objBindAttr,s=o===void 0?`__threeObj`:o,c=r.removeDelay,l=c===void 0?0:c;return _1(this,t),n=h1(this,t),w1(n,`scene`,void 0),y1(n,v0,void 0),y1(n,y0,void 0),y1(n,b0,void 0),n.scene=e,b1(v0,n,a),b1(y0,n,s),b1(b0,n,l),n.onRemoveObj(function(){}),n}return D1(t,e),C1(t,[{key:`onCreateObj`,value:function(e){var n=this;return U1(t,`onCreateObj`,this)([function(t){var r=e(t);return t[v1(y0,n)]=r,r[v1(v0,n)]=t,n.scene.add(r),r}]),this}},{key:`onRemoveObj`,value:function(e){var n=this;return U1(t,`onRemoveObj`,this)([function(r,i){var a=U1(t,`getData`,n)([r]);e(r,i);var o=function(){n.scene.remove(r),Y1(r),delete a[v1(y0,n)]};v1(b0,n)?setTimeout(o,v1(b0,n)):o()}]),this}}])}(NC),S0=window.THREE?window.THREE:{BufferGeometry:Wi,CylinderGeometry:ao,Matrix4:lr,Mesh:_a,MeshLambertMaterial:Gs,Object3D:Fr,Vector3:V},C0=Object.assign({},ES),w0=C0.BufferGeometryUtils||C0,T0=Up({props:{pointsData:{default:[]},pointLat:{default:`lat`},pointLng:{default:`lng`},pointColor:{default:function(){return`#ffffaa`}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;X1(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new x0(e,{objBindAttr:`__threeObjPoint`})},update:function(e,t){var n=U(e.pointLat),r=U(e.pointLng),i=U(e.pointAltitude),a=U(e.pointRadius),o=U(e.pointColor),s=new S0.CylinderGeometry(1,1,1,e.pointResolution);s.applyMatrix4(new S0.Matrix4().makeRotationX(Math.PI/2)),s.applyMatrix4(new S0.Matrix4().makeTranslation(0,0,-.5));var c=2*Math.PI*Q1/360,l={};if(!e.pointsMerge&&t.hasOwnProperty(`pointsMerge`)&&X1(e.scene),e.dataMapper.scene=e.pointsMerge?new S0.Object3D:e.scene,e.dataMapper.onCreateObj(f).onUpdateObj(p).digest(e.pointsData),e.pointsMerge){var u=e.pointsData.length?(w0.mergeGeometries||w0.mergeBufferGeometries)(e.pointsData.map(function(t){var n=e.dataMapper.getObj(t),r=n.geometry.clone();n.updateMatrix(),r.applyMatrix4(n.matrix);var i=p0(o(t));return r.setAttribute(`color`,g0(Array(r.getAttribute(`position`).count).fill(i),4)),r})):new S0.BufferGeometry,d=new S0.Mesh(u,new S0.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));d.__globeObjType=`points`,d.__data=e.pointsData,e.dataMapper.clear(),X1(e.scene),e.scene.add(d)}function f(){var e=new S0.Mesh(s);return e.__globeObjType=`point`,e}function p(t,s){var u=function(n){var r=t.__currentTargetD=n,i=r.r,a=r.alt,o=r.lat,s=r.lng;Object.assign(t.position,e0(o,s));var l=e.pointsMerge?new S0.Vector3(0,0,0):e.scene.localToWorld(new S0.Vector3(0,0,0));t.lookAt(l),t.scale.x=t.scale.y=Math.min(30,i)*c,t.scale.z=Math.max(a*Q1,.1)},d={alt:+i(s),r:+a(s),lat:+n(s),lng:+r(s)},f=t.__currentTargetD||Object.assign({},d,{alt:-.001});if(Object.keys(d).some(function(e){return f[e]!==d[e]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?u(d):e.tweenGroup.add(new Xp(f).to(d,e.pointsTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(u).onComplete(function(){e.tweenGroup.remove(this)}).start())),!e.pointsMerge){var p=o(s),m=p?f0(p):0,h=!!m;t.visible=h,h&&(l.hasOwnProperty(p)||(l[p]=new S0.MeshLambertMaterial({color:d0(p),transparent:m<1,opacity:m})),t.material=l[p])}}}}),E0=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` + ${Al.common} + ${Al.logdepthbuf_pars_vertex} + + uniform float dashTranslate; + + attribute vec4 color; + varying vec4 vColor; + + attribute float relDistance; + varying float vRelDistance; + + void main() { + // pass through colors and distances + vColor = color; + vRelDistance = relDistance + dashTranslate; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + + ${Al.logdepthbuf_vertex} + } + `,fragmentShader:` + ${Al.logdepthbuf_pars_fragment} + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + varying vec4 vColor; + varying float vRelDistance; + + void main() { + // ignore pixels in the gap + if (vRelDistance < dashOffset) discard; + if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard; + + // set px color: [r, g, b, a], interpolated between vertices + gl_FragColor = vColor; + + ${Al.logdepthbuf_fragment} + } + `}},D0=function(e){return e.uniforms.uSurfaceRadius={type:`float`,value:0},e.vertexShader=(`attribute float surfaceRadius; +varying float vSurfaceRadius; +varying vec3 vPos; +`+e.vertexShader).replace(`void main() {`,[`void main() {`,`vSurfaceRadius = surfaceRadius;`,`vPos = position;`].join(` +`)),e.fragmentShader=(`uniform float uSurfaceRadius; +varying float vSurfaceRadius; +varying vec3 vPos; +`+e.fragmentShader).replace(`void main() {`,[`void main() {`,`if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;`].join(` +`)),e},O0=function(e){return e.vertexShader=` + attribute float r; + + const float PI = 3.1415926535897932384626433832795; + float toRad(in float a) { + return a * PI / 180.0; + } + + vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r] + float phi = toRad(90.0 - c.x); + float theta = toRad(90.0 - c.y); + float r = c.z; + return vec3( // x,y,z + r * sin(phi) * cos(theta), + r * cos(phi), + r * sin(phi) * sin(theta) + ); + } + + vec2 Cartesian2Polar(in vec3 p) { + float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z); + float phi = acos(p.y / r); + float theta = atan(p.z, p.x); + return vec2( // lat,lng + 90.0 - phi * 180.0 / PI, + 90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0) + ); + } + ${e.vertexShader.replace(`}`,` + vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r)); + gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); + } + `)} + `,e},k0=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},A0=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(e){return e};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(e){n(e),t(e.uniforms)}}},j0=[`stroke`],M0=window.THREE?window.THREE:{BufferGeometry:Wi,CubicBezierCurve3:Oo,Curve:oo,Group:Ir,Line:Ba,Mesh:_a,NormalBlending:1,ShaderMaterial:Rs,TubeGeometry:Es,Vector3:V},N0=PC.default.default||PC.default,P0=Up({props:{arcsData:{default:[]},arcStartLat:{default:`startLat`},arcStartLng:{default:`startLng`},arcStartAltitude:{default:0},arcEndLat:{default:`endLat`},arcEndLng:{default:`endLng`},arcEndAltitude:{default:0},arcColor:{default:function(){return`#ffffaa`}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)==null||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new N0,sharedMaterial:new M0.ShaderMaterial(P1(P1({},E0()),{},{transparent:!0,blending:M0.NormalBlending}))}},init:function(e,t){X1(e),t.scene=e,t.dataMapper=new x0(e,{objBindAttr:`__threeObjArc`}).onCreateObj(function(){var e=new M0.Group;return e.__globeObjType=`arc`,e}),t.ticker.onTick.add(function(e,n){t.dataMapper.entries().map(function(e){return V1(e,2)[1]}).filter(function(e){return e.children.length&&e.children[0].material&&e.children[0].__dashAnimateStep}).forEach(function(e){var t=e.children[0],r=t.__dashAnimateStep*n,i=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=i+r})})},update:function(e){var t=U(e.arcStartLat),n=U(e.arcStartLng),r=U(e.arcStartAltitude),i=U(e.arcEndLat),a=U(e.arcEndLng),o=U(e.arcEndAltitude),s=U(e.arcAltitude),c=U(e.arcAltitudeAutoScale),l=U(e.arcStroke),u=U(e.arcColor),d=U(e.arcDashLength),f=U(e.arcDashGap),p=U(e.arcDashInitialGap),m=U(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(v,y){var b=l(y),x=b!=null;if(!v.children.length||x!==(v.children[0].type===`Mesh`)){X1(v);var S=x?new M0.Mesh:new M0.Line(new M0.BufferGeometry);S.material=e.sharedMaterial.clone(),v.add(S)}var C=v.children[0];Object.assign(C.material.uniforms,{dashSize:{value:d(y)},gapSize:{value:f(y)},dashOffset:{value:p(y)}});var w=m(y);C.__dashAnimateStep=w>0?1e3/w:0;var T=g(u(y),e.arcCurveResolution,x?e.arcCircularResolution+1:1),E=_(e.arcCurveResolution,x?e.arcCircularResolution+1:1,!0);C.geometry.setAttribute(`color`,T),C.geometry.setAttribute(`relDistance`,E);var D=function(t){var n=v.__currentTargetD=t,r=n.stroke,i=h(F1(n,j0));x?(C.geometry&&C.geometry.dispose(),C.geometry=new M0.TubeGeometry(i,e.arcCurveResolution,r/2,e.arcCircularResolution),C.geometry.setAttribute(`color`,T),C.geometry.setAttribute(`relDistance`,E)):C.geometry.setFromPoints(i.getPoints(e.arcCurveResolution))},O={stroke:b,alt:s(y),altAutoScale:+c(y),startLat:+t(y),startLng:+n(y),startAlt:+r(y),endLat:+i(y),endLng:+a(y),endAlt:+o(y)},k=v.__currentTargetD||Object.assign({},O,{altAutoScale:-.001});Object.keys(O).some(function(e){return k[e]!==O[e]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?D(O):e.tweenGroup.add(new Xp(k).to(O,e.arcsTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(D).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.arcsData);function h(e){var t=e.alt,n=e.altAutoScale,r=e.startLat,i=e.startLng,a=e.startAlt,o=e.endLat,s=e.endLng,c=e.endAlt,l=function(e){var t=V1(e,3),n=t[0],r=t[1],i=t[2],a=e0(r,n,i),o=a.x,s=a.y,c=a.z;return new M0.Vector3(o,s,c)},u=[i,r],d=[s,o],f=t;if(f??=uy(u,d)/2*n+Math.max(a,c),f||a||c){var p=wy(u,d),m=function(e,t){return t+(t-e)*(e2&&arguments[2]!==void 0?arguments[2]:1,r=t+1,i;if(e instanceof Array||e instanceof Function){var a=e instanceof Array?Ig().domain(e.map(function(t,n){return n/(e.length-1)})).range(e):e;i=function(e){return p0(a(e),!0,!0)}}else{var o=p0(e,!0,!0);i=function(){return o}}for(var s=[],c=0,l=r;c1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=e+1,i=[],a=0,o=r;a=l?i:a}),4)),r})):new F0.BufferGeometry,p=new F0.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:F0.DoubleSide});p.onBeforeCompile=function(e){p.userData.shader=D0(e)};var m=new F0.Mesh(f,p);m.__globeObjType=`hexBinPoints`,m.__data=u,e.dataMapper.clear(),X1(e.scene),e.scene.add(m)}function h(e){var t=new F0.Mesh;t.__hexCenter=rD(e.h3Idx),t.__hexGeoJson=iD(e.h3Idx,!0).reverse();var n=t.__hexCenter[1];return t.__hexGeoJson.forEach(function(e){var t=e[0];Math.abs(n-t)>170&&(e[0]+=n>t?360:-360)}),t.__globeObjType=`hexbin`,t}function g(t,n){var r=function(e,t,n){return e-(e-t)*n},i=Math.max(0,Math.min(1,+c(n))),l=V1(t.__hexCenter,2),u=l[0],f=l[1],p=i===0?t.__hexGeoJson:t.__hexGeoJson.map(function(e){var t=V1(e,2),n=t[0],a=t[1];return[[n,f],[a,u]].map(function(e){var t=V1(e,2),n=t[0],a=t[1];return r(n,a,i)})}),m=e.hexTopCurvatureResolution;t.geometry&&t.geometry.dispose(),t.geometry=new ET([p],0,Q1,!1,!0,!0,m);var h={alt:+a(n)},g=function(e){var n=(t.__currentTargetD=e).alt;t.scale.x=t.scale.y=t.scale.z=1+n;var r=Q1/(n+1);t.geometry.setAttribute(`surfaceRadius`,g0(Array(t.geometry.getAttribute(`position`).count).fill(r),1))},_=t.__currentTargetD||Object.assign({},h,{alt:-.001});if(Object.keys(h).some(function(e){return _[e]!==h[e]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?g(h):e.tweenGroup.add(new Xp(_).to(h,e.hexTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(g).onComplete(function(){e.tweenGroup.remove(this)}).start())),!e.hexBinMerge){var v=s(n),y=o(n);[v,y].forEach(function(e){if(!d.hasOwnProperty(e)){var t=f0(e);d[e]=k0(new F0.MeshLambertMaterial({color:d0(e),transparent:t<1,opacity:t,side:F0.DoubleSide}),D0)}}),t.material=[v,y].map(function(e){return d[e]})}}}}),z0=function(e){return e*e},B0=function(e){return e*Math.PI/180};function V0(e,t){var n=Math.sqrt,r=Math.cos,i=function(e){return z0(Math.sin(e/2))},a=B0(e[1]),o=B0(t[1]),s=B0(e[0]),c=B0(t[0]);return 2*Math.asin(n(i(o-a)+r(a)*r(o)*i(c-s)))}var H0=Math.sqrt(2*Math.PI);function U0(e,t){return Math.exp(-z0(e/t)/2)/(t*H0)}var W0=function(e){var t=V1(e,2),n=t[0],r=t[1],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=a.lngAccessor,s=o===void 0?function(e){return e[0]}:o,c=a.latAccessor,l=c===void 0?function(e){return e[1]}:c,u=a.weightAccessor,d=u===void 0?function(){return 1}:u,f=a.bandwidth,p=[n,r],m=f*Math.PI/180;return Um(i.map(function(e){var t=d(e);return t?U0(V0(p,[s(e),l(e)]),m)*t:0}))},G0=function(){var e=m1(R1().m(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,ee,F,te,ne,re,ie,ae,oe=arguments,se,ce,le;return R1().w(function(e){for(;;)switch(e.n){case 0:if(r=oe.length>1&&oe[1]!==void 0?oe[1]:[],i=oe.length>2&&oe[2]!==void 0?oe[2]:{},a=i.lngAccessor,o=a===void 0?function(e){return e[0]}:a,s=i.latAccessor,c=s===void 0?function(e){return e[1]}:s,l=i.weightAccessor,u=l===void 0?function(){return 1}:l,d=i.bandwidth,(n=navigator)!=null&&n.gpu){e.n=1;break}return console.warn(`WebGPU not enabled in browser. Please consider enabling it to improve performance.`),e.a(2,t.map(function(e){return W0(e,r,{lngAccessor:o,latAccessor:c,weightAccessor:u,bandwidth:d})}));case 1:return f=4,p=b$,m=x$,h=M$,g=j$,_=E$,v=D$,y=S$,b=A$,x=k$,S=w$,C=C$,w=T$,T=O$,E=g(new lU(new Float32Array(t.flat().map(B0)),2),`vec2`,t.length),D=g(new lU(new Float32Array(r.map(function(e){return[B0(o(e)),B0(c(e)),u(e)]}).flat()),3),`vec3`,r.length),O=new lU(t.length,1),k=g(O,`float`,t.length),A=_(Math.PI),j=b(A.mul(2)),M=function(e){return e.mul(e)},N=function(e){return M(x(e.div(2)))},P=function(e,t){var n=_(e[1]),r=_(t[1]),i=_(e[0]),a=_(t[0]);return _(2).mul(C(b(N(r.sub(n)).add(S(n).mul(S(r)).mul(N(a.sub(i)))))))},ee=function(e,t){return w(T(M(e.div(t)).div(2))).div(t.mul(j))},F=h(B0(d)),te=h(B0(d*f)),ne=h(r.length),re=p(function(){var e=E.element(v),t=k.element(v);t.assign(0),y(ne,function(n){var r=n.i,i=D.element(r),a=i.z;m(a,function(){var n=P(i.xy,e.xy);m(n&&n.lessThan(te),function(){t.addAssign(ee(n,F).mul(a))})})})}),ie=re().compute(t.length),ae=new y$,e.n=2,ae.computeAsync(ie);case 2:return se=Array,ce=Float32Array,e.n=3,ae.getArrayBufferAsync(O);case 3:return le=e.v,e.a(2,se.from.call(se,new ce(le)))}},e)}));return function(t){return e.apply(this,arguments)}}(),K0=window.THREE?window.THREE:{Mesh:_a,MeshLambertMaterial:Gs,SphereGeometry:Ts},q0=3.5,J0=.1,Y0=100,X0=function(e){var t=dh(cD(e));return t.opacity=Math.cbrt(e),t.formatRgb()},Z0=Up({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return X0}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;X1(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new x0(e,{objBindAttr:`__threeObjHeatmap`}).onCreateObj(function(){var e=new K0.Mesh(new K0.SphereGeometry(Q1),k0(new K0.MeshLambertMaterial({vertexColors:!0,transparent:!0}),O0));return e.__globeObjType=`heatmap`,e})},update:function(e){var t=U(e.heatmapPoints),n=U(e.heatmapPointLat),r=U(e.heatmapPointLng),i=U(e.heatmapPointWeight),a=U(e.heatmapBandwidth),o=U(e.heatmapColorFn),s=U(e.heatmapColorSaturation),c=U(e.heatmapBaseAltitude),l=U(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(u,d){var f=a(d),p=o(d),m=s(d),h=c(d),g=l(d),_=t(d).map(function(e){var t=n(e),a=r(e),o=e0(t,a);return{x:o.x,y:o.y,z:o.z,lat:t,lng:a,weight:i(e)}}),v=Math.max(J0,f/q0),y=Math.ceil(360/(v||-1));u.geometry.parameters.widthSegments!==y&&(u.geometry.dispose(),u.geometry=new K0.SphereGeometry(Q1,y,y/2)),G0(_0(u.geometry.getAttribute(`position`)).map(function(e){var t=V1(e,3),n=t[0],r=t[1],i=t[2],a=t0({x:n,y:r,z:i});return[a.lng,a.lat]}),_,{latAccessor:function(e){return e.lat},lngAccessor:function(e){return e.lng},weightAccessor:function(e){return e.weight},bandwidth:f}).then(function(t){var n=W1(Array(Y0)).map(function(e,t){return p0(p(t/(Y0-1)))}),r=function(e){var t=u.__currentTargetD=e,r=t.kdeVals,i=t.topAlt,a=t.saturation,o=Rm(r.map(Math.abs))||1e-15,s=Lg([0,o/a],n);u.geometry.setAttribute(`color`,g0(r.map(function(e){return s(Math.abs(e))}),4));var c=Ig([0,o],[Q1*(1+h),Q1*(1+(i||h))]);u.geometry.setAttribute(`r`,g0(r.map(c)))},i={kdeVals:t,topAlt:g,saturation:m},a=u.__currentTargetD||Object.assign({},i,{kdeVals:t.map(function(){return 0}),topAlt:g&&h,saturation:.5});a.kdeVals.length!==t.length&&(a.kdeVals=t.slice()),Object.keys(i).some(function(e){return a[e]!==i[e]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?r(i):e.tweenGroup.add(new Xp(a).to(i,e.heatmapsTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(r).onComplete(function(){e.tweenGroup.remove(this)}).start()))})}).digest(e.heatmapsData)}}),Q0=window.THREE?window.THREE:{DoubleSide:2,Group:Ir,LineBasicMaterial:Ma,LineSegments:Wa,Mesh:_a,MeshBasicMaterial:aa},$0=Up({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:`geometry`},polygonSideColor:{default:function(){return`#ffffaa`}},polygonSideMaterial:{},polygonCapColor:{default:function(){return`#ffffaa`}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;X1(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new x0(e,{objBindAttr:`__threeObjPolygon`}).id(function(e){return e.id}).onCreateObj(function(){var e=new Q0.Group;return e.__defaultSideMaterial=k0(new Q0.MeshBasicMaterial({side:Q0.DoubleSide,depthWrite:!0}),D0),e.__defaultCapMaterial=new Q0.MeshBasicMaterial({side:Q0.DoubleSide,depthWrite:!0}),e.add(new Q0.Mesh(void 0,[e.__defaultSideMaterial,e.__defaultCapMaterial])),e.add(new Q0.LineSegments(void 0,new Q0.LineBasicMaterial)),e.__globeObjType=`polygon`,e})},update:function(e){var t=U(e.polygonGeoJsonGeometry),n=U(e.polygonAltitude),r=U(e.polygonCapCurvatureResolution),i=U(e.polygonCapColor),a=U(e.polygonCapMaterial),o=U(e.polygonSideColor),s=U(e.polygonSideMaterial),c=U(e.polygonStrokeColor),l=[];e.polygonsData.forEach(function(e){var u={data:e,capColor:i(e),capMaterial:a(e),sideColor:o(e),sideMaterial:s(e),strokeColor:c(e),altitude:+n(e),capCurvatureResolution:+r(e)},d=t(e),f=e.__id||`${Math.round(Math.random()*1e9)}`;e.__id=f,d.type===`Polygon`?l.push(P1({id:`${f}_0`,coords:d.coordinates},u)):d.type===`MultiPolygon`?l.push.apply(l,W1(d.coordinates.map(function(e,t){return P1({id:`${f}_${t}`,coords:e},u)}))):console.warn(`Unsupported GeoJson geometry type: ${d.type}. Skipping geometry...`)}),e.dataMapper.onUpdateObj(function(t,n){var r=n.coords,i=n.capColor,a=n.capMaterial,o=n.sideColor,s=n.sideMaterial,c=n.strokeColor,l=n.altitude,u=n.capCurvatureResolution,d=V1(t.children,2),f=d[0],p=d[1],m=!!c;p.visible=m;var h=!!(i||a),g=!!(o||s);e2(f.geometry.parameters||{},{polygonGeoJson:r,curvatureResolution:u,closedTop:h,includeSides:g})||(f.geometry&&f.geometry.dispose(),f.geometry=new ET(r,0,Q1,!1,h,g,u)),m&&(!p.geometry.parameters||p.geometry.parameters.geoJson.coordinates!==r||p.geometry.parameters.resolution!==u)&&(p.geometry&&p.geometry.dispose(),p.geometry=new SS({type:`Polygon`,coordinates:r},Q1,u));var _=g?0:-1,v=h?+!!g:-1;if(_>=0&&(f.material[_]=s||t.__defaultSideMaterial),v>=0&&(f.material[v]=a||t.__defaultCapMaterial),[[!s&&o,_],[!a&&i,v]].forEach(function(e){var t=V1(e,2),n=t[0],r=t[1];if(!(!n||r<0)){var i=f.material[r],a=f0(n);i.color.set(d0(n)),i.transparent=a<1,i.opacity=a}}),m){var y=p.material,b=f0(c);y.color.set(d0(c)),y.transparent=b<1,y.opacity=b}var x={alt:l},S=function(e){var n=(t.__currentTargetD=e).alt;f.scale.x=f.scale.y=f.scale.z=1+n,m&&(p.scale.x=p.scale.y=p.scale.z=1+n+1e-4),A0(t.__defaultSideMaterial,function(e){return e.uSurfaceRadius.value=Q1/(n+1)})},C=t.__currentTargetD||Object.assign({},x,{alt:-.001});Object.keys(x).some(function(e){return C[e]!==x[e]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||C.alt===x.alt?S(x):e.tweenGroup.add(new Xp(C).to(x,e.polygonsTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(S).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(l)}});function e2(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(e,t){return e===t}};return Object.entries(t).every(function(t){var r=V1(t,2),i=r[0],a=r[1];return e.hasOwnProperty(i)&&n(i)(e[i],a)})}var t2=window.THREE?window.THREE:{BufferGeometry:Wi,DoubleSide:2,Mesh:_a,MeshLambertMaterial:Gs,Vector3:V},n2=Object.assign({},ES),r2=n2.BufferGeometryUtils||n2,i2=Up({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:`geometry`},hexPolygonColor:{default:function(){return`#ffffaa`}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;X1(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new x0(e,{objBindAttr:`__threeObjHexPolygon`}).onCreateObj(function(){var e=new t2.Mesh(void 0,new t2.MeshLambertMaterial({side:t2.DoubleSide}));return e.__globeObjType=`hexPolygon`,e})},update:function(e){var t=U(e.hexPolygonGeoJsonGeometry),n=U(e.hexPolygonColor),r=U(e.hexPolygonAltitude),i=U(e.hexPolygonResolution),a=U(e.hexPolygonMargin),o=U(e.hexPolygonUseDots),s=U(e.hexPolygonCurvatureResolution),c=U(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(l,u){var d=t(u),f=i(u),p=r(u),m=Math.max(0,Math.min(1,+a(u))),h=o(u),g=s(u),_=c(u),v=n(u),y=f0(v);l.material.color.set(d0(v)),l.material.transparent=y<1,l.material.opacity=y;var b={alt:p,margin:m,curvatureResolution:g},x={geoJson:d,h3Res:f},S=l.__currentTargetD||Object.assign({},b,{alt:-.001}),C=l.__currentMemD||x;if(Object.keys(b).some(function(e){return S[e]!==b[e]})||Object.keys(x).some(function(e){return C[e]!==x[e]})){l.__currentMemD=x;var w=[];d.type===`Polygon`?aD(d.coordinates,f,!0).forEach(function(e){return w.push(e)}):d.type===`MultiPolygon`?d.coordinates.forEach(function(e){return aD(e,f,!0).forEach(function(e){return w.push(e)})}):console.warn(`Unsupported GeoJson geometry type: ${d.type}. Skipping geometry...`);var T=w.map(function(e){var t=rD(e),n=iD(e,!0).reverse(),r=t[1];return n.forEach(function(e){var t=e[0];Math.abs(r-t)>170&&(e[0]+=r>t?360:-360)}),{h3Idx:e,hexCenter:t,hexGeoJson:n}}),E=function(e){var t=l.__currentTargetD=e,n=t.alt,r=t.margin,i=t.curvatureResolution;l.geometry&&l.geometry.dispose(),l.geometry=T.length?(r2.mergeGeometries||r2.mergeBufferGeometries)(T.map(function(e){var t=V1(e.hexCenter,2),a=t[0],o=t[1];if(h){var s=e0(a,o,n),c=e0(e.hexGeoJson[0][1],e.hexGeoJson[0][0],n),l=new io(.85*(1-r)*new t2.Vector3(s.x,s.y,s.z).distanceTo(new t2.Vector3(c.x,c.y,c.z)),_);return l.rotateX(n0(-a)),l.rotateY(n0(o)),l.translate(s.x,s.y,s.z),l}else{var u=function(e,t,n){return e-(e-t)*n};return new ET([r===0?e.hexGeoJson:e.hexGeoJson.map(function(e){var t=V1(e,2),n=t[0],i=t[1];return[[n,o],[i,a]].map(function(e){var t=V1(e,2),n=t[0],i=t[1];return u(n,i,r)})})],Q1,Q1*(1+n),!1,!0,!1,i)}})):new t2.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?E(b):e.tweenGroup.add(new Xp(S).to(b,e.hexPolygonsTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(E).onComplete(function(){e.tweenGroup.remove(this)}).start())}}).digest(e.hexPolygonsData)}}),a2=window.THREE?window.THREE:{Vector3:V};function o2(e,t){var n=function(e,t){var n=e[e.length-1];return[].concat(W1(e),W1(Array(t-e.length).fill(n)))},r=Math.max(e.length,t.length),i=Rh.apply(void 0,W1([e,t].map(function(e){return e.map(function(e){return[e.x,e.y,e.z]})}).map(function(e){return n(e,r)})));return function(n){return n===0?e:n===1?t:i(n).map(function(e){var t=V1(e,3),n=t[0],r=t[1],i=t[2];return new a2.Vector3(n,r,i)})}}var s2=window.THREE?window.THREE:{BufferGeometry:Wi,Color:Ur,Group:Ir,Line:Ba,NormalBlending:1,ShaderMaterial:Rs,Vector3:V},c2=PC.default.default||PC.default,l2=Up({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return`#ffffaa`}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;(t=e.ticker)==null||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new c2,sharedMaterial:new s2.ShaderMaterial(P1(P1({},E0()),{},{transparent:!0,blending:s2.NormalBlending}))}},init:function(e,t){X1(e),t.scene=e,t.dataMapper=new x0(e,{objBindAttr:`__threeObjPath`}).onCreateObj(function(){var e=new s2.Group;return e.__globeObjType=`path`,e}),t.ticker.onTick.add(function(e,n){t.dataMapper.entries().map(function(e){return V1(e,2)[1]}).filter(function(e){return e.children.length&&e.children[0].material&&e.children[0].__dashAnimateStep}).forEach(function(e){var t=e.children[0],r=t.__dashAnimateStep*n;if(t.type===`Line`){var i=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=i+r}else if(t.type===`Line2`){for(var a=t.material.dashOffset-r,o=t.material.dashSize+t.material.gapSize;a<=-o;)a+=o;t.material.dashOffset=a}})})},update:function(e){var t=U(e.pathPoints),n=U(e.pathPointLat),r=U(e.pathPointLng),i=U(e.pathPointAlt),a=U(e.pathStroke),o=U(e.pathColor),s=U(e.pathDashLength),c=U(e.pathDashGap),l=U(e.pathDashInitialGap),u=U(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(h,g){var _=a(g),v=_!=null;if(!h.children.length||v===(h.children[0].type===`Line`)){X1(h);var y=v?new r1(new n1,new I$):new s2.Line(new s2.BufferGeometry,e.sharedMaterial.clone());h.add(y)}var b=h.children[0],x=f(t(g),n,r,i,e.pathResolution),S=u(g);if(b.__dashAnimateStep=S>0?1e3/S:0,v){b.material.resolution=e.rendererSize;var C=s(g),w=c(g),T=l(g);b.material.dashed=w>0,b.material.dashed?b.material.defines.USE_DASH=``:delete b.material.defines.USE_DASH,b.material.dashed&&(b.material.dashScale=1/d(x),b.material.dashSize=C,b.material.gapSize=w,b.material.dashOffset=-T);var E=o(g);if(E instanceof Array){var D=p(o(g),x.length-1,1,!1);b.geometry.setColors(D.array),b.material.vertexColors=!0}else{var O=E,k=f0(O);b.material.color=new s2.Color(d0(O)),b.material.transparent=k<1,b.material.opacity=k,b.material.vertexColors=!1}b.material.needsUpdate=!0}else{Object.assign(b.material.uniforms,{dashSize:{value:s(g)},gapSize:{value:c(g)},dashOffset:{value:l(g)}});var A=p(o(g),x.length),j=m(x.length,1,!0);b.geometry.setAttribute(`color`,A),b.geometry.setAttribute(`relDistance`,j)}var M=o2(h.__currentTargetD&&h.__currentTargetD.points||[x[0]],x),N=function(e){var t=h.__currentTargetD=e,n=t.stroke,r=t.interpolK,i=h.__currentTargetD.points=M(r);if(v){var a;b.geometry.setPositions((a=[]).concat.apply(a,W1(i.map(function(e){return[e.x,e.y,e.z]})))),b.material.linewidth=n,b.material.dashed&&b.computeLineDistances()}else b.geometry.setFromPoints(i),b.geometry.computeBoundingSphere()},P={stroke:_,interpolK:1},ee=Object.assign({},h.__currentTargetD||P,{interpolK:0});Object.keys(P).some(function(e){return ee[e]!==P[e]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?N(P):e.tweenGroup.add(new Xp(ee).to(P,e.pathTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(N).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.pathsData);function d(e){var t=0,n;return e.forEach(function(e){n&&(t+=n.distanceTo(e)),n=e}),t}function f(e,t,n,r,i){var a=function(e,t,n){for(var r=[],i=1;i<=n;i++)r.push(e+(t-e)*i/(n+1));return r};return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(e){if(r){for(;Math.abs(r[1]-e[1])>180;)r[1]+=360*(r[1]t)for(var o=Math.floor(i/t),s=a(r[0],e[0],o),c=a(r[1],e[1],o),l=a(r[2],e[2],o),u=0,d=s.length;u2&&arguments[2]!==void 0?arguments[2]:1,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=t+1,a;if(e instanceof Array||e instanceof Function){var o=e instanceof Array?Ig().domain(e.map(function(t,n){return n/(e.length-1)})).range(e):e;a=function(e){return p0(o(e),r,!0)}}else{var s=p0(e,r,!0);a=function(){return s}}for(var c=[],l=0,u=i;l1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=e+1,i=[],a=0,o=r;a0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;_1(this,t),e=h1(this,t),e.type=`CircleLineGeometry`,e.parameters={radius:n,segmentCount:r};for(var i=[],a=0;a<=r;a++){var o=(a/r-.25)*Math.PI*2;i.push({x:Math.cos(o)*n,y:Math.sin(o)*n,z:0})}return e.setFromPoints(i),e}return D1(t,e),C1(t)}((window.THREE?window.THREE:{BufferGeometry:Wi}).BufferGeometry),g2=window.THREE?window.THREE:{Color:Ur,Group:Ir,Line:Ba,LineBasicMaterial:Ma,Vector3:V},_2=PC.default.default||PC.default,v2=Up({props:{ringsData:{default:[]},ringLat:{default:`lat`},ringLng:{default:`lng`},ringAltitude:{default:.0015},ringColor:{default:function(){return`#ffffaa`},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;(t=e.ticker)==null||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;X1(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new x0(e,{objBindAttr:`__threeObjRing`,removeDelay:3e4}).onCreateObj(function(){var e=new g2.Group;return e.__globeObjType=`ring`,e}),t.ticker=new _2,t.ticker.onTick.add(function(e){if(t.ringsData.length){var n=U(t.ringColor),r=U(t.ringAltitude),i=U(t.ringMaxRadius),a=U(t.ringPropagationSpeed),o=U(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(e){return V1(e,2)[1]}).forEach(function(s){var c=V1(s,2),l=c[0],u=c[1];if((u.__nextRingTime||0)<=e){var d=o(l)/1e3;u.__nextRingTime=e+(d<=0?1/0:d);var f=new g2.Line(new h2(1,t.ringResolution),new g2.LineBasicMaterial),p=n(l),m=p instanceof Array||p instanceof Function,h;m?p instanceof Array?(h=Ig().domain(p.map(function(e,t){return t/(p.length-1)})).range(p),f.material.transparent=p.some(function(e){return f0(e)<1})):(h=p,f.material.transparent=!0):(f.material.color=new g2.Color(d0(p)),m0(f.material,f0(p)));var g=Q1*(1+r(l)),_=i(l),v=_*Math.PI/180,y=a(l),b=y<=0,x=function(e){var t=e.t,n=(b?1-t:t)*v;if(f.scale.x=f.scale.y=g*Math.sin(n),f.position.z=g*(1-Math.cos(n)),m){var r=h(t);f.material.color=new g2.Color(d0(r)),f.material.transparent&&(f.material.opacity=f0(r))}};if(y===0)x({t:0}),u.add(f);else{var S=Math.abs(_/y)*1e3;t.tweenGroup.add(new Xp({t:0}).to({t:1},S).onUpdate(x).onStart(function(){return u.add(f)}).onComplete(function(){t.tweenGroup.remove(this),u.remove(f),Y1(f)}).start())}}})}})},update:function(e){var t=U(e.ringLat),n=U(e.ringLng),r=U(e.ringAltitude),i=e.scene.localToWorld(new g2.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(e,a){var o=t(a),s=n(a),c=r(a);Object.assign(e.position,e0(o,s,c)),e.lookAt(i)}).digest(e.ringsData)}}),y2={glyphs:{0:{x_min:73,x_max:715,ha:792,o:`m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 `},1:{x_min:215.671875,x_max:574,ha:792,o:`m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 `},2:{x_min:59,x_max:731,ha:792,o:`m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 `},3:{x_min:54,x_max:737,ha:792,o:`m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 `},4:{x_min:48,x_max:742.453125,ha:792,o:`m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 `},5:{x_min:54.171875,x_max:738,ha:792,o:`m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 `},6:{x_min:53,x_max:739,ha:792,o:`m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 `},7:{x_min:58.71875,x_max:730.953125,ha:792,o:`m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 `},8:{x_min:55,x_max:736,ha:792,o:`m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 `},9:{x_min:53,x_max:739,ha:792,o:`m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 `},ο:{x_min:0,x_max:712,ha:815,o:`m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 `},S:{x_min:0,x_max:788,ha:890,o:`m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 `},"¦":{x_min:343,x_max:449,ha:792,o:`m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 `},"/":{x_min:183.25,x_max:608.328125,ha:792,o:`m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 `},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:`m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 `},y:{x_min:0,x_max:684.78125,ha:771,o:`m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 `},Π:{x_min:0,x_max:803,ha:917,o:`m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 `},ΐ:{x_min:-111,x_max:339,ha:361,o:`m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 `},g:{x_min:0,x_max:686,ha:838,o:`m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 `},"²":{x_min:0,x_max:442,ha:539,o:`m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 `},"–":{x_min:0,x_max:705.5625,ha:803,o:`m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 `},Κ:{x_min:0,x_max:819.5625,ha:893,o:`m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 `},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:`m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 `},e:{x_min:0,x_max:714,ha:813,o:`m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 `},ό:{x_min:0,x_max:712,ha:815,o:`m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 `},J:{x_min:0,x_max:588,ha:699,o:`m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 `},"»":{x_min:-1,x_max:503,ha:601,o:`m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 `},"©":{x_min:-3,x_max:1008,ha:1106,o:`m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 `},ώ:{x_min:0,x_max:922,ha:1030,o:`m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 `},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:`m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 `},"«":{x_min:0,x_max:507.203125,ha:604,o:`m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 `},D:{x_min:0,x_max:828,ha:935,o:`m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 `},"∙":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 `},ÿ:{x_min:0,x_max:47,ha:125,o:`m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 `},w:{x_min:0,x_max:1009.71875,ha:1100,o:`m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 `},$:{x_min:0,x_max:700,ha:793,o:`m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 `},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:`m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 `},µ:{x_min:0,x_max:697.21875,ha:747,o:`m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 `},Ι:{x_min:42,x_max:181,ha:297,o:`m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 `},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:`m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},"’":{x_min:0,x_max:139,ha:236,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 `},Ν:{x_min:0,x_max:801,ha:915,o:`m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 `},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:`m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 `},Q:{x_min:0,x_max:968,ha:1072,o:`m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 `},ς:{x_min:1,x_max:676.28125,ha:740,o:`m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 `},M:{x_min:0,x_max:954,ha:1067,o:`m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 `},Ψ:{x_min:0,x_max:1006,ha:1094,o:`m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 `},C:{x_min:0,x_max:886,ha:944,o:`m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 `},"!":{x_min:0,x_max:138,ha:236,o:`m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 `},"{":{x_min:0,x_max:480.5625,ha:578,o:`m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 `},X:{x_min:-.015625,x_max:854.15625,ha:940,o:`m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 `},"#":{x_min:0,x_max:963.890625,ha:1061,o:`m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 `},ι:{x_min:42,x_max:284,ha:361,o:`m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 `},Ά:{x_min:0,x_max:906.953125,ha:982,o:`m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 `},")":{x_min:0,x_max:318,ha:415,o:`m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 `},ε:{x_min:0,x_max:634.71875,ha:714,o:`m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 `},Δ:{x_min:0,x_max:952.78125,ha:1028,o:`m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 `},"}":{x_min:0,x_max:481,ha:578,o:`m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 `},"‰":{x_min:-3,x_max:1672,ha:1821,o:`m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 `},a:{x_min:0,x_max:698.609375,ha:794,o:`m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 `},"—":{x_min:0,x_max:941.671875,ha:1039,o:`m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 `},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:`m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 `},N:{x_min:0,x_max:801,ha:914,o:`m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 `},ρ:{x_min:0,x_max:712,ha:797,o:`m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 `},"¯":{x_min:0,x_max:941.671875,ha:938,o:`m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 `},Z:{x_min:0,x_max:779,ha:849,o:`m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 `},u:{x_min:0,x_max:617,ha:729,o:`m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 `},k:{x_min:0,x_max:612.484375,ha:697,o:`m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 `},Η:{x_min:0,x_max:803,ha:917,o:`m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 `},Α:{x_min:0,x_max:906.953125,ha:985,o:`m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 `},s:{x_min:0,x_max:604,ha:697,o:`m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 `},B:{x_min:0,x_max:778,ha:876,o:`m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 `},"…":{x_min:0,x_max:614,ha:708,o:`m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 `},"?":{x_min:0,x_max:607,ha:704,o:`m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 `},H:{x_min:0,x_max:803,ha:915,o:`m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 `},ν:{x_min:0,x_max:675,ha:761,o:`m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 `},c:{x_min:1,x_max:701.390625,ha:775,o:`m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 `},"¶":{x_min:0,x_max:566.671875,ha:678,o:`m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 `},β:{x_min:0,x_max:660,ha:745,o:`m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 `},Μ:{x_min:0,x_max:954,ha:1068,o:`m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 `},Ό:{x_min:.109375,x_max:1120,ha:1217,o:`m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},Ή:{x_min:0,x_max:1158,ha:1275,o:`m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},"•":{x_min:0,x_max:663.890625,ha:775,o:`m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 `},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:`m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 `},"(":{x_min:0,x_max:318.0625,ha:415,o:`m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 `},U:{x_min:0,x_max:796,ha:904,o:`m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 `},γ:{x_min:.5,x_max:744.953125,ha:822,o:`m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 `},α:{x_min:0,x_max:765.5625,ha:809,o:`m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 `},F:{x_min:0,x_max:683.328125,ha:717,o:`m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 `},"­":{x_min:0,x_max:705.5625,ha:803,o:`m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 `},":":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 `},Χ:{x_min:0,x_max:854.171875,ha:935,o:`m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 `},"*":{x_min:116,x_max:674,ha:792,o:`m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 `},"†":{x_min:0,x_max:777,ha:835,o:`m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 `},"°":{x_min:0,x_max:347,ha:444,o:`m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 `},V:{x_min:0,x_max:862.71875,ha:940,o:`m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 `},Ξ:{x_min:0,x_max:734.71875,ha:763,o:`m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 `},"\xA0":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:`m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 `},"”":{x_min:0,x_max:347,ha:454,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 `},"@":{x_min:0,x_max:1260,ha:1357,o:`m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 `},Ί:{x_min:0,x_max:499,ha:613,o:`m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 `},i:{x_min:14,x_max:136,ha:275,o:`m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 `},Β:{x_min:0,x_max:778,ha:877,o:`m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 `},υ:{x_min:0,x_max:617,ha:725,o:`m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 `},"]":{x_min:0,x_max:275,ha:372,o:`m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 `},m:{x_min:0,x_max:1019,ha:1128,o:`m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 `},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:`m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 `},ί:{x_min:42,x_max:326.71875,ha:361,o:`m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 `},Ζ:{x_min:0,x_max:779.171875,ha:850,o:`m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 `},R:{x_min:0,x_max:781.953125,ha:907,o:`m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 `},o:{x_min:0,x_max:713,ha:821,o:`m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 `},K:{x_min:0,x_max:819.46875,ha:906,o:`m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 `},",":{x_min:0,x_max:142,ha:239,o:`m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 `},d:{x_min:0,x_max:683,ha:796,o:`m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 `},"¨":{x_min:-109,x_max:247,ha:232,o:`m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 `},E:{x_min:0,x_max:736.109375,ha:789,o:`m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 `},Y:{x_min:0,x_max:820,ha:886,o:`m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 `},'"':{x_min:0,x_max:299,ha:396,o:`m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 `},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:`m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 `},"„":{x_min:0,x_max:364,ha:467,o:`m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 `},δ:{x_min:1,x_max:710,ha:810,o:`m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 `},έ:{x_min:0,x_max:634.71875,ha:714,o:`m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 `},ω:{x_min:0,x_max:922,ha:1031,o:`m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 `},"´":{x_min:0,x_max:96,ha:251,o:`m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 `},"±":{x_min:11,x_max:781,ha:792,o:`m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 `},"|":{x_min:343,x_max:449,ha:792,o:`m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 `},ϋ:{x_min:0,x_max:617,ha:725,o:`m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 `},"§":{x_min:0,x_max:593,ha:690,o:`m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 `},b:{x_min:0,x_max:685,ha:783,o:`m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 `},q:{x_min:0,x_max:683,ha:876,o:`m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 `},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:`m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 `},ύ:{x_min:0,x_max:617,ha:725,o:`m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 `},z:{x_min:-.015625,x_max:613.890625,ha:697,o:`m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 `},"™":{x_min:0,x_max:894,ha:1e3,o:`m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 `},ή:{x_min:.78125,x_max:697,ha:810,o:`m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 `},Θ:{x_min:0,x_max:960,ha:1056,o:`m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 `},"®":{x_min:-3,x_max:1008,ha:1106,o:`m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 `},"~":{x_min:0,x_max:833,ha:931,o:`m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 `},Ε:{x_min:0,x_max:736.21875,ha:778,o:`m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 `},"³":{x_min:0,x_max:450,ha:547,o:`m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 `},"[":{x_min:0,x_max:273.609375,ha:371,o:`m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 `},L:{x_min:0,x_max:645.828125,ha:696,o:`m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 `},σ:{x_min:0,x_max:803.390625,ha:894,o:`m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 `},ζ:{x_min:0,x_max:573,ha:642,o:`m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 `},θ:{x_min:0,x_max:674,ha:778,o:`m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 `},Ο:{x_min:0,x_max:958,ha:1054,o:`m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 `},Γ:{x_min:0,x_max:705.28125,ha:749,o:`m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 `}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:`m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 `},P:{x_min:0,x_max:726,ha:806,o:`m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 `},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:`m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:`m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 `},_:{x_min:0,x_max:705.5625,ha:803,o:`m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 `},Ϊ:{x_min:-110,x_max:246,ha:275,o:`m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 `},"+":{x_min:23,x_max:768,ha:792,o:`m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 `},"½":{x_min:0,x_max:1050,ha:1149,o:`m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 `},Ρ:{x_min:0,x_max:720,ha:783,o:`m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 `},"'":{x_min:0,x_max:139,ha:236,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 `},ª:{x_min:0,x_max:350,ha:397,o:`m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 `},"΅":{x_min:0,x_max:450,ha:553,o:`m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 `},T:{x_min:0,x_max:777,ha:835,o:`m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 `},Φ:{x_min:0,x_max:915,ha:997,o:`m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 `},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:`m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 `},Σ:{x_min:0,x_max:756.953125,ha:819,o:`m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 `},"›":{x_min:18.0625,x_max:774,ha:792,o:`m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 `},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:`m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 `},"£":{x_min:0,x_max:704.484375,ha:801,o:`m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 `},t:{x_min:0,x_max:367,ha:458,o:`m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 `},"¬":{x_min:0,x_max:706,ha:803,o:`m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 `},λ:{x_min:0,x_max:750,ha:803,o:`m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 `},W:{x_min:0,x_max:1263.890625,ha:1351,o:`m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 `},">":{x_min:18.0625,x_max:774,ha:792,o:`m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 `},v:{x_min:0,x_max:675.15625,ha:761,o:`m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 `},τ:{x_min:.28125,x_max:644.5,ha:703,o:`m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 `},ξ:{x_min:0,x_max:624.9375,ha:699,o:`m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 `},"&":{x_min:-3,x_max:894.25,ha:992,o:`m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 `},Λ:{x_min:0,x_max:862.5,ha:942,o:`m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 `},I:{x_min:41,x_max:180,ha:293,o:`m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 `},G:{x_min:0,x_max:921,ha:1011,o:`m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 `},ΰ:{x_min:0,x_max:617,ha:725,o:`m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 `},"`":{x_min:0,x_max:138.890625,ha:236,o:`m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 `},"·":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 `},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:`m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 `},r:{x_min:0,x_max:355.5625,ha:432,o:`m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 `},x:{x_min:0,x_max:675,ha:764,o:`m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 `},μ:{x_min:0,x_max:696.609375,ha:747,o:`m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 `},h:{x_min:0,x_max:615,ha:724,o:`m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 `},".":{x_min:0,x_max:142,ha:239,o:`m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 `},φ:{x_min:-2,x_max:878,ha:974,o:`m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 `},";":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 `},f:{x_min:0,x_max:378,ha:472,o:`m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 `},"“":{x_min:1,x_max:348.21875,ha:454,o:`m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 `},A:{x_min:.03125,x_max:906.953125,ha:1008,o:`m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 `},"‘":{x_min:1,x_max:139.890625,ha:236,o:`m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 `},ϊ:{x_min:-70,x_max:283,ha:361,o:`m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 `},π:{x_min:-.21875,x_max:773.21875,ha:857,o:`m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 `},ά:{x_min:0,x_max:765.5625,ha:809,o:`m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 `},O:{x_min:0,x_max:958,ha:1057,o:`m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 `},n:{x_min:0,x_max:615,ha:724,o:`m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 `},l:{x_min:41,x_max:166,ha:279,o:`m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 `},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:`m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 `},κ:{x_min:0,x_max:632.328125,ha:679,o:`m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 `},p:{x_min:0,x_max:685,ha:786,o:`m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 `},"‡":{x_min:0,x_max:777,ha:835,o:`m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 `},ψ:{x_min:0,x_max:808,ha:907,o:`m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 `},η:{x_min:.78125,x_max:697,ha:810,o:`m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 `}},cssFontWeight:`normal`,ascender:1189,underlinePosition:-100,cssFontStyle:`normal`,boundingBox:{yMin:-334,xMin:-111,yMax:1189,xMax:1672},resolution:1e3,original_font_information:{postscript_name:`Helvetiker-Regular`,version_string:`Version 1.00 2004 initial release`,vendor_url:`http://www.magenta.gr/`,full_font_name:`Helvetiker`,font_family_name:`Helvetiker`,copyright:`Copyright (c) Μagenta ltd, 2004`,description:``,trademark:``,designer:``,designer_url:``,unique_font_identifier:`Μagenta ltd:Helvetiker:22-10-104`,license_url:`http://www.ellak.gr/fonts/MgOpen/license.html`,license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r +\r +Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r +\r +The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r +\r +The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r +\r +This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r +\r +The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r +\r +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:`Μagenta ltd`,font_sub_family_name:`Regular`},descender:-334,familyName:`Helvetiker`,lineHeight:1522,underlineThickness:50},b2=P1(P1({},window.THREE?window.THREE:{BoxGeometry:ro,CircleGeometry:io,DoubleSide:2,Group:Ir,Mesh:_a,MeshLambertMaterial:Gs,TextGeometry:s1,Vector3:V}),{},{Font:i1,TextGeometry:s1}),x2=Up({props:{labelsData:{default:[]},labelLat:{default:`lat`},labelLng:{default:`lng`},labelAltitude:{default:.002},labelText:{default:`text`},labelSize:{default:.5},labelTypeFace:{default:y2,onChange:function(e,t){t.font=new b2.Font(e)}},labelColor:{default:function(){return`lightgrey`}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return`bottom`}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;X1(e),t.scene=e,t.tweenGroup=r;var i=new b2.CircleGeometry(1,32);t.dataMapper=new x0(e,{objBindAttr:`__threeObjLabel`}).onCreateObj(function(){var e=new b2.MeshLambertMaterial;e.side=2;var t=new b2.Group;t.add(new b2.Mesh(i,e));var n=new b2.Mesh(void 0,e);t.add(n);var r=new b2.Mesh;return r.visible=!1,n.add(r),t.__globeObjType=`label`,t})},update:function(e){var t=U(e.labelLat),n=U(e.labelLng),r=U(e.labelAltitude),i=U(e.labelText),a=U(e.labelSize),o=U(e.labelRotation),s=U(e.labelColor),c=U(e.labelIncludeDot),l=U(e.labelDotRadius),u=U(e.labelDotOrientation),d=new Set([`right`,`top`,`bottom`]),f=2*Math.PI*Q1/360;e.dataMapper.onUpdateObj(function(p,m){var h=V1(p.children,2),g=h[0],_=h[1],v=V1(_.children,1)[0],y=s(m),b=f0(y);_.material.color.set(d0(y)),_.material.transparent=b<1,_.material.opacity=b;var x=c(m),S=u(m);!x||!d.has(S)&&(S=`bottom`);var C=x?+l(m)*f:1e-12;g.scale.x=g.scale.y=C;var w=+a(m)*f;if(_.geometry&&_.geometry.dispose(),_.geometry=new b2.TextGeometry(i(m),{font:e.font,size:w,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),v.geometry&&v.geometry.dispose(),_.geometry.computeBoundingBox(),v.geometry=x1(b2.BoxGeometry,W1(new b2.Vector3().subVectors(_.geometry.boundingBox.max,_.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),S!==`right`&&_.geometry.center(),x){var T=C+w/2;S===`right`&&(_.position.x=T),_.position.y={right:-w/2,top:T+w/2,bottom:-T-w/2}[S]}var E=function(t){var n=p.__currentTargetD=t,r=n.lat,i=n.lng,a=n.alt,o=n.rot,s=n.scale;Object.assign(p.position,e0(r,i,a)),p.lookAt(e.scene.localToWorld(new b2.Vector3(0,0,0))),p.rotateY(Math.PI),p.rotateZ(-o*Math.PI/180),p.scale.x=p.scale.y=p.scale.z=s},D={lat:+t(m),lng:+n(m),alt:+r(m),rot:+o(m),scale:1},O=p.__currentTargetD||Object.assign({},D,{scale:1e-12});Object.keys(D).some(function(e){return O[e]!==D[e]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?E(D):e.tweenGroup.add(new Xp(O).to(D,e.labelsTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(E).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.labelsData)}}),S2=P1(P1({},window.THREE?window.THREE:{}),{},{CSS2DObject:qf}),C2=Up({props:{htmlElementsData:{default:[]},htmlLat:{default:`lat`},htmlLng:{default:`lng`},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){e.dataMapper&&(t?[t]:e.dataMapper.entries().map(function(e){return V1(e,2)[1]}).filter(function(e){return e})).forEach(function(t){var n=!e.isBehindGlobe||!e.isBehindGlobe(t.position);e.htmlElementVisibilityModifier?(t.visible=!0,e.htmlElementVisibilityModifier(t.element,n)):t.visible=n})}},init:function(e,t,n){var r=n.tweenGroup;X1(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new x0(e,{objBindAttr:`__threeObjHtml`}).onCreateObj(function(e){var n=U(t.htmlElement)(e),r=new S2.CSS2DObject(n);return r.__globeObjType=`html`,r})},update:function(e,t){var n=this,r=U(e.htmlLat),i=U(e.htmlLng),a=U(e.htmlAltitude);t.hasOwnProperty(`htmlElement`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(t,o){var s=function(e){var r=t.__currentTargetD=e,i=r.alt,a=r.lat,o=r.lng;Object.assign(t.position,e0(a,o,i)),n.updateObjVisibility(t)},c={lat:+r(o),lng:+i(o),alt:+a(o)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!t.__currentTargetD?s(c):e.tweenGroup.add(new Xp(t.__currentTargetD).to(c,e.htmlTransitionDuration).easing(Wp.Quadratic.InOut).onUpdate(s).onComplete(function(){e.tweenGroup.remove(this)}).start())}).digest(e.htmlElementsData)}}),w2=window.THREE?window.THREE:{Group:Ir,Mesh:_a,MeshLambertMaterial:Gs,SphereGeometry:Ts},T2=Up({props:{objectsData:{default:[]},objectLat:{default:`lat`},objectLng:{default:`lng`},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new w2.Mesh(new w2.SphereGeometry(1,16,8),new w2.MeshLambertMaterial({color:`#ffffaa`,transparent:!0,opacity:.7}))}},init:function(e,t){X1(e),t.scene=e,t.dataMapper=new x0(e,{objBindAttr:`__threeObjObject`}).onCreateObj(function(e){var n=U(t.objectThreeObject)(e);t.objectThreeObject===n&&(n=n.clone());var r=new w2.Group;return r.add(n),r.__globeObjType=`object`,r})},update:function(e,t){var n=U(e.objectLat),r=U(e.objectLng),i=U(e.objectAltitude),a=U(e.objectFacesSurface),o=U(e.objectRotation);t.hasOwnProperty(`objectThreeObject`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(e,t){var s=+n(t),c=+r(t),l=+i(t);Object.assign(e.position,e0(s,c,l)),a(t)?e.setRotationFromEuler(new vr(n0(-s),n0(c),0,`YXZ`)):e.rotation.set(0,0,0);var u=e.children[0],d=o(t);d&&u.setRotationFromEuler(new vr(n0(d.x||0),n0(d.y||0),n0(d.z||0)))}).digest(e.objectsData)}}),E2=Up({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){X1(e),t.scene=e,t.dataMapper=new x0(e,{objBindAttr:`__threeObjCustom`}).onCreateObj(function(e){var n=U(t.customThreeObject)(e,Q1);return n&&(t.customThreeObject===n&&(n=n.clone()),n.__globeObjType=`custom`),n})},update:function(e,t){e.customThreeObjectUpdate||X1(e.scene);var n=U(e.customThreeObjectUpdate);t.hasOwnProperty(`customThreeObject`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(e,t){return n(e,t,Q1)}).digest(e.customLayerData)}}),D2=window.THREE?window.THREE:{Camera:Ec,Group:Ir,Vector2:B,Vector3:V},O2=[`globeLayer`,`pointsLayer`,`arcsLayer`,`hexBinLayer`,`heatmapsLayer`,`polygonsLayer`,`hexedPolygonsLayer`,`pathsLayer`,`tilesLayer`,`particlesLayer`,`ringsLayer`,`labelsLayer`,`htmlElementsLayer`,`objectsLayer`,`customLayer`],k2=Z1(`globeLayer`,u0),A2=Object.assign.apply(Object,W1([`globeImageUrl`,`bumpImageUrl`,`globeCurvatureResolution`,`globeTileEngineUrl`,`globeTileEngineMaxLevel`,`showGlobe`,`showGraticules`,`showAtmosphere`,`atmosphereColor`,`atmosphereAltitude`].map(function(e){return w1({},e,k2.linkProp(e))}))),j2=Object.assign.apply(Object,W1([`globeMaterial`,`globeTileEngineClearCache`].map(function(e){return w1({},e,k2.linkMethod(e))}))),M2=Z1(`pointsLayer`,T0),N2=Object.assign.apply(Object,W1([`pointsData`,`pointLat`,`pointLng`,`pointColor`,`pointAltitude`,`pointRadius`,`pointResolution`,`pointsMerge`,`pointsTransitionDuration`].map(function(e){return w1({},e,M2.linkProp(e))}))),P2=Z1(`arcsLayer`,P0),F2=Object.assign.apply(Object,W1([`arcsData`,`arcStartLat`,`arcStartLng`,`arcStartAltitude`,`arcEndLat`,`arcEndLng`,`arcEndAltitude`,`arcColor`,`arcAltitude`,`arcAltitudeAutoScale`,`arcStroke`,`arcCurveResolution`,`arcCircularResolution`,`arcDashLength`,`arcDashGap`,`arcDashInitialGap`,`arcDashAnimateTime`,`arcsTransitionDuration`].map(function(e){return w1({},e,P2.linkProp(e))}))),I2=Z1(`hexBinLayer`,R0),L2=Object.assign.apply(Object,W1([`hexBinPointsData`,`hexBinPointLat`,`hexBinPointLng`,`hexBinPointWeight`,`hexBinResolution`,`hexMargin`,`hexTopCurvatureResolution`,`hexTopColor`,`hexSideColor`,`hexAltitude`,`hexBinMerge`,`hexTransitionDuration`].map(function(e){return w1({},e,I2.linkProp(e))}))),R2=Z1(`heatmapsLayer`,Z0),z2=Object.assign.apply(Object,W1([`heatmapsData`,`heatmapPoints`,`heatmapPointLat`,`heatmapPointLng`,`heatmapPointWeight`,`heatmapBandwidth`,`heatmapColorFn`,`heatmapColorSaturation`,`heatmapBaseAltitude`,`heatmapTopAltitude`,`heatmapsTransitionDuration`].map(function(e){return w1({},e,R2.linkProp(e))}))),B2=Z1(`hexedPolygonsLayer`,i2),V2=Object.assign.apply(Object,W1([`hexPolygonsData`,`hexPolygonGeoJsonGeometry`,`hexPolygonColor`,`hexPolygonAltitude`,`hexPolygonResolution`,`hexPolygonMargin`,`hexPolygonUseDots`,`hexPolygonCurvatureResolution`,`hexPolygonDotResolution`,`hexPolygonsTransitionDuration`].map(function(e){return w1({},e,B2.linkProp(e))}))),H2=Z1(`polygonsLayer`,$0),U2=Object.assign.apply(Object,W1([`polygonsData`,`polygonGeoJsonGeometry`,`polygonCapColor`,`polygonCapMaterial`,`polygonSideColor`,`polygonSideMaterial`,`polygonStrokeColor`,`polygonAltitude`,`polygonCapCurvatureResolution`,`polygonsTransitionDuration`].map(function(e){return w1({},e,H2.linkProp(e))}))),W2=Z1(`pathsLayer`,l2),G2=Object.assign.apply(Object,W1([`pathsData`,`pathPoints`,`pathPointLat`,`pathPointLng`,`pathPointAlt`,`pathResolution`,`pathColor`,`pathStroke`,`pathDashLength`,`pathDashGap`,`pathDashInitialGap`,`pathDashAnimateTime`,`pathTransitionDuration`].map(function(e){return w1({},e,W2.linkProp(e))}))),K2=Z1(`tilesLayer`,d2),q2=Object.assign.apply(Object,W1([`tilesData`,`tileLat`,`tileLng`,`tileAltitude`,`tileWidth`,`tileHeight`,`tileUseGlobeProjection`,`tileMaterial`,`tileCurvatureResolution`,`tilesTransitionDuration`].map(function(e){return w1({},e,K2.linkProp(e))}))),J2=Z1(`particlesLayer`,m2),Y2=Object.assign.apply(Object,W1([`particlesData`,`particlesList`,`particleLat`,`particleLng`,`particleAltitude`,`particlesSize`,`particlesSizeAttenuation`,`particlesColor`,`particlesTexture`].map(function(e){return w1({},e,J2.linkProp(e))}))),X2=Z1(`ringsLayer`,v2),Z2=Object.assign.apply(Object,W1([`ringsData`,`ringLat`,`ringLng`,`ringAltitude`,`ringColor`,`ringResolution`,`ringMaxRadius`,`ringPropagationSpeed`,`ringRepeatPeriod`].map(function(e){return w1({},e,X2.linkProp(e))}))),Q2=Z1(`labelsLayer`,x2),$2=Object.assign.apply(Object,W1([`labelsData`,`labelLat`,`labelLng`,`labelAltitude`,`labelRotation`,`labelText`,`labelSize`,`labelTypeFace`,`labelColor`,`labelResolution`,`labelIncludeDot`,`labelDotRadius`,`labelDotOrientation`,`labelsTransitionDuration`].map(function(e){return w1({},e,Q2.linkProp(e))}))),e4=Z1(`htmlElementsLayer`,C2),t4=Object.assign.apply(Object,W1([`htmlElementsData`,`htmlLat`,`htmlLng`,`htmlAltitude`,`htmlElement`,`htmlElementVisibilityModifier`,`htmlTransitionDuration`].map(function(e){return w1({},e,e4.linkProp(e))}))),n4=Z1(`objectsLayer`,T2),r4=Object.assign.apply(Object,W1([`objectsData`,`objectLat`,`objectLng`,`objectAltitude`,`objectRotation`,`objectFacesSurface`,`objectThreeObject`].map(function(e){return w1({},e,n4.linkProp(e))}))),i4=Z1(`customLayer`,E2),a4=Object.assign.apply(Object,W1([`customLayerData`,`customThreeObject`,`customThreeObjectUpdate`].map(function(e){return w1({},e,i4.linkProp(e))}))),o4=Up({props:P1(P1(P1(P1(P1(P1(P1(P1(P1(P1(P1(P1(P1(P1(P1({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new D2.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},A2),N2),F2),L2),z2),U2),V2),G2),q2),Y2),Z2),$2),t4),r4),a4),methods:P1({getGlobeRadius:$1,getCoords:function(e){var t=[...arguments].slice(1);return e0.apply(void 0,t)},toGeoCoords:function(e){var t=[...arguments].slice(1);return t0.apply(void 0,t)},setPointOfView:function(e,t){var n=t instanceof D2.Camera?t.position:t,r=$1(),i=void 0;if(e.scene&&n){var a,o,s,c;i=function(t){a===void 0&&(a=n.clone().applyMatrix4(e.scene.matrixWorld.clone().invert())),o===void 0&&(o=a.length()),s===void 0&&(s=Math.sqrt(o**2-r**2)),c===void 0&&(c=Math.acos(s/o));var i=a.distanceTo(t);if(i1&&arguments[1]!==void 0?arguments[1]:Object,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=function(t){function r(){var t;_1(this,r);var i=[...arguments];return t=h1(this,r,[].concat(i)),t.__kapsuleInstance=x1(e,[].concat(W1(n?[t]:[]),i)),t}return D1(r,t),C1(r)}(t);return Object.keys(e()).forEach(function(e){return r.prototype[e]=function(){var t,n=(t=this.__kapsuleInstance)[e].apply(t,arguments);return n===this.__kapsuleInstance?this:n}}),r}var c4=s4(o4,(window.THREE?window.THREE:{Group:Ir}).Group,!0),l4={type:`change`},u4={type:`start`},d4={type:`end`},f4=1e-6,p4={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},m4=new B,h4=new B,g4=new V,_4=new V,v4=new V,y4=new zn,b4=new V,x4=new V,S4=new V,C4=new V,w4=class extends Tl{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=[`KeyA`,`KeyS`,`KeyD`],this.mouseButtons={LEFT:fe.ROTATE,MIDDLE:fe.DOLLY,RIGHT:fe.PAN},this.target=new V,this.state=p4.NONE,this.keyState=p4.NONE,this._lastPosition=new V,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new V,this._movePrev=new B,this._moveCurr=new B,this._lastAxis=new V,this._zoomStart=new B,this._zoomEnd=new B,this._panStart=new B,this._panEnd=new B,this._pointers=[],this._pointerPositions={},this._onPointerMove=E4.bind(this),this._onPointerDown=T4.bind(this),this._onPointerUp=D4.bind(this),this._onPointerCancel=O4.bind(this),this._onContextMenu=F4.bind(this),this._onMouseWheel=P4.bind(this),this._onKeyDown=A4.bind(this),this._onKeyUp=k4.bind(this),this._onTouchStart=I4.bind(this),this._onTouchMove=L4.bind(this),this._onTouchEnd=R4.bind(this),this._onMouseDown=j4.bind(this),this._onMouseMove=M4.bind(this),this._onMouseUp=N4.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener(`keydown`,this._onKeyDown),window.addEventListener(`keyup`,this._onKeyUp),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerCancel),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=`none`}disconnect(){window.removeEventListener(`keydown`,this._onKeyDown),window.removeEventListener(`keyup`,this._onKeyUp),this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerCancel),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=``}dispose(){this.disconnect()}handleResize(){let e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>f4&&(this.dispatchEvent(l4),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>f4||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(l4),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn(`THREE.TrackballControls: Unsupported camera type.`)}reset(){this.state=p4.NONE,this.keyState=p4.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(l4),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(h4.copy(this._panEnd).sub(this._panStart),h4.lengthSq()){if(this.object.isOrthographicCamera){let e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;h4.x*=e,h4.y*=t}h4.multiplyScalar(this._eye.length()*this.panSpeed),_4.copy(this._eye).cross(this.object.up).setLength(h4.x),_4.add(g4.copy(this.object.up).setLength(h4.y)),this.object.position.add(_4),this.target.add(_4),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(h4.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){C4.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=C4.length();e?(this._eye.copy(this.object.position).sub(this.target),b4.copy(this._eye).normalize(),x4.copy(this.object.up).normalize(),S4.crossVectors(x4,b4).normalize(),x4.setLength(this._moveCurr.y-this._movePrev.y),S4.setLength(this._moveCurr.x-this._movePrev.x),C4.copy(x4.add(S4)),v4.crossVectors(C4,this._eye).normalize(),e*=this.rotateSpeed,y4.setFromAxisAngle(v4,e),this._eye.applyQuaternion(y4),this.object.up.applyQuaternion(y4),this._lastAxis.copy(v4),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),y4.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(y4),this.object.up.applyQuaternion(y4)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===p4.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Rn.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn(`THREE.TrackballControls: Unsupported camera type`)):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Rn.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn(`THREE.TrackballControls: Unsupported camera type`)),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return m4.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),m4}_getMouseOnCircle(e,t){return m4.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),m4}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=K4),r<-Math.PI?r+=K4:r>Math.PI&&(r-=K4),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(G4.setFromSpherical(this._spherical),G4.applyQuaternion(this._quatInverse),t.copy(this.target).add(G4),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=G4.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new V(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new V(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=G4.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(H4.origin.copy(this.object.position),H4.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(H4.direction))J4||8*(1-this._lastQuaternion.dot(this.object.quaternion))>J4||this._lastTargetPosition.distanceToSquared(this.target)>J4?(this.dispatchEvent(z4),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?K4/60/60*this.autoRotateSpeed:K4/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){G4.setFromMatrixColumn(t,0),G4.multiplyScalar(-e),this._panOffset.add(G4)}_panUp(e,t){this.screenSpacePanning===!0?G4.setFromMatrixColumn(t,1):(G4.setFromMatrixColumn(t,0),G4.crossVectors(this.object.up,G4)),G4.multiplyScalar(e),this._panOffset.add(G4)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;G4.copy(r).sub(this.target);let i=G4.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(K4*this._rotateDelta.x/t.clientHeight),this._rotateUp(K4*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(K4*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-K4*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(K4*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-K4*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(K4*this._rotateDelta.x/t.clientHeight),this._rotateUp(K4*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tl3||8*(1-this._lastQuaternion.dot(t.quaternion))>l3)&&(this.dispatchEvent(c3),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){let e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement==document?{size:[window.innerWidth,window.innerHeight],offset:[0,0]}:{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}}};function f3(e){if(!(e.altKey||this.enabled===!1)){switch(e.code){case`ShiftLeft`:case`ShiftRight`:this.movementSpeedMultiplier=.1;break;case`KeyW`:this._moveState.forward=1;break;case`KeyS`:this._moveState.back=1;break;case`KeyA`:this._moveState.left=1;break;case`KeyD`:this._moveState.right=1;break;case`KeyR`:this._moveState.up=1;break;case`KeyF`:this._moveState.down=1;break;case`ArrowUp`:this._moveState.pitchUp=1;break;case`ArrowDown`:this._moveState.pitchDown=1;break;case`ArrowLeft`:this._moveState.yawLeft=1;break;case`ArrowRight`:this._moveState.yawRight=1;break;case`KeyQ`:this._moveState.rollLeft=1;break;case`KeyE`:this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function p3(e){if(this.enabled!==!1){switch(e.code){case`ShiftLeft`:case`ShiftRight`:this.movementSpeedMultiplier=1;break;case`KeyW`:this._moveState.forward=0;break;case`KeyS`:this._moveState.back=0;break;case`KeyA`:this._moveState.left=0;break;case`KeyD`:this._moveState.right=0;break;case`KeyR`:this._moveState.up=0;break;case`KeyF`:this._moveState.down=0;break;case`ArrowUp`:this._moveState.pitchUp=0;break;case`ArrowDown`:this._moveState.pitchDown=0;break;case`ArrowLeft`:this._moveState.yawLeft=0;break;case`ArrowRight`:this._moveState.yawRight=0;break;case`KeyQ`:this._moveState.rollLeft=0;break;case`KeyE`:this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function m3(e){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(e.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function h3(e){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){let t=this._getContainerDimensions(),n=t.size[0]/2,r=t.size[1]/2;this._moveState.yawLeft=-(e.pageX-t.offset[0]-n)/n,this._moveState.pitchDown=(e.pageY-t.offset[1]-r)/r,this._updateRotationVector()}}function g3(e){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(e.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function _3(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function v3(e){this.enabled!==!1&&e.preventDefault()}var y3={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + uniform float opacity; + + uniform sampler2D tDiffuse; + + varying vec2 vUv; + + void main() { + + vec4 texel = texture2D( tDiffuse, vUv ); + gl_FragColor = opacity * texel; + + + }`},b3=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},x3=new Fc(-1,1,1,-1,0,1),S3=new class extends Wi{constructor(){super(),this.setAttribute(`position`,new Mi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Mi([0,2,0,0,2,0],2))}},C3=class{constructor(e){this._mesh=new _a(S3,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,x3)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},w3=class extends b3{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Rs?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Fs.clone(e.uniforms),this.material=new Rs({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new C3(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},T3=class extends b3{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},E3=class extends b3{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},D3=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new B);this._width=n.width,this._height=n.height,t=new or(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ae}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new w3(y3),this.copyPass.material.blending=0,this.timer=new qc}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&i<1?(s=a,c=o):i>=1&&i<2?(s=o,c=a):i>=2&&i<3?(c=a,l=o):i>=3&&i<4?(c=o,l=a):i>=4&&i<5?(s=o,l=a):i>=5&&i<6&&(s=a,l=o);var u=n-a/2,d=s+u,f=c+u,p=l+u;return r(d,f,p)}var H3={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`639`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`};function U3(e){if(typeof e!=`string`)return e;var t=e.toLowerCase();return H3[t]?`#`+H3[t]:e}var W3=/^#[a-fA-F0-9]{6}$/,G3=/^#[a-fA-F0-9]{8}$/,K3=/^#[a-fA-F0-9]{3}$/,q3=/^#[a-fA-F0-9]{4}$/,J3=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Y3=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,X3=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,Z3=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function Q3(e){if(typeof e!=`string`)throw new R3(3);var t=U3(e);if(t.match(W3))return{red:parseInt(``+t[1]+t[2],16),green:parseInt(``+t[3]+t[4],16),blue:parseInt(``+t[5]+t[6],16)};if(t.match(G3)){var n=parseFloat((parseInt(``+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(``+t[1]+t[2],16),green:parseInt(``+t[3]+t[4],16),blue:parseInt(``+t[5]+t[6],16),alpha:n}}if(t.match(K3))return{red:parseInt(``+t[1]+t[1],16),green:parseInt(``+t[2]+t[2],16),blue:parseInt(``+t[3]+t[3],16)};if(t.match(q3)){var r=parseFloat((parseInt(``+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(``+t[1]+t[1],16),green:parseInt(``+t[2]+t[2],16),blue:parseInt(``+t[3]+t[3],16),alpha:r}}var i=J3.exec(t);if(i)return{red:parseInt(``+i[1],10),green:parseInt(``+i[2],10),blue:parseInt(``+i[3],10)};var a=Y3.exec(t.substring(0,50));if(a)return{red:parseInt(``+a[1],10),green:parseInt(``+a[2],10),blue:parseInt(``+a[3],10),alpha:parseFloat(``+a[4])>1?parseFloat(``+a[4])/100:parseFloat(``+a[4])};var o=X3.exec(t);if(o){var s=`rgb(`+V3(parseInt(``+o[1],10),parseInt(``+o[2],10)/100,parseInt(``+o[3],10)/100)+`)`,c=J3.exec(s);if(!c)throw new R3(4,t,s);return{red:parseInt(``+c[1],10),green:parseInt(``+c[2],10),blue:parseInt(``+c[3],10)}}var l=Z3.exec(t.substring(0,50));if(l){var u=`rgb(`+V3(parseInt(``+l[1],10),parseInt(``+l[2],10)/100,parseInt(``+l[3],10)/100)+`)`,d=J3.exec(u);if(!d)throw new R3(4,t,u);return{red:parseInt(``+d[1],10),green:parseInt(``+d[2],10),blue:parseInt(``+d[3],10),alpha:parseFloat(``+l[4])>1?parseFloat(``+l[4])/100:parseFloat(``+l[4])}}throw new R3(5)}function $3(e){var t=e.red/255,n=e.green/255,r=e.blue/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2;if(i===a)return e.alpha===void 0?{hue:0,saturation:0,lightness:o}:{hue:0,saturation:0,lightness:o,alpha:e.alpha};var s,c=i-a,l=o>.5?c/(2-i-a):c/(i+a);switch(i){case t:s=(n-r)/c+(n=1?a6(e,t,n):`rgba(`+V3(e,t,n)+`,`+r+`)`;if(typeof e==`object`&&t===void 0&&n===void 0&&r===void 0)return e.alpha>=1?a6(e.hue,e.saturation,e.lightness):`rgba(`+V3(e.hue,e.saturation,e.lightness)+`,`+e.alpha+`)`;throw new R3(2)}function c6(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return t6(`#`+n6(e)+n6(t)+n6(n));if(typeof e==`object`&&t===void 0&&n===void 0)return t6(`#`+n6(e.red)+n6(e.green)+n6(e.blue));throw new R3(6)}function l6(e,t,n,r){if(typeof e==`string`&&typeof t==`number`){var i=Q3(e);return`rgba(`+i.red+`,`+i.green+`,`+i.blue+`,`+t+`)`}else if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`)return r>=1?c6(e,t,n):`rgba(`+e+`,`+t+`,`+n+`,`+r+`)`;else if(typeof e==`object`&&t===void 0&&n===void 0&&r===void 0)return e.alpha>=1?c6(e.red,e.green,e.blue):`rgba(`+e.red+`,`+e.green+`,`+e.blue+`,`+e.alpha+`)`;throw new R3(7)}var u6=function(e){return typeof e.red==`number`&&typeof e.green==`number`&&typeof e.blue==`number`&&(typeof e.alpha!=`number`||e.alpha===void 0)},d6=function(e){return typeof e.red==`number`&&typeof e.green==`number`&&typeof e.blue==`number`&&typeof e.alpha==`number`},f6=function(e){return typeof e.hue==`number`&&typeof e.saturation==`number`&&typeof e.lightness==`number`&&(typeof e.alpha!=`number`||e.alpha===void 0)},p6=function(e){return typeof e.hue==`number`&&typeof e.saturation==`number`&&typeof e.lightness==`number`&&typeof e.alpha==`number`};function m6(e){if(typeof e!=`object`)throw new R3(8);if(d6(e))return l6(e);if(u6(e))return c6(e);if(p6(e))return s6(e);if(f6(e))return o6(e);throw new R3(8)}function h6(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):h6(e,t,r)}}function g6(e){return h6(e,e.length,[])}function _6(e,t){if(t===`transparent`)return t;var n=e6(t);return m6(k3({},n,{hue:n.hue+parseFloat(e)}))}g6(_6);function v6(e,t,n){return Math.max(e,Math.min(t,n))}function y6(e,t){if(t===`transparent`)return t;var n=e6(t);return m6(k3({},n,{lightness:v6(0,1,n.lightness-parseFloat(e))}))}g6(y6);function b6(e,t){if(t===`transparent`)return t;var n=e6(t);return m6(k3({},n,{saturation:v6(0,1,n.saturation-parseFloat(e))}))}g6(b6);function x6(e,t){if(t===`transparent`)return t;var n=e6(t);return m6(k3({},n,{lightness:v6(0,1,n.lightness+parseFloat(e))}))}g6(x6);function S6(e,t,n){if(t===`transparent`)return n;if(n===`transparent`)return t;if(e===0)return n;var r=Q3(t),i=k3({},r,{alpha:typeof r.alpha==`number`?r.alpha:1}),a=Q3(n),o=k3({},a,{alpha:typeof a.alpha==`number`?a.alpha:1}),s=i.alpha-o.alpha,c=parseFloat(e)*2-1,l=((c*s===-1?c:c+s)/(1+c*s)+1)/2,u=1-l;return l6({red:Math.floor(i.red*l+o.red*u),green:Math.floor(i.green*l+o.green*u),blue:Math.floor(i.blue*l+o.blue*u),alpha:i.alpha*parseFloat(e)+o.alpha*(1-parseFloat(e))})}var C6=g6(S6);function w6(e,t){if(t===`transparent`)return t;var n=Q3(t);return l6(k3({},n,{alpha:v6(0,1,((typeof n.alpha==`number`?n.alpha:1)*100+parseFloat(e)*100)/100)}))}var T6=g6(w6);function E6(e,t){if(t===`transparent`)return t;var n=e6(t);return m6(k3({},n,{saturation:v6(0,1,n.saturation+parseFloat(e))}))}g6(E6);function D6(e,t){return t===`transparent`?t:m6(k3({},e6(t),{hue:parseFloat(e)}))}g6(D6);function O6(e,t){return t===`transparent`?t:m6(k3({},e6(t),{lightness:parseFloat(e)}))}g6(O6);function k6(e,t){return t===`transparent`?t:m6(k3({},e6(t),{saturation:parseFloat(e)}))}g6(k6);function A6(e,t){return t===`transparent`?t:C6(parseFloat(e),`rgb(0, 0, 0)`,t)}g6(A6);function j6(e,t){return t===`transparent`?t:C6(parseFloat(e),`rgb(255, 255, 255)`,t)}g6(j6);function M6(e,t){if(t===`transparent`)return t;var n=Q3(t);return l6(k3({},n,{alpha:v6(0,1,((typeof n.alpha==`number`?n.alpha:1)*100-parseFloat(e)*100).toFixed(2)/100)}))}g6(M6);var N6={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function P6(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),N6.hasOwnProperty(t)?{space:N6[t],local:e}:e}function F6(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function I6(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function L6(e){var t=P6(e);return(t.local?I6:F6)(t)}function R6(){}function z6(e){return e==null?R6:function(){return this.querySelector(e)}}function B6(e){typeof e!=`function`&&(e=z6(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function g8(e){e||=_8;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function v8(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function y8(){return Array.from(this)}function b8(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?M8:typeof t==`function`?P8:N8)(e,t,n??``)):I8(this.node(),e)}function I8(e,t){return e.style.getPropertyValue(t)||j8(e).getComputedStyle(e,null).getPropertyValue(t)}function L8(e){return function(){delete this[e]}}function R8(e,t){return function(){this[e]=t}}function z8(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function B8(e,t){return arguments.length>1?this.each((t==null?L8:typeof t==`function`?z8:R8)(e,t)):this.node()[e]}function V8(e){return e.trim().split(/^|\s+/)}function H8(e){return e.classList||new U8(e)}function U8(e){this._node=e,this._names=V8(e.getAttribute(`class`)||``)}U8.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function W8(e,t){for(var n=H8(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function y5(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n2&&(o.children=arguments.length>3?P5.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return n7(e,o,r,i,null)}function n7(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++I5,__i:-1,__u:0};return i==null&&F5.vnode!=null&&F5.vnode(a),a}function r7(e){return e.children}function i7(e,t){this.props=e,this.context=t}function a7(e,t){if(t==null)return e.__?a7(e.__,e.__i+1):null;for(var n;tt&&R5.sort(V5),e=R5.shift(),t=R5.length,o7(e)}finally{R5.length=l7.__r=0}}function u7(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||X5,y=t.length;for(c=d7(n,t,v,c,y),d=0;d0?o=e.__k[a]=n7(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=p7(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:ic?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a+!!u){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function m7(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||Z5.test(t)?n:n+`px`}function h7(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||m7(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||m7(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(G5,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[W5]=r[W5]:(n[W5]=K5,e.addEventListener(t,a?J5:q5,a)):e.removeEventListener(t,a?J5:q5,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function g7(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[U5]==null)t[U5]=K5++;else if(t[U5]0?e:Q5(e)?e.map(b7):e.constructor===void 0?$5({},e):null}function x7(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||Y5,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l2&&(s.children=arguments.length>3?P5.call(arguments,2):n),n7(e.type,s,r||e.key,i||e.ref,null)}P5=X5.slice,F5={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},I5=0,L5=function(e){return e!=null&&e.constructor===void 0},i7.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=$5({},this.state);typeof e==`function`&&(e=e($5({},n),this.props)),e&&$5(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),c7(this))},i7.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),c7(this))},i7.prototype.render=r7,R5=[],B5=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,V5=function(e,t){return e.__v.__b-t.__v.__b},l7.__r=0,H5=Math.random().toString(8),U5=`__d`+H5,W5=`__a`+H5,G5=/(PointerCapture)$|Capture$/i,K5=0,q5=g7(!1),J5=g7(!0);function E7(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}Ute(`.float-tooltip-kap { + position: absolute; + width: max-content; /* prevent shrinking near right edge */ + max-width: max(50%, 150px); + padding: 3px 5px; + border-radius: 3px; + font: 12px sans-serif; + color: #eee; + background: rgba(0,0,0,0.6); + pointer-events: none; +} +`);var Wte=Up({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=(arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}).style,r=n===void 0?{}:n,i=j5(e&&O7(e)===`object`&&e.node&&typeof e.node==`function`?e.node():e);i.style(`position`)===`static`&&i.style(`position`,`relative`),t.tooltipEl=i.append(`div`).attr(`class`,`float-tooltip-kap`),Object.entries(r).forEach(function(e){var n=Lte(e,2),r=n[0],i=n[1];return t.tooltipEl.style(r,i)}),t.tooltipEl.style(`left`,`-10000px`).style(`display`,`none`);var a=`tooltip-${Math.round(Math.random()*0xe8d4a51000)}`;t.mouseInside=!1,i.on(`mousemove.${a}`,function(e){t.mouseInside=!0;var n=N5(e),r=i.node(),a=r.offsetWidth,o=r.offsetHeight,s=[t.offsetX===null||t.offsetX===void 0?`-${n[0]/a*100}%`:typeof t.offsetX==`number`?`calc(-50% + ${t.offsetX}px)`:t.offsetX,t.offsetY===null||t.offsetY===void 0?o>130&&o-n[1]<100?`calc(-100% - 6px)`:`21px`:typeof t.offsetY==`number`?t.offsetY<0?`calc(-100% - ${Math.abs(t.offsetY)}px)`:`${t.offsetY}px`:t.offsetY];t.tooltipEl.style(`left`,n[0]+`px`).style(`top`,n[1]+`px`).style(`transform`,`translate(${s.join(`,`)})`),t.content&&t.tooltipEl.style(`display`,`inline`)}),i.on(`mouseover.${a}`,function(){t.mouseInside=!0,t.content&&t.tooltipEl.style(`display`,`inline`)}),i.on(`mouseout.${a}`,function(){t.mouseInside=!1,t.tooltipEl.style(`display`,`none`)})},update:function(e){e.tooltipEl.style(`display`,e.content&&e.mouseInside?`inline`:`none`),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(``),e.tooltipEl.append(function(){return e.content})):typeof e.content==`string`?e.tooltipEl.html(e.content):Vte(e.content)?(e.tooltipEl.text(``),Hte(e.content,e.tooltipEl.node())):(e.tooltipEl.style(`display`,`none`),console.warn(`Tooltip content is invalid, skipping.`,e.content,e.content.toString())):e.tooltipEl.text(``)}});function Gte(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}Gte(`.scene-nav-info { + position: absolute; + bottom: 5px; + width: 100%; + text-align: center; + color: slategrey; + opacity: 0.7; + font-size: 10px; + font-family: sans-serif; + pointer-events: none; + user-select: none; +} + +.scene-container canvas:focus { + outline: none; +}`);function A7(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(t,n){return e.hoverOrderComparator(t.object,n.object)});var i=r.find(function(t){return e.hoverFilter(t.object)})||null;n=i?i.object:null,e.intersection=i||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&U(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos;return{x:t.x,y:t.y}},cameraPosition:function(e,t,n,r){var i=e.camera;if(t&&e.initialised){var a,o,s=t,c=n||{x:0,y:0,z:0};if((a=e.povPosTween)==null||a.end(),(o=e.povTgtTween)==null||o.end(),!r)d(s),f(c);else{var l=Object.assign({},i.position),u=p();e.tweenGroup.add(e.povPosTween=new Xp(l).to(s,r).easing(Wp.Quadratic.Out).onUpdate(d).onComplete(function(){e.povPosTween=void 0,e.tweenGroup.remove(this)}).start()),e.tweenGroup.add(e.povTgtTween=new Xp(u).to(c,r/3).easing(Wp.Quadratic.Out).onUpdate(f).onComplete(function(){e.povTgtTween=void 0,e.tweenGroup.remove(this)}).start())}return this}return Object.assign({},i.position,{lookAt:p()});function d(e){var t=e.x,n=e.y,r=e.z;t!==void 0&&(i.position.x=t),n!==void 0&&(i.position.y=n),r!==void 0&&(i.position.z=r)}function f(t){var n=new F7.Vector3(t.x,t.y,t.z);e.controls.enabled&&e.controls.target?e.controls.target=n:i.lookAt(n)}function p(){return Object.assign(new F7.Vector3(0,0,-1e3).applyQuaternion(i.quaternion).add(i.position))}},zoomToFit:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=[...arguments].slice(3);return this.fitToBbox(this.getBbox.apply(this,r),t,n)},fitToBbox:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,i=e.camera;if(t){var a=new F7.Vector3(0,0,0),o=Math.max.apply(Math,j7(Object.entries(t).map(function(e){var t=$te(e,2),n=t[0],r=t[1];return Math.max.apply(Math,j7(r.map(function(e){return Math.abs(a[n]-e)})))})))*2,s=(1-r*2/e.height)*i.fov,c=o/Math.atan(s*Math.PI/180),l=c/i.aspect,u=Math.max(c,l);if(u>0){var d=a.clone().sub(i.position).normalize().multiplyScalar(-u);this.cameraPosition(d,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new F7.Box3(new F7.Vector3(0,0,0),new F7.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(e){return n.expandByObject(e)}),Object.assign.apply(Object,j7([`x`,`y`,`z`].map(function(e){return Jte({},e,[n.min[e],n.max[e]])})))):null},getScreenCoords:function(e,t,n,r){var i=new F7.Vector3(t,n,r);return i.project(this.camera()),{x:(i.x+1)*e.width/2,y:-(i.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=new F7.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new F7.Raycaster;return a.setFromCamera(i,e.camera),Object.assign({},a.ray.at(r,new F7.Vector3))},intersectingObjects:function(e,t,n){var r=new F7.Vector2(t/e.width*2-1,-(n/e.height)*2+1),i=new F7.Raycaster;return i.params.Line.threshold=e.lineHoverPrecision,i.params.Points.threshold=e.pointsHoverPrecision,i.setFromCamera(r,e.camera),i.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls},_destructor:function(e){var t,n,r;nne(e.scene),(t=e.controls)==null||t.dispose(),(n=e.renderer)==null||n.dispose(),(r=e.postProcessingComposer)==null||r.dispose()}},stateInit:function(){return{scene:new F7.Scene,camera:new F7.PerspectiveCamera,timer:new F7.Timer,tweenGroup:new Kp,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,i=r===void 0?`trackball`:r,a=n.useWebGPU,o=a!==void 0&&a,s=n.rendererConfig,c=s===void 0?{}:s,l=n.extraRenderers,u=l===void 0?[]:l,d=n.waitForLoadComplete,f=d===void 0||d;e.innerHTML=``,e.appendChild(t.container=document.createElement(`div`)),t.container.className=`scene-container`,t.container.style.position=`relative`,t.container.appendChild(t.navInfo=document.createElement(`div`)),t.navInfo.className=`scene-nav-info`,t.navInfo.textContent={orbit:`Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan`,trackball:`Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan`,fly:`WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw`}[i]||``,t.navInfo.style.display=t.showNavInfo?null:`none`,t.tooltip=new Wte(t.container),t.pointerPos=new F7.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,[`pointermove`,`pointerdown`].forEach(function(e){return t.container.addEventListener(e,function(n){if(e===`pointerdown`&&(t.isPointerPressed=!0),!t.isPointerDragging&&n.type===`pointermove`&&(n.pressure>0||t.isPointerPressed)&&(n.pointerType===`mouse`||n.movementX===void 0||[n.movementX,n.movementY].some(function(e){return Math.abs(e)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var r=i(t.container);t.pointerPos.x=n.pageX-r.left,t.pointerPos.y=n.pageY-r.top}function i(e){var t=e.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,r=window.pageYOffset||document.documentElement.scrollTop;return{top:t.top+r,left:t.left+n}}},{passive:!0})}),t.container.addEventListener(`pointerup`,function(e){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){e.button===0&&t.onClick(t.hoverObj||null,e,t.intersection),e.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,e,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener(`contextmenu`,function(e){t.onRightClick&&e.preventDefault()}),t.renderer=new(o?y$:F7.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},c)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=u,t.extraRenderers.forEach(function(e){e.domElement.style.position=`absolute`,e.domElement.style.top=`0px`,e.domElement.style.pointerEvents=`none`,t.container.appendChild(e.domElement)}),t.postProcessingComposer=new D3(t.renderer),t.postProcessingComposer.addPass(new O3(t.scene,t.camera)),t.controls=new{trackball:w4,orbit:Y4,fly:d3}[i](t.camera,t.renderer.domElement),i===`fly`&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(i===`trackball`||i===`orbit`)&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener(`start`,function(){t.controlsEngaged=!0}),t.controls.addEventListener(`change`,function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener(`end`,function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(j7(t.extraRenderers)).forEach(function(e){return e.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new F7.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!f,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty(`width`)||t.hasOwnProperty(`height`))){var n,r=e.width,i=e.height;e.container.style.width=`${r}px`,e.container.style.height=`${i}px`,[e.renderer,e.postProcessingComposer].concat(j7(e.extraRenderers)).forEach(function(e){return e.setSize(r,i)}),e.camera.aspect=r/i;var a=e.viewOffset.slice(0,2);a.some(function(e){return e})&&(n=e.camera).setViewOffset.apply(n,[r,i].concat(j7(a),[r,i])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty(`viewOffset`)){var o,s=e.width,c=e.height,l=e.viewOffset.slice(0,2);l.some(function(e){return e})?(o=e.camera).setViewOffset.apply(o,[s,c].concat(j7(l),[s,c])):e.camera.clearViewOffset()}if(t.hasOwnProperty(`skyRadius`)&&e.skyRadius&&(e.controls.hasOwnProperty(`maxDistance`)&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new F7.SphereGeometry(e.skyRadius)),t.hasOwnProperty(`backgroundColor`)){var u=Q3(e.backgroundColor).alpha;u===void 0&&(u=1),e.renderer.setClearColor(new F7.Color(T6(1,e.backgroundColor)),u)}t.hasOwnProperty(`backgroundImageUrl`)&&(e.backgroundImageUrl?new F7.TextureLoader().load(e.backgroundImageUrl,function(t){t.colorSpace=F7.SRGBColorSpace,e.skysphere.material=new F7.MeshBasicMaterial({map:t,side:F7.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&d()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&d())),t.hasOwnProperty(`showNavInfo`)&&(e.navInfo.style.display=e.showNavInfo?null:`none`),t.hasOwnProperty(`lights`)&&((t.lights||[]).forEach(function(t){return e.scene.remove(t)}),e.lights.forEach(function(t){return e.scene.add(t)})),t.hasOwnProperty(`objects`)&&((t.objects||[]).forEach(function(t){return e.scene.remove(t)}),e.objects.forEach(function(t){return e.scene.add(t)}));function d(){e.loadComplete=e.scene.visible=!0}}});function rne(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}rne(`.scene-container .clickable { + cursor: pointer; +}`);function L7(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=o();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var i,a=Object.assign({},r,t);if([`lat`,`lng`,`altitude`].forEach(function(e){return a[e]=+a[e]}),(i=e.povTween)==null||i.end(),!n)s(a);else{for(;r.lng-a.lng>180;)r.lng-=360;for(;r.lng-a.lng<-180;)r.lng+=360;e.tweenGroup.add(e.povTween=new Xp(r).to(a,n).easing(Wp.Cubic.InOut).onUpdate(s).onComplete(function(){e.povTween=void 0,e.tweenGroup.remove(this)}).start())}return this;function o(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function s(t){var n=t.lat,r=t.lng,i=t.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(n,r,i)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){var t,n=[...arguments].slice(1),r=(t=e.globe).getCoords.apply(t,n);return e.renderObjs.getScreenCoords(r.x,r.y,r.z)},toGlobeCoords:function(e,t,n){var r=e.renderObjs.intersectingObjects(t,n).find(function(e){return(e.object.__globeObjType||e.object.parent.__globeObjType)===`globe`});if(!r)return null;var i=e.globe.toGeoCoords(r.point);return{lat:i.lat,lng:i.lng}},scene:function(e){return e.renderObjs.scene()},camera:function(e){return e.renderObjs.camera()},renderer:function(e){return e.renderObjs.renderer()},controls:function(e){return e.renderObjs.controls()},_destructor:function(e){this.pauseAnimation(),this.pointsData([]),this.arcsData([]),this.polygonsData([]),this.pathsData([]),this.heatmapsData([]),this.hexBinPointsData([]),this.hexPolygonsData([]),this.tilesData([]),this.particlesData([]),this.labelsData([]),this.htmlElementsData([]),this.objectsData([]),this.customLayerData([]),e.globe._destructor(),e.renderObjs._destructor()}},mne),gne),stateInit:function(e){var t=e.rendererConfig,n=e.waitForGlobeReady,r=n===void 0||n,i=sne(e,fne),a=new c4(B7({waitForGlobeReady:r},i));return{globe:a,renderObjs:I7({controlType:`orbit`,rendererConfig:t,waitForLoadComplete:r,extraRenderers:[new U7.CSS2DRenderer]}).skyRadius(a.getGlobeRadius()*500).showNavInfo(!1).objects([a]).lights([new U7.AmbientLight(13421772,Math.PI),new U7.DirectionalLight(16777215,.6*Math.PI)]),tweenGroup:new Kp}},init:function(e,t){var n=this;e.innerHTML=``,e.appendChild(t.container=document.createElement(`div`)),t.container.style.position=`relative`;var r=document.createElement(`div`);t.container.appendChild(r),t.renderObjs(r),t.globe.rendererSize(t.renderObjs.renderer().getSize(new U7.Vector2)),this.pointOfView({altitude:2.5});var i=t.globe.getGlobeRadius(),a=t.renderObjs.controls();t.renderObjs.camera().near=.05,a.minDistance=i+Math.max(.001,t.renderObjs.camera().near*1.1),a.maxDistance=i*100,a.enablePan=!1,a.enableDamping=!0,a.dampingFactor=.1,a.rotateSpeed=.3,a.zoomSpeed=.3,a.zoomToCursor=!0,a.addEventListener(`change`,function(){a.target.setScalar(0);var e=n.pointOfView();a.rotateSpeed=e.altitude*.3,a.zoomSpeed=Math.sqrt(e.altitude)*.5,t.globe.setPointOfView(t.renderObjs.camera()),t.onZoom&&t.onZoom(e)});var o=function(e){for(var t=e;t&&!t.hasOwnProperty(`__globeObjType`);)t=t.parent;return t},s={point:function(e){return e},arc:function(e){return e},polygon:function(e){return e.data},path:function(e){return e},heatmap:function(e){return e},hexbin:function(e){return e},hexPolygon:function(e){return e},tile:function(e){return e},particles:function(e,t){return!t||!t.hasOwnProperty(`index`)||e.length<=t.index?e:e[t.index]},label:function(e){return e},object:function(e){return e},custom:function(e){return e}};U7.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverFilter(function(e){var n=o(e);if(!n)return!1;var r=n.__globeObjType;if(r!==`globe`&&!s.hasOwnProperty(r))return!1;var i=s.hasOwnProperty(r)&&n.__data?s[r](n.__data):null;return[`points`,`hexBinPoints`].some(function(e){return e===r})&&Array.isArray(i)?!1:t.pointerEventsFilter(n,i)}).tooltipContent(function(e,n){var r={point:t.pointLabel,arc:t.arcLabel,polygon:t.polygonLabel,path:t.pathLabel,hexbin:t.hexLabel,hexPolygon:t.hexPolygonLabel,tile:t.tileLabel,particles:t.particleLabel,label:t.labelLabel,object:t.objectLabel,custom:t.customLayerLabel},i=o(e),a=i&&i.__globeObjType;return i&&a&&r.hasOwnProperty(a)&&s.hasOwnProperty(a)&&U(r[a])(s[a](i.__data,n))||``}).onHover(function(e,n,r){var i={point:t.onPointHover,arc:t.onArcHover,polygon:t.onPolygonHover,path:t.onPathHover,heatmap:t.onHeatmapHover,hexbin:t.onHexHover,hexPolygon:t.onHexPolygonHover,tile:t.onTileHover,particles:t.onParticleHover,label:t.onLabelHover,object:t.onObjectHover,custom:t.onCustomLayerHover},a={globe:t.onGlobeClick,point:t.onPointClick,arc:t.onArcClick,polygon:t.onPolygonClick,path:t.onPathClick,heatmap:t.onHeatmapClick,hexbin:t.onHexClick,hexPolygon:t.onHexPolygonClick,tile:t.onTileClick,particles:t.onParticleClick,label:t.onLabelClick,object:t.onObjectClick,custom:t.onCustomLayerClick},c=o(e);if(c&&!i.hasOwnProperty(c.__globeObjType)&&(c=null),c!==t.hoverObj){var l,u=t.hoverObj?t.hoverObj.__globeObjType:null,d=t.hoverData,f=c?c.__globeObjType:null,p=(l=c)!=null&&l.__data?s[f](c.__data,r):null;u&&u!==f&&i[u]&&i[u](null,d||null),f&&i[f]&&i[f](p,u===f?d:null),t.renderObjs.renderer().domElement.classList[f&&a[f]&&U(t.showPointerCursor)(f,p)?`add`:`remove`](`clickable`),t.hoverObj=c,t.hoverData=p}}).onClick(function(e,r,i){if(e){var a={globe:t.onGlobeClick,point:t.onPointClick,arc:t.onArcClick,polygon:t.onPolygonClick,path:t.onPathClick,heatmap:t.onHeatmapClick,hexbin:t.onHexClick,hexPolygon:t.onHexPolygonClick,tile:t.onTileClick,particles:t.onParticleClick,label:t.onLabelClick,object:t.onObjectClick,custom:t.onCustomLayerClick},c=o(e),l=c.__globeObjType;if(c&&a.hasOwnProperty(l)&&a[l]){var u=[r],d=i!=null&&i.isVector3?i:i?.point;if(l===`globe`){var f=n.toGeoCoords(d),p=f.lat,m=f.lng;u.unshift({lat:p,lng:m})}else u.push(n.toGeoCoords(d));s.hasOwnProperty(l)&&u.unshift(s[l](c.__data,i)),a[l].apply(a,u)}}}).onRightClick(function(e,r,i){if(e){var a={globe:t.onGlobeRightClick,point:t.onPointRightClick,arc:t.onArcRightClick,polygon:t.onPolygonRightClick,path:t.onPathRightClick,heatmap:t.onHeatmapRightClick,hexbin:t.onHexRightClick,hexPolygon:t.onHexPolygonRightClick,tile:t.onTileRightClick,particles:t.onParticleRightClick,label:t.onLabelRightClick,object:t.onObjectRightClick,custom:t.onCustomLayerRightClick},c=o(e),l=c.__globeObjType;if(c&&a.hasOwnProperty(l)&&a[l]){var u=[r],d=i!=null&&i.isVector3?i:i?.point;if(l===`globe`){var f=n.toGeoCoords(d),p=f.lat,m=f.lng;u.unshift({lat:p,lng:m})}else u.push(n.toGeoCoords(d));s.hasOwnProperty(l)&&u.unshift(s[l](c.__data,i)),a[l].apply(a,u)}}}),this._animationCycle()}}),vne=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),yne=o(((e,t)=>{var n=vne();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),$=l(o(((e,t)=>{t.exports=yne()()}))(),1),bne={width:$.default.number,height:$.default.number,globeOffset:$.default.arrayOf($.default.number),backgroundColor:$.default.string,backgroundImageUrl:$.default.string,globeImageUrl:$.default.string,bumpImageUrl:$.default.string,globeTileEngineUrl:$.default.func,showGlobe:$.default.bool,showGraticules:$.default.bool,showAtmosphere:$.default.bool,atmosphereColor:$.default.string,atmosphereAltitude:$.default.number,globeMaterial:$.default.object,onGlobeReady:$.default.func,onGlobeClick:$.default.func,onGlobeRightClick:$.default.func,pointsData:$.default.arrayOf($.default.object),pointLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pointLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pointColor:$.default.oneOfType([$.default.string,$.default.func]),pointAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pointRadius:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pointResolution:$.default.number,pointsMerge:$.default.bool,pointsTransitionDuration:$.default.number,pointLabel:$.default.oneOfType([$.default.string,$.default.func]),onPointClick:$.default.func,onPointRightClick:$.default.func,onPointHover:$.default.func,arcsData:$.default.arrayOf($.default.object),arcStartLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcStartLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcEndLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcEndLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcColor:$.default.oneOfType([$.default.string,$.default.arrayOf($.default.string),$.default.func]),arcAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcAltitudeAutoScale:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcStroke:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcCurveResolution:$.default.number,arcCircularResolution:$.default.number,arcDashLength:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcDashGap:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcDashInitialGap:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcDashAnimateTime:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcsTransitionDuration:$.default.number,arcLabel:$.default.oneOfType([$.default.string,$.default.func]),onArcClick:$.default.func,onArcRightClick:$.default.func,onArcHover:$.default.func,polygonsData:$.default.arrayOf($.default.object),polygonGeoJsonGeometry:$.default.oneOfType([$.default.string,$.default.func]),polygonCapColor:$.default.oneOfType([$.default.string,$.default.func]),polygonCapMaterial:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),polygonSideColor:$.default.oneOfType([$.default.string,$.default.func]),polygonSideMaterial:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),polygonStrokeColor:$.default.oneOfType([$.default.string,$.default.func]),polygonAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),polygonCapCurvatureResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),polygonsTransitionDuration:$.default.number,polygonLabel:$.default.oneOfType([$.default.string,$.default.func]),onPolygonClick:$.default.func,onPolygonRightClick:$.default.func,onPolygonHover:$.default.func,pathsData:$.default.array,pathPoints:$.default.oneOfType([$.default.array,$.default.string,$.default.func]),pathPointLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathPointLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathPointAlt:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathResolution:$.default.number,pathColor:$.default.oneOfType([$.default.string,$.default.arrayOf($.default.string),$.default.func]),pathStroke:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathDashLength:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathDashGap:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathDashInitialGap:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathDashAnimateTime:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathTransitionDuration:$.default.number,pathLabel:$.default.oneOfType([$.default.string,$.default.func]),onPathClick:$.default.func,onPathRightClick:$.default.func,onPathHover:$.default.func,heatmapsData:$.default.array,heatmapPoints:$.default.oneOfType([$.default.array,$.default.string,$.default.func]),heatmapPointLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapPointLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapPointWeight:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapBandwidth:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapColorFn:$.default.oneOfType([$.default.string,$.default.func]),heatmapColorSaturation:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapBaseAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapTopAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapsTransitionDuration:$.default.number,onHeatmapClick:$.default.func,onHeatmapRightClick:$.default.func,onHeatmapHover:$.default.func,hexBinPointsData:$.default.arrayOf($.default.object),hexBinPointLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexBinPointLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexBinPointWeight:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexBinResolution:$.default.number,hexMargin:$.default.oneOfType([$.default.number,$.default.func]),hexTopColor:$.default.func,hexSideColor:$.default.func,hexAltitude:$.default.oneOfType([$.default.number,$.default.func]),hexTopCurvatureResolution:$.default.number,hexBinMerge:$.default.bool,hexTransitionDuration:$.default.number,hexLabel:$.default.oneOfType([$.default.string,$.default.func]),onHexClick:$.default.func,onHexRightClick:$.default.func,onHexHover:$.default.func,hexPolygonsData:$.default.arrayOf($.default.object),hexPolygonGeoJsonGeometry:$.default.oneOfType([$.default.string,$.default.func]),hexPolygonColor:$.default.oneOfType([$.default.string,$.default.func]),hexPolygonAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonMargin:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonUseDots:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),hexPolygonCurvatureResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonDotResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonsTransitionDuration:$.default.number,hexPolygonLabel:$.default.oneOfType([$.default.string,$.default.func]),onHexPolygonClick:$.default.func,onHexPolygonRightClick:$.default.func,onHexPolygonHover:$.default.func,tilesData:$.default.arrayOf($.default.object),tileLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileWidth:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileHeight:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileUseGlobeProjection:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),tileMaterial:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),tileCurvatureResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tilesTransitionDuration:$.default.number,tileLabel:$.default.oneOfType([$.default.string,$.default.func]),onTileClick:$.default.func,onTileRightClick:$.default.func,onTileHover:$.default.func,particlesData:$.default.arrayOf($.default.object),particlesList:$.default.oneOfType([$.default.string,$.default.func]),particleLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),particleLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),particleAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),particlesSize:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),particlesSizeAttenuation:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),particlesColor:$.default.oneOfType([$.default.string,$.default.func]),particlesTexture:$.default.oneOfType([$.default.string,$.default.func]),particleLabel:$.default.oneOfType([$.default.string,$.default.func]),onParticleClick:$.default.func,onParticleRightClick:$.default.func,onParticleHover:$.default.func,ringsData:$.default.arrayOf($.default.object),ringLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringColor:$.default.oneOfType([$.default.string,$.default.arrayOf($.default.string),$.default.func]),ringResolution:$.default.number,ringMaxRadius:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringPropagationSpeed:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringRepeatPeriod:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelsData:$.default.arrayOf($.default.object),labelLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelRotation:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelText:$.default.oneOfType([$.default.string,$.default.func]),labelSize:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelTypeFace:$.default.object,labelColor:$.default.oneOfType([$.default.string,$.default.func]),labelResolution:$.default.number,labelIncludeDot:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),labelDotRadius:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelDotOrientation:$.default.oneOfType([$.default.string,$.default.func]),labelsTransitionDuration:$.default.number,labelLabel:$.default.oneOfType([$.default.string,$.default.func]),onLabelClick:$.default.func,onLabelRightClick:$.default.func,onLabelHover:$.default.func,htmlElementsData:$.default.arrayOf($.default.object),htmlLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),htmlLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),htmlAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),htmlElement:$.default.oneOfType([$.default.string,$.default.func]),htmlElementVisibilityModifier:$.default.func,htmlTransitionDuration:$.default.number,objectsData:$.default.arrayOf($.default.object),objectLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),objectLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),objectAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),objectRotation:$.default.oneOfType([$.default.shape({x:$.default.number,y:$.default.number,z:$.default.number}),$.default.string,$.default.func]),objectFacesSurface:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),objectThreeObject:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),objectLabel:$.default.oneOfType([$.default.string,$.default.func]),onObjectClick:$.default.func,onObjectRightClick:$.default.func,onObjectHover:$.default.func,customLayerData:$.default.arrayOf($.default.object),customThreeObject:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),customThreeObjectUpdate:$.default.oneOfType([$.default.string,$.default.func]),customLayerLabel:$.default.oneOfType([$.default.string,$.default.func]),onCustomLayerClick:$.default.func,onCustomLayerRightClick:$.default.func,onCustomLayerHover:$.default.func,enablePointerInteraction:$.default.bool,pointerEventsFilter:$.default.func,lineHoverPrecision:$.default.number,showPointerCursor:$.default.oneOfType([$.default.bool,$.default.func]),onZoom:$.default.func},K7=ue(_ne,{methodNames:[`pauseAnimation`,`resumeAnimation`,`pointOfView`,`lights`,`scene`,`camera`,`renderer`,`postProcessingComposer`,`controls`,`getGlobeRadius`,`getCoords`,`getScreenCoords`,`toGeoCoords`,`toGlobeCoords`,`globeTileEngineClearCache`],initPropNames:[`animateIn`,`waitForGlobeReady`,`rendererConfig`]});K7.displayName=`Globe`,K7.propTypes=bne;function q7(e){return e?e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:e.toString():`0`}var xne=(0,x.forwardRef)(function({developers:e,flyTarget:t,onSelectDev:n},r){let i=(0,x.useRef)(),a=(0,x.useRef)(null),o=(0,x.useMemo)(()=>e.filter(e=>e.lat!=null&&e.lng!=null).sort((e,t)=>t.score-e.score).slice(0,5e3),[e]),s=(0,x.useMemo)(()=>o.filter(e=>e.score>=80),[o]);(0,x.useEffect)(()=>{let e=i.current?.controls();e&&(e.autoRotate=!0,e.autoRotateSpeed=.4,e.enableDamping=!0)},[]),(0,x.useEffect)(()=>{if(t&&i.current){i.current.pointOfView({lat:t.lat,lng:t.lng,altitude:1.5},1e3);let e=i.current.controls();e&&(e.autoRotate=!1)}},[t]),(0,x.useImperativeHandle)(r,()=>({flyTo:(e,t)=>{i.current?.pointOfView({lat:e,lng:t,altitude:1.5},1e3)}}));let c=(0,x.useCallback)(e=>{let t=a.current;if(!t)return;let n=i.current?.controls();e?(t.innerHTML=` +

+
Score: ${e.score}/100
+
+ ⭐ ${q7(e.totalStars||0)} + 👥 ${q7(e.followers||0)} + ${e.soReputation?`SO ${q7(e.soReputation)}`:``} +
+
+ 📍 ${e.location||`Unknown`} + ${e.topLanguage?`· ${e.topLanguage}`:``} +
+ `,t.classList.add(`visible`),n&&(n.autoRotate=!1)):(t.classList.remove(`visible`),n&&(n.autoRotate=!0))},[]),l=(0,x.useCallback)(e=>{e&&n(e)},[n]);return(0,x.useEffect)(()=>{let e=e=>{a.current&&(a.current.style.left=e.clientX+12+`px`,a.current.style.top=e.clientY+12+`px`)};return document.addEventListener(`mousemove`,e),()=>document.removeEventListener(`mousemove`,e)},[]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{id:`globe-container`,children:(0,S.jsx)(K7,{ref:i,globeImageUrl:`https://unpkg.com/three-globe@2.31.0/example/img/earth-night.jpg`,bumpImageUrl:`https://unpkg.com/three-globe@2.31.0/example/img/earth-topology.png`,backgroundImageUrl:`https://unpkg.com/three-globe@2.31.0/example/img/night-sky.png`,showAtmosphere:!0,atmosphereColor:`#3a7ecf`,atmosphereAltitude:.2,pointsData:o,pointLat:e=>e.lat,pointLng:e=>e.lng,pointAltitude:e=>.01+e.score/100*.06,pointRadius:e=>.3+e.score/100*.7,pointColor:e=>k(e.scoreDimensions),pointResolution:6,labelsData:s,labelLat:e=>e.lat,labelLng:e=>e.lng,labelText:e=>e.login,labelSize:e=>.6+e.score/100*.4,labelColor:()=>`rgba(226, 232, 240, 0.75)`,labelDotRadius:.3,labelAltitude:.02,onPointHover:c,onPointClick:l})}),(0,S.jsx)(`div`,{className:`tooltip`,ref:a})]})}),J7=62,Y7=10;function Sne({developers:e,selectedLogin:t,onSelectDev:n}){let r=(0,x.useRef)(null),[i,a]=(0,x.useState)(0),[o,s]=(0,x.useState)(600),[c,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(`score`),m=(0,x.useMemo)(()=>{let t=new Map;return e.forEach(e=>{if(e.location){let n=e.location.split(`,`).map(e=>e.trim()),r=n[n.length-1];r&&r.length>1&&t.set(r,(t.get(r)||0)+1)}}),[...t.entries()].sort((e,t)=>t[1]-e[1]).slice(0,50)},[e]),h=(0,x.useMemo)(()=>{let t=new Set;return e.forEach(e=>{e.topLanguage&&t.add(e.topLanguage)}),[...t].sort()},[e]),g=(0,x.useMemo)(()=>{let t=e.filter(e=>{let t=!u||e.topLanguage===u,n=!c||e.location&&e.location.includes(c);return t&&n});return t.sort((e,t)=>{switch(f){case`stars`:return(t.totalStars||0)-(e.totalStars||0);case`commits`:return(t.totalCommits||0)-(e.totalCommits||0);case`soRep`:return(t.soReputation||0)-(e.soReputation||0);default:return t.score-e.score}}),t},[e,u,c,f]),_=Math.max(0,Math.floor(i/J7)-Y7),v=Math.min(g.length,Math.ceil((i+o)/J7)+Y7),y=g.length*J7,b=g.slice(_,v);(0,x.useEffect)(()=>{let e=r.current;if(!e)return;s(e.clientHeight);let t=new ResizeObserver(()=>s(e.clientHeight));return t.observe(e),()=>t.disconnect()},[]);let C=(0,x.useCallback)(e=>{a(e.target.scrollTop)},[]);return(0,x.useEffect)(()=>{if(!t||!r.current)return;let e=g.findIndex(e=>e.login===t);e>=0&&(r.current.scrollTop=e*J7-o/2)},[t,g,o]),(0,S.jsxs)(`aside`,{className:`sidebar`,id:`sidebar`,children:[(0,S.jsxs)(`div`,{className:`sidebar__header`,children:[(0,S.jsx)(`h2`,{children:`Leaderboard`}),(0,S.jsxs)(`div`,{className:`sidebar__filters`,children:[(0,S.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),children:[(0,S.jsx)(`option`,{value:``,children:`All Countries`}),m.map(([e,t])=>(0,S.jsxs)(`option`,{value:e,children:[e.length>15?e.slice(0,14)+`…`:e,` (`,t,`)`]},e))]}),(0,S.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),children:[(0,S.jsx)(`option`,{value:``,children:`All Languages`}),h.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))]}),(0,S.jsxs)(`select`,{value:f,onChange:e=>p(e.target.value),children:[(0,S.jsx)(`option`,{value:`score`,children:`Score`}),(0,S.jsx)(`option`,{value:`stars`,children:`Stars`}),(0,S.jsx)(`option`,{value:`commits`,children:`Commits`}),(0,S.jsx)(`option`,{value:`soRep`,children:`SO Rep`})]})]})]}),(0,S.jsx)(`ul`,{className:`sidebar__list`,ref:r,onScroll:C,style:{position:`relative`,overflow:`auto`},children:(0,S.jsx)(`div`,{style:{height:y,position:`relative`},children:b.map((e,r)=>{let i=_+r;return(0,S.jsxs)(`li`,{className:`lb-item${e.login===t?` active`:``}`,style:{position:`absolute`,top:i*J7,left:0,right:0,height:J7},onClick:()=>n(e),children:[(0,S.jsx)(`span`,{className:`lb-item__rank`,children:i+1}),(0,S.jsx)(`img`,{className:`lb-item__avatar`,src:e.avatarUrl,alt:e.login,loading:`lazy`}),(0,S.jsxs)(`div`,{className:`lb-item__info`,children:[(0,S.jsx)(`div`,{className:`lb-item__name`,children:e.name||e.login}),(0,S.jsxs)(`div`,{className:`lb-item__meta`,children:[e.topLanguage||``,` · `,e.location||`Unknown`]}),(0,S.jsxs)(`div`,{className:`lb-item__badges`,children:[(0,S.jsxs)(`span`,{className:`lb-badge lb-badge--gh`,title:`GitHub Stars`,children:[`★ `,q7(e.totalStars)]}),e.soReputation?(0,S.jsxs)(`span`,{className:`lb-badge lb-badge--so`,title:`SO Reputation`,children:[`● `,q7(e.soReputation)]}):null]})]}),(0,S.jsx)(`span`,{className:`lb-item__score`,children:e.score})]},e.login)})})})]})}var Cne={value:()=>{}};function X7(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Z7.prototype=X7.prototype={constructor:Z7,on:function(e,t){var n=this._,r=wne(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&e._call.call(void 0,t),e=e._next;--$7}function p9(){o9=(a9=c9.now())+s9,$7=e9=0;try{Dne()}finally{$7=0,kne(),o9=0}}function One(){var e=c9.now(),t=e-a9;t>n9&&(s9-=t,a9=e)}function kne(){for(var e,t=r9,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:r9=n);i9=e,m9(r)}function m9(e){$7||(e9&&=clearTimeout(e9),e-o9>24?(e<1/0&&(e9=setTimeout(p9,e-c9.now()-s9)),t9&&=clearInterval(t9)):(t9||=(a9=c9.now(),setInterval(One,n9)),$7=1,l9(p9)))}function h9(e,t,n){var r=new d9;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Ane=X7(`start`,`end`,`cancel`,`interrupt`),jne=[];function g9(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Mne(e,n,{name:t,index:r,group:i,on:Ane,tween:jne,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function _9(e,t){var n=y9(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function v9(e,t){var n=y9(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function y9(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Mne(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=f9(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return h9(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Pne(e){return this.each(function(){Nne(this,e)})}function Fne(e,t){var n,r;return function(){var i=v9(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o=0&&(e=e.slice(0,t)),!e||e===`start`})}function lre(e,t,n){var r,i,a=cre(t)?_9:v9;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function ure(e,t){var n=this._id;return arguments.length<2?y9(this.node(),n).on.on(e):this.each(lre(n,e,t))}function dre(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fre(){return this.on(`end.remove`,dre(this._id))}function pre(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=z6(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o=0))throw Error(`invalid digits: ${e}`);if(t>15)return A9;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;tk9)if(!(Math.abs(u*s-c*l)>k9)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((D9-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>k9&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>k9||Math.abs(this._y1-l)>k9)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%O9+O9),d>Hre?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>k9&&this._append`A${n},${n},0,${+(d>=D9)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};function Wre(){return new j9}Wre.prototype=j9.prototype;function M9(e){return function(){return e}}var N9=Math.abs,P9=Math.atan2,F9=Math.cos,Gre=Math.max,I9=Math.min,L9=Math.sin,R9=Math.sqrt,z9=Math.PI,B9=z9/2,V9=2*z9;function Kre(e){return e>1?0:e<-1?z9:Math.acos(e)}function H9(e){return e>=1?B9:e<=-1?-B9:Math.asin(e)}function U9(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new j9(t)}function qre(e){return e.innerRadius}function Jre(e){return e.outerRadius}function Yre(e){return e.startAngle}function Xre(e){return e.endAngle}function Zre(e){return e&&e.padAngle}function Qre(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function W9(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/R9(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*R9(Gre(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function $re(){var e=qre,t=Jre,n=M9(0),r=null,i=Yre,a=Xre,o=Zre,s=null,c=U9(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-B9,m=a.apply(this,arguments)-B9,h=N9(m-p),g=m>p;if(s||=l=c(),f1e-12))s.moveTo(0,0);else if(h>V9-1e-12)s.moveTo(f*F9(p),f*L9(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*F9(m),d*L9(m)),s.arc(0,0,d,m,p,g));else{var _=p,v=m,y=p,b=m,x=h,S=h,C=o.apply(this,arguments)/2,w=C>1e-12&&(r?+r.apply(this,arguments):R9(d*d+f*f)),T=I9(N9(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=H9(w/d*L9(C)),j=H9(w/f*L9(C));(x-=A*2)>1e-12?(A*=g?1:-1,y+=A,b-=A):(x=0,y=b=(p+m)/2),(S-=j*2)>1e-12?(j*=g?1:-1,_+=j,v-=j):(S=0,_=v=(p+m)/2)}var M=f*F9(_),N=f*L9(_),P=d*F9(b),ee=d*L9(b);if(T>1e-12){var F=f*F9(v),te=f*L9(v),ne=d*F9(y),re=d*L9(y),ie;if(h1e-12?D>1e-12?(O=W9(ne,re,M,N,f,D,g),k=W9(F,te,P,ee,f,D,g),s.moveTo(O.cx+O.x01,O.cy+O.y01),D1e-12)||!(x>1e-12)?s.lineTo(P,ee):E>1e-12?(O=W9(P,ee,F,te,d,-E,g),k=W9(M,N,ne,re,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),Ee?1:t>=e?0:NaN}function iie(e){return e}function aie(){var e=iie,t=rie,n=null,r=M9(0),i=M9(V9),a=M9(0);function o(o){var s,c=(o=G9(o)).length,l,u,d=0,f=Array(c),p=Array(c),m=+r.apply(this,arguments),h=Math.min(V9,Math.max(-V9,i.apply(this,arguments)-m)),g,_=Math.min(Math.abs(h)/c,a.apply(this,arguments)),v=_*(h<0?-1:1),y;for(s=0;s0&&(d+=y);for(t==null?n!=null&&f.sort(function(e,t){return n(o[e],o[t])}):f.sort(function(e,n){return t(p[e],p[n])}),s=0,u=d?(h-c*v)/d:0;s0?y*u:0)+v,p[l]={data:o[l],index:s,value:y,startAngle:m,endAngle:g,padAngle:_};return p}return o.value=function(t){return arguments.length?(e=typeof t==`function`?t:M9(+t),o):e},o.sortValues=function(e){return arguments.length?(t=e,n=null,o):t},o.sort=function(e){return arguments.length?(n=e,t=null,o):n},o.startAngle=function(e){return arguments.length?(r=typeof e==`function`?e:M9(+e),o):r},o.endAngle=function(e){return arguments.length?(i=typeof e==`function`?e:M9(+e),o):i},o.padAngle=function(e){return arguments.length?(a=typeof e==`function`?e:M9(+e),o):a},o}var oie=Y9(q9);function J9(e){this._curve=e}J9.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(e,t){this._curve.point(t*Math.sin(e),t*-Math.cos(e))}};function Y9(e){function t(t){return new J9(e(t))}return t._curve=e,t}function sie(e){var t=e.curve;return e.angle=e.x,delete e.x,e.radius=e.y,delete e.y,e.curve=function(e){return arguments.length?t(Y9(e)):t()._curve},e}function cie(){return sie(nie().curve(oie))}function X9(){}function Z9(e){this._context=e}Z9.prototype={areaStart:X9,areaEnd:X9,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function lie(e){return new Z9(e)}function Q9(e,t,n){this.k=e,this.x=t,this.y=n}Q9.prototype={constructor:Q9,scale:function(e){return e===1?this:new Q9(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Q9(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var uie=new Q9(1,0,0);die.prototype=Q9.prototype;function die(e){for(;!e.__zoom;)if(!(e=e.parentNode))return uie;return e.__zoom}function fie({dev:e,onClose:t}){let[n,r]=(0,x.useState)(null),i=(0,x.useRef)(null),a=(0,x.useRef)(null),o=(0,x.useRef)(null);(0,x.useEffect)(()=>{let t=!1;async function n(){try{let n=await fetch(`/api/developer?id=${encodeURIComponent(e.id)}`);if(n.ok){let e=await n.json();t||r(e)}}catch{}}return n(),()=>{t=!0}},[e.id]),(0,x.useEffect)(()=>{!e.scoreDimensions||!i.current||mie(i.current,e.scoreDimensions)},[e.scoreDimensions]),(0,x.useEffect)(()=>{a.current&&hie(a.current,e.totalCommits||500)},[e.totalCommits]),(0,x.useEffect)(()=>{if(!o.current)return;let t=n?.languages||(e.topLanguage?[{name:e.topLanguage,percent:100}]:[]);gie(o.current,t)},[n,e.topLanguage]);let s={...e,...n},c=s.topRepos||[],l=s.soReputation||0,u=s.soAnswers||0,d=s.soAcceptRate||0,f=s.soBadges||0;return(0,S.jsxs)(`div`,{className:`detail-panel open`,children:[(0,S.jsx)(`button`,{className:`detail-panel__close`,onClick:t,children:`×`}),(0,S.jsx)(`div`,{className:`detail-panel__header`,children:(0,S.jsxs)(`div`,{className:`detail-header`,children:[(0,S.jsx)(`img`,{className:`detail-header__avatar`,src:e.avatarUrl,alt:e.login}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`detail-header__name`,children:e.name||e.login}),(0,S.jsxs)(`div`,{className:`detail-header__location`,children:[`📍 `,e.location||`Unknown location`]}),(0,S.jsxs)(`span`,{className:`detail-header__score-badge`,children:[`Score: `,e.score,`/100`]}),(0,S.jsxs)(`div`,{className:`detail-header__links`,children:[(0,S.jsx)(`a`,{href:`https://github.com/${e.login}`,target:`_blank`,rel:`noreferrer`,children:`GitHub ↗`}),s.soUserId&&(0,S.jsx)(`a`,{href:`https://stackoverflow.com/users/${s.soUserId}`,target:`_blank`,rel:`noreferrer`,children:`StackOverflow ↗`})]})]})]})}),(0,S.jsx)(`div`,{className:`detail-panel__stats`,children:(0,S.jsxs)(`div`,{className:`stats-grid`,children:[(0,S.jsx)($9,{label:`Stars`,value:q7(s.totalStars||0)}),(0,S.jsx)($9,{label:`Commits`,value:q7(s.totalCommits||0)}),(0,S.jsx)($9,{label:`Followers`,value:q7(s.followers||0)}),(0,S.jsx)($9,{label:`SO Reputation`,value:q7(l),className:`stat-card--so`}),(0,S.jsx)($9,{label:`SO Answers`,value:q7(u),className:`stat-card--so`}),(0,S.jsx)($9,{label:`SO Badges`,value:f||0,className:`stat-card--so`})]})}),(0,S.jsxs)(`div`,{className:`detail-panel__charts`,children:[(0,S.jsxs)(`div`,{className:`chart-section`,children:[(0,S.jsx)(`h3`,{children:`Score Breakdown`}),(0,S.jsx)(`div`,{ref:i})]}),(0,S.jsxs)(`div`,{className:`chart-section`,children:[(0,S.jsx)(`h3`,{children:`StackOverflow Activity`}),l||u?(0,S.jsx)(pie,{rep:l,answers:u,acceptRate:d,badges:f,userId:s.soUserId}):(0,S.jsx)(`div`,{className:`so-empty`,children:`No StackOverflow profile linked`})]}),(0,S.jsxs)(`div`,{className:`chart-section`,children:[(0,S.jsx)(`h3`,{children:`Contribution Activity`}),(0,S.jsx)(`div`,{ref:a})]}),(0,S.jsxs)(`div`,{className:`chart-section`,children:[(0,S.jsx)(`h3`,{children:`Languages`}),(0,S.jsx)(`div`,{ref:o})]}),(0,S.jsxs)(`div`,{className:`chart-section`,children:[(0,S.jsx)(`h3`,{children:`Top Repositories`}),(0,S.jsx)(`div`,{children:c.slice(0,5).map(e=>(0,S.jsxs)(`div`,{className:`repo-item`,children:[(0,S.jsx)(`span`,{className:`repo-item__name`,children:e.name}),(0,S.jsxs)(`span`,{className:`repo-item__stats`,children:[(0,S.jsxs)(`span`,{children:[`⭐ `,q7(e.stars)]}),(0,S.jsxs)(`span`,{children:[`🍴 `,q7(e.forks)]})]})]},e.name))})]})]})]})}function $9({label:e,value:t,className:n=``}){return(0,S.jsxs)(`div`,{className:`stat-card ${n}`,children:[(0,S.jsx)(`div`,{className:`stat-card__value`,children:t}),(0,S.jsx)(`div`,{className:`stat-card__label`,children:e})]})}function pie({rep:e,answers:t,acceptRate:n,badges:r,userId:i}){return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`so-bars`,children:[{label:`Reputation`,value:e,max:1e6,color:`#f48024`},{label:`Answers`,value:t,max:1e4,color:`#ff9f4a`},{label:`Accept Rate`,value:n,max:100,color:`#ffcc80`,suffix:`%`},{label:`Badges`,value:r,max:500,color:`#ffe0b2`}].map(e=>{let t=Math.min(e.value/e.max*100,100),n=e.suffix?e.value+e.suffix:q7(e.value);return(0,S.jsxs)(`div`,{className:`so-bar`,children:[(0,S.jsx)(`div`,{className:`so-bar__label`,children:e.label}),(0,S.jsx)(`div`,{className:`so-bar__track`,children:(0,S.jsx)(`div`,{className:`so-bar__fill`,style:{width:`${t}%`,background:e.color}})}),(0,S.jsx)(`div`,{className:`so-bar__value`,children:n})]},e.label)})}),i&&(0,S.jsx)(`a`,{className:`so-profile-link`,href:`https://stackoverflow.com/users/${i}`,target:`_blank`,rel:`noreferrer`,children:`View full SO profile ↗`})]})}function mie(e,t){e.innerHTML=``;let n=[{axis:`Stars`,value:t.stars},{axis:`Commits`,value:t.commits},{axis:`Reach`,value:t.repoReach},{axis:`SO Rep`,value:t.soReputation},{axis:`SO Engage`,value:t.soEngagement},{axis:`Community`,value:t.community}],r=Math.PI*2/n.length,i=j5(e).append(`svg`).attr(`viewBox`,`0 0 260 260`).append(`g`).attr(`transform`,`translate(${260/2}, ${260/2})`);for(let e=1;e<=5;e++)i.append(`circle`).attr(`r`,100/5*e).attr(`fill`,`none`).attr(`stroke`,`#1e293b`).attr(`stroke-width`,.5);n.forEach((e,t)=>{let n=r*t-Math.PI/2;i.append(`line`).attr(`x1`,0).attr(`y1`,0).attr(`x2`,100*Math.cos(n)).attr(`y2`,100*Math.sin(n)).attr(`stroke`,`#1e293b`).attr(`stroke-width`,.5),i.append(`text`).attr(`x`,116*Math.cos(n)).attr(`y`,116*Math.sin(n)).attr(`text-anchor`,`middle`).attr(`dominant-baseline`,`middle`).attr(`fill`,`#94a3b8`).attr(`font-size`,`10px`).text(e.axis)});let a=cie().radius(e=>e.value*100).angle((e,t)=>t*r).curve(lie);i.append(`path`).datum(n).attr(`d`,a).attr(`fill`,`rgba(59, 130, 246, 0.2)`).attr(`stroke`,`#3b82f6`).attr(`stroke-width`,2),n.forEach((e,t)=>{let n=r*t-Math.PI/2;i.append(`circle`).attr(`cx`,e.value*100*Math.cos(n)).attr(`cy`,e.value*100*Math.sin(n)).attr(`r`,4).attr(`fill`,`#3b82f6`)})}function hie(e,t){e.innerHTML=``;let n=[],r=t/364;for(let e=0;e<364;e++){let t=e%7==0||e%7==6?r*.3:r*1.4;n.push(Math.max(0,Math.round(t+(Math.random()-.5)*r*2)))}let i=Lg().domain([0,Rm(n)]).range([`#161b22`,`#0e4429`,`#006d32`,`#26a641`,`#39d353`]),a=j5(e).append(`svg`).attr(`viewBox`,`0 0 716 111`).attr(`width`,`100%`);n.forEach((e,t)=>{let n=Math.floor(t/7),r=t%7;a.append(`rect`).attr(`x`,n*13+20).attr(`y`,r*13).attr(`width`,11).attr(`height`,11).attr(`rx`,2).attr(`fill`,i(e))}),[`Mon`,`Wed`,`Fri`].forEach((e,t)=>{a.append(`text`).attr(`x`,0).attr(`y`,(t*2+1)*13+11/2).attr(`fill`,`#64748b`).attr(`font-size`,`9px`).attr(`dominant-baseline`,`middle`).text(e)})}function gie(e,t){if(e.innerHTML=``,!t.length)return;let n=[`#3b82f6`,`#8b5cf6`,`#f48024`,`#2ea44f`,`#64748b`],r=aie().value(e=>e.percent).sort(null),i=$re().innerRadius(60*.55).outerRadius(60);j5(e).append(`svg`).attr(`width`,120).attr(`height`,120).append(`g`).attr(`transform`,`translate(${120/2}, ${120/2})`).selectAll(`path`).data(r(t)).join(`path`).attr(`d`,i).attr(`fill`,(e,t)=>n[t%n.length]);let a=j5(e).append(`div`).style(`font-size`,`11px`);t.forEach((e,t)=>{a.append(`div`).style(`display`,`flex`).style(`align-items`,`center`).style(`gap`,`6px`).style(`margin-bottom`,`4px`).html(` + ${e.name} + ${e.percent}%`)})}function _ie({error:e}){return e?(0,S.jsx)(`div`,{className:`loading-overlay`,children:(0,S.jsxs)(`div`,{style:{textAlign:`center`,maxWidth:400},children:[(0,S.jsx)(`div`,{style:{fontSize:48,marginBottom:16},children:`⚠️`}),(0,S.jsx)(`div`,{style:{fontSize:16,marginBottom:8},children:`Failed to load data`}),(0,S.jsx)(`div`,{style:{fontSize:13,color:`#94a3b8`},children:e}),(0,S.jsx)(`button`,{onClick:()=>location.reload(),style:{marginTop:16,padding:`8px 20px`,background:`#3b82f6`,border:`none`,borderRadius:6,color:`white`,cursor:`pointer`},children:`Retry`})]})}):(0,S.jsxs)(`div`,{className:`loading-overlay`,children:[(0,S.jsx)(`div`,{className:`loading-spinner`}),(0,S.jsx)(`div`,{className:`loading-text`,children:`Loading developer data...`})]})}function vie(){let[e,t]=(0,x.useState)([]),[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!0),[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(null),f=(0,x.useRef)(null);(0,x.useEffect)(()=>{async function e(){try{let e=await fetch(`/api/developers`);if(!e.ok)throw Error(`Failed to load data: ${e.status}`);let n=O(await e.json());t(n),r(n),s(!1)}catch(e){l(e.message),s(!1)}}e()},[]);let p=(0,x.useCallback)(e=>{let t=O(e);r(t)},[]),m=(0,x.useCallback)(()=>{r(e)},[e]),h=(0,x.useCallback)(e=>{a(e),e?.lat!=null&&e?.lng!=null&&d({lat:e.lat,lng:e.lng})},[]),g=(0,x.useCallback)(()=>{a(null)},[]);return o||c?(0,S.jsx)(_ie,{error:c}):(0,S.jsxs)(`div`,{id:`app`,children:[(0,S.jsx)(C,{}),(0,S.jsx)(j,{developers:e,onResults:p,onReset:m}),(0,S.jsxs)(`main`,{className:`main`,children:[(0,S.jsx)(xne,{ref:f,developers:n,flyTarget:u,onSelectDev:h}),(0,S.jsx)(Sne,{developers:n,selectedLogin:i?.login,onSelectDev:h}),i&&(0,S.jsx)(fie,{dev:i,onClose:g})]})]})}b.createRoot(document.getElementById(`root`)).render((0,S.jsx)(x.StrictMode,{children:(0,S.jsx)(vie,{})})); \ No newline at end of file diff --git a/dist/assets/index-uNUnB7ja.css b/dist/assets/index-uNUnB7ja.css new file mode 100644 index 0000000..b1b64f0 --- /dev/null +++ b/dist/assets/index-uNUnB7ja.css @@ -0,0 +1 @@ +:root{--bg-primary:#0a0e17;--bg-secondary:#111827;--bg-card:#1a2234;--bg-hover:#243049;--text-primary:#e2e8f0;--text-secondary:#94a3b8;--text-muted:#64748b;--accent-github:#2ea44f;--accent-so:#f48024;--accent-blue:#3b82f6;--accent-purple:#8b5cf6;--border:#1e293b;--radius:8px;--shadow:0 4px 24px #0006;--font:"Inter", -apple-system, BlinkMacSystemFont, sans-serif}*{box-sizing:border-box;margin:0;padding:0}body{font-family:var(--font);background:var(--bg-primary);color:var(--text-primary);height:100vh;overflow:hidden}.header{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border-bottom:1px solid var(--border);z-index:100;background:#0a0e17d9;justify-content:space-between;align-items:center;height:56px;padding:0 24px;display:flex;position:fixed;top:0;left:0;right:0}.header__brand{align-items:center;gap:10px;display:flex}.header__icon{font-size:24px}.header__title{background:linear-gradient(135deg, var(--accent-blue), var(--accent-purple));-webkit-text-fill-color:transparent;-webkit-background-clip:text;font-size:18px;font-weight:700}.header__subtitle{color:var(--text-muted);font-size:12px;font-weight:400}.header__actions{align-items:center;gap:8px;display:flex}.btn{font-size:12px;font-family:var(--font);white-space:nowrap;border-radius:20px;align-items:center;gap:6px;padding:6px 14px;font-weight:500;text-decoration:none;transition:background .2s,transform .15s;display:inline-flex}.btn:hover{transform:translateY(-1px)}.btn--star{border:1px solid var(--border);color:#e2e8f0;background:#ffffff14}.btn--star:hover{color:#f0c040;background:#ffffff24;border-color:#f0c040}.btn--sponsor{color:#f472b6;background:#db277726;border:1px solid #db277766}.btn--sponsor:hover{background:#db277740;border-color:#f472b6}.search-bar{z-index:90;flex-direction:column;align-items:center;gap:8px;transition:top .3s,opacity .3s;display:flex;position:fixed;top:72px;left:50%;transform:translate(-50%)}.search-bar__samples.hidden{opacity:0;pointer-events:none}.search-bar__inner{-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border:1px solid var(--border);background:#111827e6;border-radius:28px;align-items:center;gap:8px;padding:6px 8px 6px 16px;transition:border-color .2s,box-shadow .2s;display:flex;box-shadow:0 8px 32px #00000080}.search-bar__inner:focus-within{border-color:var(--accent-blue);box-shadow:0 8px 32px #3b82f626}.search-bar__icon{color:var(--text-muted);flex-shrink:0}.search-bar__inner input{width:360px;color:var(--text-primary);font-size:14px;font-family:var(--font);background:0 0;border:none;outline:none;padding:8px 4px}.search-bar__inner input::placeholder{color:var(--text-muted)}.search-bar__inner select{background:var(--bg-card);border:1px solid var(--border);color:var(--text-secondary);font-size:12px;font-family:var(--font);cursor:pointer;border-radius:16px;outline:none;padding:6px 10px;transition:border-color .2s}.search-bar__inner select:focus{border-color:var(--accent-blue)}.search-bar__samples{color:var(--text-muted);align-items:center;gap:6px;font-size:12px;transition:opacity .3s;display:flex}.search-bar__samples button{border:1px solid var(--border);color:var(--text-secondary);font-size:11px;font-family:var(--font);cursor:pointer;background:#1e293bb3;border-radius:14px;padding:4px 12px;transition:background .2s,color .2s,border-color .2s}.search-bar__samples button:hover{background:var(--bg-hover);color:var(--text-primary);border-color:var(--accent-blue)}.search-bar__clear{color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:4px;transition:color .2s,background .2s;display:flex}.search-bar__clear:hover{color:var(--text-primary);background:#ffffff1a}.search-bar__spinner{border:2px solid var(--border);border-top-color:var(--accent-blue);border-radius:50%;flex-shrink:0;width:18px;height:18px;animation:.6s linear infinite spin}@keyframes spin{to{transform:rotate(360deg)}}.search-bar__results{color:var(--text-muted);background:#111827b3;border-radius:10px;padding:3px 10px;font-size:11px}.main{width:100%;height:100vh;padding-top:56px;position:relative}#globe-container{width:100%;height:100%}.sidebar{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border-left:1px solid var(--border);z-index:50;background:#111827eb;flex-direction:column;width:320px;height:calc(100vh - 56px);transition:transform .3s;display:flex;position:fixed;top:56px;right:0}.sidebar__header{border-bottom:1px solid var(--border);padding:16px 20px}.sidebar__header h2{text-transform:uppercase;letter-spacing:.5px;color:var(--text-secondary);margin-bottom:10px;font-size:14px;font-weight:600}.sidebar__filters{grid-template-columns:1fr 1fr;gap:6px;display:grid}.sidebar__filters select{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text-primary);cursor:pointer;text-overflow:ellipsis;outline:none;max-width:100%;padding:6px 10px;font-size:11px;overflow:hidden}.sidebar__list{flex:1;padding:8px 0;list-style:none;overflow-y:auto}.sidebar__list::-webkit-scrollbar{width:6px}.sidebar__list::-webkit-scrollbar-thumb{background:var(--bg-hover);border-radius:3px}.lb-item{cursor:pointer;align-items:center;gap:12px;padding:10px 20px;transition:background .15s;display:flex}.lb-item:hover{background:var(--bg-hover)}.lb-item.active{background:var(--bg-hover);border-left:3px solid var(--accent-blue)}.lb-item__rank{color:var(--text-muted);text-align:right;width:24px;font-size:12px;font-weight:600}.lb-item__avatar{object-fit:cover;border-radius:50%;width:32px;height:32px}.lb-item__info{flex:1;min-width:0}.lb-item__name{white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:500;overflow:hidden}.lb-item__meta{color:var(--text-muted);font-size:11px}.lb-item__score{color:var(--accent-blue);font-size:14px;font-weight:700}.detail-panel{-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border-right:1px solid var(--border);z-index:60;background:#111827f2;width:420px;height:calc(100vh - 56px);padding:24px;transition:transform .3s;position:fixed;top:56px;left:0;overflow-y:auto;transform:translate(-100%)}.detail-panel.open{transform:translate(0)}.detail-panel__close{color:var(--text-secondary);cursor:pointer;background:0 0;border:none;font-size:24px;line-height:1;position:absolute;top:12px;right:16px}.detail-panel__close:hover{color:var(--text-primary)}.detail-header{align-items:center;gap:16px;margin-bottom:24px;display:flex}.detail-header__avatar{border:2px solid var(--accent-blue);border-radius:50%;width:64px;height:64px}.detail-header__name{font-size:20px;font-weight:700}.detail-header__location{color:var(--text-muted);margin-top:2px;font-size:12px}.detail-header__score-badge{background:var(--accent-blue);border-radius:12px;margin-top:6px;padding:3px 10px;font-size:12px;font-weight:600;display:inline-block}.detail-header__links{gap:8px;margin-top:8px;display:flex}.detail-header__links a{color:var(--accent-blue);font-size:11px;text-decoration:none}.detail-header__links a:hover{text-decoration:underline}.chart-section{margin-bottom:24px}.chart-section h3{text-transform:uppercase;letter-spacing:.5px;color:var(--text-secondary);margin-bottom:12px;font-size:12px;font-weight:600}#chart-radar svg{width:100%;max-width:280px;margin:0 auto;display:block}#chart-heatmap{overflow-x:auto}#chart-languages{align-items:center;gap:16px;display:flex}.repo-item{background:var(--bg-card);border-radius:var(--radius);justify-content:space-between;align-items:center;margin-bottom:6px;padding:8px 12px;display:flex}.repo-item__name{color:var(--accent-blue);font-size:13px;font-weight:500}.repo-item__stats{color:var(--text-muted);gap:12px;font-size:11px;display:flex}.tooltip{pointer-events:none;background:var(--bg-card);border:1px solid var(--border);z-index:200;opacity:0;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:12px;min-width:240px;max-width:300px;padding:14px 16px;transition:opacity .2s;position:fixed;box-shadow:0 8px 32px #00000080}.tooltip.visible{opacity:1}.tooltip__header{align-items:center;gap:10px;margin-bottom:8px;display:flex}.tooltip__avatar{border:2px solid var(--border);object-fit:cover;border-radius:50%;width:40px;height:40px}.tooltip__name{color:var(--text-primary);font-size:14px;font-weight:600}.tooltip__login{color:var(--text-muted);font-size:11px}.tooltip__score{color:var(--accent-blue);margin-bottom:6px;font-size:12px;font-weight:600}.tooltip__stats{color:var(--text-secondary);gap:10px;margin-bottom:6px;font-size:11px;display:flex}.tooltip__stats span{align-items:center;gap:2px;display:flex}.tooltip__so{color:#f48024;font-weight:500}.tooltip__meta{color:var(--text-muted);gap:4px;font-size:11px;display:flex}.stats-grid{grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:24px;display:grid}.stat-card{background:var(--bg-card);border-radius:var(--radius);text-align:center;border:1px solid var(--border);padding:12px 10px}.stat-card--so{border-color:#f480244d}.stat-card__value{color:var(--text-primary);font-size:18px;font-weight:700}.stat-card--so .stat-card__value{color:var(--accent-so)}.stat-card__label{color:var(--text-muted);text-transform:uppercase;letter-spacing:.3px;margin-top:4px;font-size:10px}.so-bars{flex-direction:column;gap:10px;display:flex}.so-bar{grid-template-columns:90px 1fr 60px;align-items:center;gap:10px;display:grid}.so-bar__label{color:var(--text-secondary);font-size:12px}.so-bar__track{background:var(--bg-primary);border-radius:4px;height:8px;overflow:hidden}.so-bar__fill{border-radius:4px;height:100%;transition:width .6s}.so-bar__value{color:var(--text-primary);text-align:right;font-size:12px;font-weight:600}.so-empty{color:var(--text-muted);padding:12px 0;font-size:12px;font-style:italic}.so-profile-link{color:var(--accent-so);margin-top:12px;font-size:11px;text-decoration:none;display:inline-block}.so-profile-link:hover{text-decoration:underline}.lb-item__badges{gap:6px;margin-top:3px;display:flex}.lb-badge{border-radius:10px;padding:1px 6px;font-size:10px;font-weight:500}.lb-badge--gh{color:var(--accent-github);background:#2ea44f26}.lb-badge--so{color:var(--accent-so);background:#f4802426}.loading-overlay{background:var(--bg-primary);z-index:999;flex-direction:column;justify-content:center;align-items:center;transition:opacity .5s;display:flex;position:fixed;inset:0}.loading-overlay.hidden{opacity:0;pointer-events:none}.loading-spinner{border:3px solid var(--border);border-top-color:var(--accent-blue);border-radius:50%;width:40px;height:40px;animation:.8s linear infinite spin}.loading-text{color:var(--text-secondary);margin-top:16px;font-size:14px}@media (width<=1024px){.sidebar{width:280px}.detail-panel{width:360px}}@media (width<=768px){.sidebar{transform:translate(100%)}.sidebar.open{transform:translate(0)}.detail-panel{width:100%}} diff --git a/dist/index.html b/dist/index.html new file mode 100644 index 0000000..38b40d3 --- /dev/null +++ b/dist/index.html @@ -0,0 +1,15 @@ + + + + + + DevGlobe — Visualizing the World's Top Open-Source Contributors + + + + + + +
+ + diff --git a/index.html b/index.html index da04f3c..15b01e7 100644 --- a/index.html +++ b/index.html @@ -4,100 +4,11 @@ DevGlobe — Visualizing the World's Top Open-Source Contributors - -
- -
-
- 🌐 -

DevGlobe

- Visualizing the World's Top Open-Source Contributors -
- -
- - -
- -
- - - - - -
- -
-
-
-
-

Score Breakdown

-
-
-
-

StackOverflow Activity

-
-
-
-

Contribution Activity

-
-
-
-

Languages

-
-
-
-

Top Repositories

-
-
-
-
-
- - -
-
- - - - - - - - - - - - +
+ diff --git a/package-lock.json b/package-lock.json index 2141159..73866a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,16 @@ "version": "1.0.0", "dependencies": { "@azure/cosmos": "^4.10.0", + "@vercel/analytics": "^2.0.1", + "@vitejs/plugin-react": "^6.0.4", + "d3": "^7.9.0", "dotenv": "^16.4.5", "express": "^5.2.1", - "node-fetch": "^3.3.2" + "node-fetch": "^3.3.2", + "react": "^19.2.8", + "react-dom": "^19.2.8", + "react-globe.gl": "^2.38.0", + "vite": "^8.1.5" }, "devDependencies": { "serve": "^14.2.0" @@ -207,6 +214,404 @@ "node": ">=22.0.0" } }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha1-EgIkUMRaTabY2Ch7GKT/Ldsj92g=", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@emnapi/core": { + "version": "1.11.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@emnapi/core/-/core-1.11.1.tgz", + "integrity": "sha1-ueEGTzprFjHiQeY460jXNr/TcqY=", + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@emnapi/runtime/-/runtime-1.11.1.tgz", + "integrity": "sha1-WPHz1dgamxL3k6tojJY3GQECfCQ=", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.2.2", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz", + "integrity": "sha1-TJO+z1v6OxPRu9zAau44MhrYE5o=", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.6", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.6.tgz", + "integrity": "sha1-7TOAbQ+b6Y3HbQw9T9hy/acBtdU=", + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.139.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@oxc-project/types/-/types-0.139.0.tgz", + "integrity": "sha1-ONdrnb+TTCoCvhdPsyzuvxgv50I=", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.1.5", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-android-arm64/-/binding-android-arm64-1.1.5.tgz", + "integrity": "sha1-9Yy5oKgSjtBYIoJyBShUf8XANfM=", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.1.5", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.1.5.tgz", + "integrity": "sha1-RBFEwFpKgxqnUmmrw6SjJDdOpwc=", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.1.5", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.1.5.tgz", + "integrity": "sha1-yC4wZSzvUsSvkl1cZsiVWkAxmBY=", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.1.5", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.1.5.tgz", + "integrity": "sha1-wy6c5/ocD7K4CROio6BcPpB9BrA=", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.1.5", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.1.5.tgz", + "integrity": "sha1-zpC14iMWretQLqAQWC9JjNBgTyc=", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.1.5", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.1.5.tgz", + "integrity": "sha1-kZRxEMTdqk7vsATlJogHCXcIUgE=", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.1.5", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.1.5.tgz", + "integrity": "sha1-6zKy1BCMHHArkejN6KBD6uXKqU0=", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.1.5", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.1.5.tgz", + "integrity": "sha1-zLlDwR5acmVcuwL8EWNUHOtkB4I=", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.1.5", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.1.5.tgz", + "integrity": "sha1-ozcx7lZ+kLdfrG5eVTB+iiswOPA=", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.1.5", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.1.5.tgz", + "integrity": "sha1-p0wBqqzt/BHDm2/rozpfoMZUlJ8=", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.1.5", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.1.5.tgz", + "integrity": "sha1-KM0XhJT6HmXbpBIim1zlXE3Vy9E=", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.1.5", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.1.5.tgz", + "integrity": "sha1-98dfqRP8IIhNJqfUiNT1xZfNccA=", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.1.5", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.1.5.tgz", + "integrity": "sha1-w3lYGUd4cIHfNj6hBhQPzV/sJS0=", + "cpu": [ + "wasm32" + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "1.11.1", + "@emnapi/runtime": "1.11.1", + "@napi-rs/wasm-runtime": "^1.1.6" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.1.5", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.1.5.tgz", + "integrity": "sha1-8jyIaU96cpoS85UCSu4434Cha6M=", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.1.5", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.1.5.tgz", + "integrity": "sha1-M3fI3g5WqIV/ESF1YRRwkOh0y0Y=", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha1-4/zuCT+7XOdl4a0Ij/TeKIn2+b4=", + "license": "MIT" + }, + "node_modules/@turf/boolean-point-in-polygon": { + "version": "7.3.5", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@turf/boolean-point-in-polygon/-/boolean-point-in-polygon-7.3.5.tgz", + "integrity": "sha1-RBbb3nISJRU1kMwiBPYU5E84i1U=", + "license": "MIT", + "dependencies": { + "@turf/helpers": "7.3.5", + "@turf/invariant": "7.3.5", + "@types/geojson": "^7946.0.10", + "point-in-polygon-hao": "^1.1.0", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "node_modules/@turf/helpers": { + "version": "7.3.5", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@turf/helpers/-/helpers-7.3.5.tgz", + "integrity": "sha1-BRkowDzfn/zHrjZYHDF6/Em/2Zk=", + "license": "MIT", + "dependencies": { + "@types/geojson": "^7946.0.10", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "node_modules/@turf/invariant": { + "version": "7.3.5", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@turf/invariant/-/invariant-7.3.5.tgz", + "integrity": "sha1-VhnQ4O83VeK+aYVbrUfhAVihggs=", + "license": "MIT", + "dependencies": { + "@turf/helpers": "7.3.5", + "@types/geojson": "^7946.0.10", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "node_modules/@tweenjs/tween.js": { + "version": "25.0.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@tweenjs/tween.js/-/tween.js-25.0.0.tgz", + "integrity": "sha1-cma668w6/+YqOlQxij6oLZBM0Lk=", + "license": "MIT" + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.3", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@tybys/wasm-util/-/wasm-util-0.10.3.tgz", + "integrity": "sha1-AVy6np3UfOFNA9KoxdVHv7FpZl0=", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha1-jr5T1p762nBERU4zBcGQF9l87So=", + "license": "MIT" + }, "node_modules/@typespec/ts-http-runtime": { "version": "0.3.7", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.7.tgz", @@ -221,6 +626,73 @@ "node": ">=22.0.0" } }, + "node_modules/@vercel/analytics": { + "version": "2.0.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@vercel/analytics/-/analytics-2.0.1.tgz", + "integrity": "sha1-19e9N698++6pXbXxMq5IifTSZAc=", + "license": "MIT", + "peerDependencies": { + "@remix-run/react": "^2", + "@sveltejs/kit": "^1 || ^2", + "next": ">= 13", + "nuxt": ">= 3", + "react": "^18 || ^19 || ^19.0.0-rc", + "svelte": ">= 4", + "vue": "^3", + "vue-router": "^4" + }, + "peerDependenciesMeta": { + "@remix-run/react": { + "optional": true + }, + "@sveltejs/kit": { + "optional": true + }, + "next": { + "optional": true + }, + "nuxt": { + "optional": true + }, + "react": { + "optional": true + }, + "svelte": { + "optional": true + }, + "vue": { + "optional": true + }, + "vue-router": { + "optional": true + } + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "6.0.4", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@vitejs/plugin-react/-/plugin-react-6.0.4.tgz", + "integrity": "sha1-o1g0um5Gi8rWheyNBKU78M68wv8=", + "license": "MIT", + "dependencies": { + "@rolldown/pluginutils": "^1.0.1" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0", + "babel-plugin-react-compiler": "^1.0.0", + "vite": "^8.0.0" + }, + "peerDependenciesMeta": { + "@rolldown/plugin-babel": { + "optional": true + }, + "babel-plugin-react-compiler": { + "optional": true + } + } + }, "node_modules/@zeit/schemas": { "version": "2.36.0", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@zeit/schemas/-/schemas-2.36.0.tgz", @@ -266,6 +738,15 @@ "node": ">= 0.6" } }, + "node_modules/accessor-fn": { + "version": "1.5.3", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/accessor-fn/-/accessor-fn-1.5.3.tgz", + "integrity": "sha1-XiVJ0pHUrAIvUy2ppVQ1jcUlsPc=", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/agent-base": { "version": "7.1.4", "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/agent-base/-/agent-base-7.1.4.tgz", @@ -666,6 +1147,15 @@ "dev": true, "license": "MIT" }, + "node_modules/commander": { + "version": "7.2.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/commander/-/commander-7.2.0.tgz", + "integrity": "sha1-o2y1fQtQHOEI5NIFWaFQo5HZerc=", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, "node_modules/compressible": { "version": "2.0.18", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/compressible/-/compressible-2.0.18.tgz", @@ -724,37 +1214,496 @@ "node": ">= 0.6" } }, - "node_modules/cookie": { - "version": "0.7.2", - "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/cookie/-/cookie-0.7.2.tgz", - "integrity": "sha1-VWNpxHKiupEPKXmJG1JrNDYjftc=", - "license": "MIT", + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha1-VWNpxHKiupEPKXmJG1JrNDYjftc=", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha1-V8f8PMKTrKuf7FTXPhVpDr5KF5M=", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha1-ilj+ePANzXDDcEUXWd+/rwPo7p8=", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/d3": { + "version": "7.9.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3/-/d3-7.9.0.tgz", + "integrity": "sha1-V556yz10nK+IYL0XQa6NNxBwzV0=", + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-axis": "3", + "d3-brush": "3", + "d3-chord": "3", + "d3-color": "3", + "d3-contour": "4", + "d3-delaunay": "6", + "d3-dispatch": "3", + "d3-drag": "3", + "d3-dsv": "3", + "d3-ease": "3", + "d3-fetch": "3", + "d3-force": "3", + "d3-format": "3", + "d3-geo": "3", + "d3-hierarchy": "3", + "d3-interpolate": "3", + "d3-path": "3", + "d3-polygon": "3", + "d3-quadtree": "3", + "d3-random": "3", + "d3-scale": "4", + "d3-scale-chromatic": "3", + "d3-selection": "3", + "d3-shape": "3", + "d3-time": "3", + "d3-time-format": "4", + "d3-timer": "3", + "d3-transition": "3", + "d3-zoom": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha1-Ff7DOyN/l6xdfJhtx32ic6jtC7U=", + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-axis": { + "version": "3.0.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-axis/-/d3-axis-3.0.0.tgz", + "integrity": "sha1-xCpKE+gTHWN7dF/Clzgkz+r5MyI=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-brush": { + "version": "3.0.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-brush/-/d3-brush-3.0.0.tgz", + "integrity": "sha1-b3Z8Ttjct53n7ePhwPieY+9k0xw=", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "3", + "d3-transition": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-chord": { + "version": "3.0.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-chord/-/d3-chord-3.0.1.tgz", + "integrity": "sha1-0VbWH0hfzoMn5qvzOctB2Mu6aWY=", + "license": "ISC", + "dependencies": { + "d3-path": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha1-OVsoM9+scVB/EqwvevI7+BneJOI=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-contour": { + "version": "4.0.2", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-contour/-/d3-contour-4.0.2.tgz", + "integrity": "sha1-u5IGO8jFZjrLJCL5nHPLtsauO8w=", + "license": "ISC", + "dependencies": { + "d3-array": "^3.2.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-delaunay": { + "version": "6.0.4", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha1-mBaQOHM6ClurvtpVBU95W7nkpYs=", + "license": "ISC", + "dependencies": { + "delaunator": "5" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha1-X8dShOnCN1w2yDlBGgz1UMv8TV4=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha1-mUqunNI8cZ9TteEOOgphCMaWB7o=", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv": { + "version": "3.0.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-dsv/-/d3-dsv-3.0.1.tgz", + "integrity": "sha1-xjr5ePTWoNCEpSpnOSK+IWB4m3M=", + "license": "ISC", + "dependencies": { + "commander": "7", + "iconv-lite": "0.6", + "rw": "1" + }, + "bin": { + "csv2json": "bin/dsv2json.js", + "csv2tsv": "bin/dsv2dsv.js", + "dsv2dsv": "bin/dsv2dsv.js", + "dsv2json": "bin/dsv2json.js", + "json2csv": "bin/json2dsv.js", + "json2dsv": "bin/json2dsv.js", + "json2tsv": "bin/json2dsv.js", + "tsv2csv": "bin/dsv2dsv.js", + "tsv2json": "bin/dsv2json.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha1-pS+AvzjaGVLrXGgXkHGYcaGnJQE=", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha1-llisOKIUDVnTRhYPH2ww/aC9EvQ=", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-fetch": { + "version": "3.0.1", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-fetch/-/d3-fetch-3.0.1.tgz", + "integrity": "sha1-gxQb/5hWoO21443onNz+Y9CmCiI=", + "license": "ISC", + "dependencies": { + "d3-dsv": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-force": { + "version": "3.0.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-force/-/d3-force-3.0.0.tgz", + "integrity": "sha1-Piuhph5wiI/j2RlOMNbRTuzhVcQ=", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-quadtree": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.2", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-format/-/d3-format-3.1.2.tgz", + "integrity": "sha1-Af20a1i+sfVbELQq1wtuNE1esq4=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo": { + "version": "3.1.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-geo/-/d3-geo-3.1.1.tgz", + "integrity": "sha1-YCfPUSRvmy69ZPmeAdx8M2QDOk0=", + "license": "ISC", + "dependencies": { + "d3-array": "2.5.0 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo-voronoi": { + "version": "2.1.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-geo-voronoi/-/d3-geo-voronoi-2.1.0.tgz", + "integrity": "sha1-8W/fIyp1FPblO2ffmP3Tu34LT4E=", + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-delaunay": "6", + "d3-geo": "3", + "d3-tricontour": "1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-hierarchy": { + "version": "3.1.2", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", + "integrity": "sha1-sBzULB7tPUbbd6WWbPcm+MCRYMY=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha1-PEeqWzLFs9+1bvP9Q0IHimMrQA0=", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-octree": { + "version": "1.1.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-octree/-/d3-octree-1.1.0.tgz", + "integrity": "sha1-8H41O3bfhyZE5xMKsadMXvL0KH4=", + "license": "MIT" + }, + "node_modules/d3-path": { + "version": "3.1.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-path/-/d3-path-3.1.0.tgz", + "integrity": "sha1-It+TkDL7WnGuixgA1h3beFHEJSY=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-polygon": { + "version": "3.0.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-polygon/-/d3-polygon-3.0.1.tgz", + "integrity": "sha1-C0XT3RxIopyOBX5hNWk+yAvxY5g=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-quadtree": { + "version": "3.0.1", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-quadtree/-/d3-quadtree-3.0.1.tgz", + "integrity": "sha1-bco+i+Kzk8mp1RTau9gKkt7vGk8=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-random": { + "version": "3.0.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-random/-/d3-random-3.0.1.tgz", + "integrity": "sha1-1JJjeNMz2cC/0eb6AZTTCuuqIPQ=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha1-grOOjo/3CAdk+Nzsd71L45Nok5Y=", + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha1-NMOdopiyPCDgLxpLI5vQ8i5/ExQ=", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha1-wlM4IH76csxbm9FFihpBkB8eGzE=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-shape": { + "version": "3.2.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-shape/-/d3-shape-3.2.0.tgz", + "integrity": "sha1-oag5y9m6RfKGdMadf4Vbz5HfxqU=", + "license": "ISC", + "dependencies": { + "d3-path": "^3.1.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha1-kxDbVumS48AXXh7zheVF5Iqbtcc=", + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha1-erUlelBB0R7LT+cKXH0WoZW7QIo=", + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha1-YoTSonCChbGrt+IB7aQ4CvNeY7A=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha1-aGn93hRIhoB3/dWYkgDLYbKhZF8=", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-tricontour": { + "version": "1.1.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-tricontour/-/d3-tricontour-1.1.0.tgz", + "integrity": "sha1-ZfnqSID9A27c3F/FJorAT+3T+Z0=", + "license": "ISC", + "dependencies": { + "d3-delaunay": "6", + "d3-scale": "4" + }, "engines": { - "node": ">= 0.6" + "node": ">=12" } }, - "node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha1-V8f8PMKTrKuf7FTXPhVpDr5KF5M=", - "license": "MIT", + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha1-0T9BZccyF//qpUKVzWlps+eu6PM=", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, "engines": { - "node": ">=6.6.0" + "node": ">=12" } }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha1-ilj+ePANzXDDcEUXWd+/rwPo7p8=", - "dev": true, + "node_modules/data-bind-mapper": { + "version": "1.0.3", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/data-bind-mapper/-/data-bind-mapper-1.0.3.tgz", + "integrity": "sha1-J15V/RcDMbEUZHnzx+tCVrgjlIE=", "license": "MIT", "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" + "accessor-fn": "1" }, "engines": { - "node": ">= 8" + "node": ">=12" } }, "node_modules/data-uri-to-buffer": { @@ -786,6 +1735,15 @@ "node": ">=4.0.0" } }, + "node_modules/delaunator": { + "version": "5.1.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/delaunator/-/delaunator-5.1.0.tgz", + "integrity": "sha1-0TJx+/Ov9nU/nqbiNVV/IJAQRuo=", + "license": "ISC", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/depd/-/depd-2.0.0.tgz", @@ -795,6 +1753,15 @@ "node": ">= 0.8" } }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha1-aJxdzcGQDvVYOky59te0c3QgdK0=", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, "node_modules/dotenv": { "version": "16.6.1", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/dotenv/-/dotenv-16.6.1.tgz", @@ -821,6 +1788,12 @@ "node": ">= 0.4" } }, + "node_modules/earcut": { + "version": "3.2.3", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/earcut/-/earcut-3.2.3.tgz", + "integrity": "sha1-dK7BlVWn4odzQpgmcp0uS/6xkCI=", + "license": "ISC" + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -1057,6 +2030,23 @@ ], "license": "BSD-3-Clause" }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha1-7Sq5Z6MxreYvGNB32uGSaE1Q01A=", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, "node_modules/fetch-blob": { "version": "3.2.0", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/fetch-blob/-/fetch-blob-3.2.0.tgz", @@ -1124,6 +2114,20 @@ "integrity": "sha1-V0yBOM4dK1hh8LRFedut1gxmFbI=", "license": "MIT" }, + "node_modules/float-tooltip": { + "version": "1.7.5", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/float-tooltip/-/float-tooltip-1.7.5.tgz", + "integrity": "sha1-cIO/ePDeWpf5wtaqjpDSE580BH8=", + "license": "MIT", + "dependencies": { + "d3-selection": "2 - 3", + "kapsule": "^1.16", + "preact": "10" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -1145,6 +2149,15 @@ "node": ">= 0.6" } }, + "node_modules/frame-ticker": { + "version": "1.0.3", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/frame-ticker/-/frame-ticker-1.0.3.tgz", + "integrity": "sha1-LJnT/rtJP9HTYhNRzQAxiXlKEkU=", + "license": "MIT", + "dependencies": { + "simplesignal": "^2.1.6" + } + }, "node_modules/fresh": { "version": "2.0.0", "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/fresh/-/fresh-2.0.0.tgz", @@ -1154,6 +2167,19 @@ "node": ">= 0.8" } }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha1-ysZAd4XQNnWipeGlMFxpezR9kNY=", + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/function-bind/-/function-bind-1.1.2.tgz", @@ -1213,6 +2239,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globe.gl": { + "version": "2.46.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/globe.gl/-/globe.gl-2.46.1.tgz", + "integrity": "sha1-vYkqluSUmBqeRFisdbwFZPPTbyg=", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "kapsule": "^1.16", + "three": ">=0.179 <1", + "three-globe": "^2.45", + "three-render-objects": "^1.41" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/gopd/-/gopd-1.2.0.tgz", @@ -1225,6 +2268,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/h3-js": { + "version": "4.5.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/h3-js/-/h3-js-4.5.0.tgz", + "integrity": "sha1-eGaBLvO2QyZS7grOdKUnVy9mRMU=", + "license": "Apache-2.0", + "engines": { + "node": ">=4", + "npm": ">=3", + "yarn": ">=1.3.0" + } + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/has-flag/-/has-flag-4.0.0.tgz", @@ -1377,6 +2431,15 @@ "url": "https://opencollective.com/express" } }, + "node_modules/index-array-by": { + "version": "1.4.2", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/index-array-by/-/index-array-by-1.4.2.tgz", + "integrity": "sha1-1vgun7/zIBxNq2S6QV1NKSMkL+o=", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/inherits/-/inherits-2.0.4.tgz", @@ -1390,6 +2453,15 @@ "dev": true, "license": "ISC" }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha1-ZoXyN1XkPFJOJR0py8lySOMGEAk=", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -1432,58 +2504,364 @@ "dev": true, "license": "MIT", "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha1-Qv+fhCBsGZHSbev1IN1cAQQt0vM=", + "license": "MIT" + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha1-+sHj1TuXrVqdCunO8jifWBClwHc=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha1-dKTHbnfKn9P5MvKQwX6jJs0VcnE=", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true, + "license": "ISC" + }, + "node_modules/jerrypick": { + "version": "1.1.2", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/jerrypick/-/jerrypick-1.1.2.tgz", + "integrity": "sha1-61AWMErrmsm33qZxSqX+hbJMuK0=", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha1-GSA/tZmR35jjoocFDUZHzerzJJk=", + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha1-rnvLNlard6c7pcSb9lTzjmtoYOI=", + "dev": true, + "license": "MIT" + }, + "node_modules/kapsule": { + "version": "1.16.3", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/kapsule/-/kapsule-1.16.3.tgz", + "integrity": "sha1-VoTtiYOLZlizDQ8swFbf/DumjDA=", + "license": "MIT", + "dependencies": { + "lodash-es": "4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha1-wIhn1xp5OFxuGQIU/XL+8+X5Xws=", + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha1-mmhB+IrlD8g1ApA4krQa9BvCuQc=", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha1-wPLDHAv9GfpN0/GOlXofGhUgl9Y=", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha1-ywcFllrLU4xmg5Sc5pJfs833w2E=", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha1-djU4gosmurJoDa2vzITueLDrUCs=", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha1-aGLjF2ozGu297B7TUrTX0N0HhN4=", + "cpu": [ + "arm" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha1-xqOi7RUUHa9r3CYokw+OOb30c6o=", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha1-f6EzSXH8goRfmCffbvigsgkUusY=", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha1-i5J4YuqMK7xoMaRlCSRLUNmTblU=", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha1-DFJbsHff2UQEwFnP5C2teX6Wrq8=", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha1-hQ7hED2smJz6tQ46wi0aaeOU5j0=", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "type": "opencollective", + "url": "https://opencollective.com/parcel" } }, - "node_modules/is-promise": { - "version": "4.0.0", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha1-Qv+fhCBsGZHSbev1IN1cAQQt0vM=", - "license": "MIT" - }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha1-+sHj1TuXrVqdCunO8jifWBClwHc=", - "dev": true, - "license": "MIT", + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha1-40OuFS7tNgncbhGUnRo785oclG8=", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], "engines": { - "node": ">=8" + "node": ">= 12.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "type": "opencollective", + "url": "https://opencollective.com/parcel" } }, - "node_modules/is-wsl": { - "version": "2.2.0", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha1-dKTHbnfKn9P5MvKQwX6jJs0VcnE=", - "dev": true, + "node_modules/lodash-es": { + "version": "4.18.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lodash-es/-/lodash-es-4.18.1.tgz", + "integrity": "sha1-uWLuuA2dmDqQC/NClh+3QYyhCx0=", + "license": "MIT" + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha1-ce5R+nvkyuwaY4OffmgtgTLTDK8=", "license": "MIT", "dependencies": { - "is-docker": "^2.0.0" + "js-tokens": "^3.0.0 || ^4.0.0" }, - "engines": { - "node": ">=8" + "bin": { + "loose-envify": "cli.js" } }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true, - "license": "ISC" - }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha1-rnvLNlard6c7pcSb9lTzjmtoYOI=", - "dev": true, - "license": "MIT" - }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -1593,6 +2971,24 @@ "dev": true, "license": "MIT" }, + "node_modules/nanoid": { + "version": "3.3.16", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/nanoid/-/nanoid-3.3.16.tgz", + "integrity": "sha1-oE2OxLHxAAnS1TOUeu/kKTc3gWw=", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/negotiator": { "version": "0.6.4", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/negotiator/-/negotiator-0.6.4.tgz", @@ -1654,6 +3050,15 @@ "node": ">=8" } }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object-inspect": { "version": "1.13.4", "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/object-inspect/-/object-inspect-1.13.4.tgz", @@ -1746,12 +3151,108 @@ "dev": true, "license": "MIT" }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha1-PTIa8+q5ObCDyPkpodEs2oHCa2s=", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.5", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/picomatch/-/picomatch-4.0.5.tgz", + "integrity": "sha1-UepXoX2G9gX4EDlZX7xA7QalX6s=", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/point-in-polygon-hao": { + "version": "1.2.4", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/point-in-polygon-hao/-/point-in-polygon-hao-1.2.4.tgz", + "integrity": "sha1-hmKr3MhLzKIwzD7LsLCrGjBvG9Y=", + "license": "MIT", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, + "node_modules/polished": { + "version": "4.3.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/polished/-/polished-4.3.1.tgz", + "integrity": "sha1-WgCuMnFWCfg9ifbzHQ8CYcYXBUg=", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.17.8" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/postcss": { + "version": "8.5.23", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/postcss/-/postcss-8.5.23.tgz", + "integrity": "sha1-NJNVARb0eEhymDAdLC6NxaVuZZQ=", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.16", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/preact": { + "version": "10.29.7", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/preact/-/preact-10.29.7.tgz", + "integrity": "sha1-tw3y6wbpgsesZbbfFUHlhGrA9ro=", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + }, + "peerDependencies": { + "preact-render-to-string": ">=5" + }, + "peerDependenciesMeta": { + "preact-render-to-string": { + "optional": true + } + } + }, "node_modules/priorityqueuejs": { "version": "2.0.0", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/priorityqueuejs/-/priorityqueuejs-2.0.0.tgz", "integrity": "sha1-lgZAQO3YR+6d0wE9jhYpc5mmvU8=", "license": "MIT" }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha1-Z9h78aaU9IQ1zzMsJK8QIUoxQLU=", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -1822,6 +3323,65 @@ "rc": "cli.js" } }, + "node_modules/react": { + "version": "19.2.8", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/react/-/react-19.2.8.tgz", + "integrity": "sha1-qAZj27WNacb+P9KR08syTop9/y0=", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.2.8", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/react-dom/-/react-dom-19.2.8.tgz", + "integrity": "sha1-O0a57tqHfN/yzxPSdw//SuNsLsI=", + "license": "MIT", + "dependencies": { + "scheduler": "^0.27.0" + }, + "peerDependencies": { + "react": "^19.2.8" + } + }, + "node_modules/react-globe.gl": { + "version": "2.38.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/react-globe.gl/-/react-globe.gl-2.38.0.tgz", + "integrity": "sha1-Ov5Z4/TKfuyJV//9Y6RDH7X4Ax0=", + "license": "MIT", + "dependencies": { + "globe.gl": "^2.46", + "prop-types": "15", + "react-kapsule": "^2.5" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "react": "*" + } + }, + "node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha1-eJcppNw23imZ3BVt1sHZwYzqVqQ=", + "license": "MIT" + }, + "node_modules/react-kapsule": { + "version": "2.6.0", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/react-kapsule/-/react-kapsule-2.6.0.tgz", + "integrity": "sha1-qSgTjsl6dpcMuCqv3fkVwjrvGVU=", + "license": "MIT", + "dependencies": { + "jerrypick": "^1.1.2" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "react": ">=16.13.1" + } + }, "node_modules/registry-auth-token": { "version": "3.3.2", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/registry-auth-token/-/registry-auth-token-3.3.2.tgz", @@ -1856,6 +3416,45 @@ "node": ">=0.10.0" } }, + "node_modules/robust-predicates": { + "version": "3.0.3", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/robust-predicates/-/robust-predicates-3.0.3.tgz", + "integrity": "sha1-EJkGGzNJ4sWr7GwqsKzUQNJNQGI=", + "license": "Unlicense" + }, + "node_modules/rolldown": { + "version": "1.1.5", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/rolldown/-/rolldown-1.1.5.tgz", + "integrity": "sha1-M5quJQhENR/FW3TiZS0+vW+6OJ0=", + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.139.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm64": "1.1.5", + "@rolldown/binding-darwin-arm64": "1.1.5", + "@rolldown/binding-darwin-x64": "1.1.5", + "@rolldown/binding-freebsd-x64": "1.1.5", + "@rolldown/binding-linux-arm-gnueabihf": "1.1.5", + "@rolldown/binding-linux-arm64-gnu": "1.1.5", + "@rolldown/binding-linux-arm64-musl": "1.1.5", + "@rolldown/binding-linux-ppc64-gnu": "1.1.5", + "@rolldown/binding-linux-s390x-gnu": "1.1.5", + "@rolldown/binding-linux-x64-gnu": "1.1.5", + "@rolldown/binding-linux-x64-musl": "1.1.5", + "@rolldown/binding-openharmony-arm64": "1.1.5", + "@rolldown/binding-wasm32-wasi": "1.1.5", + "@rolldown/binding-win32-arm64-msvc": "1.1.5", + "@rolldown/binding-win32-x64-msvc": "1.1.5" + } + }, "node_modules/router": { "version": "2.2.0", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/router/-/router-2.2.0.tgz", @@ -1905,6 +3504,12 @@ "url": "https://opencollective.com/express" } }, + "node_modules/rw": { + "version": "1.3.3", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/rw/-/rw-1.3.3.tgz", + "integrity": "sha1-P4Yt+pGrdmsUiF700BEkv9oHT7Q=", + "license": "BSD-3-Clause" + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1932,6 +3537,12 @@ "integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=", "license": "MIT" }, + "node_modules/scheduler": { + "version": "0.27.0", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/scheduler/-/scheduler-0.27.0.tgz", + "integrity": "sha1-DE74LWfR5cHjWej8dtOofwRf5b0=", + "license": "MIT" + }, "node_modules/semaphore": { "version": "1.1.0", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/semaphore/-/semaphore-1.1.0.tgz", @@ -2197,6 +3808,21 @@ "dev": true, "license": "ISC" }, + "node_modules/simplesignal": { + "version": "2.1.7", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/simplesignal/-/simplesignal-2.1.7.tgz", + "integrity": "sha1-jhWXix+LRNVb19cIHcN7cUfPEp8=", + "license": "MIT" + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha1-HOVlD93YerwJnto33P8CTCZnrkY=", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/statuses": { "version": "2.0.2", "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/statuses/-/statuses-2.0.2.tgz", @@ -2273,6 +3899,139 @@ "node": ">=8" } }, + "node_modules/three": { + "version": "0.185.1", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/three/-/three-0.185.1.tgz", + "integrity": "sha1-Y+niQaF7EB4hGWUSGgF7S02AVK4=", + "license": "MIT" + }, + "node_modules/three-conic-polygon-geometry": { + "version": "2.1.3", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/three-conic-polygon-geometry/-/three-conic-polygon-geometry-2.1.3.tgz", + "integrity": "sha1-JSahkngDM2dhFu49c1HUKXVJLZ0=", + "license": "MIT", + "dependencies": { + "@turf/boolean-point-in-polygon": "^7.2", + "d3-array": "1 - 3", + "d3-geo": "1 - 3", + "d3-geo-voronoi": "2", + "d3-scale": "1 - 4", + "delaunator": "5", + "earcut": "3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.72.0" + } + }, + "node_modules/three-geojson-geometry": { + "version": "2.1.1", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/three-geojson-geometry/-/three-geojson-geometry-2.1.1.tgz", + "integrity": "sha1-F6FTTHqAL9rynMCI9A9An+U+DKY=", + "license": "MIT", + "dependencies": { + "d3-geo": "1 - 3", + "d3-interpolate": "1 - 3", + "earcut": "3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.72.0" + } + }, + "node_modules/three-globe": { + "version": "2.45.2", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/three-globe/-/three-globe-2.45.2.tgz", + "integrity": "sha1-/ZRYciezYWhSreUN2q8M0g2oSYo=", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "d3-array": "3", + "d3-color": "3", + "d3-geo": "3", + "d3-interpolate": "3", + "d3-scale": "4", + "d3-scale-chromatic": "3", + "data-bind-mapper": "1", + "frame-ticker": "1", + "h3-js": "4", + "index-array-by": "1", + "kapsule": "^1.16", + "three-conic-polygon-geometry": "2", + "three-geojson-geometry": "2", + "three-slippy-map-globe": "1", + "tinycolor2": "1" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.154" + } + }, + "node_modules/three-render-objects": { + "version": "1.42.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/three-render-objects/-/three-render-objects-1.42.0.tgz", + "integrity": "sha1-Mq0ab4PsuS7GdXPHn3hltE1JGqY=", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "float-tooltip": "^1.7", + "kapsule": "^1.16", + "polished": "4" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.179" + } + }, + "node_modules/three-slippy-map-globe": { + "version": "1.0.6", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/three-slippy-map-globe/-/three-slippy-map-globe-1.0.6.tgz", + "integrity": "sha1-zFFyijKILITrIZ0ezsdUmdJJKyU=", + "license": "MIT", + "dependencies": { + "d3-geo": "1 - 3", + "d3-octree": "^1.1", + "d3-scale": "1 - 4" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.154" + } + }, + "node_modules/tinycolor2": { + "version": "1.6.0", + "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/tinycolor2/-/tinycolor2-1.6.0.tgz", + "integrity": "sha1-+YAHRgFpsCY7lwcsWukkhM4C0J4=", + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha1-ViqabJ6ys7Ej05cZ+a9btE/NdjE=", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/toidentifier/-/toidentifier-1.0.1.tgz", @@ -2377,6 +4136,83 @@ "node": ">= 0.8" } }, + "node_modules/vite": { + "version": "8.1.5", + "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/vite/-/vite-8.1.5.tgz", + "integrity": "sha1-zP/OPuSHsYhiI7JOuye5FnSCfTA=", + "license": "MIT", + "dependencies": { + "lightningcss": "^1.32.0", + "picomatch": "^4.0.5", + "postcss": "^8.5.17", + "rolldown": "~1.1.5", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.3.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, "node_modules/web-streams-polyfill": { "version": "3.3.3", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", diff --git a/package.json b/package.json index 3b31212..f2069de 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,10 @@ "version": "1.0.0", "description": "Interactive 3D globe visualization of top GitHub developers", "scripts": { - "dev": "node server.js", + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "server": "node server.js", "build-data": "node scripts/build-dataset.js", "fetch-github": "node scripts/fetch-github.js", "fetch-stackoverflow": "node scripts/fetch-stackoverflow.js", @@ -12,9 +15,16 @@ }, "dependencies": { "@azure/cosmos": "^4.10.0", + "@vercel/analytics": "^2.0.1", + "@vitejs/plugin-react": "^6.0.4", + "d3": "^7.9.0", "dotenv": "^16.4.5", "express": "^5.2.1", - "node-fetch": "^3.3.2" + "node-fetch": "^3.3.2", + "react": "^19.2.8", + "react-dom": "^19.2.8", + "react-globe.gl": "^2.38.0", + "vite": "^8.1.5" }, "devDependencies": { "serve": "^14.2.0" diff --git a/scripts/check-data.js b/scripts/check-data.js new file mode 100644 index 0000000..20032c9 --- /dev/null +++ b/scripts/check-data.js @@ -0,0 +1,36 @@ +import { CosmosClient } from '@azure/cosmos'; +import dotenv from 'dotenv'; +dotenv.config(); + +const client = new CosmosClient({ endpoint: process.env.COSMOS_ENDPOINT, key: process.env.COSMOS_KEY }); +const container = client.database('devglobe').container('developers'); + +// Sample some developers to check field completeness +const { resources: sample } = await container.items.query( + 'SELECT TOP 5 c.login, c.totalStars, c.totalCommits, c.totalForks, c.followers, c.topLanguage, c.soReputation, c.soAnswers, c.topRepos, c.languages FROM c ORDER BY c.followers DESC' +).fetchAll(); + +console.log('=== Top 5 by followers ==='); +sample.forEach(d => { + console.log(` ${d.login}: stars=${d.totalStars ?? 'MISSING'}, commits=${d.totalCommits ?? 'MISSING'}, forks=${d.totalForks ?? 'MISSING'}, lang=${d.topLanguage ?? 'MISSING'}, soRep=${d.soReputation ?? 'MISSING'}, repos=${d.topRepos?.length ?? 'MISSING'}, langs=${d.languages?.length ?? 'MISSING'}`); +}); + +// Count missing fields +const queries = [ + ['totalStars = 0 or missing', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.totalStars) OR c.totalStars = 0"], + ['totalCommits = 0 or missing', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.totalCommits) OR c.totalCommits = 0"], + ['totalForks = 0 or missing', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.totalForks) OR c.totalForks = 0"], + ['topLanguage missing', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.topLanguage) OR c.topLanguage = null"], + ['soReputation = 0', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.soReputation) OR c.soReputation = 0"], + ['topRepos missing', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.topRepos) OR ARRAY_LENGTH(c.topRepos) = 0"], + ['languages missing', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.languages) OR ARRAY_LENGTH(c.languages) = 0"], + ['location missing', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.location) OR c.location = null"], + ['lat/lng missing', "SELECT VALUE COUNT(1) FROM c WHERE NOT IS_DEFINED(c.lat) OR c.lat = null"], + ['total', "SELECT VALUE COUNT(1) FROM c"], +]; + +console.log('\n=== Data completeness (out of total) ==='); +for (const [label, query] of queries) { + const { resources } = await container.items.query(query).fetchAll(); + console.log(` ${label}: ${resources[0]}`); +} diff --git a/scripts/enrich-and-upload.js b/scripts/enrich-and-upload.js deleted file mode 100644 index 8fbd578..0000000 --- a/scripts/enrich-and-upload.js +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Enrich & Upload — Takes existing github-raw.json, adds SO + geocoding, uploads to Cosmos DB - * - * Skips the slow GitHub fetch (already done). Focuses on enrichment + upload. - * Run: node scripts/enrich-and-upload.js > enrich.log 2>&1 - */ -import 'dotenv/config'; -import { CosmosClient } from '@azure/cosmos'; -import { writeFileSync, readFileSync, existsSync } from 'fs'; - -const SO_API_KEY = process.env.SO_API_KEY || ''; -const SO_ACCESS_TOKEN = process.env.SO_ACCESS_TOKEN || ''; -const GEOCODE_API_KEY = process.env.GEOCODE_API_KEY || ''; -const COSMOS_ENDPOINT = process.env.COSMOS_ENDPOINT || 'https://devglobe-cosmos.documents.azure.com:443/'; -const COSMOS_KEY = process.env.COSMOS_KEY; - -if (!COSMOS_KEY) { console.error('COSMOS_KEY required in .env'); process.exit(1); } - -function log(msg) { console.log(`[${new Date().toISOString()}] ${msg}`); } -function sleep(ms) { return new Promise(r => setTimeout(r, ms)); } - -// ============ STACKOVERFLOW ============ -// Alternate between key-only and access_token calls for 20K/day total -let useAccessToken = false; - -async function fetchSO(login) { - if (!SO_API_KEY) return null; - let url = `https://api.stackexchange.com/2.3/users?order=desc&sort=reputation&inname=${encodeURIComponent(login)}&site=stackoverflow&key=${SO_API_KEY}&pagesize=1&filter=!nNPvSNVZJS`; - - // Alternate with access_token for separate quota - if (SO_ACCESS_TOKEN && useAccessToken) { - url += `&access_token=${SO_ACCESS_TOKEN}`; - } - useAccessToken = !useAccessToken; - - try { - const res = await fetch(url); - if (!res.ok) return null; - const data = await res.json(); - if (data.backoff) { log(` SO backoff: ${data.backoff}s`); await sleep(data.backoff * 1000); } - if (data.items?.[0]) { - const u = data.items[0]; - return { soUserId: u.user_id, soReputation: u.reputation || 0, soAnswers: u.answer_count || 0, soAcceptRate: u.accept_rate || 0, soBadges: (u.badge_counts?.gold||0)+(u.badge_counts?.silver||0)+(u.badge_counts?.bronze||0) }; - } - } catch(e) {} - return null; -} - -// ============ GEOCODING ============ -const geoCache = new Map(); -async function geocode(location) { - if (!location || !GEOCODE_API_KEY) return { lat: null, lng: null }; - if (geoCache.has(location)) return geoCache.get(location); - try { - const res = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${encodeURIComponent(location)}&key=${GEOCODE_API_KEY}&limit=1&no_annotations=1`); - if (!res.ok) { geoCache.set(location, {lat:null,lng:null}); return {lat:null,lng:null}; } - const data = await res.json(); - if (data.results?.[0]) { - const {lat, lng} = data.results[0].geometry; - geoCache.set(location, {lat,lng}); - return {lat,lng}; - } - } catch(e) {} - geoCache.set(location, {lat:null,lng:null}); - return {lat:null,lng:null}; -} - -// ============ MAIN ============ -async function main() { - const start = Date.now(); - log('Loading github-raw.json...'); - const devs = JSON.parse(readFileSync('data/github-raw.json', 'utf-8')); - log(`Loaded ${devs.length} developers`); - - // SO enrichment - log('\n--- SO Enrichment ---'); - let soCount = 0; - for (let i = 0; i < devs.length; i++) { - const dev = devs[i]; - if (/^[a-zA-Z0-9_-]+$/.test(dev.login)) { - const so = await fetchSO(dev.login); - if (so) { Object.assign(dev, so); soCount++; } - await sleep(400); - } - dev.soUserId = dev.soUserId || null; - dev.soReputation = dev.soReputation || 0; - dev.soAnswers = dev.soAnswers || 0; - dev.soAcceptRate = dev.soAcceptRate || 0; - dev.soBadges = dev.soBadges || 0; - - if ((i+1) % 100 === 0) log(` SO: ${i+1}/${devs.length} (matched: ${soCount})`); - } - log(` SO done: ${soCount} matched\n`); - - // Geocoding - log('--- Geocoding ---'); - let geoCount = 0; - for (let i = 0; i < devs.length; i++) { - const {lat, lng} = await geocode(devs[i].location); - devs[i].lat = lat; - devs[i].lng = lng; - if (lat) geoCount++; - // Only delay for non-cached lookups (1 req/sec free tier) - if (!geoCache.has(devs[i].location)) await sleep(1100); - if ((i+1) % 100 === 0) log(` Geo: ${i+1}/${devs.length} (resolved: ${geoCount})`); - } - log(` Geo done: ${geoCount} resolved\n`); - - // Scoring - log('--- Scoring ---'); - const maxV = { - stars: Math.max(1,...devs.map(d=>d.totalStars||0)), - commits: Math.max(1,...devs.map(d=>d.totalCommits||0)), - forks: Math.max(1,...devs.map(d=>d.totalForks||0)), - soRep: Math.max(1,...devs.map(d=>d.soReputation||0)), - followers: Math.max(1,...devs.map(d=>d.followers||0)) - }; - const norm = (v,m) => Math.log(1+v)/Math.log(1+m); - - devs.forEach(dev => { - const dims = { - stars: norm(dev.totalStars||0, maxV.stars), - commits: norm(dev.totalCommits||0, maxV.commits), - repoReach: norm(dev.totalForks||0, maxV.forks), - soReputation: norm(dev.soReputation||0, maxV.soRep), - soEngagement: norm(((dev.soAcceptRate||0)/100)*(dev.soAnswers||0), 1000), - community: norm(dev.followers||0, maxV.followers) - }; - dev.score = Math.round((dims.stars*0.25 + dims.commits*0.25 + dims.repoReach*0.20 + dims.soReputation*0.15 + dims.soEngagement*0.10 + dims.community*0.05)*100); - dev.scoreDimensions = dims; - }); - devs.sort((a,b) => b.score - a.score); - log(` Scored ${devs.length} developers`); - - // Save locally - writeFileSync('data/developers.json', JSON.stringify(devs, null, 2)); - log(` Saved data/developers.json\n`); - - // Upload to Cosmos DB - log('--- Uploading to Cosmos DB ---'); - const client = new CosmosClient({ endpoint: COSMOS_ENDPOINT, key: COSMOS_KEY }); - const container = client.database('devglobe').container('developers'); - - let uploaded = 0, errors = 0; - for (let i = 0; i < devs.length; i += 25) { - const batch = devs.slice(i, i + 25); - await Promise.all(batch.map(async dev => { - try { - await container.items.upsert({ ...dev, id: dev.login, location: dev.location || 'Unknown' }); - uploaded++; - } catch(e) { errors++; } - })); - if ((i+25) % 100 === 0 || i+25 >= devs.length) log(` Cosmos: ${uploaded}/${devs.length} uploaded`); - } - - const mins = ((Date.now()-start)/60000).toFixed(1); - log(`\n═══ COMPLETE in ${mins} min ═══`); - log(` Developers: ${devs.length}`); - log(` SO enriched: ${soCount}`); - log(` Geocoded: ${geoCount}`); - log(` Cosmos: ${uploaded} uploaded, ${errors} errors`); -} - -main().catch(e => { log(`FATAL: ${e.message}`); process.exit(1); }); diff --git a/scripts/enrich-data.js b/scripts/enrich-data.js new file mode 100644 index 0000000..7d615c8 --- /dev/null +++ b/scripts/enrich-data.js @@ -0,0 +1,276 @@ +/** + * Enrich developers — adds real commit counts, better star/fork totals, + * and deduplicates records in Cosmos DB. + * + * Uses GitHub GraphQL API (batching 20 users per request, 1 point each). + */ +import { CosmosClient } from '@azure/cosmos'; +import dotenv from 'dotenv'; +import fs from 'fs'; + +dotenv.config(); + +const GITHUB_TOKEN = process.env.GITHUB_TOKEN; +const COSMOS_ENDPOINT = process.env.COSMOS_ENDPOINT; +const COSMOS_KEY = process.env.COSMOS_KEY; + +const client = new CosmosClient({ endpoint: COSMOS_ENDPOINT, key: COSMOS_KEY }); +const container = client.database('devglobe').container('developers'); + +const BATCH_SIZE = 10; +const CHECKPOINT_FILE = 'data/enrich-checkpoint.json'; + +// ─── Load/save checkpoint ─────────────────────────────────────────────────── +function loadCheckpoint() { + try { return JSON.parse(fs.readFileSync(CHECKPOINT_FILE, 'utf8')); } + catch { return { enriched: [], deduped: false }; } +} + +function saveCheckpoint(cp) { + fs.mkdirSync('data', { recursive: true }); + fs.writeFileSync(CHECKPOINT_FILE, JSON.stringify(cp)); +} + +// ─── Step 1: Deduplicate ──────────────────────────────────────────────────── +async function deduplicate() { + console.log('\n📋 Step 1: Finding duplicates...'); + + const { resources } = await container.items.query( + 'SELECT c.id, c.login, c.totalStars, c.totalCommits, c.followers, c.topLanguage, c.location FROM c' + ).fetchAll(); + + // Group by login + const byLogin = new Map(); + for (const dev of resources) { + if (!byLogin.has(dev.login)) byLogin.set(dev.login, []); + byLogin.get(dev.login).push(dev); + } + + const duplicates = [...byLogin.entries()].filter(([, docs]) => docs.length > 1); + console.log(` Found ${duplicates.length} logins with duplicates`); + + let deleted = 0; + for (const [login, docs] of duplicates) { + // Keep the doc with the most data (highest totalStars + totalCommits + followers) + docs.sort((a, b) => { + const scoreA = (a.totalStars || 0) + (a.totalCommits || 0) + (a.followers || 0) + (a.topLanguage ? 100 : 0); + const scoreB = (b.totalStars || 0) + (b.totalCommits || 0) + (b.followers || 0) + (b.topLanguage ? 100 : 0); + return scoreB - scoreA; + }); + + // Delete all but the best one + for (let i = 1; i < docs.length; i++) { + try { + await container.item(docs[i].id, docs[i].location || 'Unknown').delete(); + deleted++; + } catch (err) { + // Try without partition key match + try { + const { resources: found } = await container.items.query({ + query: 'SELECT * FROM c WHERE c.id = @id', + parameters: [{ name: '@id', value: docs[i].id }] + }).fetchAll(); + if (found.length > 0) { + await container.item(found[0].id, found[0].location).delete(); + deleted++; + } + } catch { /* skip */ } + } + } + } + + console.log(` ✅ Deleted ${deleted} duplicate records`); + return deleted; +} + +// ─── Step 2: Enrich with commits + better repo data ──────────────────────── +async function fetchEnrichmentBatch(logins) { + const fragments = logins.map((login, i) => { + const alias = `u${i}`; + return `${alias}: user(login: "${login.replace(/"/g, '')}") { + login + contributionsCollection { + contributionCalendar { totalContributions } + } + repositories(first: 10, orderBy: {field: STARGAZERS, direction: DESC}, ownerAffiliations: OWNER) { + totalCount + nodes { name stargazerCount forkCount primaryLanguage { name } } + } + }`; + }); + + const query = `query { ${fragments.join('\n')} }`; + + for (let attempt = 0; attempt < 5; attempt++) { + const resp = await fetch('https://api.github.com/graphql', { + method: 'POST', + headers: { + 'Authorization': `Bearer ${GITHUB_TOKEN}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ query }), + signal: AbortSignal.timeout(45000), + }).catch(err => { + console.log(` ⚠ Fetch error: ${err.message?.slice(0, 60)}`); + return null; + }); + + if (!resp) { await new Promise(r => setTimeout(r, 5000)); continue; } + + if (resp.status === 200) { + let json; + try { + json = await resp.json(); + } catch (e) { + console.log(` ⚠ JSON parse error, retrying...`); + await new Promise(r => setTimeout(r, 3000)); + continue; + } + if (json.errors && !json.data) return []; + const users = []; + for (let i = 0; i < logins.length; i++) { + const userData = json.data?.[`u${i}`]; + if (userData) users.push(userData); + } + return users; + } + + if (resp.status === 403 || resp.status === 429) { + const reset = resp.headers.get('x-ratelimit-reset'); + const waitSec = reset ? Math.max(0, parseInt(reset) - Math.floor(Date.now() / 1000)) + 5 : 65; + console.log(` ⏳ Rate limited, waiting ${waitSec}s...`); + await new Promise(r => setTimeout(r, waitSec * 1000)); + continue; + } + + if (resp.status === 502 || resp.status === 503) { + await new Promise(r => setTimeout(r, (attempt + 1) * 5000)); + continue; + } + + await new Promise(r => setTimeout(r, 5000)); + } + return []; +} + +function processEnrichment(user) { + const repos = user.repositories?.nodes || []; + const totalStars = repos.reduce((s, r) => s + (r?.stargazerCount || 0), 0); + const totalForks = repos.reduce((s, r) => s + (r?.forkCount || 0), 0); + const totalCommits = user.contributionsCollection?.contributionCalendar?.totalContributions || 0; + + const langCounts = {}; + repos.forEach(r => { + const lang = r?.primaryLanguage?.name; + if (lang) langCounts[lang] = (langCounts[lang] || 0) + 1; + }); + const topLanguage = Object.entries(langCounts).sort((a, b) => b[1] - a[1])[0]?.[0] || null; + + return { + totalStars, + totalForks, + totalCommits, + topLanguage, + publicRepos: user.repositories?.totalCount || 0, + languages: Object.entries(langCounts).sort((a, b) => b[1] - a[1]).slice(0, 6) + .map(([name, count]) => ({ name, percent: Math.round((count / (repos.length || 1)) * 100) })), + topRepos: repos.filter(r => r).slice(0, 10).map(r => ({ + name: r.name, stars: r.stargazerCount, forks: r.forkCount + })), + }; +} + +async function enrichDevs() { + console.log('\n📊 Step 2: Enriching developers with commits & repo data...'); + + const cp = loadCheckpoint(); + const enrichedSet = new Set(cp.enriched); + + // Get all devs that need enrichment (commits = 0 or missing topLanguage) + const { resources: needsEnrich } = await container.items.query( + 'SELECT c.id, c.login, c.location FROM c WHERE c.totalCommits = 0 OR NOT IS_DEFINED(c.topLanguage) OR c.topLanguage = null' + ).fetchAll(); + + // Filter out already-enriched + const remaining = needsEnrich.filter(d => !enrichedSet.has(d.login)); + console.log(` Found ${needsEnrich.length} needing enrichment, ${remaining.length} remaining after checkpoint`); + + let processed = enrichedSet.size; + let errors = 0; + + for (let i = 0; i < remaining.length; i += BATCH_SIZE) { + const batch = remaining.slice(i, i + BATCH_SIZE); + console.log(` [batch ${i / BATCH_SIZE}] Fetching ${batch.length} users from GitHub...`); + const users = await fetchEnrichmentBatch(batch.map(d => d.login)); + console.log(` [batch ${i / BATCH_SIZE}] Got ${users.length} users, patching Cosmos...`); + + const enrichMap = new Map(); + for (const user of users) { + enrichMap.set(user.login, processEnrichment(user)); + } + + // Patch Cosmos DB (10 concurrent, with 15s timeout per patch) + for (let p = 0; p < batch.length; p += 10) { + const chunk = batch.slice(p, p + 10); + await Promise.all(chunk.map(async (dev) => { + const enrichData = enrichMap.get(dev.login); + if (!enrichData) return; + try { + const operations = [ + { op: 'set', path: '/totalCommits', value: enrichData.totalCommits }, + { op: 'set', path: '/totalStars', value: enrichData.totalStars }, + { op: 'set', path: '/totalForks', value: enrichData.totalForks }, + { op: 'set', path: '/publicRepos', value: enrichData.publicRepos }, + { op: 'set', path: '/topRepos', value: enrichData.topRepos }, + { op: 'set', path: '/languages', value: enrichData.languages }, + ]; + if (enrichData.topLanguage) { + operations.push({ op: 'set', path: '/topLanguage', value: enrichData.topLanguage }); + } + const patchPromise = container.item(dev.id, dev.location || 'Unknown').patch({ operations }); + const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), 15000)); + await Promise.race([patchPromise, timeout]); + enrichedSet.add(dev.login); + } catch (err) { + if (errors < 5) console.log(` ⚠ Patch error ${dev.login}: ${err.message?.slice(0, 50)}`); + errors++; + } + })); + } + + processed += batch.length; + console.log(` Enriched: ${processed}/${needsEnrich.length} (errors: ${errors})`); + if (processed % 200 === 0 || i + BATCH_SIZE >= remaining.length) { + cp.enriched = [...enrichedSet]; + saveCheckpoint(cp); + } + } + + console.log(` ✅ Enrichment complete. ${processed} processed, ${errors} errors`); +} + +// ─── Main ─────────────────────────────────────────────────────────────────── +async function main() { + console.log('🔧 Developer Data Enrichment'); + console.log('============================\n'); + + // Step 1: Deduplicate + const cp = loadCheckpoint(); + if (!cp.deduped) { + await deduplicate(); + cp.deduped = true; + saveCheckpoint(cp); + } else { + console.log('📋 Step 1: Dedup already done, skipping'); + } + + // Step 2: Enrich (commits, stars, repos) + await enrichDevs(); + + console.log('\n🎉 All done!'); +} + +main().catch(err => { + console.error('Fatal error:', err); + process.exit(1); +}); diff --git a/scripts/generate-embeddings.js b/scripts/generate-embeddings.js index 7885b1c..784cf25 100644 --- a/scripts/generate-embeddings.js +++ b/scripts/generate-embeddings.js @@ -80,29 +80,40 @@ async function main() { console.log(` Found ${developers.length} developers needing embeddings\n`); let processed = 0; + let errors = 0; for (let i = 0; i < developers.length; i += BATCH_SIZE) { const batch = developers.slice(i, i + BATCH_SIZE); const texts = batch.map(buildEmbeddingText); // Generate embeddings - const embeddings = await getEmbeddings(texts); - - // Patch each document with its embedding - for (let j = 0; j < batch.length; j++) { - const dev = batch[j]; - await container.item(dev.id, dev.location || '').patch({ - operations: [ - { op: 'add', path: '/embedding', value: embeddings[j] } - ] - }); + let embeddings; + try { + embeddings = await getEmbeddings(texts); + } catch (err) { + console.log(` ⚠ Embedding API error at ${i}: ${err.message.slice(0, 80)}`); + await new Promise(r => setTimeout(r, 5000)); + try { embeddings = await getEmbeddings(texts); } catch { errors += batch.length; continue; } + } + + // Patch documents in parallel (10 concurrent) + const CONCURRENCY = 10; + for (let c = 0; c < batch.length; c += CONCURRENCY) { + const chunk = batch.slice(c, c + CONCURRENCY); + await Promise.all(chunk.map(async (dev, idx) => { + try { + await container.item(dev.id, dev.location || '').patch({ + operations: [{ op: 'add', path: '/embedding', value: embeddings[c + idx] }] + }); + } catch { errors++; } + })); } processed += batch.length; - console.log(` Embedded: ${processed}/${developers.length}`); + console.log(` Embedded: ${processed}/${developers.length} (errors: ${errors})`); - // Rate limit: ~3 requests/sec for embedding API + // Rate limit for embedding API if (i + BATCH_SIZE < developers.length) { - await new Promise(r => setTimeout(r, 400)); + await new Promise(r => setTimeout(r, 300)); } } diff --git a/scripts/pipeline-background.js b/scripts/pipeline-background.js deleted file mode 100644 index 03856de..0000000 --- a/scripts/pipeline-background.js +++ /dev/null @@ -1,403 +0,0 @@ -/** - * Full Background Pipeline — Fetch GitHub + SO + Geocode → Insert into Cosmos DB - * - * Run and go to sleep: - * node scripts/pipeline-background.js > pipeline.log 2>&1 - * - * Or on Windows: - * Start-Process -NoNewWindow -FilePath node -ArgumentList "scripts/pipeline-background.js" -RedirectStandardOutput pipeline.log -RedirectStandardError pipeline-err.log - * - * Progress is logged to pipeline.log. Check results in Cosmos DB when you wake up. - */ -import 'dotenv/config'; -import { CosmosClient } from '@azure/cosmos'; -import { writeFileSync, readFileSync, existsSync, mkdirSync, appendFileSync } from 'fs'; - -// ============ CONFIG ============ -const GITHUB_TOKEN = process.env.GITHUB_TOKEN; -const SO_API_KEY = process.env.SO_API_KEY || ''; -const GEOCODE_API_KEY = process.env.GEOCODE_API_KEY || ''; -const COSMOS_ENDPOINT = process.env.COSMOS_ENDPOINT || 'https://devglobe-cosmos.documents.azure.com:443/'; -const COSMOS_KEY = process.env.COSMOS_KEY; - -if (!GITHUB_TOKEN) { console.error('GITHUB_TOKEN required'); process.exit(1); } -if (!COSMOS_KEY) { console.error('COSMOS_KEY required'); process.exit(1); } - -const DATABASE_NAME = 'devglobe'; -const CONTAINER_NAME = 'developers'; -const LOG_FILE = 'pipeline.log'; - -function log(msg) { - const line = `[${new Date().toISOString()}] ${msg}`; - console.log(line); -} - -// ============ GITHUB FETCH ============ -const GRAPHQL_URL = 'https://api.github.com/graphql'; - -const COUNTRY_QUERIES = [ - 'United States', 'San Francisco', 'New York', 'Seattle', 'Los Angeles', - 'China', 'Beijing', 'Shanghai', 'Shenzhen', - 'India', 'Bangalore', 'Mumbai', 'Delhi', 'Hyderabad', - 'United Kingdom', 'London', - 'Germany', 'Berlin', 'Munich', - 'Brazil', 'São Paulo', 'Rio de Janeiro', - 'Canada', 'Toronto', 'Vancouver', - 'France', 'Paris', - 'Japan', 'Tokyo', 'Osaka', - 'Australia', 'Sydney', 'Melbourne', - 'Russia', 'Moscow', 'Saint Petersburg', - 'Netherlands', 'Amsterdam', - 'Sweden', 'Stockholm', - 'South Korea', 'Seoul', - 'Israel', 'Tel Aviv', - 'Singapore', - 'Poland', 'Warsaw', 'Krakow', - 'Spain', 'Barcelona', 'Madrid', - 'Italy', 'Milan', 'Rome', - 'Switzerland', 'Zurich', - 'Indonesia', 'Jakarta', - 'Turkey', 'Istanbul', - 'Nigeria', 'Lagos', - 'Argentina', 'Buenos Aires', - 'Ukraine', 'Kyiv', - 'Vietnam', 'Ho Chi Minh', - 'Taiwan', 'Taipei', - 'Mexico', 'Mexico City', - 'Ireland', 'Dublin', - 'Finland', 'Helsinki', - 'Denmark', 'Copenhagen', - 'Norway', 'Oslo', - 'Austria', 'Vienna', - 'Portugal', 'Lisbon', - 'Czech Republic', 'Prague', - 'New Zealand', 'Auckland', - 'Thailand', 'Bangkok', - 'Pakistan', 'Karachi', 'Lahore', - 'Colombia', 'Bogota', 'Medellin', - 'Kenya', 'Nairobi', - 'South Africa', 'Cape Town', 'Johannesburg', - 'Egypt', 'Cairo', - 'Chile', 'Santiago', - 'Philippines', 'Manila', - 'Bangladesh', 'Dhaka', - 'Romania', 'Bucharest', - 'Hungary', 'Budapest', - 'Greece', 'Athens', - 'Malaysia', 'Kuala Lumpur', - 'Peru', 'Lima', - 'Sri Lanka', 'Colombo', - 'Morocco', 'Casablanca', - 'Ghana', 'Accra', - 'Ethiopia', 'Addis Ababa', - 'Nepal', 'Kathmandu' -]; - -async function graphql(query, variables = {}) { - const response = await fetch(GRAPHQL_URL, { - method: 'POST', - headers: { - 'Authorization': `Bearer ${GITHUB_TOKEN}`, - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ query, variables }), - }); - - if (response.status === 403 || response.status === 429) { - log(' Rate limited, waiting 60s...'); - await sleep(60000); - return graphql(query, variables); - } - - if (!response.ok) { - throw new Error(`GitHub API ${response.status}: ${await response.text()}`); - } - - const data = await response.json(); - if (data.errors) { - // Partial data is OK — just log - log(` GraphQL warnings: ${data.errors[0]?.message}`); - } - return data.data; -} - -async function fetchGitHubUsers(location, first = 20) { - const gql = ` - query($query: String!, $first: Int!) { - search(query: $query, type: USER, first: $first) { - nodes { - ... on User { - login - name - avatarUrl - location - followers { totalCount } - repositories(first: 5, orderBy: {field: STARGAZERS, direction: DESC}, ownerAffiliations: OWNER) { - totalCount - nodes { - name - stargazerCount - forkCount - primaryLanguage { name } - } - } - contributionsCollection { - totalCommitContributions - restrictedContributionsCount - } - } - } - } - } - `; - - const query = `location:"${location}" followers:>100 repos:>5`; - const data = await graphql(gql, { query, first }); - - if (!data?.search?.nodes) return []; - - return data.search.nodes - .filter(u => u && u.login) // Filter null/org nodes - .map(u => { - const repos = u.repositories?.nodes || []; - return { - login: u.login, - name: u.name || u.login, - avatarUrl: u.avatarUrl, - location: u.location || location, - followers: u.followers?.totalCount || 0, - totalStars: repos.reduce((s, r) => s + (r?.stargazerCount || 0), 0), - totalForks: repos.reduce((s, r) => s + (r?.forkCount || 0), 0), - totalCommits: (u.contributionsCollection?.totalCommitContributions || 0) + - (u.contributionsCollection?.restrictedContributionsCount || 0), - topLanguage: repos.find(r => r?.primaryLanguage)?.primaryLanguage?.name || null, - topRepos: repos.slice(0, 3).map(r => ({ - name: r?.name, stars: r?.stargazerCount || 0, forks: r?.forkCount || 0 - })) - }; - }); -} - -// ============ STACKOVERFLOW FETCH ============ -async function fetchSOReputation(login) { - if (!SO_API_KEY) return null; - - const url = `https://api.stackexchange.com/2.3/users?order=desc&sort=reputation&inname=${encodeURIComponent(login)}&site=stackoverflow&key=${SO_API_KEY}&pagesize=1&filter=!nNPvSNVZJS`; - - try { - const res = await fetch(url); - if (res.status === 429) return null; // Skip on rate limit - if (!res.ok) return null; - - const data = await res.json(); - if (data.items && data.items.length > 0) { - const user = data.items[0]; - return { - soUserId: user.user_id, - soReputation: user.reputation || 0, - soAnswers: user.answer_count || 0, - soAcceptRate: user.accept_rate || 0, - soBadges: (user.badge_counts?.gold || 0) + (user.badge_counts?.silver || 0) + (user.badge_counts?.bronze || 0) - }; - } - } catch (e) { /* skip */ } - return null; -} - -// ============ GEOCODING ============ -const geoCache = new Map(); - -async function geocodeLocation(location) { - if (!location || !GEOCODE_API_KEY) return { lat: null, lng: null }; - if (geoCache.has(location)) return geoCache.get(location); - - try { - const url = `https://api.opencagedata.com/geocode/v1/json?q=${encodeURIComponent(location)}&key=${GEOCODE_API_KEY}&limit=1&no_annotations=1`; - const res = await fetch(url); - if (!res.ok) { geoCache.set(location, { lat: null, lng: null }); return { lat: null, lng: null }; } - - const data = await res.json(); - if (data.results && data.results.length > 0) { - const { lat, lng } = data.results[0].geometry; - geoCache.set(location, { lat, lng }); - return { lat, lng }; - } - } catch (e) { /* skip */ } - - geoCache.set(location, { lat: null, lng: null }); - return { lat: null, lng: null }; -} - -// ============ SCORING ============ -function scoreDevs(developers) { - const maxValues = { - stars: Math.max(1, ...developers.map(d => d.totalStars || 0)), - commits: Math.max(1, ...developers.map(d => d.totalCommits || 0)), - repoReach: Math.max(1, ...developers.map(d => (d.totalForks || 0))), - soReputation: Math.max(1, ...developers.map(d => d.soReputation || 0)), - community: Math.max(1, ...developers.map(d => d.followers || 0)) - }; - - return developers.map(dev => { - const norm = (val, max) => Math.log(1 + val) / Math.log(1 + max); - const dims = { - stars: norm(dev.totalStars || 0, maxValues.stars), - commits: norm(dev.totalCommits || 0, maxValues.commits), - repoReach: norm(dev.totalForks || 0, maxValues.repoReach), - soReputation: norm(dev.soReputation || 0, maxValues.soReputation), - soEngagement: norm(((dev.soAcceptRate || 0) / 100) * (dev.soAnswers || 0), 1000), - community: norm(dev.followers || 0, maxValues.community) - }; - - const score = Math.round( - (dims.stars * 0.25 + dims.commits * 0.25 + dims.repoReach * 0.20 + - dims.soReputation * 0.15 + dims.soEngagement * 0.10 + dims.community * 0.05) * 100 - ); - - return { ...dev, score, scoreDimensions: dims }; - }); -} - -// ============ UTILITIES ============ -function sleep(ms) { return new Promise(r => setTimeout(r, ms)); } - -// ============ MAIN PIPELINE ============ -async function main() { - const startTime = Date.now(); - log('═══════════════════════════════════════════'); - log(' DevGlobe Full Pipeline → Cosmos DB'); - log('═══════════════════════════════════════════'); - - mkdirSync('data', { recursive: true }); - - // STEP 1: Fetch GitHub data - log('\n📡 STEP 1: Fetching GitHub developers...'); - const allDevs = new Map(); - - for (let i = 0; i < COUNTRY_QUERIES.length; i++) { - const location = COUNTRY_QUERIES[i]; - log(` [${i + 1}/${COUNTRY_QUERIES.length}] Searching: ${location}`); - - try { - const users = await fetchGitHubUsers(location); - users.forEach(u => { - if (!allDevs.has(u.login)) { - allDevs.set(u.login, u); - } - }); - log(` Found ${users.length} users (total unique: ${allDevs.size})`); - } catch (err) { - log(` ❌ Error: ${err.message}`); - } - - await sleep(2000); // Respect GitHub rate limits - } - - log(`\n ✅ GitHub fetch complete: ${allDevs.size} unique developers`); - - // STEP 2: Enrich with StackOverflow - log('\n📡 STEP 2: Fetching StackOverflow data...'); - let soEnriched = 0; - const devList = [...allDevs.values()]; - - for (let i = 0; i < devList.length; i++) { - const dev = devList[i]; - // Only try ASCII logins (SO search doesn't handle non-ASCII well) - if (/^[a-zA-Z0-9_-]+$/.test(dev.login)) { - const soData = await fetchSOReputation(dev.login); - if (soData) { - Object.assign(dev, soData); - soEnriched++; - } - } - - // Default SO fields - dev.soUserId = dev.soUserId || null; - dev.soReputation = dev.soReputation || 0; - dev.soAnswers = dev.soAnswers || 0; - dev.soAcceptRate = dev.soAcceptRate || 0; - dev.soBadges = dev.soBadges || 0; - - if ((i + 1) % 50 === 0) { - log(` Progress: ${i + 1}/${devList.length} (enriched: ${soEnriched})`); - } - await sleep(350); // SO rate limit: ~3/sec with key - } - - log(` ✅ SO enrichment complete: ${soEnriched} profiles matched`); - - // STEP 3: Geocode locations - log('\n📡 STEP 3: Geocoding locations...'); - let geocoded = 0; - - for (let i = 0; i < devList.length; i++) { - const dev = devList[i]; - const { lat, lng } = await geocodeLocation(dev.location); - dev.lat = lat; - dev.lng = lng; - if (lat) geocoded++; - - if ((i + 1) % 50 === 0) { - log(` Progress: ${i + 1}/${devList.length} (geocoded: ${geocoded})`); - } - - // Only sleep if not cached (OpenCage: 1 req/sec on free tier) - if (!geoCache.has(dev.location)) { - await sleep(1100); - } - } - - log(` ✅ Geocoding complete: ${geocoded}/${devList.length} locations resolved`); - - // STEP 4: Score - log('\n📊 STEP 4: Computing scores...'); - const scored = scoreDevs(devList); - scored.sort((a, b) => b.score - a.score); - - // Save locally as backup - writeFileSync('data/developers.json', JSON.stringify(scored, null, 2)); - log(` ✅ Saved data/developers.json (${scored.length} developers)`); - - // STEP 5: Upload to Cosmos DB - log('\n☁️ STEP 5: Uploading to Cosmos DB...'); - const client = new CosmosClient({ endpoint: COSMOS_ENDPOINT, key: COSMOS_KEY }); - const container = client.database(DATABASE_NAME).container(CONTAINER_NAME); - - let uploaded = 0; - let errors = 0; - const batchSize = 25; - - for (let i = 0; i < scored.length; i += batchSize) { - const batch = scored.slice(i, i + batchSize); - const promises = batch.map(async (dev) => { - const doc = { ...dev, id: dev.login, location: dev.location || 'Unknown' }; - try { - await container.items.upsert(doc); - uploaded++; - } catch (err) { - errors++; - if (errors <= 3) log(` ❌ ${dev.login}: ${err.message}`); - } - }); - - await Promise.all(promises); - - if ((i + batchSize) % 100 === 0 || i + batchSize >= scored.length) { - log(` Uploaded: ${uploaded}/${scored.length}`); - } - } - - const elapsed = ((Date.now() - startTime) / 60000).toFixed(1); - log('\n═══════════════════════════════════════════'); - log(` ✅ PIPELINE COMPLETE in ${elapsed} minutes`); - log(` Developers: ${scored.length}`); - log(` SO enriched: ${soEnriched}`); - log(` Geocoded: ${geocoded}`); - log(` Cosmos DB: ${uploaded} uploaded, ${errors} errors`); - log('═══════════════════════════════════════════'); -} - -main().catch(err => { - log(`FATAL: ${err.message}`); - process.exit(1); -}); diff --git a/scripts/pipeline-to-cosmos.js b/scripts/pipeline-to-cosmos.js index 2587af5..36cd861 100644 --- a/scripts/pipeline-to-cosmos.js +++ b/scripts/pipeline-to-cosmos.js @@ -80,15 +80,31 @@ const COUNTRY_QUERIES = [ ]; async function graphql(query, variables = {}) { - const response = await fetch(GRAPHQL_URL, { - method: 'POST', - headers: { 'Authorization': `Bearer ${GITHUB_TOKEN}`, 'Content-Type': 'application/json' }, - body: JSON.stringify({ query, variables }), - }); - if (!response.ok) throw new Error(`GitHub API ${response.status}`); - const data = await response.json(); - if (data.errors && !data.data) throw new Error(`GraphQL: ${data.errors[0]?.message}`); - return data.data; + for (let attempt = 0; attempt < 3; attempt++) { + const response = await fetch(GRAPHQL_URL, { + method: 'POST', + headers: { 'Authorization': `Bearer ${GITHUB_TOKEN}`, 'Content-Type': 'application/json' }, + body: JSON.stringify({ query, variables }), + }); + if (response.status === 502 || response.status === 503) { + const wait = (attempt + 1) * 5; + log(` ⏳ GitHub ${response.status}, retrying in ${wait}s (attempt ${attempt + 1}/3)`); + await new Promise(r => setTimeout(r, wait * 1000)); + continue; + } + if (response.status === 403) { + const reset = response.headers.get('x-ratelimit-reset'); + const waitSec = reset ? Math.max(0, parseInt(reset) - Math.floor(Date.now() / 1000)) + 5 : 60; + log(` ⏳ Rate limited, waiting ${waitSec}s...`); + await new Promise(r => setTimeout(r, waitSec * 1000)); + continue; + } + if (!response.ok) throw new Error(`GitHub API ${response.status}`); + const data = await response.json(); + if (data.errors && !data.data) throw new Error(`GraphQL: ${data.errors[0]?.message}`); + return data.data; + } + throw new Error('GitHub API failed after 3 retries'); } async function searchGitHubUsers(query, first = 50) { @@ -121,7 +137,7 @@ async function searchGitHubUsers(query, first = 50) { after = data.search.pageInfo.endCursor; } catch (err) { log(` ⚠ Search page failed: ${err.message.slice(0, 60)}`); - break; + // Continue to next page instead of breaking } await new Promise(r => setTimeout(r, 1200)); } diff --git a/server.js b/server.js index 982b8a5..64de138 100644 --- a/server.js +++ b/server.js @@ -156,6 +156,28 @@ app.get('/api/search', async (req, res) => { } }); +// Single developer detail endpoint +app.get('/api/developer', async (req, res) => { + res.setHeader('Content-Type', 'application/json'); + const { id } = req.query; + if (!id) return res.status(400).json({ error: 'Query parameter "id" is required' }); + + try { + const client = new CosmosClient({ endpoint: COSMOS_ENDPOINT, key: COSMOS_KEY }); + const container = client.database(DATABASE).container(CONTAINER); + const { resources } = await container.items.query({ + query: 'SELECT c.id, c.login, c.name, c.avatarUrl, c.bio, c.location, c.lat, c.lng, c.followers, c.totalStars, c.totalForks, c.totalCommits, c.topLanguage, c.languages, c.publicRepos, c.topRepos, c.soReputation, c.soAnswers, c.soAcceptRate, c.soBadges, c.soUserId FROM c WHERE c.id = @id', + parameters: [{ name: '@id', value: id }] + }).fetchAll(); + + if (resources.length === 0) return res.status(404).json({ error: 'Developer not found' }); + res.json(resources[0]); + } catch (err) { + console.error('Detail error:', err.message); + res.status(500).json({ error: 'Failed to fetch developer' }); + } +}); + // Serve static files app.use(express.static(__dirname)); diff --git a/src/App.jsx b/src/App.jsx new file mode 100644 index 0000000..e46f1ea --- /dev/null +++ b/src/App.jsx @@ -0,0 +1,87 @@ +import React, { useState, useEffect, useCallback, useRef } from 'react'; +import Header from './components/Header.jsx'; +import SearchBar from './components/SearchBar.jsx'; +import Globe from './components/Globe.jsx'; +import Leaderboard from './components/Leaderboard.jsx'; +import DetailPanel from './components/DetailPanel.jsx'; +import LoadingOverlay from './components/LoadingOverlay.jsx'; +import { scoreAll } from './utils/scoring.js'; + +export default function App() { + const [developers, setDevelopers] = useState([]); + const [filtered, setFiltered] = useState([]); + const [selectedDev, setSelectedDev] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [flyTarget, setFlyTarget] = useState(null); + const globeRef = useRef(null); + + useEffect(() => { + async function loadData() { + try { + const res = await fetch('/api/developers'); + if (!res.ok) throw new Error(`Failed to load data: ${res.status}`); + const raw = await res.json(); + const scored = scoreAll(raw); + setDevelopers(scored); + setFiltered(scored); + setLoading(false); + } catch (err) { + setError(err.message); + setLoading(false); + } + } + loadData(); + }, []); + + const handleSearch = useCallback((results) => { + const scored = scoreAll(results); + setFiltered(scored); + }, []); + + const handleResetFilter = useCallback(() => { + setFiltered(developers); + }, [developers]); + + const handleSelectDev = useCallback((dev) => { + setSelectedDev(dev); + if (dev?.lat != null && dev?.lng != null) { + setFlyTarget({ lat: dev.lat, lng: dev.lng }); + } + }, []); + + const handleCloseDetail = useCallback(() => { + setSelectedDev(null); + }, []); + + if (loading || error) { + return ; + } + + return ( +
+
+ +
+ + + {selectedDev && ( + + )} +
+
+ ); +} diff --git a/src/app.js b/src/app.js deleted file mode 100644 index de360da..0000000 --- a/src/app.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * App — main entry point, orchestrates data loading and module initialization - */ -const App = (() => { - const DATA_URL = '/api/developers'; - - async function init() { - showLoading(true); - - try { - // Load developer data - const response = await fetch(DATA_URL); - if (!response.ok) throw new Error(`Failed to load data: ${response.status}`); - const rawDevelopers = await response.json(); - - // Score all developers - const developers = Scoring.scoreAll(rawDevelopers); - - // Initialize modules - GlobeViz.init('globe-container', developers); - Leaderboard.init(developers); - - showLoading(false); - } catch (err) { - console.error('Failed to initialize app:', err); - showError(err.message); - } - } - - function showLoading(visible) { - let overlay = document.querySelector('.loading-overlay'); - if (!overlay && visible) { - overlay = document.createElement('div'); - overlay.className = 'loading-overlay'; - overlay.innerHTML = ` -
-
Loading developer data...
- `; - document.body.appendChild(overlay); - } else if (overlay && !visible) { - overlay.classList.add('hidden'); - setTimeout(() => overlay.remove(), 500); - } - } - - function showError(message) { - const overlay = document.querySelector('.loading-overlay'); - if (overlay) { - overlay.innerHTML = ` -
-
⚠️
-
Failed to load data
-
${message}
- -
- `; - } - } - - // Boot - document.addEventListener('DOMContentLoaded', init); - - return { init }; -})(); diff --git a/src/components/DetailPanel.jsx b/src/components/DetailPanel.jsx new file mode 100644 index 0000000..7d5d907 --- /dev/null +++ b/src/components/DetailPanel.jsx @@ -0,0 +1,332 @@ +import React, { useEffect, useRef, useState } from 'react'; +import * as d3 from 'd3'; +import { formatNum } from '../utils/format.js'; + +export default function DetailPanel({ dev, onClose }) { + const [fullData, setFullData] = useState(null); + const radarRef = useRef(null); + const heatmapRef = useRef(null); + const langRef = useRef(null); + + // Fetch full details on mount + useEffect(() => { + let cancelled = false; + async function fetchFull() { + try { + const res = await fetch(`/api/developer?id=${encodeURIComponent(dev.id)}`); + if (res.ok) { + const data = await res.json(); + if (!cancelled) setFullData(data); + } + } catch { /* use existing data */ } + } + fetchFull(); + return () => { cancelled = true; }; + }, [dev.id]); + + // Radar chart + useEffect(() => { + if (!dev.scoreDimensions || !radarRef.current) return; + renderRadar(radarRef.current, dev.scoreDimensions); + }, [dev.scoreDimensions]); + + // Heatmap + useEffect(() => { + if (!heatmapRef.current) return; + renderHeatmap(heatmapRef.current, dev.totalCommits || 500); + }, [dev.totalCommits]); + + // Languages donut + useEffect(() => { + if (!langRef.current) return; + const langs = fullData?.languages || (dev.topLanguage ? [{ name: dev.topLanguage, percent: 100 }] : []); + renderLanguages(langRef.current, langs); + }, [fullData, dev.topLanguage]); + + const merged = { ...dev, ...fullData }; + const repos = merged.topRepos || []; + const soRep = merged.soReputation || 0; + const soAnswers = merged.soAnswers || 0; + const soAcceptRate = merged.soAcceptRate || 0; + const soBadges = merged.soBadges || 0; + + return ( +
+ + + {/* Header */} + + + {/* Stats */} +
+
+ + + + + + +
+
+ + {/* Charts */} +
+
+

Score Breakdown

+
+
+ +
+

StackOverflow Activity

+ {soRep || soAnswers ? ( + + ) : ( +
No StackOverflow profile linked
+ )} +
+ +
+

Contribution Activity

+
+
+ +
+

Languages

+
+
+ +
+

Top Repositories

+
+ {repos.slice(0, 5).map(repo => ( +
+ {repo.name} + + ⭐ {formatNum(repo.stars)} + 🍴 {formatNum(repo.forks)} + +
+ ))} +
+
+
+
+ ); +} + +function StatCard({ label, value, className = '' }) { + return ( +
+
{value}
+
{label}
+
+ ); +} + +function SOBars({ rep, answers, acceptRate, badges, userId }) { + const metrics = [ + { label: 'Reputation', value: rep, max: 1000000, color: '#f48024' }, + { label: 'Answers', value: answers, max: 10000, color: '#ff9f4a' }, + { label: 'Accept Rate', value: acceptRate, max: 100, color: '#ffcc80', suffix: '%' }, + { label: 'Badges', value: badges, max: 500, color: '#ffe0b2' }, + ]; + + return ( +
+
+ {metrics.map(m => { + const pct = Math.min((m.value / m.max) * 100, 100); + const display = m.suffix ? m.value + m.suffix : formatNum(m.value); + return ( +
+
{m.label}
+
+
+
+
{display}
+
+ ); + })} +
+ {userId && ( + + View full SO profile ↗ + + )} +
+ ); +} + +function renderRadar(container, dims) { + container.innerHTML = ''; + const data = [ + { axis: 'Stars', value: dims.stars }, + { axis: 'Commits', value: dims.commits }, + { axis: 'Reach', value: dims.repoReach }, + { axis: 'SO Rep', value: dims.soReputation }, + { axis: 'SO Engage', value: dims.soEngagement }, + { axis: 'Community', value: dims.community }, + ]; + + const width = 260, height = 260; + const radius = Math.min(width, height) / 2 - 30; + const levels = 5; + const angleSlice = (Math.PI * 2) / data.length; + + const svg = d3.select(container) + .append('svg') + .attr('viewBox', `0 0 ${width} ${height}`) + .append('g') + .attr('transform', `translate(${width / 2}, ${height / 2})`); + + for (let i = 1; i <= levels; i++) { + svg.append('circle') + .attr('r', (radius / levels) * i) + .attr('fill', 'none') + .attr('stroke', '#1e293b') + .attr('stroke-width', 0.5); + } + + data.forEach((d, i) => { + const angle = angleSlice * i - Math.PI / 2; + svg.append('line') + .attr('x1', 0).attr('y1', 0) + .attr('x2', radius * Math.cos(angle)) + .attr('y2', radius * Math.sin(angle)) + .attr('stroke', '#1e293b') + .attr('stroke-width', 0.5); + + svg.append('text') + .attr('x', (radius + 16) * Math.cos(angle)) + .attr('y', (radius + 16) * Math.sin(angle)) + .attr('text-anchor', 'middle') + .attr('dominant-baseline', 'middle') + .attr('fill', '#94a3b8') + .attr('font-size', '10px') + .text(d.axis); + }); + + const line = d3.lineRadial() + .radius(d => d.value * radius) + .angle((d, i) => i * angleSlice) + .curve(d3.curveLinearClosed); + + svg.append('path') + .datum(data) + .attr('d', line) + .attr('fill', 'rgba(59, 130, 246, 0.2)') + .attr('stroke', '#3b82f6') + .attr('stroke-width', 2); + + data.forEach((d, i) => { + const angle = angleSlice * i - Math.PI / 2; + svg.append('circle') + .attr('cx', d.value * radius * Math.cos(angle)) + .attr('cy', d.value * radius * Math.sin(angle)) + .attr('r', 4) + .attr('fill', '#3b82f6'); + }); +} + +function renderHeatmap(container, totalCommits) { + container.innerHTML = ''; + const days = 364; + const data = []; + const avg = totalCommits / days; + for (let i = 0; i < days; i++) { + const isWeekend = (i % 7 === 0 || i % 7 === 6); + const base = isWeekend ? avg * 0.3 : avg * 1.4; + data.push(Math.max(0, Math.round(base + (Math.random() - 0.5) * avg * 2))); + } + + const cellSize = 11; + const weeks = 52; + const width = weeks * (cellSize + 2) + 40; + const height = 7 * (cellSize + 2) + 20; + + const colorScale = d3.scaleQuantize() + .domain([0, d3.max(data)]) + .range(['#161b22', '#0e4429', '#006d32', '#26a641', '#39d353']); + + const svg = d3.select(container) + .append('svg') + .attr('viewBox', `0 0 ${width} ${height}`) + .attr('width', '100%'); + + data.forEach((value, i) => { + const week = Math.floor(i / 7); + const day = i % 7; + svg.append('rect') + .attr('x', week * (cellSize + 2) + 20) + .attr('y', day * (cellSize + 2)) + .attr('width', cellSize) + .attr('height', cellSize) + .attr('rx', 2) + .attr('fill', colorScale(value)); + }); + + ['Mon', 'Wed', 'Fri'].forEach((label, i) => { + svg.append('text') + .attr('x', 0) + .attr('y', (i * 2 + 1) * (cellSize + 2) + cellSize / 2) + .attr('fill', '#64748b') + .attr('font-size', '9px') + .attr('dominant-baseline', 'middle') + .text(label); + }); +} + +function renderLanguages(container, languages) { + container.innerHTML = ''; + if (!languages.length) return; + + const width = 120, height = 120; + const radius = Math.min(width, height) / 2; + const colors = ['#3b82f6', '#8b5cf6', '#f48024', '#2ea44f', '#64748b']; + + const pie = d3.pie().value(d => d.percent).sort(null); + const arc = d3.arc().innerRadius(radius * 0.55).outerRadius(radius); + + const svg = d3.select(container) + .append('svg') + .attr('width', width) + .attr('height', height) + .append('g') + .attr('transform', `translate(${width / 2}, ${height / 2})`); + + svg.selectAll('path') + .data(pie(languages)) + .join('path') + .attr('d', arc) + .attr('fill', (d, i) => colors[i % colors.length]); + + const legend = d3.select(container) + .append('div') + .style('font-size', '11px'); + + languages.forEach((lang, i) => { + legend.append('div') + .style('display', 'flex') + .style('align-items', 'center') + .style('gap', '6px') + .style('margin-bottom', '4px') + .html(` + ${lang.name} + ${lang.percent}%`); + }); +} diff --git a/src/components/Globe.jsx b/src/components/Globe.jsx new file mode 100644 index 0000000..0b927b8 --- /dev/null +++ b/src/components/Globe.jsx @@ -0,0 +1,130 @@ +import React, { useEffect, useRef, useMemo, forwardRef, useImperativeHandle, useCallback } from 'react'; +import GlobeGL from 'react-globe.gl'; +import { getPlatformColor } from '../utils/scoring.js'; +import { formatNum } from '../utils/format.js'; + +const Globe = forwardRef(function Globe({ developers, flyTarget, onSelectDev }, ref) { + const globeEl = useRef(); + const tooltipRef = useRef(null); + + const geoDevs = useMemo(() => { + return developers + .filter(d => d.lat != null && d.lng != null) + .sort((a, b) => b.score - a.score) + .slice(0, 5000); + }, [developers]); + + const labelDevs = useMemo(() => { + return geoDevs.filter(d => d.score >= 80); + }, [geoDevs]); + + // Auto-rotate on mount + useEffect(() => { + const controls = globeEl.current?.controls(); + if (controls) { + controls.autoRotate = true; + controls.autoRotateSpeed = 0.4; + controls.enableDamping = true; + } + }, []); + + // Fly to target + useEffect(() => { + if (flyTarget && globeEl.current) { + globeEl.current.pointOfView({ lat: flyTarget.lat, lng: flyTarget.lng, altitude: 1.5 }, 1000); + const controls = globeEl.current.controls(); + if (controls) controls.autoRotate = false; + } + }, [flyTarget]); + + useImperativeHandle(ref, () => ({ + flyTo: (lat, lng) => { + globeEl.current?.pointOfView({ lat, lng, altitude: 1.5 }, 1000); + }, + })); + + const handleHover = useCallback((point) => { + const tooltip = tooltipRef.current; + if (!tooltip) return; + const controls = globeEl.current?.controls(); + + if (point) { + tooltip.innerHTML = ` +
+ ${point.login} +
+
${point.name || point.login}
+ +
+
+
Score: ${point.score}/100
+
+ ⭐ ${formatNum(point.totalStars || 0)} + 👥 ${formatNum(point.followers || 0)} + ${point.soReputation ? `SO ${formatNum(point.soReputation)}` : ''} +
+
+ 📍 ${point.location || 'Unknown'} + ${point.topLanguage ? `· ${point.topLanguage}` : ''} +
+ `; + tooltip.classList.add('visible'); + if (controls) controls.autoRotate = false; + } else { + tooltip.classList.remove('visible'); + if (controls) controls.autoRotate = true; + } + }, []); + + const handleClick = useCallback((point) => { + if (point) onSelectDev(point); + }, [onSelectDev]); + + // Track mouse for tooltip + useEffect(() => { + const handler = (e) => { + if (tooltipRef.current) { + tooltipRef.current.style.left = (e.clientX + 12) + 'px'; + tooltipRef.current.style.top = (e.clientY + 12) + 'px'; + } + }; + document.addEventListener('mousemove', handler); + return () => document.removeEventListener('mousemove', handler); + }, []); + + return ( + <> +
+ d.lat} + pointLng={d => d.lng} + pointAltitude={d => 0.01 + (d.score / 100) * 0.06} + pointRadius={d => 0.3 + (d.score / 100) * 0.7} + pointColor={d => getPlatformColor(d.scoreDimensions)} + pointResolution={6} + labelsData={labelDevs} + labelLat={d => d.lat} + labelLng={d => d.lng} + labelText={d => d.login} + labelSize={d => 0.6 + (d.score / 100) * 0.4} + labelColor={() => 'rgba(226, 232, 240, 0.75)'} + labelDotRadius={0.3} + labelAltitude={0.02} + onPointHover={handleHover} + onPointClick={handleClick} + /> +
+
+ + ); +}); + +export default Globe; diff --git a/src/components/Header.jsx b/src/components/Header.jsx new file mode 100644 index 0000000..02542a2 --- /dev/null +++ b/src/components/Header.jsx @@ -0,0 +1,27 @@ +import React from 'react'; + +export default function Header() { + return ( +
+
+ 🌐 +

DevGlobe

+ Visualizing the World's Top Open-Source Contributors +
+ +
+ ); +} diff --git a/src/components/Leaderboard.jsx b/src/components/Leaderboard.jsx new file mode 100644 index 0000000..92b1762 --- /dev/null +++ b/src/components/Leaderboard.jsx @@ -0,0 +1,140 @@ +import React, { useMemo, useRef, useState, useEffect, useCallback } from 'react'; +import { formatNum } from '../utils/format.js'; + +const ITEM_HEIGHT = 62; +const BUFFER = 10; + +export default function Leaderboard({ developers, selectedLogin, onSelectDev }) { + const listRef = useRef(null); + const [scrollTop, setScrollTop] = useState(0); + const [viewHeight, setViewHeight] = useState(600); + + // Filters + const [countryFilter, setCountryFilter] = useState(''); + const [langFilter, setLangFilter] = useState(''); + const [sortBy, setSortBy] = useState('score'); + + const countries = useMemo(() => { + const map = new Map(); + developers.forEach(d => { + if (d.location) { + const parts = d.location.split(',').map(s => s.trim()); + const country = parts[parts.length - 1]; + if (country && country.length > 1) map.set(country, (map.get(country) || 0) + 1); + } + }); + return [...map.entries()].sort((a, b) => b[1] - a[1]).slice(0, 50); + }, [developers]); + + const languages = useMemo(() => { + const set = new Set(); + developers.forEach(d => { if (d.topLanguage) set.add(d.topLanguage); }); + return [...set].sort(); + }, [developers]); + + const filtered = useMemo(() => { + let result = developers.filter(d => { + const matchLang = !langFilter || d.topLanguage === langFilter; + const matchCountry = !countryFilter || (d.location && d.location.includes(countryFilter)); + return matchLang && matchCountry; + }); + + result.sort((a, b) => { + switch (sortBy) { + case 'stars': return (b.totalStars || 0) - (a.totalStars || 0); + case 'commits': return (b.totalCommits || 0) - (a.totalCommits || 0); + case 'soRep': return (b.soReputation || 0) - (a.soReputation || 0); + default: return b.score - a.score; + } + }); + + return result; + }, [developers, langFilter, countryFilter, sortBy]); + + // Virtual scroll range + const start = Math.max(0, Math.floor(scrollTop / ITEM_HEIGHT) - BUFFER); + const end = Math.min(filtered.length, Math.ceil((scrollTop + viewHeight) / ITEM_HEIGHT) + BUFFER); + const totalHeight = filtered.length * ITEM_HEIGHT; + const visibleItems = filtered.slice(start, end); + + useEffect(() => { + const el = listRef.current; + if (!el) return; + setViewHeight(el.clientHeight); + const observer = new ResizeObserver(() => setViewHeight(el.clientHeight)); + observer.observe(el); + return () => observer.disconnect(); + }, []); + + const handleScroll = useCallback((e) => { + setScrollTop(e.target.scrollTop); + }, []); + + // Scroll to selected + useEffect(() => { + if (!selectedLogin || !listRef.current) return; + const idx = filtered.findIndex(d => d.login === selectedLogin); + if (idx >= 0) { + listRef.current.scrollTop = idx * ITEM_HEIGHT - viewHeight / 2; + } + }, [selectedLogin, filtered, viewHeight]); + + return ( + + ); +} diff --git a/src/components/LoadingOverlay.jsx b/src/components/LoadingOverlay.jsx new file mode 100644 index 0000000..48a73fe --- /dev/null +++ b/src/components/LoadingOverlay.jsx @@ -0,0 +1,28 @@ +import React from 'react'; + +export default function LoadingOverlay({ error }) { + if (error) { + return ( +
+
+
⚠️
+
Failed to load data
+
{error}
+ +
+
+ ); + } + + return ( +
+
+
Loading developer data...
+
+ ); +} diff --git a/src/components/SearchBar.jsx b/src/components/SearchBar.jsx new file mode 100644 index 0000000..3e2a3ce --- /dev/null +++ b/src/components/SearchBar.jsx @@ -0,0 +1,145 @@ +import React, { useState, useRef, useCallback } from 'react'; +import { scoreAll } from '../utils/scoring.js'; + +const SAMPLES = [ + { query: 'open source contributors in San Francisco', label: 'SF contributors' }, + { query: 'Python developer working on AI and deep learning', label: 'AI & deep learning' }, + { query: 'full stack JavaScript developer', label: 'full stack JS dev' }, + { query: 'Linux kernel and systems programming in C', label: 'Linux kernel devs' }, +]; + +export default function SearchBar({ developers, onResults, onReset }) { + const [query, setQuery] = useState(''); + const [mode, setMode] = useState('hybrid'); + const [searching, setSearching] = useState(false); + const [resultCount, setResultCount] = useState(null); + const inputRef = useRef(null); + const abortRef = useRef(null); + const timerRef = useRef(null); + + const doSearch = useCallback(async (q, m) => { + if (!q.trim()) { + onReset(); + setResultCount(null); + return; + } + + if (m === 'text') { + const lower = q.toLowerCase(); + const results = developers.filter(d => + (d.login && d.login.toLowerCase().includes(lower)) || + (d.name && d.name.toLowerCase().includes(lower)) || + (d.location && d.location.toLowerCase().includes(lower)) + ); + onResults(results); + setResultCount(results.length); + return; + } + + if (abortRef.current) abortRef.current.abort(); + const controller = new AbortController(); + abortRef.current = controller; + setSearching(true); + + try { + const res = await fetch( + `/api/search?q=${encodeURIComponent(q)}&mode=${m}&top=20`, + { signal: controller.signal } + ); + const data = await res.json(); + if (!controller.signal.aborted) { + const results = data.results || []; + onResults(results); + setResultCount(results.length); + } + } catch (e) { + if (e.name !== 'AbortError') console.error('Search failed:', e); + } finally { + if (!controller.signal.aborted) setSearching(false); + } + }, [developers, onResults, onReset]); + + const handleInput = (e) => { + const val = e.target.value; + setQuery(val); + clearTimeout(timerRef.current); + timerRef.current = setTimeout(() => doSearch(val, mode), 400); + }; + + const handleKeyDown = (e) => { + if (e.key === 'Enter') { + clearTimeout(timerRef.current); + doSearch(query, mode); + } + if (e.key === 'Escape') { + handleClear(); + } + }; + + const handleModeChange = (e) => { + const m = e.target.value; + setMode(m); + if (query.trim()) doSearch(query, m); + }; + + const handleSample = (q) => { + setQuery(q); + doSearch(q, mode); + inputRef.current?.focus(); + }; + + const handleClear = () => { + setQuery(''); + setResultCount(null); + onReset(); + inputRef.current?.focus(); + }; + + return ( +