@selvajs/selva 4.21.0-beta.17 → 4.21.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/adapter-node.js +2 -2
- package/build/client/_app/immutable/assets/baseHDR.Dkr46J8-.hdr +0 -0
- package/build/client/_app/immutable/chunks/a5NclWb-.js +2 -0
- package/build/client/_app/immutable/chunks/a5NclWb-.js.br +0 -0
- package/build/client/_app/immutable/chunks/a5NclWb-.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.CqykPefk.js → app.D3YN7-nC.js} +2 -2
- package/build/client/_app/immutable/entry/app.D3YN7-nC.js.br +0 -0
- package/build/client/_app/immutable/entry/app.D3YN7-nC.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{20.B2EnikH5.js → 20.B8bN-AYw.js} +1 -1
- package/build/client/_app/immutable/nodes/20.B8bN-AYw.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.B8bN-AYw.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{25.C7VDbaM3.js → 25.DbMk0htM.js} +20 -20
- package/build/client/_app/immutable/nodes/25.DbMk0htM.js.br +0 -0
- package/build/client/_app/immutable/nodes/25.DbMk0htM.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/server/.vite/manifest.json +88 -6
- package/build/server/_app/immutable/assets/baseHDR.Dkr46J8-.hdr +0 -0
- package/build/server/chunks/DefinitionCard.js +1 -1
- package/build/server/chunks/DefinitionCard.js.map +1 -1
- package/build/server/chunks/api.js +1 -1
- package/build/server/chunks/baseHDR.js +5 -0
- package/build/server/chunks/baseHDR.js.map +1 -0
- package/build/server/chunks/capture.js +5 -0
- package/build/server/chunks/capture.js.map +1 -0
- package/build/server/chunks/diff.js +1 -8
- package/build/server/chunks/diff.js.map +1 -1
- package/build/server/chunks/functions.js +1 -1
- package/build/server/chunks/handlers.js +71 -25
- package/build/server/chunks/handlers.js.map +1 -1
- package/build/server/chunks/instance.js +5 -5
- package/build/server/chunks/instanceAdmins.server.js +1 -1
- package/build/server/chunks/internal.js +3 -3
- package/build/server/chunks/inventory.js +59 -16
- package/build/server/chunks/inventory.js.map +1 -1
- package/build/server/chunks/package.js +2 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/path.js +7 -0
- package/build/server/chunks/path.js.map +1 -0
- package/build/server/chunks/presets.server.js +1 -1
- package/build/server/chunks/providers.server.js +21 -12
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/chunks/registry.js +18 -3
- package/build/server/chunks/registry.js.map +1 -1
- package/build/server/chunks/remote.js +1559 -0
- package/build/server/chunks/remote.js.map +1 -0
- package/build/server/chunks/rhino3dm.js.map +1 -1
- package/build/server/chunks/server-errors.js +19 -1
- package/build/server/chunks/server-errors.js.map +1 -1
- package/build/server/chunks/server5.js +52 -0
- package/build/server/chunks/server5.js.map +1 -0
- package/build/server/chunks/solve.js +5 -0
- package/build/server/chunks/solve.js.map +1 -0
- package/build/server/chunks/stash-instance.js +94 -0
- package/build/server/chunks/stash-instance.js.map +1 -0
- package/build/server/chunks/sveltekit.js +2 -1
- package/build/server/chunks/sveltekit.js.map +1 -1
- package/build/server/chunks/types4.js +10 -0
- package/build/server/chunks/types4.js.map +1 -0
- package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +3 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/changes/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/inventory/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/scripts/_scriptId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/check/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/starred/_guid_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/token/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/assets/_kind_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_userId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_tokenId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +1 -1
- package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
- package/build/server/entries/endpoints/mcp/_server.ts.js +1085 -91
- package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/mcp/files/_token_/_name_/_server.ts.js +18 -0
- package/build/server/entries/endpoints/mcp/files/_token_/_name_/_server.ts.js.map +1 -0
- package/build/server/entries/hooks.server.js +8 -3
- package/build/server/entries/hooks.server.js.map +1 -1
- package/build/server/entries/pages/projects/_page.svelte.js +12 -6
- package/build/server/entries/pages/projects/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/team/tokens/_page.server.ts.js +1 -1
- package/build/server/index.js +1 -1
- package/build/server/manifest-full.js +8 -1
- package/build/server/manifest.js +8 -1
- package/build/server/nodes/20.js +1 -1
- package/build/server/nodes/25.js +1 -1
- package/build/server/remote-entry.js +1 -1559
- package/build/server/server.js +8 -1
- package/package.json +6 -5
- package/templates/.env.example +6 -0
- package/build/client/_app/immutable/chunks/Cv7GBWJh.js +0 -2
- package/build/client/_app/immutable/chunks/Cv7GBWJh.js.br +0 -0
- package/build/client/_app/immutable/chunks/Cv7GBWJh.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.CqykPefk.js.br +0 -0
- package/build/client/_app/immutable/entry/app.CqykPefk.js.gz +0 -0
- package/build/client/_app/immutable/nodes/20.B2EnikH5.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.B2EnikH5.js.gz +0 -0
- package/build/client/_app/immutable/nodes/25.C7VDbaM3.js.br +0 -0
- package/build/client/_app/immutable/nodes/25.C7VDbaM3.js.gz +0 -0
- package/build/server/remote-entry.js.map +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// ../mcp/dist/views/solve.html?raw
|
|
2
|
+
var solve_default = "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <title>Solve in 3D</title>\n <style>:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--fg:var(--color-text-primary,#1f2328);--muted:var(--color-text-secondary,#656d76);--bg:var(--color-background-primary,#fff);--line:var(--color-border-primary,#d0d7de)}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}:root:not([data-theme=light]){--fg:var(--color-text-primary,#e6edf3);--muted:var(--color-text-secondary,#8d96a0);--bg:var(--color-background-primary,#0d1117);--line:var(--color-border-primary,#30363d)}}:root[data-theme=dark]{--fg:var(--color-text-primary,#e6edf3);--muted:var(--color-text-secondary,#8d96a0);--bg:var(--color-background-primary,#0d1117);--line:var(--color-border-primary,#30363d)}*{box-sizing:border-box}html,body{background:var(--bg);color:var(--fg);font:14px/1.4 var(--font-sans,system-ui, sans-serif);margin:0}header{border-bottom:1px solid var(--line);align-items:center;gap:8px;padding:8px 12px;display:flex}h1{text-overflow:ellipsis;white-space:nowrap;flex:1;margin:0;font-size:14px;font-weight:600;overflow:hidden}button{font:inherit;color:inherit;border:1px solid var(--line);cursor:pointer;background:0 0;border-radius:6px;padding:2px 10px}main{height:420px;display:flex}body.fullscreen main{height:calc(100vh - 41px)}#stage{flex:1;min-width:0;position:relative}#form{border-right:1px solid var(--line);flex-direction:column;flex:none;gap:10px;width:240px;padding:10px 12px;display:flex;overflow-y:auto}#form[hidden]{display:none}@media (width<=560px){main{flex-direction:column;height:auto}#stage{height:320px}#form{border-right:0;border-bottom:1px solid var(--line);width:auto}}.field{flex-direction:column;gap:4px;display:flex}.field.inline{flex-direction:row-reverse;justify-content:flex-end;align-items:center;gap:8px}.field .name{color:var(--muted);font-size:12px}.field input:not([type=checkbox]),.field select{font:inherit;color:inherit;border:1px solid var(--line);background:0 0;border-radius:6px;min-width:0;padding:4px 6px}button.solve{align-self:flex-start;padding:4px 14px}#status{text-align:center;color:var(--muted);pointer-events:none;place-items:center;padding:16px;display:grid;position:absolute;inset:0}</style>\n <script type=\"module\" crossorigin>(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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Object.defineProperty,t=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&&e(r,Symbol.toStringTag,{value:`Module`}),r},r=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]);function i(e){return typeof e==`string`&&r.has(e.replace(/#$/,``))}function a(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function o(e,t=`|`){return e.map(e=>P(e)).join(t)}function s(e,t){return typeof t==`bigint`?t.toString():t}var c=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function l(e){return new c(e)}function u(e){return e==null}function d(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function f(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var p=Symbol(`evaluating`);function m(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==p)return r===void 0&&(r=p,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function h(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function g(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function _(e){return g(e._zod.def)??e._zod.def.shape}function v(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return h(this,t,e),e},enumerable:!0,configurable:!0})}function y(e,t,n){t in e?h(e,t,n):e[t]=n}function b(e,t,n,r){let i=_(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?v(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):y(e,a,r?r(n.value,a):n.value))}}function x(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?v(e,n,()=>t[n]):y(e,n,r.value))}}function S(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function C(e){return JSON.stringify(e)}function w(e){return e.toLowerCase().trim().replace(/[^\\w\\s-]/g,``).replace(/[\\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var T=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var D=l(()=>{if(Be.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function O(e){if(E(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return E(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function k(e){return O(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var A=new Set([`string`,`number`,`symbol`]);function j(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`)}function M(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function P(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`\"${e}\"`:`${e}`}function ee(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var te={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ne={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function re(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return b(i,e,ie(e,t)),M(e,S(n,{shape:i,checks:[]}))}function ie(e,t){let n=_(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: \"${String(e)}\"`);t[e]&&r.push(e)}return r}function ae(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(ie(e,t)),a={};return b(a,e,Reflect.ownKeys(_(e)).filter(e=>!i.has(e))),M(e,S(n,{shape:a,checks:[]}))}function oe(e,t){if(!O(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=_(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\")}return M(e,S(e._zod.def,{shape:se(e,t)}))}function se(e,t){let n={};return b(n,e,Reflect.ownKeys(_(e))),x(n,t),n}function ce(e,t){if(!O(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return M(e,S(e._zod.def,{shape:se(e,t)}))}function le(e,t){if(!t?._zod?.def)throw Error(\"Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.\");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return b(n,e,Reflect.ownKeys(_(e))),b(n,t,Reflect.ownKeys(_(t))),M(e,S(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ue(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(ie(t,n)):void 0,o={};return b(o,t,Reflect.ownKeys(_(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),M(t,S(t._zod.def,{shape:o,checks:[]}))}function de(e,t,n){let r=n?new Set(ie(t,n)):void 0,i={};return b(i,t,Reflect.ownKeys(_(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),M(t,S(t._zod.def,{shape:i}))}function fe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function me(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function he(e){return typeof e==`string`?e:e?.message}function ge(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function _e(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function ve(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:he(e.inst?._zod.def?.error?.(e))??he(a?.(e))??he(t?.error?.(e))??he(n.customError?.(e))??he(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var ye=/[\\uD800-\\uDBFF]/;function be(e){let t=e.length;if(!ye.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function xe(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Se(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Ce(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function F(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):I(e,n,r.value)}}function we(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Te(e,t,n){return we(e,t,n,!1)}function Ee(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return we(this,n,r(this))},set(e){we(this,n,e)}})}return t}function I(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:we(this,t,n.bind(this))},set(e){we(this,t,e)}})}function De(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var L,R=!1,Oe={configurable:!0,get(){R=!0}};function ke(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&L!==e._zod?L=void 0:(L=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Oe);let e=R;R=!1;try{let r=n(this);return R?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),R||=e,r}catch(n){throw delete this[t],R||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Ae(e,t,n,r){let i=De(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var je=`~constantCatch`;function Me(e){let t=()=>e;return t[je]=!0,t}var Ne,Pe=Object.freeze({status:`aborted`}),Fe={value:void 0,enumerable:!1},Ie=`captureStackTrace`in Error?Error:null;function Le(e){let t=Ie;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Ie=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function z(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Fe.value=new a(r);try{Object.defineProperty(n,\"_zod\",Fe)}finally{Fe.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),F(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,\"name\",{value:e});function d(e){let t=r?.Parent?Le(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,\"init\",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,\"name\",{value:e}),d}var Re=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ze=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Ne=globalThis).__zod_globalConfig??(Ne.__zod_globalConfig={});var Be=globalThis.__zod_globalConfig;function Ve(e){return e&&Object.assign(Be,e),Be}function He(){let e=this._zod;return e.message??=JSON.stringify(e.def,s,2),e.message}function Ue(e){this._zod.message=e}var We={get:He,set:Ue,enumerable:!0,configurable:!0},Ge={value:void 0,enumerable:!1},Ke=new WeakSet([Object.prototype,Error.prototype]),qe=z(`$ZodError`,(e,t)=>{e.name=`$ZodError`,Ge.value=t,Object.defineProperty(e,\"issues\",Ge),Ge.value=void 0,Object.defineProperty(e,\"message\",We);let n=Object.getPrototypeOf(e);Ke.has(n)||(Ke.add(n),Object.defineProperty(n,\"toString\",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,\"toString\",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,\"toString\",{value:e,configurable:!0,writable:!0})}}))});function Je(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Ye(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Je(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Xe(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Ze(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Qe=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Re;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ve(e,o,Ve())));throw T(n,a?.callee??t),n}return s.value};return t},$e=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ve(e,o,Ve())));throw T(n,a?.callee??t),n}return s.value};return t},et=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Re;return a.issues.length?tt(e,a.issues,i):{success:!0,data:a.value}};function tt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>ve(e,n,Ve()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var nt=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?tt(e,a.issues,i):{success:!0,data:a.value}},rt=Symbol.for(`zod.compile.invalid`),it=Symbol.for(`zod.compile.fallback`),at=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==rt)return!0;if(r.definite===!0&&n===void 0)return!1}return ot(e,t,n)});function ot(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[it]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Re;return a.issues.length===0}var st=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},ct=e=>{let t=Qe(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Ze(n,a))};return n},lt=e=>{let t=Qe(e),n=(e,r,i,a)=>t(e,r,i,Ze(n,a));return n},ut=e=>{let t=$e(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Ze(n,a))};return n},dt=e=>{let t=$e(e),n=async(e,r,i,a)=>await t(e,r,i,Ze(n,a));return n},ft=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return et(e)(t,n,i)},pt=e=>(t,n,r)=>et(e)(t,n,r),mt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return nt(e)(t,n,i)},ht=e=>async(t,n,r)=>nt(e)(t,n,r),gt=/^[cC][0-9a-z]{6,}$/,_t=/^[0-9a-z]+$/,vt=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,yt=/^[0-9a-vA-V]{20}$/,bt=/^[A-Za-z0-9]{27}$/,xt=/^[a-zA-Z0-9_-]{21}$/;function St(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Ct=/^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/,wt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Tt=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Et=/^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/,Dt=`^(?=[\\\\s\\\\S]*[\\\\p{Extended_Pictographic}\\\\p{Regional_Indicator}\\\\u20E3])[\\\\p{Extended_Pictographic}\\\\p{Emoji_Component}]+$`;function Ot(){return new RegExp(Dt,`u`)}var kt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,At=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,jt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/,Mt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Nt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pt=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ft=/^https?$/,It=/^\\+[1-9]\\d{6,14}$/,Lt=`(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))`;function Rt(e){return RegExp(`^${e}$`)}var zt=Rt(Lt);function Bt(e){let t=`(?:[01]\\\\d|2[0-3]):[0-5]\\\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\\\d`:`${t}:[0-5]\\\\d\\\\.\\\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\\\d(?:\\\\.\\\\d+)?`:`${t}(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?`}function Vt(e){return RegExp(`^${Bt(e)}$`)}function Ht(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)`);let n=`${Bt({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Bt({precision:e.precision})}`:n;return RegExp(`^${Lt}T(?:${r})$`)}var Ut=/^[\\s\\S]{0,}$/,Wt=/^-?\\d+$/,Gt=/^-?\\d+(?:\\.\\d+)?$/,Kt=/^(?:true|false)$/i,qt=/^null$/i,Jt=/^undefined$/i,Yt=/^[^A-Z]*$/,Xt=/^[^a-z]*$/,Zt=z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Qt=e=>{let t=e.value;return!u(t)&&t.length!==void 0},$t={number:`number`,bigint:`bigint`,object:`date`},en=z(`$ZodCheckLessThan`,(e,t)=>{Zt.init(e,t);let n=$t[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:$t[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tn=z(`$ZodCheckGreaterThan`,(e,t)=>{Zt.init(e,t);let n=$t[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:$t[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nn=z(`$ZodCheckMultipleOf`,(e,t)=>{Zt.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):f(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),rn=z(`$ZodCheckNumberFormat`,(e,t)=>{Zt.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=te[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),an=z(`$ZodCheckMaxLength`,(e,t)=>{var n;Zt.init(e,t),(n=e._zod.def).when??(n.when=Qt),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?be(r):i)<=t.maximum)return;let a=xe(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),on=z(`$ZodCheckMinLength`,(e,t)=>{var n;Zt.init(e,t),(n=e._zod.def).when??(n.when=Qt),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?be(r):i)>=t.minimum)return;let a=xe(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),sn=z(`$ZodCheckLengthEquals`,(e,t)=>{var n;Zt.init(e,t),(n=e._zod.def).when??(n.when=Qt),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?be(r):i;if(a===t.length)return;let o=xe(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),cn=z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Zt.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ln=z(`$ZodCheckRegex`,(e,t)=>{cn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),un=z(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Yt,cn.init(e,t)}),dn=z(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Xt,cn.init(e,t)}),fn=z(`$ZodCheckIncludes`,(e,t)=>{Zt.init(e,t);let n=j(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),pn=z(`$ZodCheckStartsWith`,(e,t)=>{Zt.init(e,t);let n=RegExp(`^${j(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),mn=z(`$ZodCheckEndsWith`,(e,t)=>{Zt.init(e,t);let n=RegExp(`.*${j(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),hn=z(`$ZodCheckOverwrite`,(e,t)=>{Zt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),gn=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`\n`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\\n${t.join(`\n`)}\\n};`)(...Object.values(this.closed))}},_n={major:4,minor:6,patch:7},vn=z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_n;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=fe(t),a;for(let o of n){if(o._zod.def.when){if(pe(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Re;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(_e(t.issues,n,e),i||=fe(t,n))});else{if(t.issues.length===n)continue;_e(t.issues,n,e),i||=fe(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(fe(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Re;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Re;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get\"~standard\"(){return Te(this,`~standard`,xn(this))},set\"~standard\"(e){we(this,`~standard`,e)}}),yn=(e,t)=>e.issues.length?{issues:e.issues.map(e=>ve(e,t,Ve()))}:{value:e.value};async function bn(e,t){let n={async:!0};return yn(await e._zod.run({value:t,issues:[]},n),n)}function xn(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return yn(r,n)}catch{}return bn(e,t)},vendor:`zod`,version:1}}var Sn=z(`$ZodString`,(e,t)=>{vn.init(e,t),e._zod.pattern=t.pattern??Ut,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Cn=z(`$ZodStringFormat`,(e,t)=>{cn.init(e,t),Sn.init(e,t)}),wn=z(`$ZodGUID`,(e,t)=>{t.pattern??=wt,Cn.init(e,t)}),Tn=z(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: \"${t.version}\"`);t.pattern??=Tt(e)}else t.pattern??=Tt();Cn.init(e,t)}),En=z(`$ZodEmail`,(e,t)=>{t.pattern??=Et,Cn.init(e,t)});function Dn(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function On(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Dn(e)||2:kn(e,t)}function kn(e,t){if(!t.normalize&&t.protocol?.source===Ft.source&&!/^https?:\\/\\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var An=/[\\t\\n\\r]/g;function jn(e){return e.replace(An,``)}function Mn(e,t){return t.lastIndex=0,t.test(e.hostname)}function Nn(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Pn=z(`$ZodURL`,(e,t)=>{Cn.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=On(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=jn(r);return}t.hostname&&!Mn(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Nn(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:jn(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Fn=z(`$ZodEmoji`,(e,t)=>{t.pattern??=Ot(),Cn.init(e,t)}),In=z(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?xt:St(t.length),Cn.init(e,t)}),Ln=z(`$ZodCUID`,(e,t)=>{t.pattern??=gt,Cn.init(e,t)}),Rn=z(`$ZodCUID2`,(e,t)=>{t.pattern??=_t,Cn.init(e,t)}),zn=z(`$ZodULID`,(e,t)=>{t.pattern??=vt,Cn.init(e,t)}),Bn=z(`$ZodXID`,(e,t)=>{t.pattern??=yt,Cn.init(e,t)}),Vn=z(`$ZodKSUID`,(e,t)=>{t.pattern??=bt,Cn.init(e,t)}),Hn=z(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ht(t),Cn.init(e,t)}),Un=z(`$ZodISODate`,(e,t)=>{t.pattern??=zt,Cn.init(e,t)}),Wn=z(`$ZodISOTime`,(e,t)=>{t.pattern??=Vt(t),Cn.init(e,t)}),Gn=z(`$ZodISODuration`,(e,t)=>{t.pattern??=Ct,Cn.init(e,t)}),Kn=z(`$ZodIPv4`,(e,t)=>{t.pattern??=kt,Cn.init(e,t)}),qn=/^[0-9a-fA-F:.]+$/;function Jn(e){return qn.test(e)?Dn(`http://[${e}]`):!1}var Yn=z(`$ZodIPv6`,(e,t)=>{t.pattern??=At,Cn.init(e,t),e._zod.check=n=>{Jn(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Xn=z(`$ZodCIDRv4`,(e,t)=>{t.pattern??=jt,Cn.init(e,t)});function Zn(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Jn(n)}var Qn=z(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Mt,Cn.init(e,t),e._zod.check=n=>{Zn(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function $n(e){if(e===``)return!0;if(/\\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var er=/^[0-9a-zA-Z+/]*={0,2}$/,tr=z(`$ZodBase64`,(e,t)=>{t.pattern??=er,Cn.init(e,t),e._zod.check=n=>{$n(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),nr=/^[A-Za-z0-9_-]*$/;function rr(e){if(!nr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return $n(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var ir=z(`$ZodBase64URL`,(e,t)=>{t.pattern??=nr,Cn.init(e,t),e._zod.check=n=>{rr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ar=z(`$ZodE164`,(e,t)=>{t.pattern??=It,Cn.init(e,t)});function or(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var sr=z(`$ZodJWT`,(e,t)=>{Cn.init(e,t),e._zod.check=n=>{or(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),cr=z(`$ZodNumber`,(e,t)=>{vn.init(e,t),e._zod.pattern=Gt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),lr=z(`$ZodNumberFormat`,(e,t)=>{rn.init(e,t),cr.init(e,t)}),ur=z(`$ZodBoolean`,(e,t)=>{vn.init(e,t),e._zod.pattern=Kt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),dr=z(`$ZodUndefined`,(e,t)=>{vn.init(e,t),e._zod.pattern=Jt,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),fr=z(`$ZodNull`,(e,t)=>{vn.init(e,t),e._zod.pattern=qt,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),pr=z(`$ZodAny`,(e,t)=>{vn.init(e,t),e._zod.parse=e=>e}),mr=z(`$ZodUnknown`,(e,t)=>{vn.init(e,t),e._zod.parse=e=>e}),hr=z(`$ZodNever`,(e,t)=>{vn.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function gr(e,t){let n=ge(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of ge(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,_e(n.issues,t,e),n}}return i(n,a)}}var _r=e=>Array.isArray(e)?e.length:-1;function vr(e,t,n){e.issues.length&&t.issues.push(...me(n,e.issues)),t.value[n]=e.value}var yr=z(`$ZodArray`,(e,t)=>{vn.init(e,t);let n=Be.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>vr(t,r,e)));else if(vr(c,r,e),s&&c.issues.length!==0&&fe(c))break}return o.length?Promise.all(o).then(()=>r):r},gr(e,_r)});function br(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...me(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var xr=[];function Sr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:xr,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key \"${String(t)}\": expected a Zod schema`);let a=ee(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Cr(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(fe(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>br(e,n,i,t,d,f))):br(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var wr=z(`$ZodObject`,(e,t)=>{vn.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,\"shape\",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,\"shape\",{get:e})}let i=l(()=>Sr(t));ke(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||h(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=E,o=t.catchall,s,c=Be.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(fe(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>br(n,t,e,r,a,o))):br(s,t,e,r,a,o)}return o?Cr(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Tr=z(`$ZodObjectJIT`,(e,t)=>{wr.init(e,t);let n=e._zod.parse,r=l(()=>Sr(t)),i=Be.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new gn([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`\n let ${e}_ab = false;\n for (let i = 0; i < ${e}.issues.length; i++) {\n const iss = ${e}.issues[i];\n iss.path = iss.path ? [${t}, ...iss.path] : [${t}];\n payload.issues.push(iss);\n if (iss.continue !== true) ${e}_ab = true;\n }\n if (${e}_ab && ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:C(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`\n const ${n}_present = ${i};\n if (!${n}.issues.length || ${n}_present) {\n if (${n}.issues.length) {${c(n,r)}\n }\n\n if (${e}) {\n newResult[${r}] = ${n}.value;\n }\n }\n\n `)}else f?(o.write(`\n if (${n}.issues.length) {${c(n,r)}\n }\n `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`\n if (${n}.value !== undefined || ${i}) {\n newResult[${r}] = ${n}.value;\n }\n `)):o.write(`\n const ${n}_present = ${i};\n if (${n}.issues.length) {${c(n,r)}\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${r}]\n });\n if (ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }\n }\n\n if (${n}_present) {\n newResult[${r}] = ${n}.value;\n }\n\n `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=E,c=!Be.jitless,u=c&&D.value,d=t.catchall,f;e._zod.parse=(i,l)=>{f??=r.value;let p=i.value;return s(p)?c&&u&&l?.async===!1&&l.jitless!==!0?(o||=a(t.shape),i=o(i,l),d?Cr([],p,i,l,f,e,l?.abortEarly===!0):i):n(i,l):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Er(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!fe(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>ve(e,r,Ve())))}),t)}var Dr=z(`$ZodUnion`,(e,t)=>{vn.init(e,t),ke(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),ke(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),ke(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),ke(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>d(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Er(t,r,e,i)):Er(o,r,e,i)}});function Or(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index \"${e.options.indexOf(n)}\"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value \"${String(e)}\"`);t.set(e,null)}else t.set(e,n)}return t}var kr=z(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Dr.init(e,t);let n=e._zod.parse;ke(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index \"${e.def.options.indexOf(r)}\"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||h(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=g(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index \"${n}\"`)});let r=l(()=>Or(t));e._zod.parse=(i,a)=>{let o=i.value;if(!E(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Ar=z(`$ZodIntersection`,(e,t)=>{vn.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Mr(e,t,n)):Mr(e,i,a)}});function jr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(O(e)&&O(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=jr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=jr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Mr(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=jr(t.value,n.value);if(!c.valid){if(fe(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Nr=z(`$ZodRecord`,(e,t)=>{vn.init(e,t);let n=Be.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!O(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>ve(e,i,Ve())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...me(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...me(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Gt.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>ve(e,i,Ve())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...me(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...me(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Pr=z(`$ZodEnum`,(e,t)=>{vn.init(e,t);let n=a(t.entries),r=new Set(n);e._zod.values=r,ke(e,`pattern`,e=>{let t=a(e.def.entries).filter(e=>A.has(typeof e));return RegExp(t.length?`^(${t.map(e=>j(e.toString())).join(`|`)})$`:`^[^\\\\s\\\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Fr=z(`$ZodLiteral`,(e,t)=>{vn.init(e,t);let n=new Set(t.values);e._zod.values=n,ke(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?j(e):e?j(e.toString()):String(e)).join(`|`)})$`:`^[^\\\\s\\\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Ir=z(`$ZodTransform`,(e,t)=>{vn.init(e,t),e._zod.optin=`optional`,Be.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ze(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Re;return n.value=i,n}});function Lr(e,t){return e.value=t.issues.length?void 0:t.value,e}var Rr=z(`$ZodOptional`,(e,t)=>{vn.init(e,t),ke(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,ke(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),ke(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${d(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Lr(e,t)):Lr(e,r)}return t.innerType._zod.run(e,n)}}),zr=z(`$ZodExactOptional`,(e,t)=>{Rr.init(e,t),ke(e,`values`,e=>e.def.innerType._zod.values),ke(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Br=z(`$ZodNullable`,(e,t)=>{vn.init(e,t),ke(e,`optin`,e=>e.def.innerType._zod.optin),ke(e,`optout`,e=>e.def.innerType._zod.optout),ke(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${d(t.source)}|null)$`):void 0}),ke(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Vr=z(`$ZodDefault`,(e,t)=>{vn.init(e,t),e._zod.optin=`defaulted`,ke(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Hr(e,t)):Hr(r,t)}});function Hr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ur=z(`$ZodPrefault`,(e,t)=>{vn.init(e,t),e._zod.optin=`defaulted`,ke(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Wr=z(`$ZodNonOptional`,(e,t)=>{vn.init(e,t),ke(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Gr(t,e)):Gr(i,e)}});function Gr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Kr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>ve(e,r,Ve()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var qr=z(`$ZodCatch`,(e,t)=>{vn.init(e,t),ke(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),ke(e,`optout`,e=>e.def.innerType._zod.optout),ke(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Kr(e,r,t,n)):Kr(e,r,t,n)}}),Jr=z(`$ZodPipe`,(e,t)=>{vn.init(e,t),ke(e,`values`,e=>e.def.in._zod.values),ke(e,`optin`,e=>e.def.in._zod.optin),ke(e,`optout`,e=>e.def.out._zod.optout),ke(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Yr(e,t.in,n)):Yr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Yr(e,t.out,n)):Yr(r,t.out,n)}});function Yr(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Xr=z(`$ZodPreprocess`,(e,t)=>{Jr.init(e,t)}),Zr=z(`$ZodReadonly`,(e,t)=>{vn.init(e,t),ke(e,`propValues`,e=>e.def.innerType._zod.propValues),ke(e,`values`,e=>e.def.innerType._zod.values),ke(e,`optin`,e=>e.def.innerType?._zod?.optin),ke(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Qr):Qr(r)}});function Qr(e){return e.memo||(e.value=Object.freeze(e.value)),e}var $r=z(`$ZodLazy`,(e,t)=>{vn.init(e,t),m(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),ke(e,`pattern`,e=>e.innerType?._zod?.pattern),ke(e,`propValues`,e=>e.innerType?._zod?.propValues),ke(e,`optin`,e=>e.innerType?._zod?.optin??void 0),ke(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),ei=z(`$ZodCustom`,(e,t)=>{Zt.init(e,t),vn.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ti(t,n,r,e));ti(i,n,r,e)}});function ti(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ce(e))}}var ni=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},ri=`~memo`,ii=[];function ai(e){return typeof e==`object`&&!!e}function oi(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var si=new WeakMap,ci=0,li=1,ui=2;function di(e,t,n){let r=si.get(e);if(r!==void 0)return r?ui:ci;if(t.has(e))return ui;t.add(e);let i=ci,a=e=>{if(i!==ui&&e?._zod){let r=di(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=ci;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?li:o.value?._zod?di(o.value,t,n):ci;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=g(c);s(e?o(e,!0):li),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?di(r,t,!1):li);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),fi(e,i)}function fi(e,t){return t!==li&&si.set(e,t===ui),t}function pi(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var mi,hi=[],gi={alloc(e,t,n){let r=mi;if(!r)return n;mi=void 0;let i={value:n,issues:null};return r.set(t.value,i),hi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&vi(n,e.value))throw new ni;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=di(e,new Set,!1);if(i===ci)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===ui||r?n=!0:r=!0}let l=s.value;if(!ai(l))return t(s,c);let u=c[ri];u||(u={buckets:new WeakMap,backEdges:void 0},c[ri]=u);let d;i===c?d=a:(d=pi(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...oi(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;mi=d;let p=hi.length,m=t(s,c);mi=void 0;let h=hi.length>p?hi.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?oi(e.issues):ii),e)):(h&&(h.issues=m.issues.length?oi(m.issues):ii),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function _i(){return gi}function vi(e,t){let n=e[ri]?.backEdges;return n!==void 0&&ai(t)&&n.has(t)}var yi=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Se(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${P(e.values[0])}`:`Invalid option: expected one of ${o(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with \"${t.prefix}\"`:t.format===`ends_with`?`Invalid string: must end with \"${t.suffix}\"`:t.format===`includes`?`Invalid string: must include \"${t.includes}\"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${o(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function bi(){return{localeError:yi()}}var xi,Si=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ci(){return new Si}(xi=globalThis).__zod_globalRegistry??(xi.__zod_globalRegistry=Ci());var wi=globalThis.__zod_globalRegistry;function Ti(e){return e.checks&&=[...e.checks],e}function Ei(e,t){return new e(Ti({type:`string`,...N(t)}))}function Di(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function Oi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function ki(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function Ai(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function ji(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function Mi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function Ni(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function Pi(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function Fi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function Ii(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function Li(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function Ri(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function zi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function Bi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function Vi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function Hi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function Ui(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function Wi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function Gi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function Ki(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function qi(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function Ji(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function Yi(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function Xi(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function Zi(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function Qi(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function $i(e,t){return new e(Ti({type:`number`,checks:[],...N(t)}))}function ea(e,t){return new e(Ti({type:`number`,coerce:!0,checks:[],...N(t)}))}function ta(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function na(e,t){return new e({type:`boolean`,...N(t)})}function ra(e,t){return new e({type:`undefined`,...N(t)})}function ia(e,t){return new e({type:`null`,...N(t)})}function aa(e){return new e({type:`any`})}function oa(e){return new e({type:`unknown`})}function sa(e,t){return new e({type:`never`,...N(t)})}function ca(e,t){return new en({check:`less_than`,...N(t),value:e,inclusive:!1})}function la(e,t){return new en({check:`less_than`,...N(t),value:e,inclusive:!0})}function ua(e,t){return new tn({check:`greater_than`,...N(t),value:e,inclusive:!1})}function da(e,t){return new tn({check:`greater_than`,...N(t),value:e,inclusive:!0})}function fa(e,t){return new nn({check:`multiple_of`,...N(t),value:e})}function pa(e,t){return new an({check:`max_length`,...N(t),maximum:e})}function ma(e,t){return new on({check:`min_length`,...N(t),minimum:e})}function ha(e,t){return new sn({check:`length_equals`,...N(t),length:e})}function ga(e,t){return new ln({check:`string_format`,format:`regex`,...N(t),pattern:e})}function _a(e){return new un({check:`string_format`,format:`lowercase`,...N(e)})}function va(e){return new dn({check:`string_format`,format:`uppercase`,...N(e)})}function ya(e,t){return new fn({check:`string_format`,format:`includes`,...N(t),includes:e})}function ba(e,t){return new pn({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function xa(e,t){return new mn({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function Sa(e){return new hn({check:`overwrite`,tx:e})}function Ca(e){return Sa(t=>t.normalize(e))}function wa(){return Sa(e=>e.trim())}function Ta(){return Sa(e=>e.toLowerCase())}function Ea(){return Sa(e=>e.toUpperCase())}function Da(){return Sa(e=>w(e))}function Oa(e,t,n){return new e({type:`array`,element:t,...N(n)})}function ka(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...N(n)})}function Aa(e,t){let n=ja(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ce(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ce(r))}},e(t.value,t)),t);return n}function ja(e,t){let n=new Zt({check:`custom`,...N(t)});return n._zod.check=e,n}function Ma(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&h(e,t,n[t]);return e}function Na(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??wi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Pa(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Fa(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Fa(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ma(o.schema,c),t.io===`input`&&Ga(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ia(e){return e.replace(/~/g,`~0`).replace(/\\//g,`~1`)}function La(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id \"${n}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Ia(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ia(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>\n\nSet the \\`cycles\\` parameter to \\`\"ref\"\\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ra(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Ra(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var za=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ba=[`oneOf`,`anyOf`];function Va(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ha(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!za.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Va(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}h(n,r,e.length===1?e[0]:Ha(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Va(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Ua(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of za)if(t in e)return;let n=t.filter(e=>Ba.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ha(t);else{let e=n[0],i=Ba.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ha([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ma(e,r))}function Wa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Ma(i,s),Ma(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Ra(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Ua(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error(\"Schema is missing an `id` property\");i.$id=e.external.uri(n)}Ma(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,h(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,\"~standard\",{value:{...t[`~standard`],jsonSchema:{input:qa(t,`input`,e.processors),output:qa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ga(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ga(r.element,n);if(r.type===`set`)return Ga(r.valueType,n);if(r.type===`lazy`)return Ga(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===\"default\"||r.type===`prefault`||r.type===`catch`)return Ga(r.innerType,n);if(r.type===`intersection`)return Ga(r.left,n)||Ga(r.right,n);if(r.type===`record`||r.type===`map`)return Ga(r.keyType,n)||Ga(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ga(r.in,n)||Ga(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ga(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ga(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ga(e,n))return!0;return!!(r.rest&&Ga(r.rest,n))}return!1}var Ka=(e,t={})=>n=>{let r=Na({...n,processors:t});return Fa(e,r),La(r,e),Wa(r,e)},qa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Na({...i??{},target:a,io:t,processors:n});return Fa(e,o),La(o,e),Wa(o,e)},Ja=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ya=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Xa=(e,t)=>{Ja(e,`minimum`,t),Ya(e,`maximum`,t)},Za=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Qa=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},$a=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},eo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},to=(e,t)=>Ja(e,`minimum`,t.minimum),no=(e,t)=>Ya(e,`maximum`,t.maximum),ro=e=>(t,n)=>{eo(t,n.format);let[r,i]=e[n.format];Ja(t,`minimum`,r),Ya(t,`maximum`,i)},io={greater_than:(e,t)=>Ja(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ya(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Za(e,t.value),number_format:ro(te),bigint_format:ro(ne),min_length:to,max_length:no,length_equals:(e,t)=>Xa(e,t.length),min_size:to,max_size:no,size_equals:(e,t)=>Xa(e,t.size),string_format:(e,t)=>{eo(e,t.format),t.pattern&&Qa(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>$a(e,t.mime)};function ao(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)io[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ja(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ja(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ya(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ya(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Za(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&$a(t,i.mime);for(let e of i.patterns??[])Qa(t,e);return t}var oo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},so=new Map([[er,Nt],[nr,Pt]]),co=e=>so.get(e)??e,lo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=ao(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=oo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(co);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},uo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ao(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Pa(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},fo=(e,t,n,r)=>{n.type=`boolean`},po=(e,t,n,r)=>{Pa(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},mo=(e,t,n,r)=>{Pa(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},go=(e,t,n,r)=>{Pa(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},_o=(e,t,n,r)=>{Pa(e,t,n,r,`Void cannot be represented in JSON Schema`)},vo=(e,t,n,r)=>{n.not={}},yo=(e,t,n,r)=>{},bo=(e,t,n,r)=>{},xo=(e,t,n,r)=>{Pa(e,t,n,r,`Date cannot be represented in JSON Schema`)},So=(e,t,n,r)=>{let i=e._zod.def,o=a(i.entries);o.length===0?n.not={}:(o.every(e=>typeof e==`number`)&&(n.type=`number`),o.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=o)},Co=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Pa(e,t,n,r,\"Literal `undefined` cannot be represented in JSON Schema\"))return}else if(typeof o==`bigint`){if(Pa(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},wo=(e,t,n,r)=>{Pa(e,t,n,r,`NaN cannot be represented in JSON Schema`)},To=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},Eo=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=ao(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},Do=(e,t,n,r)=>{n.type=`boolean`},Oo=(e,t,n,r)=>{Pa(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ko=(e,t,n,r)=>{Pa(e,t,n,r,`Function types cannot be represented in JSON Schema`)},Ao=(e,t,n,r)=>{Pa(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},jo=(e,t,n,r)=>{Pa(e,t,n,r,`Map cannot be represented in JSON Schema`)},Mo=(e,t,n,r)=>{Pa(e,t,n,r,`Set cannot be represented in JSON Schema`)},No=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=ao(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Fa(a.element,t,{...r,path:[...r.path,`items`]})};function Po(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Po(t.out):t.type===`catch`?Po(t.innerType):e._zod.optin}var Fo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Pa(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)h(i.properties,e,Fa(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Po(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Fa(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Io=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Fa(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Lo=(e,t,n,r)=>{let i=e._zod.def,a=Fa(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Fa(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Ro=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Fa(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Fa(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?Po(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=ao(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function zo(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=zo(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>zo(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Gt:Wt).source)),p}var Bo=new WeakMap;function Vo(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Bo.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=zo(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var Ho=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=ao(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Fa(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)h(i.patternProperties,co(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Fa(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Bo.get(t);n||(n=[],Bo.set(t,n),t.deferred.push(()=>Vo(t))),n.push(e)}i.additionalProperties=Fa(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Po(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Uo=(e,t,n,r)=>{let i=e._zod.def,a=Fa(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Wo=(e,t,n,r)=>{let i=e._zod.def;Fa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Go=Symbol();function Ko(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Pa(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Go):JSON.parse(o)}var qo=(e,t,n,r)=>{let i=e._zod.def;Fa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Ko(i.defaultValue,e,t,n,r);o!==Go&&(n.default=o)},Jo=(e,t,n,r)=>{let i=e._zod.def;Fa(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Ko(i.defaultValue,e,t,n,r);o!==Go&&(n._prefault=o)},Yo=(e,t,n,r)=>{let i=e._zod.def;Fa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Pa(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Xo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Fa(o,t,r);let s=t.seen.get(e);s.ref=o},Zo=(e,t,n,r)=>{let i=e._zod.def;Fa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Qo=(e,t,n,r)=>{let i=e._zod.def;Fa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},$o=(e,t,n,r)=>{let i=e._zod.def;Fa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},es=(e,t,n,r)=>{let i=e._zod.innerType;Fa(i,t,r);let a=t.seen.get(e);a.ref=i},ts={string:lo,number:uo,boolean:fo,bigint:po,symbol:mo,null:ho,undefined:go,void:_o,never:vo,any:yo,unknown:bo,date:xo,enum:So,literal:Co,nan:wo,template_literal:To,file:Eo,success:Do,custom:Oo,function:ko,transform:Ao,map:jo,set:Mo,array:No,object:Fo,union:Io,intersection:Lo,tuple:Ro,record:Ho,nullable:Uo,nonoptional:Wo,default:qo,prefault:Jo,catch:Yo,pipe:Xo,readonly:Zo,promise:Qo,optional:$o,lazy:es};function ns(e,t){if(`_idmap`in e){let n=e,r=Na({...t,processors:ts}),i={};for(let e of n._idmap.entries()){let[t,n]=e;Fa(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;La(r,n),h(a,t,Wa(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Na({...t,processors:ts});return Fa(e,n),La(n,e),Wa(n,e)}var rs=new WeakSet([Object.prototype,Error.prototype]);function is(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var as=z(`ZodError`,(e,t)=>{qe.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);rs.has(n)||(rs.add(n),is(n,`format`,e=>t=>Xe(e,t)),is(n,`flatten`,e=>t=>Ye(e,t)),is(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,s,2)}),is(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,s,2)}),Object.defineProperty(n,\"isEmpty\",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),os=Qe(as),ss=$e(as),cs=et(as),ls=nt(as),us=ct(as),ds=lt(as),fs=ut(as),ps=dt(as),ms=ft(as),hs=pt(as),gs=mt(as),_s=ht(as);function vs(){Be.localeError||Ve(bi())}function ys(){Be.memoizer||Ve({memoizer:_i()})}var bs=z(`ZodType`,(e,t)=>(vs(),vn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(S(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return M(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Uc(e,t))},superRefine(e,t){return this.check(Wc(e,t))},overwrite(e){return this.check(Sa(e))},optional(){return Y(this)},exactOptional(){return wc(this)},nullable(){return Ec(this)},nullish(){return Y(Ec(this))},nonoptional(e){return Mc(this,e)},array(){return W(this)},or(e){return K([this,e])},and(e){return hc(this,e)},transform(e){return Ic(this,xc(e))},default(e){return Oc(this,e)},prefault(e){return Ac(this,e)},catch(e){return Pc(this,e)},pipe(e){return Ic(this,e)},readonly(){return zc(this)},describe(e){let t=this.clone();return wi.add(t,{description:e}),t},meta(...e){if(e.length===0)return wi.get(this);let t=this.clone();return wi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get\"~standard\"(){return Te(this,`~standard`,{...xn(this),jsonSchema:{input:qa(this,`input`),output:qa(this,`output`)}})},set\"~standard\"(e){we(this,`~standard`,e)},parse:function e(t,n){return os(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ss(this,t,n,{callee:e})},safeParse(e,t){return cs(this,e,t)},async safeParseAsync(e,t){return ls(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){we(this,`spa`,e)},validate(e,t){return at(this,e,t)},validateAsync(e,t){return st(this,e,t)},encode:function e(t,n){return us(this,t,n,{callee:e})},decode:function e(t,n){return ds(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await fs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await ps(this,t,n,{callee:e})},safeEncode(e,t){return ms(this,e,t)},safeDecode(e,t){return hs(this,e,t)},async safeEncodeAsync(e,t){return gs(this,e,t)},async safeDecodeAsync(e,t){return _s(this,e,t)},toJSONSchema(e){return Ka(this,{})(e)},get description(){return wi.get(this)?.description},get _def(){return this._zod.def}}),xs=z(`_ZodString`,(e,t)=>{Sn.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)},Ee({format:e=>ao(e).format??null,minLength:e=>ao(e).minimum??null,maxLength:e=>ao(e).maximum??null},{regex(...e){return this.check(ga(...e))},includes(...e){return this.check(ya(...e))},startsWith(...e){return this.check(ba(...e))},endsWith(...e){return this.check(xa(...e))},min(...e){return this.check(ma(...e))},max(...e){return this.check(pa(...e))},length(...e){return this.check(ha(...e))},nonempty(...e){return this.check(ma(1,...e))},lowercase(e){return this.check(_a(e))},uppercase(e){return this.check(va(e))},trim(){return this.check(wa())},normalize(...e){return this.check(Ca(...e))},toLowerCase(){return this.check(Ta())},toUpperCase(){return this.check(Ea())},slugify(){return this.check(Da())}})),Ss=z(`ZodString`,(e,t)=>{Sn.init(e,t),xs.init(e,t)},{email(e){return this.check(Di(Os,e))},url(e){return this.check(Ni(Ms,e))},jwt(e){return this.check(Ji(Js,e))},emoji(e){return this.check(Pi(Ps,e))},guid(e){return this.check(Oi(As,e))},uuid(e){return this.check(ki(js,e))},uuidv4(e){return this.check(Ai(js,e))},uuidv6(e){return this.check(ji(js,e))},uuidv7(e){return this.check(Mi(js,e))},nanoid(e){return this.check(Fi(Fs,e))},cuid(e){return this.check(Ii(Is,e))},cuid2(e){return this.check(Li(Ls,e))},ulid(e){return this.check(Ri(Rs,e))},base64(e){return this.check(Gi(Gs,e))},base64url(e){return this.check(Ki(Ks,e))},xid(e){return this.check(zi(zs,e))},ksuid(e){return this.check(Bi(Bs,e))},ipv4(e){return this.check(Vi(Vs,e))},ipv6(e){return this.check(Hi(Hs,e))},cidrv4(e){return this.check(Ui(Us,e))},cidrv6(e){return this.check(Wi(Ws,e))},e164(e){return this.check(qi(qs,e))},datetime(e){return this.check(Yi(ws,e))},date(e){return this.check(Xi(Ts,e))},time(e){return this.check(Zi(Es,e))},duration(e){return this.check(Qi(Ds,e))}});function B(e){return Ei(Ss,e)}var Cs=z(`ZodStringFormat`,(e,t)=>{Cn.init(e,t),xs.init(e,t)}),ws=z(`ZodISODateTime`,(e,t)=>{Hn.init(e,t),Cs.init(e,t)}),Ts=z(`ZodISODate`,(e,t)=>{Un.init(e,t),Cs.init(e,t)}),Es=z(`ZodISOTime`,(e,t)=>{Wn.init(e,t),Cs.init(e,t)}),Ds=z(`ZodISODuration`,(e,t)=>{Gn.init(e,t),Cs.init(e,t)}),Os=z(`ZodEmail`,(e,t)=>{En.init(e,t),Cs.init(e,t)});function ks(e){return Di(Os,e)}var As=z(`ZodGUID`,(e,t)=>{wn.init(e,t),Cs.init(e,t)}),js=z(`ZodUUID`,(e,t)=>{Tn.init(e,t),Cs.init(e,t)}),Ms=z(`ZodURL`,(e,t)=>{Pn.init(e,t),Cs.init(e,t)});function Ns(e){return Ni(Ms,e)}var Ps=z(`ZodEmoji`,(e,t)=>{Fn.init(e,t),Cs.init(e,t)}),Fs=z(`ZodNanoID`,(e,t)=>{In.init(e,t),Cs.init(e,t)}),Is=z(`ZodCUID`,(e,t)=>{Ln.init(e,t),Cs.init(e,t)}),Ls=z(`ZodCUID2`,(e,t)=>{Rn.init(e,t),Cs.init(e,t)}),Rs=z(`ZodULID`,(e,t)=>{zn.init(e,t),Cs.init(e,t)}),zs=z(`ZodXID`,(e,t)=>{Bn.init(e,t),Cs.init(e,t)}),Bs=z(`ZodKSUID`,(e,t)=>{Vn.init(e,t),Cs.init(e,t)}),Vs=z(`ZodIPv4`,(e,t)=>{Kn.init(e,t),Cs.init(e,t)}),Hs=z(`ZodIPv6`,(e,t)=>{Yn.init(e,t),Cs.init(e,t)}),Us=z(`ZodCIDRv4`,(e,t)=>{Xn.init(e,t),Cs.init(e,t)}),Ws=z(`ZodCIDRv6`,(e,t)=>{Qn.init(e,t),Cs.init(e,t)}),Gs=z(`ZodBase64`,(e,t)=>{tr.init(e,t),Cs.init(e,t)}),Ks=z(`ZodBase64URL`,(e,t)=>{ir.init(e,t),Cs.init(e,t)}),qs=z(`ZodE164`,(e,t)=>{ar.init(e,t),Cs.init(e,t)}),Js=z(`ZodJWT`,(e,t)=>{sr.init(e,t),Cs.init(e,t)}),Ys=z(`ZodNumber`,(e,t)=>{cr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.isFinite=!0},Ee({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=ao(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=ao(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=ao(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ao(e).format??null},{gt(e,t){return this.check(ua(e,t))},gte(e,t){return this.check(da(e,t))},min(e,t){return this.check(da(e,t))},lt(e,t){return this.check(ca(e,t))},lte(e,t){return this.check(la(e,t))},max(e,t){return this.check(la(e,t))},int(e){return this.check(Zs(e))},safe(e){return this.check(Zs(e))},positive(e){return this.check(ua(0,e))},nonnegative(e){return this.check(da(0,e))},negative(e){return this.check(ca(0,e))},nonpositive(e){return this.check(la(0,e))},multipleOf(e,t){return this.check(fa(e,t))},step(e,t){return this.check(fa(e,t))},finite(){return this}}));function V(e){return $i(Ys,e)}var Xs=z(`ZodNumberFormat`,(e,t)=>{lr.init(e,t),Ys.init(e,t)});function Zs(e){return ta(Xs,e)}var Qs=z(`ZodBoolean`,(e,t)=>{ur.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r)});function H(e){return na(Qs,e)}var $s=z(`ZodUndefined`,(e,t)=>{dr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r)});function ec(e){return ra($s,e)}var tc=z(`ZodNull`,(e,t)=>{fr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r)});function nc(e){return ia(tc,e)}var rc=z(`ZodAny`,(e,t)=>{pr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ic(){return aa(rc)}var ac=z(`ZodUnknown`,(e,t)=>{mr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function U(){return oa(ac)}var oc=z(`ZodNever`,(e,t)=>{hr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function sc(e){return sa(oc,e)}var cc=z(`ZodArray`,(e,t)=>{ys(),yr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ma(e,t))},nonempty(e){return this.check(ma(1,e))},max(e,t){return this.check(pa(e,t))},length(e,t){return this.check(ha(e,t))},unwrap(){return this.element}});function W(e,t){return Oa(cc,e,t)}var lc=z(`ZodObject`,(e,t)=>{ys(),Tr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),Ae(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return vc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(S(this._zod.def,{catchall:e}))},passthrough(){return this.clone(S(this._zod.def,{catchall:U()}))},loose(){return this.clone(S(this._zod.def,{catchall:U()}))},strict(){return this.clone(S(this._zod.def,{catchall:sc()}))},strip(){return this.clone(S(this._zod.def,{catchall:void 0}))},extend(e){return oe(this,e)},safeExtend(e){return ce(this,e)},merge(e){return le(this,e)},pick(e){return re(this,e)},omit(e){return ae(this,e)},partial(...e){return ue(Sc,this,e[0])},exactPartial(...e){return ue(Cc,this,e[0],`exactPartial`)},required(...e){return de(jc,this,e[0])}});function G(e,t){return new lc({type:`object`,shape:e??{},...N(t)})}function uc(e,t){return new lc({type:`object`,shape:e,catchall:U(),...N(t)})}var dc=z(`ZodUnion`,(e,t)=>{Dr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.options=t.options});function K(e,t){return new dc({type:`union`,options:e,...N(t)})}var fc=z(`ZodDiscriminatedUnion`,(e,t)=>{dc.init(e,t),kr.init(e,t)});function pc(e,t,n){return new fc({type:`union`,options:t,discriminator:e,...N(n)})}var mc=z(`ZodIntersection`,(e,t)=>{Ar.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r)});function hc(e,t){return new mc({type:`intersection`,left:e,right:t})}var gc=z(`ZodRecord`,(e,t)=>{ys(),Nr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function q(e,t,n){return!t||!t._zod?new gc({type:`record`,keyType:B(),valueType:e,...N(t)}):new gc({type:`record`,keyType:e,valueType:t,...N(n)})}var _c=z(`ZodEnum`,(e,t)=>{Pr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new _c({...t,checks:[],...N(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new _c({...t,checks:[],...N(r),entries:i})}});function vc(e,t){return new _c({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...N(t)})}var yc=z(`ZodLiteral`,(e,t)=>{Fr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,\"value\",{get(){if(t.values.length>1)throw Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");return t.values[0]}})});function J(e,t){return new yc({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}var bc=z(`ZodTransform`,(e,t)=>{ys(),Ir.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ze(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ce(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Ce(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function xc(e){return new bc({type:`transform`,transform:e})}var Sc=z(`ZodOptional`,(e,t)=>{Rr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Y(e){return new Sc({type:`optional`,innerType:e})}var Cc=z(`ZodExactOptional`,(e,t)=>{zr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wc(e){return new Cc({type:`optional`,innerType:e})}var Tc=z(`ZodNullable`,(e,t)=>{Br.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e){return new Tc({type:`nullable`,innerType:e})}var Dc=z(`ZodDefault`,(e,t)=>{Vr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Oc(e,t){return new Dc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():k(t)}})}var kc=z(`ZodPrefault`,(e,t)=>{Ur.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ac(e,t){return new kc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():k(t)}})}var jc=z(`ZodNonOptional`,(e,t)=>{Wr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mc(e,t){return new jc({type:`nonoptional`,innerType:e,...N(t)})}var Nc=z(`ZodCatch`,(e,t)=>{qr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Pc(e,t){return new Nc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Me(t)})}var Fc=z(`ZodPipe`,(e,t)=>{Jr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.in=t.in,e.out=t.out});function Ic(e,t){return new Fc({type:`pipe`,in:e,out:t})}var Lc=z(`ZodPreprocess`,(e,t)=>{Fc.init(e,t),Xr.init(e,t)}),Rc=z(`ZodReadonly`,(e,t)=>{Zr.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`readonly`,innerType:e})}var Bc=z(`ZodLazy`,(e,t)=>{$r.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Vc(e){return new Bc({type:`lazy`,getter:e})}var Hc=z(`ZodCustom`,(e,t)=>{ei.init(e,t),bs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r)});function Uc(e,t={}){return ka(Hc,e,t)}function Wc(e,t){return Aa(e,t)}function Gc(e,t){return new Lc({type:`pipe`,in:xc(e),out:t})}var Kc={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},qc;qc||={};function Jc(e){return Yi(ws,e)}function Yc(e){return Xi(Ts,e)}function Xc(e){return ea(Ys,e)}var Zc=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Qc=`io.modelcontextprotocol/related-task`,$c=`io.modelcontextprotocol/protocolVersion`,el=`io.modelcontextprotocol/clientInfo`,tl=`io.modelcontextprotocol/serverInfo`,nl=`io.modelcontextprotocol/clientCapabilities`,rl=`io.modelcontextprotocol/subscriptionId`,il=`io.modelcontextprotocol/logLevel`,al=Vc(()=>K([B(),V(),H(),nc(),q(B(),al),W(al)])),ol=q(B(),al),sl=W(al),cl=K([B(),V().int()]),ll=B(),ul=G({ttl:V().optional()}),dl=G({taskId:B()}),fl=uc({progressToken:cl.optional(),[Qc]:dl.optional()}),pl=G({_meta:fl.optional()}),ml=pl.extend({task:ul.optional()}),hl=G({method:B(),params:pl.loose().optional()}),gl=G({_meta:fl.optional()}),_l=G({method:B(),params:gl.loose().optional()}),vl=uc({get[tl](){return Nl.optional().catch(void 0)}}),yl=uc({_meta:vl.optional()}),bl=K([B(),V().int()]),xl=G({jsonrpc:J(`2.0`),id:bl,...hl.shape}).strict(),Sl=G({jsonrpc:J(`2.0`),..._l.shape}).strict(),Cl=G({jsonrpc:J(`2.0`),id:bl,result:yl}).strict(),wl=G({jsonrpc:J(`2.0`),id:bl.optional(),error:G({code:V().int(),message:B(),data:U().optional()})}).strict(),Tl=K([xl,Sl,Cl,wl]),El=K([Cl,wl]),Dl=yl.strict(),Ol=gl.extend({requestId:bl.optional(),reason:B().optional()}),kl=_l.extend({method:J(`notifications/cancelled`),params:Ol}),Al=G({src:B(),mimeType:B().optional(),sizes:W(B()).optional(),theme:vc([`light`,`dark`]).optional()}),jl=G({icons:W(Al).optional()}),Ml=G({name:B(),title:B().optional()}),Nl=Ml.extend({...Ml.shape,...jl.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),Pl=Gc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,hc(G({form:hc(G({applyDefaults:H().optional()}),ol).optional(),url:ol.optional()}),ol.optional())),Fl=uc({list:ol.optional(),cancel:ol.optional(),requests:uc({sampling:uc({createMessage:ol.optional()}).optional(),elicitation:uc({create:ol.optional()}).optional()}).optional()}),Il=uc({list:ol.optional(),cancel:ol.optional(),requests:uc({tools:uc({call:ol.optional()}).optional()}).optional()}),Ll=G({experimental:q(B(),ol).optional(),sampling:G({context:ol.optional(),tools:ol.optional()}).optional(),elicitation:Pl.optional(),roots:G({listChanged:H().optional()}).optional(),tasks:Fl.optional(),extensions:q(B(),ol).optional()}),Rl=pl.extend({protocolVersion:B(),capabilities:Ll,clientInfo:Nl}),zl=hl.extend({method:J(`initialize`),params:Rl}),Bl=G({experimental:q(B(),ol).optional(),logging:ol.optional(),completions:ol.optional(),prompts:G({listChanged:H().optional()}).optional(),resources:G({subscribe:H().optional(),listChanged:H().optional()}).optional(),tools:G({listChanged:H().optional()}).optional(),tasks:Il.optional(),extensions:q(B(),ol).optional()}),Vl=yl.extend({protocolVersion:B(),capabilities:Bl,serverInfo:Nl,instructions:B().optional()}),Hl=_l.extend({method:J(`notifications/initialized`),params:gl.optional()}),Ul=hl.extend({method:J(`server/discover`),params:pl.optional()}),Wl=yl.extend({supportedVersions:W(B()),capabilities:Bl,instructions:B().optional()}),Gl=hl.extend({method:J(`ping`),params:pl.optional()}),Kl=G({progress:V(),total:Y(V()),message:Y(B())}),ql=G({...gl.shape,...Kl.shape,progressToken:cl}),Jl=_l.extend({method:J(`notifications/progress`),params:ql}),Yl=pl.extend({cursor:ll.optional()}),Xl=hl.extend({params:Yl.optional()}),Zl=yl.extend({nextCursor:ll.optional()}),Ql=G({uri:B(),mimeType:Y(B()),_meta:q(B(),U()).optional()}),$l=Ql.extend({text:B()}),eu=B().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),tu=Ql.extend({blob:eu}),nu=vc([`user`,`assistant`]),ru=G({audience:W(nu).optional(),priority:V().min(0).max(1).optional(),lastModified:Jc({offset:!0}).optional()}),iu=G({...Ml.shape,...jl.shape,uri:B(),description:Y(B()),mimeType:Y(B()),size:Y(V()),annotations:ru.optional(),_meta:Y(uc({}))}),au=G({...Ml.shape,...jl.shape,uriTemplate:B(),description:Y(B()),mimeType:Y(B()),annotations:ru.optional(),_meta:Y(uc({}))}),ou=Xl.extend({method:J(`resources/list`)}),su=Zl.extend({resources:W(iu)}),cu=Xl.extend({method:J(`resources/templates/list`)}),lu=Zl.extend({resourceTemplates:W(au)}),uu=pl.extend({uri:B()}),du=uu,fu=hl.extend({method:J(`resources/read`),params:du}),pu=yl.extend({contents:W(K([$l,tu]))}),mu=_l.extend({method:J(`notifications/resources/list_changed`),params:gl.optional()}),hu=uu,gu=hl.extend({method:J(`resources/subscribe`),params:hu}),_u=uu,vu=hl.extend({method:J(`resources/unsubscribe`),params:_u}),yu=G({toolsListChanged:H().optional(),promptsListChanged:H().optional(),resourcesListChanged:H().optional(),resourceSubscriptions:W(B()).optional()}),bu=pl.extend({notifications:yu}),xu=hl.extend({method:J(`subscriptions/listen`),params:bu}),Su=gl.extend({notifications:yu}),Cu=_l.extend({method:J(`notifications/subscriptions/acknowledged`),params:Su}),wu=vl.extend({[rl]:bl}),Tu=yl.extend({_meta:wu}),Eu=gl.extend({uri:B()}),Du=_l.extend({method:J(`notifications/resources/updated`),params:Eu}),Ou=G({name:B(),description:Y(B()),required:Y(H())}),ku=G({...Ml.shape,...jl.shape,description:Y(B()),arguments:Y(W(Ou)),_meta:Y(uc({}))}),Au=Xl.extend({method:J(`prompts/list`)}),ju=Zl.extend({prompts:W(ku)}),Mu=pl.extend({name:B(),arguments:q(B(),B()).optional()}),Nu=hl.extend({method:J(`prompts/get`),params:Mu}),Pu=G({type:J(`text`),text:B(),annotations:ru.optional(),_meta:q(B(),U()).optional()}),Fu=G({type:J(`image`),data:eu,mimeType:B(),annotations:ru.optional(),_meta:q(B(),U()).optional()}),Iu=G({type:J(`audio`),data:eu,mimeType:B(),annotations:ru.optional(),_meta:q(B(),U()).optional()}),Lu=G({type:J(`tool_use`),name:B(),id:B(),input:q(B(),U()),_meta:q(B(),U()).optional()}),Ru=G({type:J(`resource`),resource:K([$l,tu]),annotations:ru.optional(),_meta:q(B(),U()).optional()}),zu=iu.extend({type:J(`resource_link`)}),Bu=K([Pu,Fu,Iu,zu,Ru]),Vu=G({role:nu,content:Bu}),Hu=yl.extend({description:B().optional(),messages:W(Vu)}),Uu=_l.extend({method:J(`notifications/prompts/list_changed`),params:gl.optional()}),Wu=G({title:B().optional(),readOnlyHint:H().optional(),destructiveHint:H().optional(),idempotentHint:H().optional(),openWorldHint:H().optional()}),Gu=G({taskSupport:vc([`required`,`optional`,`forbidden`]).optional()}),Ku=G({...Ml.shape,...jl.shape,description:B().optional(),inputSchema:G({type:J(`object`),properties:q(B(),al).optional(),required:W(B()).optional()}).catchall(U()),outputSchema:uc({$schema:B().optional()}).optional(),annotations:Wu.optional(),execution:Gu.optional(),_meta:q(B(),U()).optional()}),qu=Xl.extend({method:J(`tools/list`)}),Ju=Zl.extend({tools:W(Ku)}),Yu=yl.extend({content:W(Bu).default([]),structuredContent:U().optional(),isError:H().optional()}),Xu=Yu.or(yl.extend({toolResult:U()})),Zu=ml.extend({name:B(),arguments:q(B(),U()).optional()}),Qu=hl.extend({method:J(`tools/call`),params:Zu}),$u=_l.extend({method:J(`notifications/tools/list_changed`),params:gl.optional()}),ed=G({autoRefresh:H().default(!0),debounceMs:V().int().nonnegative().default(300)}),td=vc([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),nd=pl.extend({level:td}),rd=hl.extend({method:J(`logging/setLevel`),params:nd}),id=gl.extend({level:td,logger:B().optional(),data:U()}),ad=_l.extend({method:J(`notifications/message`),params:id}),od=G({name:B().optional()}),sd=G({hints:W(od).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),cd=G({mode:vc([`auto`,`required`,`none`]).optional()}),ld=G({type:J(`tool_result`),toolUseId:B().describe(`The unique identifier for the corresponding tool call.`),content:W(Bu),structuredContent:U().optional(),isError:H().optional(),_meta:q(B(),U()).optional()}),ud=pc(`type`,[Pu,Fu,Iu]),dd=pc(`type`,[Pu,Fu,Iu,Lu,ld]),fd=G({role:nu,content:K([dd,W(dd)]),_meta:q(B(),U()).optional()}),pd=ml.extend({messages:W(fd),modelPreferences:sd.optional(),systemPrompt:B().optional(),includeContext:vc([`none`,`thisServer`,`allServers`]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:W(B()).optional(),metadata:ol.optional(),tools:W(Ku).optional(),toolChoice:cd.optional()}),md=hl.extend({method:J(`sampling/createMessage`),params:pd}),hd=yl.extend({model:B(),stopReason:Y(vc([`endTurn`,`stopSequence`,`maxTokens`]).or(B())),role:nu,content:ud}),gd=yl.extend({model:B(),stopReason:Y(vc([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(B())),role:nu,content:K([dd,W(dd)])}),_d=G({type:J(`boolean`),title:B().optional(),description:B().optional(),default:H().optional()}),vd=G({type:J(`string`),title:B().optional(),description:B().optional(),minLength:V().optional(),maxLength:V().optional(),format:vc([`email`,`uri`,`date`,`date-time`]).optional(),default:B().optional()}),yd=G({type:vc([`number`,`integer`]),title:B().optional(),description:B().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),bd=G({type:J(`string`),title:B().optional(),description:B().optional(),enum:W(B()),default:B().optional()}),xd=G({type:J(`string`),title:B().optional(),description:B().optional(),oneOf:W(G({const:B(),title:B()})),default:B().optional()}),Sd=G({type:J(`string`),title:B().optional(),description:B().optional(),enum:W(B()),enumNames:W(B()).optional(),default:B().optional()}),Cd=K([bd,xd]),wd=G({type:J(`array`),title:B().optional(),description:B().optional(),minItems:V().optional(),maxItems:V().optional(),items:G({type:J(`string`),enum:W(B())}),default:W(B()).optional()}),Td=G({type:J(`array`),title:B().optional(),description:B().optional(),minItems:V().optional(),maxItems:V().optional(),items:G({anyOf:W(G({const:B(),title:B()}))}),default:W(B()).optional()}),Ed=K([wd,Td]),Dd=K([Sd,Cd,Ed]),Od=K([Dd,_d,vd,yd]),kd=ml.extend({mode:J(`form`).optional(),message:B(),requestedSchema:G({type:J(`object`),properties:q(B(),Od),required:W(B()).optional()}).catchall(U())}),Ad=ml.extend({mode:J(`url`),message:B(),elicitationId:B(),url:B().url()}),jd=K([kd,Ad]),Md=hl.extend({method:J(`elicitation/create`),params:jd}),Nd=gl.extend({elicitationId:B()}),Pd=_l.extend({method:J(`notifications/elicitation/complete`),params:Nd}),Fd=yl.extend({action:vc([`accept`,`decline`,`cancel`]),content:Gc(e=>e===null?void 0:e,q(B(),K([B(),V(),H(),W(B())])).optional())}),Id=G({type:J(`ref/resource`),uri:B()}),Ld=G({type:J(`ref/prompt`),name:B()}),Rd=pl.extend({ref:K([Ld,Id]),argument:G({name:B(),value:B()}),context:G({arguments:q(B(),B()).optional()}).optional()}),zd=hl.extend({method:J(`completion/complete`),params:Rd}),Bd=yl.extend({completion:uc({values:W(B()).max(100),total:Y(V().int()),hasMore:Y(H())})}),Vd=G({uri:B().startsWith(`file://`),name:B().optional(),_meta:q(B(),U()).optional()}),Hd=hl.extend({method:J(`roots/list`),params:pl.optional()}),Ud=yl.extend({roots:W(Vd)}),Wd=_l.extend({method:J(`notifications/roots/list_changed`),params:gl.optional()}),Gd=uc({ttl:V().optional(),pollInterval:V().optional()}),Kd=vc([`working`,`input_required`,`completed`,`failed`,`cancelled`]),qd=G({taskId:B(),status:Kd,ttl:K([V(),nc()]),createdAt:B(),lastUpdatedAt:B(),pollInterval:Y(V()),statusMessage:Y(B())}),Jd=yl.extend({task:qd}),Yd=gl.merge(qd),Xd=_l.extend({method:J(`notifications/tasks/status`),params:Yd}),Zd=hl.extend({method:J(`tasks/get`),params:pl.extend({taskId:B()})}),Qd=yl.merge(qd),$d=hl.extend({method:J(`tasks/result`),params:pl.extend({taskId:B()})}),ef=yl.loose(),tf=Xl.extend({method:J(`tasks/list`)}),nf=Zl.extend({tasks:W(qd)}),rf=hl.extend({method:J(`tasks/cancel`),params:pl.extend({taskId:B()})}),af=yl.merge(qd),of=K([Gl,zl,Ul,zd,rd,Nu,Au,ou,cu,fu,gu,vu,xu,Qu,qu]),sf=K([kl,Jl,Hl,Wd]),cf=K([Dl,hd,gd,Fd,Ud]),lf=K([Gl,md,Md,Hd]),uf=K([kl,Jl,ad,Du,mu,$u,Uu,Cu,Pd]),df=K([Dl,Vl,Wl,Bd,Hu,ju,su,lu,pu,Yu,Ju,Tu]),ff=Ns().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Kc.custom,message:`URL must be parseable`,fatal:!0}),Pe}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),pf=uc({resource:B().url(),authorization_servers:W(ff).optional(),jwks_uri:B().url().optional(),scopes_supported:W(B()).optional(),bearer_methods_supported:W(B()).optional(),resource_signing_alg_values_supported:W(B()).optional(),resource_name:B().optional(),resource_documentation:B().optional(),resource_policy_uri:B().url().optional(),resource_tos_uri:B().url().optional(),tls_client_certificate_bound_access_tokens:H().optional(),authorization_details_types_supported:W(B()).optional(),dpop_signing_alg_values_supported:W(B()).optional(),dpop_bound_access_tokens_required:H().optional()}),mf=uc({issuer:B(),authorization_endpoint:ff,token_endpoint:ff,registration_endpoint:ff.optional(),scopes_supported:W(B()).optional(),response_types_supported:W(B()),response_modes_supported:W(B()).optional(),grant_types_supported:W(B()).optional(),token_endpoint_auth_methods_supported:W(B()).optional(),token_endpoint_auth_signing_alg_values_supported:W(B()).optional(),service_documentation:ff.optional(),revocation_endpoint:ff.optional(),revocation_endpoint_auth_methods_supported:W(B()).optional(),revocation_endpoint_auth_signing_alg_values_supported:W(B()).optional(),introspection_endpoint:B().optional(),introspection_endpoint_auth_methods_supported:W(B()).optional(),introspection_endpoint_auth_signing_alg_values_supported:W(B()).optional(),code_challenge_methods_supported:W(B()).optional(),client_id_metadata_document_supported:H().optional(),authorization_response_iss_parameter_supported:H().optional().catch(void 0),dpop_signing_alg_values_supported:W(B()).optional()}),hf=uc({issuer:B(),authorization_endpoint:ff,token_endpoint:ff,userinfo_endpoint:ff.optional(),jwks_uri:ff,registration_endpoint:ff.optional(),scopes_supported:W(B()).optional(),response_types_supported:W(B()),response_modes_supported:W(B()).optional(),grant_types_supported:W(B()).optional(),acr_values_supported:W(B()).optional(),subject_types_supported:W(B()),id_token_signing_alg_values_supported:W(B()),id_token_encryption_alg_values_supported:W(B()).optional(),id_token_encryption_enc_values_supported:W(B()).optional(),userinfo_signing_alg_values_supported:W(B()).optional(),userinfo_encryption_alg_values_supported:W(B()).optional(),userinfo_encryption_enc_values_supported:W(B()).optional(),request_object_signing_alg_values_supported:W(B()).optional(),request_object_encryption_alg_values_supported:W(B()).optional(),request_object_encryption_enc_values_supported:W(B()).optional(),token_endpoint_auth_methods_supported:W(B()).optional(),token_endpoint_auth_signing_alg_values_supported:W(B()).optional(),display_values_supported:W(B()).optional(),claim_types_supported:W(B()).optional(),claims_supported:W(B()).optional(),service_documentation:B().optional(),claims_locales_supported:W(B()).optional(),ui_locales_supported:W(B()).optional(),claims_parameter_supported:H().optional(),request_parameter_supported:H().optional(),request_uri_parameter_supported:H().optional(),require_request_uri_registration:H().optional(),op_policy_uri:ff.optional(),op_tos_uri:ff.optional(),client_id_metadata_document_supported:H().optional(),authorization_response_iss_parameter_supported:H().optional().catch(void 0)}),gf=G({...hf.shape,...mf.pick({code_challenge_methods_supported:!0}).shape}),_f=G({access_token:B(),id_token:B().optional(),token_type:B(),expires_in:Xc().optional(),scope:B().optional(),refresh_token:B().optional(),issuer:B().optional().catch(void 0)}).strip(),vf=G({issued_token_type:J(`urn:ietf:params:oauth:token-type:id-jag`),access_token:B(),token_type:B().optional(),expires_in:V().optional(),scope:B().optional()}).strip(),yf=G({error:B(),error_description:B().optional(),error_uri:B().optional()}),bf=ff.optional().or(J(``).transform(()=>void 0)),xf=G({redirect_uris:W(ff),token_endpoint_auth_method:B().optional(),grant_types:W(B()).optional(),response_types:W(B()).optional(),application_type:B().optional(),client_name:B().optional(),client_uri:ff.optional(),logo_uri:bf,scope:B().optional(),contacts:W(B()).optional(),tos_uri:bf,policy_uri:B().optional(),jwks_uri:ff.optional(),jwks:ic().optional(),software_id:B().optional(),software_version:B().optional(),software_statement:B().optional()}).strip(),Sf=G({client_id:B(),client_secret:B().optional(),client_id_issued_at:V().optional(),client_secret_expires_at:V().optional(),issuer:B().optional().catch(void 0)}).strip(),Cf=xf.merge(Sf),wf=G({error:B(),error_description:B().optional()}).strip(),Tf=G({token:B(),token_type_hint:B().optional()}).strip(),Ef=Symbol.for(`mcp.sdk.errorBrands`);function Df(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Ef,{value:n,enumerable:!1,configurable:!0})}function Of(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Ef)){let n=t[Ef];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}(class e extends Error{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return Of(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError(\"isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`\");return Of(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Df(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}});var kf=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),Af=class extends Error{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return Of(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError(\"isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`\");return Of(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,Df(this,new.target)}};(class extends Af{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}});var jf=`2026-07-28`;function Mf(e){return e>=jf}function Nf(e){let t=e.structuredContent;return t===void 0||typeof t==`object`&&t&&!Array.isArray(t)||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}var Pf=[`task`,`inputRequests`,`requestState`];function Ff(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||Pf.some(t=>t in e)?e:{...e,content:[]}}function If(){let e=Vc(()=>K([B(),V(),H(),nc(),q(B(),e),W(e)])),t=q(B(),e),n=K([B(),V().int()]),r=B(),i=G({ttl:V().optional()}),a=G({taskId:B()}),o=uc({progressToken:n.optional(),\"io.modelcontextprotocol/related-task\":a.optional()}),s=G({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=G({method:B(),params:s.loose().optional()}),u=G({_meta:o.optional()}),d=G({method:B(),params:u.loose().optional()}),f=uc({_meta:o.optional()}),p=K([B(),V().int()]),m=f.strict(),h=u.extend({requestId:p.optional(),reason:B().optional()}),g=d.extend({method:J(`notifications/cancelled`),params:h}),_=G({src:B(),mimeType:B().optional(),sizes:W(B()).optional(),theme:vc([`light`,`dark`]).optional()}),v=G({icons:W(_).optional()}),y=G({name:B(),title:B().optional()}),b=y.extend({...y.shape,...v.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),x=Gc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,hc(G({form:hc(G({applyDefaults:H().optional()}),t).optional(),url:t.optional()}),t.optional())),S=uc({list:t.optional(),cancel:t.optional(),requests:uc({sampling:uc({createMessage:t.optional()}).optional(),elicitation:uc({create:t.optional()}).optional()}).optional()}),C=uc({list:t.optional(),cancel:t.optional(),requests:uc({tools:uc({call:t.optional()}).optional()}).optional()}),w=G({experimental:q(B(),t).optional(),sampling:G({context:t.optional(),tools:t.optional()}).optional(),elicitation:x.optional(),roots:G({listChanged:H().optional()}).optional(),tasks:S.optional(),extensions:q(B(),t).optional()}),T=s.extend({protocolVersion:B(),capabilities:w,clientInfo:b}),E=l.extend({method:J(`initialize`),params:T}),D=G({experimental:q(B(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:G({listChanged:H().optional()}).optional(),resources:G({subscribe:H().optional(),listChanged:H().optional()}).optional(),tools:G({listChanged:H().optional()}).optional(),tasks:C.optional(),extensions:q(B(),t).optional()}),O=f.extend({protocolVersion:B(),capabilities:D,serverInfo:b,instructions:B().optional()}),k=d.extend({method:J(`notifications/initialized`),params:u.optional()}),A=l.extend({method:J(`ping`),params:s.optional()}),j=G({progress:V(),total:Y(V()),message:Y(B())}),M=G({...u.shape,...j.shape,progressToken:n}),N=d.extend({method:J(`notifications/progress`),params:M}),P=s.extend({cursor:r.optional()}),ee=l.extend({params:P.optional()}),te=f.extend({nextCursor:r.optional()}),ne=G({uri:B(),mimeType:Y(B()),_meta:q(B(),U()).optional()}),re=ne.extend({text:B()}),ie=B().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),ae=ne.extend({blob:ie}),oe=vc([`user`,`assistant`]),se=G({audience:W(oe).optional(),priority:V().min(0).max(1).optional(),lastModified:Jc({offset:!0}).optional()}),ce=G({...y.shape,...v.shape,uri:B(),description:Y(B()),mimeType:Y(B()),size:Y(V()),annotations:se.optional(),_meta:Y(uc({}))}),le=G({...y.shape,...v.shape,uriTemplate:B(),description:Y(B()),mimeType:Y(B()),annotations:se.optional(),_meta:Y(uc({}))}),ue=ee.extend({method:J(`resources/list`)}),de=te.extend({resources:W(ce)}),fe=ee.extend({method:J(`resources/templates/list`)}),pe=te.extend({resourceTemplates:W(le)}),me=s.extend({uri:B()}),he=me,ge=l.extend({method:J(`resources/read`),params:he}),_e=f.extend({contents:W(K([re,ae]))}),ve=d.extend({method:J(`notifications/resources/list_changed`),params:u.optional()}),ye=me,be=l.extend({method:J(`resources/subscribe`),params:ye}),xe=me,Se=l.extend({method:J(`resources/unsubscribe`),params:xe}),Ce=u.extend({uri:B()}),F=d.extend({method:J(`notifications/resources/updated`),params:Ce}),we=G({name:B(),description:Y(B()),required:Y(H())}),Te=G({...y.shape,...v.shape,description:Y(B()),arguments:Y(W(we)),_meta:Y(uc({}))}),Ee=ee.extend({method:J(`prompts/list`)}),I=te.extend({prompts:W(Te)}),De=s.extend({name:B(),arguments:q(B(),B()).optional()}),L=l.extend({method:J(`prompts/get`),params:De}),R=G({type:J(`text`),text:B(),annotations:se.optional(),_meta:q(B(),U()).optional()}),Oe=G({type:J(`image`),data:ie,mimeType:B(),annotations:se.optional(),_meta:q(B(),U()).optional()}),ke=G({type:J(`audio`),data:ie,mimeType:B(),annotations:se.optional(),_meta:q(B(),U()).optional()}),Ae=G({type:J(`tool_use`),name:B(),id:B(),input:q(B(),U()),_meta:q(B(),U()).optional()}),je=G({type:J(`resource`),resource:K([re,ae]),annotations:se.optional(),_meta:q(B(),U()).optional()}),Me=ce.extend({type:J(`resource_link`)}),Ne=K([R,Oe,ke,Me,je]),Pe=G({role:oe,content:Ne}),Fe=f.extend({description:B().optional(),messages:W(Pe)}),Ie=d.extend({method:J(`notifications/prompts/list_changed`),params:u.optional()}),Le=G({title:B().optional(),readOnlyHint:H().optional(),destructiveHint:H().optional(),idempotentHint:H().optional(),openWorldHint:H().optional()}),z=G({taskSupport:vc([`required`,`optional`,`forbidden`]).optional()}),Re=G({...y.shape,...v.shape,description:B().optional(),inputSchema:G({type:J(`object`),properties:q(B(),e).optional(),required:W(B()).optional()}).catchall(U()),outputSchema:G({type:J(`object`),properties:q(B(),e).optional(),required:W(B()).optional()}).catchall(U()).optional(),annotations:Le.optional(),execution:z.optional(),_meta:q(B(),U()).optional()}),ze=ee.extend({method:J(`tools/list`)}),Be=te.extend({tools:W(Re)}),Ve=f.extend({content:W(Ne),structuredContent:q(B(),U()).optional(),isError:H().optional()}),He=c.extend({name:B(),arguments:q(B(),U()).optional()}),Ue=l.extend({method:J(`tools/call`),params:He}),We=d.extend({method:J(`notifications/tools/list_changed`),params:u.optional()}),Ge=vc([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Ke=s.extend({level:Ge}),qe=l.extend({method:J(`logging/setLevel`),params:Ke}),Je=u.extend({level:Ge,logger:B().optional(),data:U()}),Ye=d.extend({method:J(`notifications/message`),params:Je}),Xe=G({name:B().optional()}),Ze=G({hints:W(Xe).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),Qe=G({mode:vc([`auto`,`required`,`none`]).optional()}),$e=G({type:J(`tool_result`),toolUseId:B().describe(`The unique identifier for the corresponding tool call.`),content:W(Ne),structuredContent:G({}).loose().optional(),isError:H().optional(),_meta:q(B(),U()).optional()}),et=pc(`type`,[R,Oe,ke]),tt=pc(`type`,[R,Oe,ke,Ae,$e]),nt=G({role:oe,content:K([tt,W(tt)]),_meta:q(B(),U()).optional()}),rt=c.extend({messages:W(nt),modelPreferences:Ze.optional(),systemPrompt:B().optional(),includeContext:vc([`none`,`thisServer`,`allServers`]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:W(B()).optional(),metadata:t.optional(),tools:W(Re).optional(),toolChoice:Qe.optional()}),it=l.extend({method:J(`sampling/createMessage`),params:rt}),at=f.extend({model:B(),stopReason:Y(vc([`endTurn`,`stopSequence`,`maxTokens`]).or(B())),role:oe,content:et}),ot=f.extend({model:B(),stopReason:Y(vc([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(B())),role:oe,content:K([tt,W(tt)])}),st=G({type:J(`boolean`),title:B().optional(),description:B().optional(),default:H().optional()}),ct=G({type:J(`string`),title:B().optional(),description:B().optional(),minLength:V().optional(),maxLength:V().optional(),format:vc([`email`,`uri`,`date`,`date-time`]).optional(),default:B().optional()}),lt=G({type:vc([`number`,`integer`]),title:B().optional(),description:B().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),ut=G({type:J(`string`),title:B().optional(),description:B().optional(),enum:W(B()),default:B().optional()}),dt=G({type:J(`string`),title:B().optional(),description:B().optional(),oneOf:W(G({const:B(),title:B()})),default:B().optional()}),ft=G({type:J(`string`),title:B().optional(),description:B().optional(),enum:W(B()),enumNames:W(B()).optional(),default:B().optional()}),pt=K([ut,dt]),mt=G({type:J(`array`),title:B().optional(),description:B().optional(),minItems:V().optional(),maxItems:V().optional(),items:G({type:J(`string`),enum:W(B())}),default:W(B()).optional()}),ht=G({type:J(`array`),title:B().optional(),description:B().optional(),minItems:V().optional(),maxItems:V().optional(),items:G({anyOf:W(G({const:B(),title:B()}))}),default:W(B()).optional()}),gt=K([mt,ht]),_t=K([ft,pt,gt]),vt=K([_t,st,ct,lt]),yt=c.extend({mode:J(`form`).optional(),message:B(),requestedSchema:G({type:J(`object`),properties:q(B(),vt),required:W(B()).optional()}).catchall(U())}),bt=c.extend({mode:J(`url`),message:B(),elicitationId:B(),url:B().url()}),xt=K([yt,bt]),St=l.extend({method:J(`elicitation/create`),params:xt}),Ct=u.extend({elicitationId:B()}),wt=d.extend({method:J(`notifications/elicitation/complete`),params:Ct}),Tt=f.extend({action:vc([`accept`,`decline`,`cancel`]),content:Gc(e=>e===null?void 0:e,q(B(),K([B(),V(),H(),W(B())])).optional())}),Et=G({type:J(`ref/resource`),uri:B()}),Dt=G({type:J(`ref/prompt`),name:B()}),Ot=s.extend({ref:K([Dt,Et]),argument:G({name:B(),value:B()}),context:G({arguments:q(B(),B()).optional()}).optional()}),kt=l.extend({method:J(`completion/complete`),params:Ot}),At=f.extend({completion:uc({values:W(B()).max(100),total:Y(V().int()),hasMore:Y(H())})}),jt=G({uri:B().startsWith(`file://`),name:B().optional(),_meta:q(B(),U()).optional()}),Mt=l.extend({method:J(`roots/list`),params:s.optional()}),Nt=f.extend({roots:W(jt)}),Pt=d.extend({method:J(`notifications/roots/list_changed`),params:u.optional()}),Ft=uc({ttl:V().optional(),pollInterval:V().optional()}),It=vc([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Lt=G({taskId:B(),status:It,ttl:K([V(),nc()]),createdAt:B(),lastUpdatedAt:B(),pollInterval:Y(V()),statusMessage:Y(B())}),Rt=f.extend({task:Lt}),zt=u.merge(Lt),Bt=d.extend({method:J(`notifications/tasks/status`),params:zt}),Vt=l.extend({method:J(`tasks/get`),params:s.extend({taskId:B()})}),Ht=f.merge(Lt),Ut=l.extend({method:J(`tasks/result`),params:s.extend({taskId:B()})}),Wt=f.loose(),Gt=ee.extend({method:J(`tasks/list`)}),Kt=te.extend({tasks:W(Lt)}),qt=l.extend({method:J(`tasks/cancel`),params:s.extend({taskId:B()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:m,CancelledNotificationParamsSchema:h,CancelledNotificationSchema:g,IconSchema:_,IconsSchema:v,BaseMetadataSchema:y,ImplementationSchema:b,ClientTasksCapabilitySchema:S,ServerTasksCapabilitySchema:C,ClientCapabilitiesSchema:w,InitializeRequestParamsSchema:T,InitializeRequestSchema:E,ServerCapabilitiesSchema:D,InitializeResultSchema:O,InitializedNotificationSchema:k,PingRequestSchema:A,ProgressSchema:j,ProgressNotificationParamsSchema:M,ProgressNotificationSchema:N,PaginatedRequestParamsSchema:P,PaginatedRequestSchema:ee,PaginatedResultSchema:te,ResourceContentsSchema:ne,TextResourceContentsSchema:re,BlobResourceContentsSchema:ae,RoleSchema:oe,AnnotationsSchema:se,ResourceSchema:ce,ResourceTemplateSchema:le,ListResourcesRequestSchema:ue,ListResourcesResultSchema:de,ListResourceTemplatesRequestSchema:fe,ListResourceTemplatesResultSchema:pe,ResourceRequestParamsSchema:me,ReadResourceRequestParamsSchema:he,ReadResourceRequestSchema:ge,ReadResourceResultSchema:_e,ResourceListChangedNotificationSchema:ve,SubscribeRequestParamsSchema:ye,SubscribeRequestSchema:be,UnsubscribeRequestParamsSchema:xe,UnsubscribeRequestSchema:Se,ResourceUpdatedNotificationParamsSchema:Ce,ResourceUpdatedNotificationSchema:F,PromptArgumentSchema:we,PromptSchema:Te,ListPromptsRequestSchema:Ee,ListPromptsResultSchema:I,GetPromptRequestParamsSchema:De,GetPromptRequestSchema:L,TextContentSchema:R,ImageContentSchema:Oe,AudioContentSchema:ke,ToolUseContentSchema:Ae,EmbeddedResourceSchema:je,ResourceLinkSchema:Me,ContentBlockSchema:Ne,PromptMessageSchema:Pe,GetPromptResultSchema:Fe,PromptListChangedNotificationSchema:Ie,ToolAnnotationsSchema:Le,ToolExecutionSchema:z,ToolSchema:Re,ListToolsRequestSchema:ze,ListToolsResultSchema:Be,CallToolResultSchema:Ve,CallToolRequestParamsSchema:He,CallToolRequestSchema:Ue,ToolListChangedNotificationSchema:We,LoggingLevelSchema:Ge,SetLevelRequestParamsSchema:Ke,SetLevelRequestSchema:qe,LoggingMessageNotificationParamsSchema:Je,LoggingMessageNotificationSchema:Ye,ModelHintSchema:Xe,ModelPreferencesSchema:Ze,ToolChoiceSchema:Qe,ToolResultContentSchema:$e,SamplingContentSchema:et,SamplingMessageContentBlockSchema:tt,SamplingMessageSchema:nt,CreateMessageRequestParamsSchema:rt,CreateMessageRequestSchema:it,CreateMessageResultSchema:at,CreateMessageResultWithToolsSchema:ot,BooleanSchemaSchema:st,StringSchemaSchema:ct,NumberSchemaSchema:lt,UntitledSingleSelectEnumSchemaSchema:ut,TitledSingleSelectEnumSchemaSchema:dt,LegacyTitledEnumSchemaSchema:ft,SingleSelectEnumSchemaSchema:pt,UntitledMultiSelectEnumSchemaSchema:mt,TitledMultiSelectEnumSchemaSchema:ht,MultiSelectEnumSchemaSchema:gt,EnumSchemaSchema:_t,PrimitiveSchemaDefinitionSchema:vt,ElicitRequestFormParamsSchema:yt,ElicitRequestURLParamsSchema:bt,ElicitRequestParamsSchema:xt,ElicitRequestSchema:St,ElicitationCompleteNotificationParamsSchema:Ct,ElicitationCompleteNotificationSchema:wt,ElicitResultSchema:Tt,ResourceTemplateReferenceSchema:Et,PromptReferenceSchema:Dt,CompleteRequestParamsSchema:Ot,CompleteRequestSchema:kt,CompleteResultSchema:At,RootSchema:jt,ListRootsRequestSchema:Mt,ListRootsResultSchema:Nt,RootsListChangedNotificationSchema:Pt,TaskCreationParamsSchema:Ft,TaskStatusSchema:It,TaskSchema:Lt,CreateTaskResultSchema:Rt,TaskStatusNotificationParamsSchema:zt,TaskStatusNotificationSchema:Bt,GetTaskRequestSchema:Vt,GetTaskResultSchema:Ht,GetTaskPayloadRequestSchema:Ut,GetTaskPayloadResultSchema:Wt,ListTasksRequestSchema:Gt,ListTasksResultSchema:Kt,CancelTaskRequestSchema:qt,CancelTaskResultSchema:f.merge(Lt),ClientRequestSchema:K([A,E,kt,qe,L,Ee,ue,fe,ge,be,Se,Ue,ze,Vt,Ut,Gt,qt]),ClientNotificationSchema:K([g,N,k,Pt,Bt]),ClientResultSchema:K([m,at,ot,Tt,Nt,Ht,Kt,Rt]),ServerRequestSchema:K([A,it,St,Mt,Vt,Ut,Gt,qt]),ServerNotificationSchema:K([g,N,Ye,F,ve,We,Ie,Bt,wt]),ServerResultSchema:K([m,O,At,Fe,I,de,pe,_e,Ve,Be,Ht,Kt,Rt]),CallToolResultWireSchema:U().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of Pf)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(Ff).pipe(Ve)}}var Lf;function Rf(){return Lf??=If()}function zf(e){return e.type!==`object`}var Bf=new Set([`const`,`enum`,`default`,`examples`]),Vf=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function Hf(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function Uf(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(Hf(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=i(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&Hf(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=Bf.has(o)?s:Vf.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}var Wf={ping:null,initialize:null,\"completion/complete\":null,\"logging/setLevel\":null,\"prompts/get\":null,\"prompts/list\":null,\"resources/list\":null,\"resources/templates/list\":null,\"resources/read\":null,\"resources/subscribe\":null,\"resources/unsubscribe\":null,\"tools/call\":null,\"tools/list\":null,\"tasks/get\":null,\"tasks/result\":null,\"tasks/list\":null,\"tasks/cancel\":null,\"sampling/createMessage\":null,\"elicitation/create\":null,\"roots/list\":null},Gf={\"notifications/cancelled\":null,\"notifications/progress\":null,\"notifications/initialized\":null,\"notifications/roots/list_changed\":null,\"notifications/tasks/status\":null,\"notifications/message\":null,\"notifications/resources/updated\":null,\"notifications/resources/list_changed\":null,\"notifications/tools/list_changed\":null,\"notifications/prompts/list_changed\":null,\"notifications/elicitation/complete\":null},Kf={ping:null,initialize:null,\"completion/complete\":null,\"logging/setLevel\":null,\"prompts/get\":null,\"prompts/list\":null,\"resources/list\":null,\"resources/templates/list\":null,\"resources/read\":null,\"resources/subscribe\":null,\"resources/unsubscribe\":null,\"tools/call\":null,\"tools/list\":null,\"sampling/createMessage\":null,\"elicitation/create\":null,\"roots/list\":null},qf;function Jf(){if(qf)return qf;let e=Rf();return qf={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,\"completion/complete\":e.CompleteRequestSchema,\"logging/setLevel\":e.SetLevelRequestSchema,\"prompts/get\":e.GetPromptRequestSchema,\"prompts/list\":e.ListPromptsRequestSchema,\"resources/list\":e.ListResourcesRequestSchema,\"resources/templates/list\":e.ListResourceTemplatesRequestSchema,\"resources/read\":e.ReadResourceRequestSchema,\"resources/subscribe\":e.SubscribeRequestSchema,\"resources/unsubscribe\":e.UnsubscribeRequestSchema,\"tools/call\":e.CallToolRequestSchema,\"tools/list\":e.ListToolsRequestSchema,\"tasks/get\":e.GetTaskRequestSchema,\"tasks/result\":e.GetTaskPayloadRequestSchema,\"tasks/list\":e.ListTasksRequestSchema,\"tasks/cancel\":e.CancelTaskRequestSchema,\"sampling/createMessage\":e.CreateMessageRequestSchema,\"elicitation/create\":e.ElicitRequestSchema,\"roots/list\":e.ListRootsRequestSchema},notificationSchemas:{\"notifications/cancelled\":e.CancelledNotificationSchema,\"notifications/progress\":e.ProgressNotificationSchema,\"notifications/initialized\":e.InitializedNotificationSchema,\"notifications/roots/list_changed\":e.RootsListChangedNotificationSchema,\"notifications/tasks/status\":e.TaskStatusNotificationSchema,\"notifications/message\":e.LoggingMessageNotificationSchema,\"notifications/resources/updated\":e.ResourceUpdatedNotificationSchema,\"notifications/resources/list_changed\":e.ResourceListChangedNotificationSchema,\"notifications/tools/list_changed\":e.ToolListChangedNotificationSchema,\"notifications/prompts/list_changed\":e.PromptListChangedNotificationSchema,\"notifications/elicitation/complete\":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,\"completion/complete\":e.CompleteResultSchema,\"logging/setLevel\":e.EmptyResultSchema,\"prompts/get\":e.GetPromptResultSchema,\"prompts/list\":e.ListPromptsResultSchema,\"resources/list\":e.ListResourcesResultSchema,\"resources/templates/list\":e.ListResourceTemplatesResultSchema,\"resources/read\":e.ReadResourceResultSchema,\"resources/subscribe\":e.EmptyResultSchema,\"resources/unsubscribe\":e.EmptyResultSchema,\"tools/call\":e.CallToolResultWireSchema,\"tools/list\":e.ListToolsResultSchema,\"sampling/createMessage\":e.CreateMessageResultWithToolsSchema,\"elicitation/create\":e.ElicitResultSchema,\"roots/list\":e.ListRootsResultSchema}},qf}function Yf(e){return Object.prototype.hasOwnProperty.call(Wf,e)}function Xf(e){return Object.prototype.hasOwnProperty.call(Gf,e)}function Zf(e){return Object.prototype.hasOwnProperty.call(Kf,e)}function Qf(e){return Zf(e)?Jf().resultSchemas[e]:void 0}function $f(e){return Yf(e)?Jf().requestSchemas[e]:void 0}function ep(e){return Xf(e)?Jf().notificationSchemas[e]:void 0}Object.keys(Wf),Object.keys(Gf);function tp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function np(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var rp={ok:!1,reason:`not-in-era`};function ip(e){return tp(e)&&tp(e.outputSchema)&&zf(e.outputSchema)}function ap(e){return e}var op={era:`2025-11-25`,hasRequestMethod:Yf,hasNotificationMethod:Xf,validateRequest:(e,t)=>np($f(e),t),validateResult:(e,t)=>np(Qf(e),t),validateNotification:(e,t)=>np(ep(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>rp,validateInputResponse:()=>rp,samplingResultVariant:((e,t)=>{let n=Rf();return np(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=Nf(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&zf(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(tp(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:ap(e)}}return{kind:`complete`,result:ap(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>ip(e))?t:{...t,tools:n.map(e=>ip(e)?{...e,outputSchema:Uf(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function sp(){let e=Vc(()=>K([B(),V(),H(),nc(),q(B(),e),W(e)])),t=q(B(),e),n=K([B(),V().int()]),r=B(),i=K([B(),V().int()]),a=vc([`user`,`assistant`]),o=vc([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=B().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=G({ttl:V().optional()}),l=G({taskId:B()}),u=uc({progressToken:n.optional(),\"io.modelcontextprotocol/related-task\":l.optional()}),d=G({_meta:u.optional()}),f=d.extend({task:c.optional()}),p=G({_meta:u.optional()}),m=G({method:B(),params:p.loose().optional()}),h=G({src:B(),mimeType:B().optional(),sizes:W(B()).optional(),theme:vc([`light`,`dark`]).optional()}),g=G({icons:W(h).optional()}),_=G({name:B(),title:B().optional()}),v=_.extend({..._.shape,...g.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),y=Gc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,hc(G({form:hc(G({applyDefaults:H().optional()}),t).optional(),url:t.optional()}),t.optional())),b=uc({list:t.optional(),cancel:t.optional(),requests:uc({sampling:uc({createMessage:t.optional()}).optional(),elicitation:uc({create:t.optional()}).optional()}).optional()}),x=uc({list:t.optional(),cancel:t.optional(),requests:uc({tools:uc({call:t.optional()}).optional()}).optional()}),S=G({experimental:q(B(),t).optional(),sampling:G({context:t.optional(),tools:t.optional()}).optional(),elicitation:y.optional(),roots:G({listChanged:H().optional()}).optional(),tasks:b.optional(),extensions:q(B(),t).optional()}),C=G({experimental:q(B(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:G({listChanged:H().optional()}).optional(),resources:G({subscribe:H().optional(),listChanged:H().optional()}).optional(),tools:G({listChanged:H().optional()}).optional(),tasks:x.optional(),extensions:q(B(),t).optional()}),w=G({progress:V(),total:Y(V()),message:Y(B())}),T=G({...p.shape,...w.shape,progressToken:n}),E=m.extend({method:J(`notifications/progress`),params:T}),D=p.extend({level:o,logger:B().optional(),data:U()}),O=m.extend({method:J(`notifications/message`),params:D}),k=G({uri:B(),mimeType:Y(B()),_meta:q(B(),U()).optional()}),A=k.extend({text:B()}),j=k.extend({blob:s}),M=G({audience:W(a).optional(),priority:V().min(0).max(1).optional(),lastModified:Jc({offset:!0}).optional()}),N=G({..._.shape,...g.shape,uri:B(),description:Y(B()),mimeType:Y(B()),size:Y(V()),annotations:M.optional(),_meta:Y(uc({}))}),P=G({..._.shape,...g.shape,uriTemplate:B(),description:Y(B()),mimeType:Y(B()),annotations:M.optional(),_meta:Y(uc({}))}),ee=m.extend({method:J(`notifications/resources/list_changed`),params:p.optional()}),te=p.extend({uri:B()}),ne=m.extend({method:J(`notifications/resources/updated`),params:te}),re=G({name:B(),description:Y(B()),required:Y(H())}),ie=G({..._.shape,...g.shape,description:Y(B()),arguments:Y(W(re)),_meta:Y(uc({}))}),ae=m.extend({method:J(`notifications/prompts/list_changed`),params:p.optional()}),oe=G({type:J(`text`),text:B(),annotations:M.optional(),_meta:q(B(),U()).optional()}),se=G({type:J(`image`),data:s,mimeType:B(),annotations:M.optional(),_meta:q(B(),U()).optional()}),ce=G({type:J(`audio`),data:s,mimeType:B(),annotations:M.optional(),_meta:q(B(),U()).optional()}),le=G({type:J(`tool_use`),name:B(),id:B(),input:q(B(),U()),_meta:q(B(),U()).optional()}),ue=G({type:J(`resource`),resource:K([A,j]),annotations:M.optional(),_meta:q(B(),U()).optional()}),de=N.extend({type:J(`resource_link`)}),fe=K([oe,se,ce,de,ue]),pe=G({role:a,content:fe}),me=G({title:B().optional(),readOnlyHint:H().optional(),destructiveHint:H().optional(),idempotentHint:H().optional(),openWorldHint:H().optional()}),he=m.extend({method:J(`notifications/tools/list_changed`),params:p.optional()}),ge=G({name:B().optional()}),_e=G({hints:W(ge).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),ve=G({mode:vc([`auto`,`required`,`none`]).optional()}),ye=G({type:J(`boolean`),title:B().optional(),description:B().optional(),default:H().optional()}),be=G({type:J(`string`),title:B().optional(),description:B().optional(),minLength:V().optional(),maxLength:V().optional(),format:vc([`email`,`uri`,`date`,`date-time`]).optional(),default:B().optional()}),xe=G({type:vc([`number`,`integer`]),title:B().optional(),description:B().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),Se=G({type:J(`string`),title:B().optional(),description:B().optional(),enum:W(B()),default:B().optional()}),Ce=G({type:J(`string`),title:B().optional(),description:B().optional(),oneOf:W(G({const:B(),title:B()})),default:B().optional()}),F=G({type:J(`string`),title:B().optional(),description:B().optional(),enum:W(B()),enumNames:W(B()).optional(),default:B().optional()}),we=K([Se,Ce]),Te=G({type:J(`array`),title:B().optional(),description:B().optional(),minItems:V().optional(),maxItems:V().optional(),items:G({type:J(`string`),enum:W(B())}),default:W(B()).optional()}),Ee=G({type:J(`array`),title:B().optional(),description:B().optional(),minItems:V().optional(),maxItems:V().optional(),items:G({anyOf:W(G({const:B(),title:B()}))}),default:W(B()).optional()}),I=K([Te,Ee]),De=K([F,we,I]),L=K([De,ye,be,xe]),R=f.extend({mode:J(`form`).optional(),message:B(),requestedSchema:G({type:J(`object`),properties:q(B(),L),required:W(B()).optional()}).catchall(U())}),Oe=G({type:J(`ref/resource`),uri:B()}),ke=G({type:J(`ref/prompt`),name:B()}),Ae=G({uri:B().startsWith(`file://`),name:B().optional(),_meta:q(B(),U()).optional()}),je=S.shape,Me=G({experimental:je.experimental,sampling:je.sampling,elicitation:je.elicitation,roots:je.roots,extensions:je.extensions}),Ne=C.shape,Pe=G({experimental:Ne.experimental,logging:Ne.logging,completions:Ne.completions,prompts:Ne.prompts,resources:Ne.resources,tools:Ne.tools,extensions:Ne.extensions}),Fe=uc({progressToken:n.optional(),[$c]:B(),[el]:v.optional(),[nl]:Me,[il]:o.optional()}),Ie=G({..._.shape,...g.shape,description:B().optional(),inputSchema:uc({$schema:B().optional(),type:J(`object`)}),outputSchema:uc({$schema:B().optional()}).optional(),annotations:me.optional(),_meta:q(B(),U()).optional()}),Le=G({type:J(`tool_result`),toolUseId:B(),content:W(fe),structuredContent:U().optional(),isError:H().optional(),_meta:q(B(),U()).optional()}),z=K([oe,se,ce,le,Le]),Re=G({role:a,content:K([z,W(z)]),_meta:q(B(),U()).optional()}),ze=B(),Be=uc({[tl]:v.optional().catch(void 0)}),Ve=Be.optional();function He(e){return uc({_meta:Ve,resultType:ze.default(`complete`),...e})}let Ue=He({}),We=He({nextCursor:r.optional()}),Ge=He({content:W(fe),structuredContent:U().optional(),isError:H().optional()}),Ke=He({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),tools:W(Ie),nextCursor:r.optional()}),qe=He({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),prompts:W(ie),nextCursor:r.optional()}),Je=He({description:B().optional(),messages:W(pe)}),Ye=He({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),resources:W(N),nextCursor:r.optional()}),Xe=He({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),resourceTemplates:W(P),nextCursor:r.optional()}),Ze=He({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),contents:W(K([A,j]))}),Qe=He({completion:G({values:W(B()).max(100),total:V().int().optional(),hasMore:H().optional()}).loose()}),$e=He({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`])}),et=He({ttlMs:V().int().min(0).catch(0),cacheScope:vc([`public`,`private`]).catch(`private`),supportedVersions:W(B()),capabilities:Pe,instructions:B().optional()}),tt=G({messages:W(Re),modelPreferences:_e.optional(),systemPrompt:B().optional(),includeContext:vc([`none`,`thisServer`,`allServers`]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:W(B()).optional(),metadata:t.optional(),tools:W(Ie).optional(),toolChoice:ve.optional()}),nt=G({method:J(`sampling/createMessage`),params:tt}),rt=G({method:J(`roots/list`),params:G({_meta:q(B(),U()).optional()}).optional()}),it=G({...Re.shape,model:B(),stopReason:B().optional()}),at=G({roots:W(Ae)}),ot=G({action:vc([`accept`,`decline`,`cancel`]),content:q(B(),K([B(),V(),H(),W(B())])).optional()}),st=G({mode:J(`url`),message:B(),url:B().url()}),ct=K([R,st]),lt=G({method:J(`elicitation/create`),params:ct}),ut=K([nt,rt,lt]),dt=K([it,at,ot]),ft=q(B(),ut),pt=q(B(),dt),mt=He({inputRequests:ft.optional(),requestState:B().optional()}),ht={inputResponses:pt.optional(),requestState:B().optional()},gt=G({_meta:Fe,...ht}),_t=uc({progressToken:n.optional()});function vt(e,t){return G({method:J(e),params:G({_meta:Fe,...t})})}function yt(e,t){return G({method:J(e),params:G({_meta:_t.optional(),...t}).optional()})}let bt={name:B(),arguments:q(B(),U()).optional(),...ht},xt={cursor:r.optional()},St=vt(`tools/call`,bt),Ct=vt(`tools/list`,xt),wt=vt(`prompts/list`,xt),Tt=vt(`prompts/get`,{name:B(),arguments:q(B(),B()).optional(),...ht}),Et=vt(`resources/list`,xt),Dt=vt(`resources/templates/list`,xt),Ot=vt(`resources/read`,{uri:B(),...ht}),kt={ref:K([ke,Oe]),argument:G({name:B(),value:B()}),context:G({arguments:q(B(),B()).optional()}).optional()},At=vt(`completion/complete`,kt),jt=vt(`server/discover`,{}),Mt=G({toolsListChanged:H().optional(),promptsListChanged:H().optional(),resourcesListChanged:H().optional(),resourceSubscriptions:W(B()).optional()}),Nt={notifications:Mt},Pt=vt(`subscriptions/listen`,Nt),Ft=Be.extend({\"io.modelcontextprotocol/subscriptionId\":i}),It=uc({_meta:Ft,resultType:ze.default(`complete`)}),Lt={\"tools/call\":yt(`tools/call`,bt),\"tools/list\":yt(`tools/list`,xt),\"prompts/get\":yt(`prompts/get`,{name:B(),arguments:q(B(),B()).optional()}),\"prompts/list\":yt(`prompts/list`,xt),\"resources/list\":yt(`resources/list`,xt),\"resources/templates/list\":yt(`resources/templates/list`,xt),\"resources/read\":yt(`resources/read`,{uri:B()}),\"completion/complete\":yt(`completion/complete`,kt),\"server/discover\":yt(`server/discover`,{}),\"subscriptions/listen\":yt(`subscriptions/listen`,Nt)};function Rt(e){return uc({_meta:Ve,...e})}let zt={\"tools/call\":Rt({content:W(fe),structuredContent:U().optional(),isError:H().optional()}),\"tools/list\":Rt({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),tools:W(Ie),nextCursor:r.optional()}),\"prompts/get\":Rt({description:B().optional(),messages:W(pe)}),\"prompts/list\":Rt({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),prompts:W(ie),nextCursor:r.optional()}),\"resources/list\":Rt({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),resources:W(N),nextCursor:r.optional()}),\"resources/templates/list\":Rt({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),resourceTemplates:W(P),nextCursor:r.optional()}),\"resources/read\":Rt({ttlMs:V().int().min(0),cacheScope:vc([`public`,`private`]),contents:W(K([A,j]))}),\"completion/complete\":Rt({completion:G({values:W(B()).max(100),total:V().int().optional(),hasMore:H().optional()}).loose()}),\"server/discover\":Rt({ttlMs:V().int().min(0).catch(0),cacheScope:vc([`public`,`private`]).catch(`private`),supportedVersions:W(B()),capabilities:Pe,instructions:B().optional()}),\"subscriptions/listen\":Rt({})},Bt=uc({\"io.modelcontextprotocol/subscriptionId\":i.optional()}),Vt=G({method:J(`notifications/subscriptions/acknowledged`),params:G({_meta:Bt.optional(),notifications:Mt})}),Ht=G({_meta:Bt.optional(),requestId:i,reason:B().optional()}),Ut=G({method:J(`notifications/cancelled`),params:Ht}),Wt={\"notifications/cancelled\":Ut,\"notifications/progress\":E,\"notifications/message\":O,\"notifications/resources/updated\":ne,\"notifications/resources/list_changed\":ee,\"notifications/tools/list_changed\":he,\"notifications/prompts/list_changed\":ae,\"notifications/subscriptions/acknowledged\":Vt},Gt=e=>G({jsonrpc:J(`2.0`),id:K([B(),V().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:p,NotificationSchema:m,IconSchema:h,IconsSchema:g,BaseMetadataSchema:_,ImplementationSchema:v,ClientTasksCapabilitySchema:b,ServerTasksCapabilitySchema:x,ClientCapabilitiesSchema:S,ServerCapabilitiesSchema:C,ProgressSchema:w,ProgressNotificationParamsSchema:T,ProgressNotificationSchema:E,LoggingMessageNotificationParamsSchema:D,LoggingMessageNotificationSchema:O,ResourceContentsSchema:k,TextResourceContentsSchema:A,BlobResourceContentsSchema:j,AnnotationsSchema:M,ResourceSchema:N,ResourceTemplateSchema:P,ResourceListChangedNotificationSchema:ee,ResourceUpdatedNotificationParamsSchema:te,ResourceUpdatedNotificationSchema:ne,PromptArgumentSchema:re,PromptSchema:ie,PromptListChangedNotificationSchema:ae,TextContentSchema:oe,ImageContentSchema:se,AudioContentSchema:ce,ToolUseContentSchema:le,EmbeddedResourceSchema:ue,ResourceLinkSchema:de,ContentBlockSchema:fe,PromptMessageSchema:pe,ToolAnnotationsSchema:me,ToolListChangedNotificationSchema:he,ModelHintSchema:ge,ModelPreferencesSchema:_e,ToolChoiceSchema:ve,BooleanSchemaSchema:ye,StringSchemaSchema:be,NumberSchemaSchema:xe,UntitledSingleSelectEnumSchemaSchema:Se,TitledSingleSelectEnumSchemaSchema:Ce,LegacyTitledEnumSchemaSchema:F,SingleSelectEnumSchemaSchema:we,UntitledMultiSelectEnumSchemaSchema:Te,TitledMultiSelectEnumSchemaSchema:Ee,MultiSelectEnumSchemaSchema:I,EnumSchemaSchema:De,PrimitiveSchemaDefinitionSchema:L,ElicitRequestFormParamsSchema:R,ResourceTemplateReferenceSchema:Oe,PromptReferenceSchema:ke,RootSchema:Ae,ClientCapabilities2026Schema:Me,ServerCapabilities2026Schema:Pe,RequestMetaEnvelopeSchema:Fe,ToolSchema:Ie,ToolResultContentSchema:Le,SamplingMessageContentBlockSchema:z,SamplingMessageSchema:Re,ResultTypeSchema:ze,ResultMetaSchema:Be,ResultSchema:Ue,PaginatedResultSchema:We,CallToolResultSchema:Ge,ListToolsResultSchema:Ke,ListPromptsResultSchema:qe,GetPromptResultSchema:Je,ListResourcesResultSchema:Ye,ListResourceTemplatesResultSchema:Xe,ReadResourceResultSchema:Ze,CompleteResultSchema:Qe,CacheableResultSchema:$e,DiscoverResultSchema:et,CreateMessageRequestParamsSchema:tt,CreateMessageRequestSchema:nt,ListRootsRequestSchema:rt,CreateMessageResultSchema:it,ListRootsResultSchema:at,ElicitResultSchema:ot,ElicitRequestURLParamsSchema:st,ElicitRequestParamsSchema:ct,ElicitRequestSchema:lt,InputRequestSchema:ut,InputResponseSchema:dt,InputRequestsSchema:ft,InputResponsesSchema:pt,InputRequiredResultSchema:mt,InputResponseRequestParamsSchema:gt,CallToolRequestSchema:St,ListToolsRequestSchema:Ct,ListPromptsRequestSchema:wt,GetPromptRequestSchema:Tt,ListResourcesRequestSchema:Et,ListResourceTemplatesRequestSchema:Dt,ReadResourceRequestSchema:Ot,CompleteRequestSchema:At,DiscoverRequestSchema:jt,SubscriptionFilterSchema:Mt,SubscriptionsListenRequestSchema:Pt,SubscriptionsListenResultMetaSchema:Ft,SubscriptionsListenResultSchema:It,dispatchRequestSchemas:Lt,dispatchResultSchemas:zt,NotificationMetaSchema:Bt,SubscriptionsAcknowledgedNotificationSchema:Vt,CancelledNotificationParamsSchema:Ht,CancelledNotificationSchema:Ut,notificationSchemas2026:Wt,JSONRPCResultResponseSchema:Gt(Ue),CallToolResultResponseSchema:Gt(K([Ge,mt])),ListToolsResultResponseSchema:Gt(Ke),ListPromptsResultResponseSchema:Gt(qe),GetPromptResultResponseSchema:Gt(K([Je,mt])),ListResourcesResultResponseSchema:Gt(Ye),ListResourceTemplatesResultResponseSchema:Gt(Xe),ReadResourceResultResponseSchema:Gt(K([Ze,mt])),CompleteResultResponseSchema:Gt(Qe),DiscoverResultResponseSchema:Gt(et),SubscriptionsListenResultResponseSchema:Gt(It)}}var cp;function lp(){return cp??=sp()}var up=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function dp(e){return up.includes(e)}var fp=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function pp(e){return e[fp]}function mp(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function hp(e){return e===`public`||e===`private`}var gp=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),_p=class e extends Error{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return Of(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError(\"isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`\");return Of(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Df(this,new.target)}static fromError(t,n,r){if(t===gp.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new yp(e.elicitations,n)}if(t===gp.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new bp({supported:e.supported,requested:e.requested},n)}if(t===gp.InvalidParams||t===gp.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===gp.ResourceNotFound||Object.keys(e).length===1))return new vp(e.uri,n)}if(t===gp.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new xp({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},vp=class extends _p{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(gp.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},yp=class extends _p{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(gp.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},bp=class extends _p{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(gp.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},xp=class extends _p{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(gp.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Sp=0,Cp=`private`,wp=[`tools/call`,`prompts/get`,`resources/read`];function Tp(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||wp.includes(e))return t;throw new _p(gp.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Ep(e,t){let n=pp(t);if(t.resultType!==`complete`||!dp(e))return n===void 0?t:jp(t);let r=t,i=mp(r.ttlMs)?r.ttlMs:kp(n),a=hp(r.cacheScope)?r.cacheScope:Ap(n),o={...r,ttlMs:i,cacheScope:a};return delete o[fp],o}function Dp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Op(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[tl]:t}}:!Dp(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[tl]:t}}}function kp(e){return e!==void 0&&mp(e.ttlMs)?e.ttlMs:Sp}function Ap(e){return e!==void 0&&hp(e.cacheScope)?e.cacheScope:Cp}function jp(e){let t={...e};return delete t[fp],t}var Mp=[`elicitation/create`,`sampling/createMessage`,`roots/list`],Np;function Pp(){if(Np)return Np;let e=lp();return Np={request:{\"elicitation/create\":G({method:J(`elicitation/create`),params:e.ElicitRequestParamsSchema}),\"sampling/createMessage\":G({method:J(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),\"roots/list\":G({method:J(`roots/list`),params:uc({}).optional()})},response:{\"elicitation/create\":e.ElicitResultSchema,\"sampling/createMessage\":e.CreateMessageResultSchema,\"roots/list\":e.ListRootsResultSchema}},Np}function Fp(e){return Mp.includes(e)}function Ip(e){return Fp(e)?Pp().request[e]:void 0}function Lp(e){return Fp(e)?Pp().response[e]:void 0}var Rp={\"tools/call\":null,\"tools/list\":null,\"prompts/get\":null,\"prompts/list\":null,\"resources/list\":null,\"resources/templates/list\":null,\"resources/read\":null,\"completion/complete\":null,\"server/discover\":null,\"subscriptions/listen\":null},zp={\"notifications/cancelled\":null,\"notifications/progress\":null,\"notifications/message\":null,\"notifications/resources/updated\":null,\"notifications/resources/list_changed\":null,\"notifications/tools/list_changed\":null,\"notifications/prompts/list_changed\":null,\"notifications/subscriptions/acknowledged\":null};function Bp(e){return Object.prototype.hasOwnProperty.call(Rp,e)}function Vp(e){return Object.prototype.hasOwnProperty.call(zp,e)}function Hp(e){return Object.prototype.hasOwnProperty.call(Rp,e)}function Up(e){return Bp(e)?lp().dispatchRequestSchemas[e]:void 0}function Wp(e){return Hp(e)?lp().dispatchResultSchemas[e]:void 0}function Gp(e){return Vp(e)?lp().notificationSchemas2026[e]:void 0}Object.keys(Rp),Object.keys(zp);function Kp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qp(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Jp={ok:!1,reason:`not-in-era`},Yp=[$c,nl];function Xp(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>Kp(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!Kp(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(Kp(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}var Zp={era:`2026-07-28`,hasRequestMethod:Bp,hasNotificationMethod:Vp,hasInputRequestMethod:e=>Ip(e)!==void 0,validateRequest:(e,t)=>qp(Up(e),t),validateResult:(e,t)=>qp(Wp(e),t),validateNotification:(e,t)=>qp(Gp(e),t),validateInputRequest:(e,t)=>qp(Ip(e),t),validateInputResponse:(e,t)=>qp(Lp(e),t),samplingResultVariant:()=>Jp,outboundEnvelope(e){return{[$c]:e.protocolVersion,[el]:e.clientInfo,[nl]:e.clientCapabilities,...e.logLevel!==void 0&&{\"io.modelcontextprotocol/logLevel\":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of Yp)n in e||t.push({key:n,problem:`missing`});let n=lp().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>Nf(e),inputRequestSchema:Ip,decodeResult(e,t){if(!Kp(t))return{kind:`invalid`,error:new Af(kf.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new Af(kf.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new Af(kf.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=Kp(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:lp().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new Af(kf.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new Af(kf.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=$p(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new Af(kf.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return Op(Ep(e,Tp(e,Xp(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=lp().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}},Qp;function $p(){if(Qp)return Qp;let e=lp();return Qp={\"tools/call\":e.CallToolResultSchema,\"tools/list\":e.ListToolsResultSchema,\"prompts/get\":e.GetPromptResultSchema,\"prompts/list\":e.ListPromptsResultSchema,\"resources/list\":e.ListResourcesResultSchema,\"resources/templates/list\":e.ListResourceTemplatesResultSchema,\"resources/read\":e.ReadResourceResultSchema,\"completion/complete\":e.CompleteResultSchema,\"server/discover\":e.DiscoverResultSchema},Qp}var em=`2026-07-28`;function tm(e){return e!==void 0&&Mf(e)?Zp:op}function nm(e){return e.revision===void 0?e.era===`modern`?Zp.era:op.era:tm(e.revision).era}function rm(e){return om.some(t=>t.hasRequestMethod(e))}function im(e){return om.some(t=>t.hasNotificationMethod(e))}function am(e){return e===`tasks/get`||e===`tasks/cancel`}var om=[op,Zp],sm=n({AnnotationsSchema:()=>ru,AudioContentSchema:()=>Iu,BaseMetadataSchema:()=>Ml,BaseRequestParamsSchema:()=>pl,BlobResourceContentsSchema:()=>tu,BooleanSchemaSchema:()=>_d,CallToolRequestParamsSchema:()=>Zu,CallToolRequestSchema:()=>Qu,CallToolResultSchema:()=>Yu,CancelTaskRequestSchema:()=>rf,CancelTaskResultSchema:()=>af,CancelledNotificationParamsSchema:()=>Ol,CancelledNotificationSchema:()=>kl,ClientCapabilitiesSchema:()=>Ll,ClientNotificationSchema:()=>sf,ClientRequestSchema:()=>of,ClientResultSchema:()=>cf,ClientTasksCapabilitySchema:()=>Fl,CompatibilityCallToolResultSchema:()=>Xu,CompleteRequestParamsSchema:()=>Rd,CompleteRequestSchema:()=>zd,CompleteResultSchema:()=>Bd,ContentBlockSchema:()=>Bu,CreateMessageRequestParamsSchema:()=>pd,CreateMessageRequestSchema:()=>md,CreateMessageResultSchema:()=>hd,CreateMessageResultWithToolsSchema:()=>gd,CreateTaskResultSchema:()=>Jd,CursorSchema:()=>ll,DiscoverRequestSchema:()=>Ul,DiscoverResultSchema:()=>Wl,ElicitRequestFormParamsSchema:()=>kd,ElicitRequestParamsSchema:()=>jd,ElicitRequestSchema:()=>Md,ElicitRequestURLParamsSchema:()=>Ad,ElicitResultSchema:()=>Fd,ElicitationCompleteNotificationParamsSchema:()=>Nd,ElicitationCompleteNotificationSchema:()=>Pd,EmbeddedResourceSchema:()=>Ru,EmptyResultSchema:()=>Dl,EnumSchemaSchema:()=>Dd,GetPromptRequestParamsSchema:()=>Mu,GetPromptRequestSchema:()=>Nu,GetPromptResultSchema:()=>Hu,GetTaskPayloadRequestSchema:()=>$d,GetTaskPayloadResultSchema:()=>ef,GetTaskRequestSchema:()=>Zd,GetTaskResultSchema:()=>Qd,IconSchema:()=>Al,IconsSchema:()=>jl,ImageContentSchema:()=>Fu,ImplementationSchema:()=>Nl,InitializeRequestParamsSchema:()=>Rl,InitializeRequestSchema:()=>zl,InitializeResultSchema:()=>Vl,InitializedNotificationSchema:()=>Hl,JSONArraySchema:()=>sl,JSONObjectSchema:()=>ol,JSONRPCErrorResponseSchema:()=>wl,JSONRPCMessageSchema:()=>Tl,JSONRPCNotificationSchema:()=>Sl,JSONRPCRequestSchema:()=>xl,JSONRPCResponseSchema:()=>El,JSONRPCResultResponseSchema:()=>Cl,JSONValueSchema:()=>al,LegacyTitledEnumSchemaSchema:()=>Sd,ListChangedOptionsBaseSchema:()=>ed,ListPromptsRequestSchema:()=>Au,ListPromptsResultSchema:()=>ju,ListResourceTemplatesRequestSchema:()=>cu,ListResourceTemplatesResultSchema:()=>lu,ListResourcesRequestSchema:()=>ou,ListResourcesResultSchema:()=>su,ListRootsRequestSchema:()=>Hd,ListRootsResultSchema:()=>Ud,ListTasksRequestSchema:()=>tf,ListTasksResultSchema:()=>nf,ListToolsRequestSchema:()=>qu,ListToolsResultSchema:()=>Ju,LoggingLevelSchema:()=>td,LoggingMessageNotificationParamsSchema:()=>id,LoggingMessageNotificationSchema:()=>ad,ModelHintSchema:()=>od,ModelPreferencesSchema:()=>sd,MultiSelectEnumSchemaSchema:()=>Ed,NotificationSchema:()=>_l,NotificationsParamsSchema:()=>gl,NumberSchemaSchema:()=>yd,PaginatedRequestParamsSchema:()=>Yl,PaginatedRequestSchema:()=>Xl,PaginatedResultSchema:()=>Zl,PingRequestSchema:()=>Gl,PrimitiveSchemaDefinitionSchema:()=>Od,ProgressNotificationParamsSchema:()=>ql,ProgressNotificationSchema:()=>Jl,ProgressSchema:()=>Kl,ProgressTokenSchema:()=>cl,PromptArgumentSchema:()=>Ou,PromptListChangedNotificationSchema:()=>Uu,PromptMessageSchema:()=>Vu,PromptReferenceSchema:()=>Ld,PromptSchema:()=>ku,ReadResourceRequestParamsSchema:()=>du,ReadResourceRequestSchema:()=>fu,ReadResourceResultSchema:()=>pu,RelatedTaskMetadataSchema:()=>dl,RequestIdSchema:()=>bl,RequestMetaSchema:()=>fl,RequestSchema:()=>hl,ResourceContentsSchema:()=>Ql,ResourceLinkSchema:()=>zu,ResourceListChangedNotificationSchema:()=>mu,ResourceRequestParamsSchema:()=>uu,ResourceSchema:()=>iu,ResourceTemplateReferenceSchema:()=>Id,ResourceTemplateSchema:()=>au,ResourceUpdatedNotificationParamsSchema:()=>Eu,ResourceUpdatedNotificationSchema:()=>Du,ResultMetaObjectSchema:()=>vl,ResultSchema:()=>yl,RoleSchema:()=>nu,RootSchema:()=>Vd,RootsListChangedNotificationSchema:()=>Wd,SamplingContentSchema:()=>ud,SamplingMessageContentBlockSchema:()=>dd,SamplingMessageSchema:()=>fd,ServerCapabilitiesSchema:()=>Bl,ServerNotificationSchema:()=>uf,ServerRequestSchema:()=>lf,ServerResultSchema:()=>df,ServerTasksCapabilitySchema:()=>Il,SetLevelRequestParamsSchema:()=>nd,SetLevelRequestSchema:()=>rd,SingleSelectEnumSchemaSchema:()=>Cd,StringSchemaSchema:()=>vd,SubscribeRequestParamsSchema:()=>hu,SubscribeRequestSchema:()=>gu,SubscriptionFilterSchema:()=>yu,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Su,SubscriptionsAcknowledgedNotificationSchema:()=>Cu,SubscriptionsListenRequestParamsSchema:()=>bu,SubscriptionsListenRequestSchema:()=>xu,SubscriptionsListenResultMetaSchema:()=>wu,SubscriptionsListenResultSchema:()=>Tu,TaskAugmentedRequestParamsSchema:()=>ml,TaskCreationParamsSchema:()=>Gd,TaskMetadataSchema:()=>ul,TaskSchema:()=>qd,TaskStatusNotificationParamsSchema:()=>Yd,TaskStatusNotificationSchema:()=>Xd,TaskStatusSchema:()=>Kd,TextContentSchema:()=>Pu,TextResourceContentsSchema:()=>$l,TitledMultiSelectEnumSchemaSchema:()=>Td,TitledSingleSelectEnumSchemaSchema:()=>xd,ToolAnnotationsSchema:()=>Wu,ToolChoiceSchema:()=>cd,ToolExecutionSchema:()=>Gu,ToolListChangedNotificationSchema:()=>$u,ToolResultContentSchema:()=>ld,ToolSchema:()=>Ku,ToolUseContentSchema:()=>Lu,UnsubscribeRequestParamsSchema:()=>_u,UnsubscribeRequestSchema:()=>vu,UntitledMultiSelectEnumSchemaSchema:()=>wd,UntitledSingleSelectEnumSchemaSchema:()=>bd}),cm=e=>xl.safeParse(e).success,lm=e=>Sl.safeParse(e).success,um=e=>Cl.safeParse(e).success,dm=e=>wl.safeParse(e).success;gp.InvalidRequest,gp.UnsupportedProtocolVersion,gp.InvalidParams,gp.MethodNotFound,gp.InvalidParams,gp.MissingRequiredClientCapability,gp.ParseError,gp.InvalidRequest,gp.MethodNotFound,gp.UnsupportedProtocolVersion,gp.MissingRequiredClientCapability;function fm(e,t){return cs(e,t)}function pm(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function mm(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}var hm=!1,gm=`draft-2020-12`;function _m(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:gm});else if(n.vendor===`zod`){if(!(`_zod`in e))throw Error(`Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().`);hm||(hm=!0,console.warn(\"[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.\")),r=ns(e,{target:gm,io:t})}else throw Error(`Schema library \"${n.vendor}\" does not implement StandardJSONSchemaV1 (\\`~standard.jsonSchema\\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&ym(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}var vm=/^#\\/(\\$defs|definitions)\\/([^/~%]+)$/;function ym(e,t=e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;let n=typeof e.$ref==`string`&&vm.exec(e.$ref);if(n&&t[n[1]]?.[n[2]]?.type===`object`)return!0;for(let n of[`oneOf`,`anyOf`,`allOf`]){let r=e[n];if(Array.isArray(r)&&r.length>0)return r.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||ym(e,`$id`in e?{}:t)))}return!1}function bm(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function xm(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>bm(e)).join(`, `)}:{success:!0,data:n.value}}function Sm(e){let t=ns(e,{target:gm,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}var Cm=/\\\\\\.\\\\d\\{(\\d+)\\}/;function wm(e){let t=Cm.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>Jc({local:e,offset:t,precision:n}))))}function Tm(e,t){let n;switch(e){case`email`:n=[ks()];break;case`uri`:n=[Ns()];break;case`date`:n=[Yc()];break;case`date-time`:n=wm(t)}return new Set(n.map(e=>Sm(e)).filter(e=>e!==void 0))}function Em(e,t,n){return n!==`zod`||Tm(e,t).has(t)}function Dm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Om(e){try{return _m(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new _p(gp.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}var km=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function Am(e){return km.has(e)||e.startsWith(`x-`)}var jm=new Set([`$schema`,...Object.keys(kd.shape.requestedSchema.shape)]),Mm={string:pm([vd,bd,xd,Sd]),number:pm([yd]),integer:pm([yd]),boolean:pm([_d]),array:pm([wd,Td])},Nm=new Set(vd.shape.format.unwrap().options);function Pm(e,t,n,r){if(!Dm(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(Mm,e.type)?Mm[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||Am(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?Nm.has(e.format)?typeof s==`string`&&Em(e.format,s,n)||r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function Fm(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&Dm(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,Pm(n,`properties.${e}`,t,r)])):jm.has(i)?n[i]=a:Am(i)||r.push(i);if(r.length>0)throw new _p(gp.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function Im(e,t){if(!Dm(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!fm(Od,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function Lm(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>Lm(e,t[r],`${n}[${r}]`)):!Dm(e)||!Dm(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?Lm(r,t[e],i):Am(e)?[]:[i]})}function Rm(e){if(!mm(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=Fm(Om(e.requestedSchema),t),r=fm(kd.shape.requestedSchema,n);if(!r.success)throw new _p(gp.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${Im(n,r.error.message)}`);let i=Lm(n,r.data);if(i.length>0)throw new _p(gp.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new _p(gp.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function zm(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw TypeError(`inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)`);return{resultType:`input_required`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(zm,{elicit(e){try{return{method:`elicitation/create`,params:Rm(e)}}catch(e){throw e instanceof _p?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});var Bm=`AnnotationsSchema.AudioContentSchema.BaseMetadataSchema.BlobResourceContentsSchema.BooleanSchemaSchema.CallToolRequestSchema.CallToolRequestParamsSchema.CallToolResultSchema.CancelledNotificationSchema.CancelledNotificationParamsSchema.CancelTaskRequestSchema.CancelTaskResultSchema.ClientCapabilitiesSchema.ClientNotificationSchema.ClientRequestSchema.ClientResultSchema.CompatibilityCallToolResultSchema.CompleteRequestSchema.CompleteRequestParamsSchema.CompleteResultSchema.ContentBlockSchema.CreateMessageRequestSchema.CreateMessageRequestParamsSchema.CreateMessageResultSchema.CreateMessageResultWithToolsSchema.CreateTaskResultSchema.CursorSchema.DiscoverRequestSchema.DiscoverResultSchema.ElicitationCompleteNotificationSchema.ElicitationCompleteNotificationParamsSchema.ElicitRequestSchema.ElicitRequestFormParamsSchema.ElicitRequestParamsSchema.ElicitRequestURLParamsSchema.ElicitResultSchema.EmbeddedResourceSchema.EmptyResultSchema.EnumSchemaSchema.GetPromptRequestSchema.GetPromptRequestParamsSchema.GetPromptResultSchema.GetTaskPayloadRequestSchema.GetTaskPayloadResultSchema.GetTaskRequestSchema.GetTaskResultSchema.IconSchema.IconsSchema.ImageContentSchema.ImplementationSchema.InitializedNotificationSchema.InitializeRequestSchema.InitializeRequestParamsSchema.InitializeResultSchema.JSONArraySchema.JSONObjectSchema.JSONRPCErrorResponseSchema.JSONRPCMessageSchema.JSONRPCNotificationSchema.JSONRPCRequestSchema.JSONRPCResponseSchema.JSONRPCResultResponseSchema.JSONValueSchema.LegacyTitledEnumSchemaSchema.ListPromptsRequestSchema.ListPromptsResultSchema.ListResourcesRequestSchema.ListResourcesResultSchema.ListResourceTemplatesRequestSchema.ListResourceTemplatesResultSchema.ListRootsRequestSchema.ListRootsResultSchema.ListTasksRequestSchema.ListTasksResultSchema.ListToolsRequestSchema.ListToolsResultSchema.LoggingLevelSchema.LoggingMessageNotificationSchema.LoggingMessageNotificationParamsSchema.ModelHintSchema.ModelPreferencesSchema.MultiSelectEnumSchemaSchema.NotificationSchema.NumberSchemaSchema.PaginatedRequestSchema.PaginatedRequestParamsSchema.PaginatedResultSchema.PingRequestSchema.PrimitiveSchemaDefinitionSchema.ProgressSchema.ProgressNotificationSchema.ProgressNotificationParamsSchema.ProgressTokenSchema.PromptSchema.PromptArgumentSchema.PromptListChangedNotificationSchema.PromptMessageSchema.PromptReferenceSchema.ReadResourceRequestSchema.ReadResourceRequestParamsSchema.ReadResourceResultSchema.RelatedTaskMetadataSchema.RequestSchema.RequestIdSchema.RequestMetaSchema.ResourceSchema.ResourceContentsSchema.ResourceLinkSchema.ResourceListChangedNotificationSchema.ResourceRequestParamsSchema.ResourceTemplateSchema.ResourceTemplateReferenceSchema.ResourceUpdatedNotificationSchema.ResourceUpdatedNotificationParamsSchema.ResultMetaObjectSchema.ResultSchema.RoleSchema.RootSchema.RootsListChangedNotificationSchema.SamplingContentSchema.SamplingMessageSchema.SamplingMessageContentBlockSchema.ServerCapabilitiesSchema.ServerNotificationSchema.ServerRequestSchema.ServerResultSchema.SetLevelRequestSchema.SetLevelRequestParamsSchema.SingleSelectEnumSchemaSchema.StringSchemaSchema.SubscribeRequestSchema.SubscribeRequestParamsSchema.SubscriptionFilterSchema.SubscriptionsAcknowledgedNotificationSchema.SubscriptionsAcknowledgedNotificationParamsSchema.SubscriptionsListenRequestSchema.SubscriptionsListenRequestParamsSchema.SubscriptionsListenResultSchema.SubscriptionsListenResultMetaSchema.TaskAugmentedRequestParamsSchema.TaskCreationParamsSchema.TaskMetadataSchema.TaskSchema.TaskStatusSchema.TaskStatusNotificationSchema.TaskStatusNotificationParamsSchema.TextContentSchema.TextResourceContentsSchema.TitledMultiSelectEnumSchemaSchema.TitledSingleSelectEnumSchemaSchema.ToolSchema.ToolAnnotationsSchema.ToolChoiceSchema.ToolExecutionSchema.ToolListChangedNotificationSchema.ToolResultContentSchema.ToolUseContentSchema.UnsubscribeRequestSchema.UnsubscribeRequestParamsSchema.UntitledMultiSelectEnumSchemaSchema.UntitledSingleSelectEnumSchemaSchema`.split(`.`),Vm={IdJagTokenExchangeResponseSchema:vf,OAuthClientInformationFullSchema:Cf,OAuthClientInformationSchema:Sf,OAuthClientMetadataSchema:xf,OAuthClientRegistrationErrorSchema:wf,OAuthErrorResponseSchema:yf,OAuthMetadataSchema:mf,OAuthProtectedResourceMetadataSchema:pf,OAuthTokenRevocationRequestSchema:Tf,OAuthTokensSchema:_f,OpenIdProviderDiscoveryMetadataSchema:gf,OpenIdProviderMetadataSchema:hf},Hm={},Um={};function Wm(e,t){let n=e.slice(0,-6);Hm[n]=t,Um[n]=e=>t.safeParse(e).success}for(let e of Bm)Wm(e,sm[e]);for(let[e,t]of Object.entries(Vm))Wm(e,t);Object.freeze(Hm),Object.freeze(Um);function Gm(e){switch(e){case`initialize`:case`notifications/initialized`:return tm(void 0);case`server/discover`:return tm(em);default:return}}var Km=[$c,el,nl,il],qm=[`inputResponses`,`requestState`];function Jm(e,t){let n=e.params;if(!$m(n))return{message:e,lifted:{}};let r=n._meta,i=$m(r)?Km.filter(e=>e in r):[],a=t===`request`?qm.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&$m(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function Ym(e,t){let n=e.validateResult(t,void 0);if(n.ok||n.reason!==`not-in-era`)return{\"~standard\":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function Xm(e){return()=>e}var Zm=Xm(void 0),Qm=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Zc,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new Af(kf.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Af(kf.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),um(e)||dm(e)?this._onresponse(e):cm(e)?this._onrequest(e,t):lm(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new Af(kf.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=Jm(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=nm(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(im(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=Jm(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=nm(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(gp.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(rm(n.method)&&!i.hasRequestMethod(n.method)&&!(am(n.method)&&this._customSchemaRequestMethods.has(n.method))){o(gp.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(gp.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(gp.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:th(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?Zm:Xm(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),mm(t))return u(e,t,n);let i=Ym(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(gp.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:gp.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);n===void 0?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`)):(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),um(e)?n(e):n(_p.fromError(e.error.code,e.error.message,e.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(mm(t))return am(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=Ym(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return tm(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=Gm(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(rm(t)&&!e.hasRequestMethod(t))throw new Af(kf.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof Af?e:new Af(kf.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof Af?e:new Af(kf.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(nh(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;xm(n,o).then(e=>{e.success?d(e.data):f(new Af(kf.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new Af(kf.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new Af(kf.NotConnected,`Not connected`);if(im(t.method)&&!e.hasNotificationMethod(t.method))throw new Af(kf.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))})}else await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!rm(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new _p(gp.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await xm(t.params,{...r.params});if(!a.success)throw new _p(gp.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!im(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new _p(gp.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))})}else{if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await xm(t.params,{...r.params});if(!i.success)throw new _p(gp.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function $m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function eh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function th(e){let t={},n=[];if(!eh(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e))!eh(i)||`method`in i||`result`in i?n.push(r):t[r]=i;return{accepted:t,droppedKeys:n}}function nh(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}t((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *(\"(?:[\\u000b\\u0020\\u0021\\u0023-\\u005b\\u005d-\\u007e\\u0080-\\u00ff]|\\\\[\\u000b\\u0020-\\u00ff])*\"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\\\([\\u000b\\u0020-\\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))(),typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);var rh=/^(\\d\\d):(\\d\\d):(\\d\\d)(\\.\\d+)?(z|[+-]\\d\\d(?::?\\d\\d)?)?$/i,ih=/^(?=.{1,253}\\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\\.?$/i,ah=/^(?:[a-z][a-z0-9+\\-.]*:)?(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'\"()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\\?(?:[a-z0-9\\-._~!$&'\"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'\"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,oh=/^(?:(?:[^\\x00-\\x20\"'<>%\\\\^`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$/i,sh=/^(?:(?:https?|ftp):\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u{00a1}-\\u{ffff}0-9]+-?)*[a-z\\u{00a1}-\\u{ffff}0-9]+)(?:\\.(?:[a-z\\u{00a1}-\\u{ffff}0-9]+-?)*[a-z\\u{00a1}-\\u{ffff}0-9]+)*(?:\\.(?:[a-z\\u{00a1}-\\u{ffff}]{2,})))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu,ch=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,lh=/^(?:\\/(?:[^~/]|~0|~1)*)*$/,uh=/^#(?:\\/(?:[a-z0-9_\\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,dh=/^(?:0|[1-9][0-9]*)(?:#|(?:\\/(?:[^~/]|~0|~1)*)*)$/,fh=/^(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/,ph=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))$/i;function mh(e){return e.test.bind(e)}hh.bind(void 0,!1),mh(ah),mh(oh),mh(sh),mh(ih),mh(fh),mh(ph),mh(ch),mh(lh),mh(uh),mh(dh);function hh(e,t){let n=t.match(rh);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}globalThis.crypto;var gh=class extends Error{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.OAuthClientFlowError`})}static[Symbol.hasInstance](e){return Of(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError(\"isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`\");return Of(this,e)}constructor(e){super(e),this.name=new.target.name,Df(this,new.target)}};(class extends gh{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.IssuerMismatchError`})}kind;expected;received;constructor(e,t,n){super(`Issuer mismatch in ${e===`metadata`?`authorization server metadata (RFC 8414 §3.3)`:`authorization response (RFC 9207)`}: expected ${JSON.stringify(t)}, received ${JSON.stringify(n)}`),this.kind=e,this.expected=t,this.received=n}}),class extends gh{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.RegistrationRejectedError`})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`),this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},class extends gh{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.InsecureTokenEndpointError`})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`),this.tokenEndpoint=e}},class extends gh{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.AuthorizationServerMismatchError`})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`),this.recordedIssuer=e,this.currentIssuer=t}},class extends gh{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.InsufficientScopeError`})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required \"${e.requiredScope}\"`:``}`),this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}},class extends Error{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.UnauthorizedError`})}static[Symbol.hasInstance](e){return Of(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError(\"isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`\");return Of(this,e)}constructor(e){super(e??`Unauthorized`),this.name=`UnauthorizedError`,Df(this,new.target)}},class extends Error{static{Object.defineProperty(this,\"mcpBrand\",{value:`mcp.SseError`})}static[Symbol.hasInstance](e){return Of(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError(\"isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`\");return Of(this,e)}constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n,Df(this,new.target)}};var _h=class{_eventSlots=new Map;setHandler(e,t){let n=this._ensureEventSlot(e);n.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener(\"${String(e)}\", …) to add multiple listeners without replacing.`),n.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let n=this._eventSlots.get(e);if(!n)return;let r=n.listeners.indexOf(t);r!==-1&&n.listeners.splice(r,1)}dispatch(e,t){let n=this._eventSlots.get(e);if(n){n.onHandler?.(t);for(let e of[...n.listeners])e(t)}}_ensureEventSlot(e){let t=this._eventSlots.get(e);return t||(t={listeners:[]},this._eventSlots.set(e,t)),t}},vh=class{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for \"${e}\" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}},yh=new Set;function bh(e,t){let[n,r]=t,i=n?.shape;if(typeof i?.method?.value!=`string`)return;let a=i.method.value,o=e===`request`?`setRequestHandler`:`setNotificationHandler`;yh.has(o)||(yh.add(o),console.warn(`[ext-apps] ${o}(Schema, handler) is deprecated; use ${o}(\"${a}\", { params: Schema.shape.params }, handler).`));let s=r;return[a,{params:i.params},e===`request`?(e,t)=>s({method:a,params:e},xh(t)):e=>s({method:a,params:e})]}function xh(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var Sh=`2026-01-26`,Ch=class{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource){console.debug(`Ignoring message from unknown source`,e);return}let n=Tl.safeParse(e.data);n.success?(console.debug(`Parsed message`,n.data),this.onmessage?.(n.data)):e.data?.jsonrpc===`2.0`?(console.error(`Failed to parse message`,n.error.message,e),this.onerror?.(Error(`Invalid JSON-RPC message received: `+n.error.message))):console.debug(`Ignoring non-JSON-RPC message`,n.error.message,e)}}async start(){window.addEventListener(`message`,this.messageListener)}async send(e,t){e.method!==`ui/notifications/tool-input-partial`&&console.debug(`Sending message`,e),this.eventTarget.postMessage(e,`*`)}async close(){window.removeEventListener(`message`,this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},wh=K([J(`light`),J(`dark`)]).describe(`Color theme preference for the host environment.`),Th=K([J(`inline`),J(`fullscreen`),J(`pip`)]).describe(`Display mode for UI presentation.`),Eh=q(K([J(`--color-background-primary`),J(`--color-background-secondary`),J(`--color-background-tertiary`),J(`--color-background-inverse`),J(`--color-background-ghost`),J(`--color-background-info`),J(`--color-background-danger`),J(`--color-background-success`),J(`--color-background-warning`),J(`--color-background-disabled`),J(`--color-text-primary`),J(`--color-text-secondary`),J(`--color-text-tertiary`),J(`--color-text-inverse`),J(`--color-text-ghost`),J(`--color-text-info`),J(`--color-text-danger`),J(`--color-text-success`),J(`--color-text-warning`),J(`--color-text-disabled`),J(`--color-border-primary`),J(`--color-border-secondary`),J(`--color-border-tertiary`),J(`--color-border-inverse`),J(`--color-border-ghost`),J(`--color-border-info`),J(`--color-border-danger`),J(`--color-border-success`),J(`--color-border-warning`),J(`--color-border-disabled`),J(`--color-ring-primary`),J(`--color-ring-secondary`),J(`--color-ring-inverse`),J(`--color-ring-info`),J(`--color-ring-danger`),J(`--color-ring-success`),J(`--color-ring-warning`),J(`--font-sans`),J(`--font-mono`),J(`--font-weight-normal`),J(`--font-weight-medium`),J(`--font-weight-semibold`),J(`--font-weight-bold`),J(`--font-text-xs-size`),J(`--font-text-sm-size`),J(`--font-text-md-size`),J(`--font-text-lg-size`),J(`--font-heading-xs-size`),J(`--font-heading-sm-size`),J(`--font-heading-md-size`),J(`--font-heading-lg-size`),J(`--font-heading-xl-size`),J(`--font-heading-2xl-size`),J(`--font-heading-3xl-size`),J(`--font-text-xs-line-height`),J(`--font-text-sm-line-height`),J(`--font-text-md-line-height`),J(`--font-text-lg-line-height`),J(`--font-heading-xs-line-height`),J(`--font-heading-sm-line-height`),J(`--font-heading-md-line-height`),J(`--font-heading-lg-line-height`),J(`--font-heading-xl-line-height`),J(`--font-heading-2xl-line-height`),J(`--font-heading-3xl-line-height`),J(`--border-radius-xs`),J(`--border-radius-sm`),J(`--border-radius-md`),J(`--border-radius-lg`),J(`--border-radius-xl`),J(`--border-radius-full`),J(`--border-width-regular`),J(`--shadow-hairline`),J(`--shadow-sm`),J(`--shadow-md`),J(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses \\`Record<K, string | undefined>\\` rather than \\`Partial<Record<K, string>>\\`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.`),K([B(),ec()]).describe(`Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses \\`Record<K, string | undefined>\\` rather than \\`Partial<Record<K, string>>\\`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses \\`Record<K, string | undefined>\\` rather than \\`Partial<Record<K, string>>\\`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.`);G({method:J(`ui/open-link`),params:G({url:B().describe(`URL to open in the host's browser`)})});var Dh=G({isError:H().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),Oh=G({isError:H().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),kh=G({isError:H().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough();G({method:J(`ui/notifications/sandbox-proxy-ready`),params:G({})});var Ah=G({connectDomains:W(B()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).\n\n- Maps to CSP \\`connect-src\\` directive\n- Empty or omitted → no network connections (secure default)`),resourceDomains:W(B()).optional().describe(\"Origins for static resources (images, scripts, stylesheets, fonts, media).\\n\\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\\n- Wildcard subdomains supported: `https://*.example.com`\\n- Empty or omitted → no network resources (secure default)\"),frameDomains:W(B()).optional().describe(\"Origins for nested iframes.\\n\\n- Maps to CSP `frame-src` directive\\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)\"),baseUriDomains:W(B()).optional().describe(\"Allowed base URIs for the document.\\n\\n- Maps to CSP `base-uri` directive\\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)\")}),jh=G({camera:G({}).optional().describe(`Request camera access.\n\nMaps to Permission Policy \\`camera\\` feature.`),microphone:G({}).optional().describe(`Request microphone access.\n\nMaps to Permission Policy \\`microphone\\` feature.`),geolocation:G({}).optional().describe(`Request geolocation access.\n\nMaps to Permission Policy \\`geolocation\\` feature.`),clipboardWrite:G({}).optional().describe(`Request clipboard write access.\n\nMaps to Permission Policy \\`clipboard-write\\` feature.`)});G({method:J(`ui/notifications/size-changed`),params:G({width:V().optional().describe(`New width in pixels.`),height:V().optional().describe(`New height in pixels.`)})});var Mh=G({method:J(`ui/notifications/tool-input`),params:G({arguments:q(B(),U().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),Nh=G({method:J(`ui/notifications/tool-input-partial`),params:G({arguments:q(B(),U().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),Ph=G({method:J(`ui/notifications/tool-cancelled`),params:G({reason:B().optional().describe(`Optional reason for the cancellation (e.g., \"user action\", \"timeout\").`)})}),Fh=G({fonts:B().optional()}),Ih=G({variables:Eh.optional().describe(`CSS variables for theming the app.`),css:Fh.optional().describe(`CSS blocks that apps can inject.`)}),Lh=G({method:J(`ui/resource-teardown`),params:G({})}),Rh=q(B(),U()),zh=G({text:G({}).optional().describe(`Host supports text content blocks.`),image:G({}).optional().describe(`Host supports image content blocks.`),audio:G({}).optional().describe(`Host supports audio content blocks.`),resource:G({}).optional().describe(`Host supports resource content blocks.`),resourceLink:G({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:G({}).optional().describe(`Host supports structured content.`)});G({method:J(`ui/notifications/request-teardown`),params:G({}).optional()});var Bh=G({experimental:q(B(),q(B(),ic()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),openLinks:G({}).optional().describe(`Host supports opening external URLs.`),downloadFile:G({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:G({listChanged:H().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:G({listChanged:H().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:G({}).optional().describe(`Host accepts log messages.`),sandbox:G({permissions:jh.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:Ah.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:zh.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:zh.optional().describe(`Host supports receiving content messages (ui/message) from the view.`),sampling:G({tools:G({}).optional().describe(\"Host supports tool use via `tools` and `toolChoice` parameters.\")}).optional().describe(\"Host supports LLM sampling (sampling/createMessage) from the view.\\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.\")}),Vh=G({experimental:q(B(),q(B(),ic()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),tools:G({listChanged:H().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:W(Th).optional().describe(`Display modes the app supports.`)});G({method:J(`ui/notifications/initialized`),params:G({}).optional()}),G({csp:Ah.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:jh.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:B().optional().describe(`Dedicated origin for view sandbox.\n\nUseful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.\n\n**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:\n- Hash-based subdomains (e.g., \\`{hash}.claudemcpcontent.com\\`)\n- URL-derived subdomains (e.g., \\`www-example-com.oaiusercontent.com\\`)\n\nIf omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:H().optional().describe(`Visual boundary preference - true if view prefers a visible border.\n\nBoolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.\n\n- \\`true\\`: request visible border + background\n- \\`false\\`: request no visible border + background\n- omitted: host decides border`)}),G({method:J(`ui/request-display-mode`),params:G({mode:Th.describe(`The display mode being requested.`)})});var Hh=G({mode:Th.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),Uh=K([J(`model`),J(`app`)]).describe(`Tool visibility scope - who can access the tool.`);G({resourceUri:B().optional(),visibility:W(Uh).optional().describe(`Who can access this tool. Default: [\"model\", \"app\"]\n- \"model\": Tool visible to and callable by the agent\n- \"app\": Tool callable by the app from this server only`),csp:sc().optional(),permissions:sc().optional()}),G({mimeTypes:W(B()).optional().describe('Array of supported MIME types for UI resources.\\nMust include `\"text/html;profile=mcp-app\"` for MCP Apps support.')}),G({method:J(`ui/download-file`),params:G({contents:W(K([Ru,zu])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),G({method:J(`ui/message`),params:G({role:J(`user`).describe(`Message role, currently only \"user\" is supported.`),content:W(Bu).describe(`Message content blocks (text, image, etc.).`)})}),G({method:J(`ui/notifications/sandbox-resource-ready`),params:G({html:B().describe(`HTML content to load into the inner iframe.`),sandbox:B().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:Ah.optional().describe(`CSP configuration from resource metadata.`),permissions:jh.optional().describe(`Sandbox permissions from resource metadata.`)})});var Wh=G({method:J(`ui/notifications/tool-result`),params:Yu.describe(`Standard MCP tool execution result.`)}),Gh=G({toolInfo:G({id:bl.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Ku.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:wh.optional().describe(`Current color theme preference.`),styles:Ih.optional().describe(`Style configuration for theming the app.`),displayMode:Th.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:W(Th).optional().describe(`Display modes the host supports.`),containerDimensions:K([G({height:V().describe(`Fixed container height in pixels.`)}),G({maxHeight:K([V(),ec()]).optional().describe(`Maximum container height in pixels.`)})]).and(K([G({width:V().describe(`Fixed container width in pixels.`)}),G({maxWidth:K([V(),ec()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other\ncontainer holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:B().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:B().optional().describe(`User's timezone in IANA format.`),userAgent:B().optional().describe(`Host application identifier.`),platform:K([J(`web`),J(`desktop`),J(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:G({touch:H().optional().describe(`Whether the device supports touch input.`),hover:H().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:G({top:V().describe(`Top safe area inset in pixels.`),right:V().describe(`Right safe area inset in pixels.`),bottom:V().describe(`Bottom safe area inset in pixels.`),left:V().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Kh=G({method:J(`ui/notifications/host-context-changed`),params:Gh.describe(`Partial context update containing only changed fields.`)});G({method:J(`ui/update-model-context`),params:G({content:W(Bu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:q(B(),U().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),G({method:J(`ui/initialize`),params:G({appInfo:Nl.describe(`App identification (name and version).`),appCapabilities:Vh.describe(`Features and capabilities this app provides.`),protocolVersion:B().describe(`Protocol version this app supports.`)})});var qh=G({protocolVersion:B().describe(`Negotiated protocol version string (e.g., \"2025-11-21\").`),hostInfo:Nl.describe(`Host application identification and version.`),hostCapabilities:Bh.describe(`Features and capabilities provided by the host.`),hostContext:Gh.describe(`Rich context about the host environment.`)}).passthrough(),Jh={target:`draft-2020-12`};async function Yh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Jh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Xh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Zh(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Qh(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function $h(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}function eg(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var tg=class e extends Qm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new _h;_methods=new vh;setRequestHandler=(...e)=>{let[t,...n]=bh(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=bh(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:Mh,toolinputpartial:Nh,toolresult:Wh,toolcancelled:Ph,hostcontextchanged:Kh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] \"${String(t)}\" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&Ve({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=eg(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Xh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Xh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Yh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Yh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Lh.shape.params,result:Rh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string (\"${e}\"). Did you mean: callServerTool({ name: \"${e}\", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},kh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},Dl,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},Dh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},Oh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Hh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new Ch(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:Sh}},qh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}},ng=new Set;function rg(e){return e?!ng.has(e):!1}var ig=new WeakSet;function ag(e){ig.add(e)}function og(e){ig.delete(e)}function sg(e){return ig.has(e)}var cg=new WeakMap;function lg(e,t){cg.set(e,t)}function ug(e){if(ig.has(e))return e;let t=cg.get(e);return t&&ig.has(t)?t:null}var dg={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},fg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},pg=1e3,mg=1001,hg=1002,gg=1003,_g=1004,vg=1005,yg=1006,bg=1007,xg=1008,Sg=1009,Cg=1010,wg=1011,Tg=1012,Eg=1013,Dg=1014,Og=1015,kg=1016,Ag=1017,jg=1018,Mg=1020,Ng=35902,Pg=35899,Fg=1021,Ig=1022,Lg=1023,Rg=1026,zg=1027,Bg=1028,Vg=1029,Hg=1030,Ug=1031,Wg=1033,Gg=33776,Kg=33777,qg=33778,Jg=33779,Yg=35840,Xg=35841,Zg=35842,Qg=35843,$g=36196,e_=37492,t_=37496,n_=37488,r_=37489,i_=37490,a_=37491,o_=37808,s_=37809,c_=37810,l_=37811,u_=37812,d_=37813,f_=37814,p_=37815,m_=37816,h_=37817,g_=37818,__=37819,v_=37820,y_=37821,b_=36492,x_=36494,S_=36495,C_=36283,w_=36284,T_=36285,E_=36286,D_=2300,O_=2301,k_=2302,A_=2303,j_=2400,M_=2401,N_=2402,P_=3200,F_=`srgb`,I_=`srgb-linear`,L_=`linear`,R_=`srgb`,z_=7680,B_=35044,V_=2e3;function H_(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function U_(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function W_(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function G_(){let e=W_(`canvas`);return e.style.display=`block`,e}var K_={};function q_(...e){let t=`THREE.`+e.shift();console.log(t,...e)}function J_(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 Y_(...e){e=J_(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function X_(...e){e=J_(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Z_(...e){let t=e.join(` `);t in K_||(K_[t]=!0,Y_(...e))}function Q_(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 $_={0:0,2:6,4:4,3:5,1:1,6:2,7:7,5:3},ev=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<r;n++)t[n].call(this,e);e.target=null}}},tv=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),nv=1234567,rv=Math.PI/180,iv=180/Math.PI;function av(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(tv[e&255]+tv[e>>8&255]+tv[e>>16&255]+tv[e>>24&255]+`-`+tv[t&255]+tv[t>>8&255]+`-`+tv[t>>16&15|64]+tv[t>>24&255]+`-`+tv[n&63|128]+tv[n>>8&255]+`-`+tv[n>>16&255]+tv[n>>24&255]+tv[r&255]+tv[r>>8&255]+tv[r>>16&255]+tv[r>>24&255]).toLowerCase()}function ov(e,t,n){return Math.max(t,Math.min(n,e))}function sv(e,t){return(e%t+t)%t}function cv(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function lv(e,t,n){return e===t?0:(n-e)/(t-e)}function uv(e,t,n){return(1-n)*e+n*t}function dv(e,t,n,r){return uv(e,t,1-Math.exp(-n*r))}function fv(e,t=1){return t-Math.abs(sv(e,t*2)-t)}function pv(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function mv(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function hv(e,t){return e+Math.floor(Math.random()*(t-e+1))}function gv(e,t){return e+Math.random()*(t-e)}function _v(e){return e*(.5-Math.random())}function vv(e){e!==void 0&&(nv=e);let t=nv+=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 yv(e){return e*rv}function bv(e){return e*iv}function xv(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Sv(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Cv(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function wv(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:Y_(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Tv(e){switch(e.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function Ev(e,t){if(t.constructor===Float32Array)return e;let n=Tv(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.max(e/n,-1)}function Dv(e,t){if(t.constructor===Float32Array)return e;let n=Tv(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.round(e*n)}var Ov={DEG2RAD:rv,RAD2DEG:iv,generateUUID:av,clamp:ov,euclideanModulo:sv,mapLinear:cv,inverseLerp:lv,lerp:uv,damp:dv,pingpong:fv,smoothstep:pv,smootherstep:mv,randInt:hv,randFloat:gv,randFloatSpread:_v,seededRandom:vv,degToRad:yv,radToDeg:bv,isPowerOfTwo:xv,ceilPowerOfTwo:Sv,floorPowerOfTwo:Cv,setQuaternionFromProperEuler:wv,normalize:Dv,denormalize:Ev},X=class{static{this.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=ov(this.x,e.x,t.x),this.y=ov(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ov(this.x,e,t),this.y=ov(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ov(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(ov(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}},kv=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:Y_(`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(ov(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}},Z=class{static{this.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(jv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(jv.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=ov(this.x,e.x,t.x),this.y=ov(this.y,e.y,t.y),this.z=ov(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ov(this.x,e,t),this.y=ov(this.y,e,t),this.z=ov(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ov(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 Av.copy(this).projectOnVector(e),this.sub(Av)}reflect(e){return this.sub(Av.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(ov(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}},Av=new Z,jv=new kv,Mv=class{static{this.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 Z_(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(Nv.makeScale(e,t)),this}rotate(e){return Z_(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(Nv.makeRotation(-e)),this}translate(e,t){return Z_(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(Nv.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)}},Nv=new Mv,Pv=new Mv().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Fv=new Mv().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Iv(){let e={enabled:!0,workingColorSpace:I_,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n||(this.spaces[t].transfer===`srgb`&&(e.r=Rv(e.r),e.g=Rv(e.g),e.b=Rv(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=zv(e.r),e.g=zv(e.g),e.b=zv(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===``?L_: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[n].fromXYZ).multiply(this.spaces[t].toXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[I_]:{primaries:t,whitePoint:r,transfer:L_,toXYZ:Pv,fromXYZ:Fv,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:F_},outputColorSpaceConfig:{drawingBufferColorSpace:F_}},[F_]:{primaries:t,whitePoint:r,transfer:R_,toXYZ:Pv,fromXYZ:Fv,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:F_}}}),e}var Lv=Iv();function Rv(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function zv(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Bv,Vv=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{Bv===void 0&&(Bv=W_(`canvas`)),Bv.width=e.width,Bv.height=e.height;let t=Bv.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Bv}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=W_(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Rv(i[e]/255)*255;return n.putImageData(r,0,0),t}if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Rv(t[e]/255)*255):t[e]=Rv(t[e]);return{data:t,width:e.width,height:e.height}}return Y_(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},Hv=0,Uv=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,\"id\",{value:Hv++}),this.uuid=av(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width||0,t.height||0,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(Wv(r[t].image)):e.push(Wv(r[t]))}else e=Wv(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function Wv(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Vv.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(Y_(`Texture: Unable to serialize Texture.`),{})}var Gv=0,Kv=new Z,qv=class e extends ev{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=mg,i=mg,a=yg,o=xg,s=Lg,c=Sg,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,\"id\",{value:Gv++}),this.uuid=av(),this.name=``,this.source=new Uv(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new X(0,0),this.repeat=new X(1,1),this.center=new X(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Mv,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(Kv).x}get height(){return this.source.getSize(Kv).y}get depth(){return this.source.getSize(Kv).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.mipmapsAutoUpdate=e.mipmapsAutoUpdate,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.isPMREMTexture=e.isPMREMTexture,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){Y_(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?Y_(`Texture.setValues(): property '${t}' does not exist.`):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,mipmapsAutoUpdate:this.mipmapsAutoUpdate,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 pg:e.x-=Math.floor(e.x);break;case mg:e.x=e.x<0?0:1;break;case hg:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case pg:e.y-=Math.floor(e.y);break;case mg:e.y=e.y<0?0:1;break;case hg:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}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++}};qv.DEFAULT_IMAGE=null,qv.DEFAULT_MAPPING=300,qv.DEFAULT_ANISOTROPY=1;var Jv=class{static{this.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)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ov(this.x,e.x,t.x),this.y=ov(this.y,e.y,t.y),this.z=ov(this.z,e.z,t.z),this.w=ov(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ov(this.x,e,t),this.y=ov(this.y,e,t),this.z=ov(this.z,e,t),this.w=ov(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ov(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Yv=class extends ev{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yg,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Jv(0,0,e,t),this.scissorTest=!1,this.viewport=new Jv(0,0,e,t),this.textures=[];let r=n.count;for(let i=0;i<r;i++)this.textures[i]=new qv({width:e,height:t,depth:n.depth}),this.textures[i].isRenderTargetTexture=!0,this.textures[i].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:yg,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Uv(n)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null){if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture}else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:`dispose`})}},Xv=class extends Yv{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Zv=class extends qv{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=gg,this.minFilter=gg,this.wrapR=mg,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Qv=class extends qv{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=gg,this.minFilter=gg,this.wrapR=mg,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}},$v=class e{static{this.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,r=1/ey.setFromMatrixColumn(e,0).length(),i=1/ey.setFromMatrixColumn(e,1).length(),a=1/ey.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(ny,e,ry)}lookAt(e,t,n){let r=this.elements;return oy.subVectors(e,t),oy.lengthSq()===0&&(oy.z=1),oy.normalize(),iy.crossVectors(n,oy),iy.lengthSq()===0&&(Math.abs(n.z)===1?oy.x+=1e-4:oy.z+=1e-4,oy.normalize(),iy.crossVectors(n,oy)),iy.normalize(),ay.crossVectors(oy,iy),r[0]=iy.x,r[4]=ay.x,r[8]=oy.x,r[1]=iy.y,r[5]=ay.y,r[9]=oy.y,r[2]=iy.z,r[6]=ay.z,r[10]=oy.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],ee=r[11],te=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*ee,i[12]=a*w+o*O+s*M+c*te,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*ee,i[13]=l*w+u*O+d*M+f*te,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*ee,i[14]=p*w+m*O+h*M+g*te,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*ee,i[15]=_*w+v*O+y*M+b*te,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],c=e[6],l=e[10];return t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinantAffine();if(i===0)return n.set(1,1,1),t.identity(),this;let a=ey.set(r[0],r[1],r[2]).length(),o=ey.set(r[4],r[5],r[6]).length(),s=ey.set(r[8],r[9],r[10]).length();i<0&&(a=-a),ty.copy(this);let c=1/a,l=1/o,u=1/s;return ty.elements[0]*=c,ty.elements[1]*=c,ty.elements[2]*=c,ty.elements[4]*=l,ty.elements[5]*=l,ty.elements[6]*=l,ty.elements[8]*=u,ty.elements[9]*=u,ty.elements[10]*=u,t.setFromRotationMatrix(ty),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=V_,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=V_,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},ey=new Z,ty=new $v,ny=new Z(0,0,0),ry=new Z(1,1,1),iy=new Z,ay=new Z,oy=new Z,sy=new $v,cy=new kv,ly=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(ov(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-ov(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(ov(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-ov(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(ov(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-ov(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:Y_(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return sy.makeRotationFromQuaternion(e),this.setFromRotationMatrix(sy,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return cy.setFromEuler(this),this.setFromQuaternion(cy,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ly.DEFAULT_ORDER=`XYZ`;var uy=class{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return!!(this.mask&1<<e)}},dy=0,fy=new Z,py=new kv,my=new $v,hy=new Z,gy=new Z,_y=new Z,vy=new kv,yy=new Z(1,0,0),by=new Z(0,1,0),xy=new Z(0,0,1),Sy={type:`added`},Cy={type:`removed`},wy={type:`childadded`,child:null},Ty={type:`childremoved`,child:null},Ey=class e extends ev{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,\"id\",{value:dy++}),this.uuid=av(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new Z,n=new ly,r=new kv,i=new Z(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new $v},normalMatrix:{value:new Mv}}),this.matrix=new $v,this.matrixWorld=new $v,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uy,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return py.setFromAxisAngle(e,t),this.quaternion.multiply(py),this}rotateOnWorldAxis(e,t){return py.setFromAxisAngle(e,t),this.quaternion.premultiply(py),this}rotateX(e){return this.rotateOnAxis(yy,e)}rotateY(e){return this.rotateOnAxis(by,e)}rotateZ(e){return this.rotateOnAxis(xy,e)}translateOnAxis(e,t){return fy.copy(e).applyQuaternion(this.quaternion),this.position.add(fy.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(yy,e)}translateY(e){return this.translateOnAxis(by,e)}translateZ(e){return this.translateOnAxis(xy,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(my.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?hy.copy(e):hy.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),gy.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?my.lookAt(gy,hy,this.up):my.lookAt(hy,gy,this.up),this.quaternion.setFromRotationMatrix(my),r&&(my.extractRotation(r.matrixWorld),py.setFromRotationMatrix(my),this.quaternion.premultiply(py.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(X_(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Sy),wy.child=e,this.dispatchEvent(wy),wy.child=null):X_(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Cy),Ty.child=e,this.dispatchEvent(Ty),Ty.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),my.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),my.multiply(e.parent.matrixWorld)),e.applyMatrix4(my),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Sy),wy.child=e,this.dispatchEvent(wy),wy.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gy,e,_y),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gy,vy,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let e=this.children;for(let t=0,r=e.length;t<r;t++)e[t].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0){if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material)}if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}dispose(){this.dispatchEvent({type:`dispose`})}};Ey.DEFAULT_UP=new Z(0,1,0),Ey.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ey.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Dy=class extends Ey{constructor(){super(),this.isGroup=!0,this.type=`Group`}},Oy={type:`move`},ky=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Dy,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Dy,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Z),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Dy,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Z,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,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.quaternion,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(Oy)))}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 Dy;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Ay={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},jy={h:0,s:0,l:0},My={h:0,s:0,l:0};function Ny(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 Q=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=F_){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Lv.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Lv.workingColorSpace){return this.r=e,this.g=t,this.b=n,Lv.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Lv.workingColorSpace){if(e=sv(e,1),t=ov(t,0,1),n=ov(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=Ny(i,r,e+1/3),this.g=Ny(i,r,e),this.b=Ny(i,r,e-1/3)}return Lv.colorSpaceToWorking(this,r),this}setStyle(e,t=F_){function n(t){t!==void 0&&parseFloat(t)<1&&Y_(`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+)?|\\.\\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+(?:\\.\\d+)?|\\.\\d+)\\%\\s*,\\s*(\\d+(?:\\.\\d+)?|\\.\\d+)\\%\\s*,\\s*(\\d+(?:\\.\\d+)?|\\.\\d+)\\%\\s*(?:,\\s*(\\d+(?:\\.\\d+)?|\\.\\d+)\\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseFloat(i[1]))/100,Math.min(100,parseFloat(i[2]))/100,Math.min(100,parseFloat(i[3]))/100,t);break;case`hsl`:case`hsla`:if(i=/^\\s*([+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+))\\s*,\\s*(\\d+(?:\\.\\d+)?|\\.\\d+)\\%\\s*,\\s*(\\d+(?:\\.\\d+)?|\\.\\d+)\\%\\s*(?:,\\s*(\\d+(?:\\.\\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:Y_(`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);Y_(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=F_){let n=Ay[e.toLowerCase()];return n===void 0?Y_(`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=Rv(e.r),this.g=Rv(e.g),this.b=Rv(e.b),this}copyLinearToSRGB(e){return this.r=zv(e.r),this.g=zv(e.g),this.b=zv(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=F_){return Lv.workingToColorSpace(Py.copy(this),e),Math.round(ov(Py.r*255,0,255))*65536+Math.round(ov(Py.g*255,0,255))*256+Math.round(ov(Py.b*255,0,255))}getHexString(e=F_){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Lv.workingColorSpace){Lv.workingToColorSpace(Py.copy(this),t);let n=Py.r,r=Py.g,i=Py.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Lv.workingColorSpace){return Lv.workingToColorSpace(Py.copy(this),t),e.r=Py.r,e.g=Py.g,e.b=Py.b,e}getStyle(e=F_){Lv.workingToColorSpace(Py.copy(this),e);let t=Py.r,n=Py.g,r=Py.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(jy),this.setHSL(jy.h+e,jy.s+t,jy.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(jy),e.getHSL(My);let n=uv(jy.h,My.h,t),r=uv(jy.s,My.s,t),i=uv(jy.l,My.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Py=new Q;Q.NAMES=Ay;var Fy=class extends Ey{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ly,this.environmentIntensity=1,this.environmentRotation=new ly,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background===null?null:e.background.clone(),this.environment=e.environment===null?null:e.environment.clone(),this.fog=e.fog===null?null:e.fog.clone(),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial===null?null:e.overrideMaterial.clone(),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Iy=new Z,Ly=new Z,Ry=new Z,zy=new Z,By=new Z,Vy=new Z,Hy=new Z,Uy=new Z,Wy=new Z,Gy=new Z,Ky=new Jv,qy=new Jv,Jy=new Jv,Yy=class e{constructor(e=new Z,t=new Z,n=new Z){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Iy.subVectors(e,t),r.cross(Iy);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){Iy.subVectors(r,t),Ly.subVectors(n,t),Ry.subVectors(e,t);let a=Iy.dot(Iy),o=Iy.dot(Ly),s=Iy.dot(Ry),c=Ly.dot(Ly),l=Ly.dot(Ry),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,zy)!==null&&zy.x>=0&&zy.y>=0&&zy.x+zy.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,zy)===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,zy.x),s.addScaledVector(a,zy.y),s.addScaledVector(o,zy.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Ky.setScalar(0),qy.setScalar(0),Jy.setScalar(0),Ky.fromBufferAttribute(e,t),qy.fromBufferAttribute(e,n),Jy.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Ky,i.x),a.addScaledVector(qy,i.y),a.addScaledVector(Jy,i.z),a}static isFrontFacing(e,t,n,r){return Iy.subVectors(n,t),Ly.subVectors(e,t),Iy.cross(Ly).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 Iy.subVectors(this.c,this.b),Ly.subVectors(this.a,this.b),Iy.cross(Ly).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;By.subVectors(r,n),Vy.subVectors(i,n),Uy.subVectors(e,n);let s=By.dot(Uy),c=Vy.dot(Uy);if(s<=0&&c<=0)return t.copy(n);Wy.subVectors(e,r);let l=By.dot(Wy),u=Vy.dot(Wy);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0&&s-l>0)return a=s/(s-l),t.copy(n).addScaledVector(By,a);Gy.subVectors(e,i);let f=By.dot(Gy),p=Vy.dot(Gy);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(Vy,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Hy.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Hy,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(By,a).addScaledVector(Vy,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Xy=class{constructor(e=new Z(1/0,1/0,1/0),t=new Z(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Qy.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Qy.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Qy.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,Qy):Qy.fromBufferAttribute(r,t),Qy.applyMatrix4(e.matrixWorld),this.expandByPoint(Qy);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),$y.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),$y.copy(e.boundingBox)),$y.applyMatrix4(e.matrixWorld),this.union($y)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Qy),Qy.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(ob),sb.subVectors(this.max,ob),eb.subVectors(e.a,ob),tb.subVectors(e.b,ob),nb.subVectors(e.c,ob),rb.subVectors(tb,eb),ib.subVectors(nb,tb),ab.subVectors(eb,nb);let t=[0,-rb.z,rb.y,0,-ib.z,ib.y,0,-ab.z,ab.y,rb.z,0,-rb.x,ib.z,0,-ib.x,ab.z,0,-ab.x,-rb.y,rb.x,0,-ib.y,ib.x,0,-ab.y,ab.x,0];return!ub(t,eb,tb,nb,sb)||(t=[1,0,0,0,1,0,0,0,1],!ub(t,eb,tb,nb,sb))?!1:(cb.crossVectors(rb,ib),t=[cb.x,cb.y,cb.z],ub(t,eb,tb,nb,sb))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Qy).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Qy).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()||(Zy[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zy[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zy[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zy[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zy[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zy[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zy[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zy[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zy)),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}},Zy=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],Qy=new Z,$y=new Xy,eb=new Z,tb=new Z,nb=new Z,rb=new Z,ib=new Z,ab=new Z,ob=new Z,sb=new Z,cb=new Z,lb=new Z;function ub(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){lb.fromArray(e,a);let o=i.x*Math.abs(lb.x)+i.y*Math.abs(lb.y)+i.z*Math.abs(lb.z),s=t.dot(lb),c=n.dot(lb),l=r.dot(lb);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var db=fb();function fb(){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 pb(e){Math.abs(e)>65504&&Y_(`DataUtils.toHalfFloat(): Value out of range.`),e=ov(e,-65504,65504),db.floatView[0]=e;let t=db.uint32View[0],n=t>>23&511;return db.baseTable[n]+((t&8388607)>>db.shiftTable[n])}function mb(e){let t=e>>10;return db.uint32View[0]=db.mantissaTable[db.offsetTable[t]+(e&1023)]+db.exponentTable[t],db.floatView[0]}var hb=class{static toHalfFloat(e){return pb(e)}static fromHalfFloat(e){return mb(e)}},gb=new Z,_b=new X,vb=0,yb=class extends ev{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:vb++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=B_,this.updateRanges=[],this.gpuType=Og,this.version=0,this._normalizationScale=e===void 0?void 0:Tv(e)}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._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)_b.fromBufferAttribute(this,t),_b.applyMatrix3(e),this.setXY(t,_b.x,_b.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)gb.fromBufferAttribute(this,t),gb.applyMatrix3(e),this.setXYZ(t,gb.x,gb.y,gb.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)gb.fromBufferAttribute(this,t),gb.applyMatrix4(e),this.setXYZ(t,gb.x,gb.y,gb.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gb.fromBufferAttribute(this,t),gb.applyNormalMatrix(e),this.setXYZ(t,gb.x,gb.y,gb.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gb.fromBufferAttribute(this,t),gb.transformDirection(e),this.setXYZ(t,gb.x,gb.y,gb.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:`dispose`})}_denormalize(e){let t=this._normalizationScale;return t===void 0?Ev(e,this.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?Dv(e,this.array):Math.round(e*t)}},bb=class extends yb{constructor(e,t,n){super(new Uint16Array(e),t,n)}},xb=class extends yb{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Sb=class extends yb{constructor(e,t,n){super(new Float32Array(e),t,n)}},Cb=new Xy,wb=new Z,Tb=new Z,Eb=class{constructor(e=new Z,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Cb.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;wb.subVectors(e,this.center);let t=wb.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(wb,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):(Tb.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(wb.copy(e.center).add(Tb)),this.expandByPoint(wb.copy(e.center).sub(Tb))),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}},Db=0,Ob=new $v,kb=new Ey,Ab=new Z,jb=new Xy,Mb=new Xy,Nb=new Z,Pb=class e extends ev{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,\"id\",{value:Db++}),this.uuid=av(),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 this.index=Array.isArray(e)?new(H_(e)?xb:bb)(e,1):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 Mv().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 Ob.makeRotationFromQuaternion(e),this.applyMatrix4(Ob),this}rotateX(e){return Ob.makeRotationX(e),this.applyMatrix4(Ob),this}rotateY(e){return Ob.makeRotationY(e),this.applyMatrix4(Ob),this}rotateZ(e){return Ob.makeRotationZ(e),this.applyMatrix4(Ob),this}translate(e,t,n){return Ob.makeTranslation(e,t,n),this.applyMatrix4(Ob),this}scale(e,t,n){return Ob.makeScale(e,t,n),this.applyMatrix4(Ob),this}lookAt(e){return kb.lookAt(e),kb.updateMatrix(),this.applyMatrix4(kb.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ab).negate(),this.translate(Ab.x,Ab.y,Ab.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Sb(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&Y_(`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 Xy);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)X_(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new Z(-1/0,-1/0,-1/0),new Z(1/0,1/0,1/0));else{if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];jb.setFromBufferAttribute(n),this.morphTargetsRelative?(Nb.addVectors(this.boundingBox.min,jb.min),this.boundingBox.expandByPoint(Nb),Nb.addVectors(this.boundingBox.max,jb.max),this.boundingBox.expandByPoint(Nb)):(this.boundingBox.expandByPoint(jb.min),this.boundingBox.expandByPoint(jb.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&X_(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.`,this)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Eb);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)X_(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new Z,1/0);else if(e){let n=this.boundingSphere.center;if(jb.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Mb.setFromBufferAttribute(n),this.morphTargetsRelative?(Nb.addVectors(jb.min,Mb.min),jb.expandByPoint(Nb),Nb.addVectors(jb.max,Mb.max),jb.expandByPoint(Nb)):(jb.expandByPoint(Mb.min),jb.expandByPoint(Mb.max))}jb.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Nb.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Nb));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Nb.fromBufferAttribute(a,t),o&&(Ab.fromBufferAttribute(e,t),Nb.add(Ab)),r=Math.max(r,n.distanceToSquared(Nb))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&X_(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){X_(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv,a=this.getAttribute(`tangent`);(a===void 0||a.count!==n.count)&&(a=new yb(new Float32Array(4*n.count),4),this.setAttribute(`tangent`,a));let o=[],s=[],c=new Uint8Array(n.count);for(let e=0;e<n.count;e++)o[e]=new Z,s[e]=new Z;let l=new Z,u=new Z,d=new Z,f=new X,p=new X,m=new X,h=new Z,g=new Z;function _(e,t,r){c[e]=c[t]=c[r]=1,l.fromBufferAttribute(n,e),u.fromBufferAttribute(n,t),d.fromBufferAttribute(n,r),f.fromBufferAttribute(i,e),p.fromBufferAttribute(i,t),m.fromBufferAttribute(i,r),u.sub(l),d.sub(l),p.sub(f),m.sub(f);let a=1/(p.x*m.y-m.x*p.y);isFinite(a)&&(h.copy(u).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(a),g.copy(d).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(a),o[e].add(h),o[t].add(h),o[r].add(h),s[e].add(g),s[t].add(g),s[r].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let t=0,n=v.length;t<n;++t){let n=v[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)_(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let y=new Z,b=new Z,x=new Z,S=new Z;function C(e){x.fromBufferAttribute(r,e),S.copy(x);let t=o[e];y.copy(t),y.sub(x.multiplyScalar(x.dot(t))).normalize(),b.crossVectors(S,t);let n=b.dot(s[e])<0?-1:1;a.setXYZW(e,y.x,y.y,y.z,n)}for(let e=0,t=n.count;e<t;++e)c[e]&&C(e);this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0||n.count!==t.count)n=new yb(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new Z,i=new Z,a=new Z,o=new Z,s=new Z,c=new Z,l=new Z,u=new Z;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Nb.fromBufferAttribute(e,t),Nb.normalize(),e.setXYZ(t,Nb.x,Nb.y,Nb.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new yb(a,r,i)}if(this.index===null)return Y_(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?`BufferGeometry`:this.type,e.name=this.name,Object.keys(this.userData).length>0&&(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;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:`dispose`})}},Fb=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=B_,this.updateRanges=[],this.version=0,this.uuid=av()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=Ib(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=this.array.slice(0).buffer);let n=new this.array.constructor(e.arrayBuffers[t]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=Ib(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=Array.from(new Uint32Array(this.array.slice(0).buffer)));let n={uuid:this.uuid,buffer:t,type:this.array.constructor.name,stride:this.stride};return n.usage=this.usage,n}};function Ib(e){return e.buffer._uuid===void 0&&(e.buffer._uuid=av()),e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer._uuid:e.buffer._uuid+`:`+e.byteOffset+`:`+e.byteLength}var Lb=new Z,Rb=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r,this._normalizationScale=e===void 0?void 0:Tv(e.array)}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Lb.fromBufferAttribute(this,t),Lb.applyMatrix4(e),this.setXYZ(t,Lb.x,Lb.y,Lb.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Lb.fromBufferAttribute(this,t),Lb.applyNormalMatrix(e),this.setXYZ(t,Lb.x,Lb.y,Lb.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Lb.fromBufferAttribute(this,t),Lb.transformDirection(e),this.setXYZ(t,Lb.x,Lb.y,Lb.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=this._denormalize(t)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=this._denormalize(t)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=this._denormalize(t)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=this._denormalize(t)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){q_(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new yb(new this.array.constructor(e),this.itemSize,this.normalized)}return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){q_(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}_denormalize(e){let t=this._normalizationScale;return t===void 0?Ev(e,this.data.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?Dv(e,this.data.array):Math.round(e*t)}},zb=new Z,Bb=new Z,Vb=new Mv,Hb=class{constructor(e=new Z(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=zb.subVectors(n,t).cross(Bb.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(zb),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||Vb.getNormalMatrix(e),r=this.coplanarPoint(zb).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)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},Ub=0,Wb=class extends ev{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,\"id\",{value:Ub++}),this.uuid=av(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Q(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=z_,this.stencilZFail=z_,this.stencilZPass=z_,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Y_(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?Y_(`Material: '${t}' is not a property of THREE.${this.type}.`):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,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,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&&(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.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),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.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),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&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(e=>e.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),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.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),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 Q().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.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),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.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(e=>new Hb().fromJSON(e))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),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.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),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&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0: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 X().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 X().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),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++}},Gb=class extends Wb{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new Q(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}},Kb,qb=new Z,Jb=new Z,Yb=new Z,Xb=new X,Zb=new X,Qb=new $v,$b=new Z,ex=new Z,tx=new Z,nx=new X,rx=new X,ix=new X,ax=class extends Ey{constructor(e=new Gb){if(super(),this.isSprite=!0,this.type=`Sprite`,Kb===void 0){Kb=new Pb;let e=new Fb(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Kb.setIndex([0,1,2,0,2,3]),Kb.setAttribute(`position`,new Rb(e,3,0,!1)),Kb.setAttribute(`uv`,new Rb(e,2,3,!1))}this.geometry=Kb,this.material=e,this.center=new X(.5,.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){e.camera===null&&X_(`Sprite: \"Raycaster.camera\" needs to be set in order to raycast against sprites.`),Jb.setFromMatrixScale(this.matrixWorld),Qb.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Yb.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Jb.multiplyScalar(-Yb.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;ox($b.set(-.5,-.5,0),Yb,a,Jb,r,i),ox(ex.set(.5,-.5,0),Yb,a,Jb,r,i),ox(tx.set(.5,.5,0),Yb,a,Jb,r,i),nx.set(0,0),rx.set(1,0),ix.set(1,1);let o=e.ray.intersectTriangle($b,ex,tx,!1,qb);if(o===null&&(ox(ex.set(-.5,.5,0),Yb,a,Jb,r,i),rx.set(0,1),o=e.ray.intersectTriangle($b,tx,ex,!1,qb),o===null))return;let s=e.ray.origin.distanceTo(qb);s<e.near||s>e.far||t.push({distance:s,point:qb.clone(),uv:Yy.getInterpolation(qb,$b,ex,tx,nx,rx,ix,new X),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}toJSON(e){let t=super.toJSON(e);return t.object.center=this.center.toArray(),t}};function ox(e,t,n,r,i,a){Xb.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?Zb.copy(Xb):(Zb.x=a*Xb.x-i*Xb.y,Zb.y=i*Xb.x+a*Xb.y),e.copy(t),e.x+=Zb.x,e.y+=Zb.y,e.applyMatrix4(Qb)}var sx=new Z,cx=new Z,lx=new Z,ux=new Z,dx=class{constructor(e=new Z,t=new Z(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,sx)),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=sx.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(sx.copy(this.origin).addScaledVector(this.direction,t),sx.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){cx.copy(e).add(t).multiplyScalar(.5),lx.copy(t).sub(e).normalize(),ux.copy(this.origin).sub(cx);let i=e.distanceTo(t)*.5,a=-this.direction.dot(lx),o=ux.dot(this.direction),s=-ux.dot(lx),c=ux.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(cx).addScaledVector(lx,d),f}intersectSphere(e,t){if(e.radius<0)return null;sx.subVectors(e.center,this.origin);let n=sx.dot(this.direction),r=sx.dot(sx)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,sx)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,o=this.direction,s=o.x,c=o.y,l=o.z,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,p=t.x-a.x,m=t.y-a.y,h=t.z-a.z,g=n.x-a.x,_=n.y-a.y,v=n.z-a.z,y=Math.abs(s),b=Math.abs(c),x=Math.abs(l),S,C,w,T,E,D,O,k,A,j,M,N;if(y>=b&&y>=x?(w=s,D=u,A=p,N=g,s>=0?(S=c,C=l,T=d,E=f,O=m,k=h,j=_,M=v):(S=l,C=c,T=f,E=d,O=h,k=m,j=v,M=_)):b>=x?(w=c,D=d,A=m,N=_,c>=0?(S=l,C=s,T=f,E=u,O=h,k=p,j=v,M=g):(S=s,C=l,T=u,E=f,O=p,k=h,j=g,M=v)):(w=l,D=f,A=h,N=v,l>=0?(S=s,C=c,T=u,E=d,O=p,k=m,j=g,M=_):(S=c,C=s,T=d,E=u,O=m,k=p,j=_,M=g)),w===0)return null;let P=S/w,ee=C/w,te=1/w,ne=T-P*D,re=E-ee*D,ie=O-P*A,ae=k-ee*A,oe=j-P*N,se=M-ee*N,ce=oe*ae-se*ie,le=ne*se-re*oe,ue=ie*re-ae*ne;if(r){if(ce<0||le<0||ue<0)return null}else if((ce<0||le<0||ue<0)&&(ce>0||le>0||ue>0))return null;let de=ce+le+ue;if(de===0)return null;let fe=te*(ce*D+le*A+ue*N);return(de>0?fe<0:fe>0)?null:this.at(fe/de,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)}},fx=class extends Wb{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Q(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 ly,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}},px=new $v,mx=new dx,hx=new Eb,gx=new Z,_x=new Z,vx=new Z,yx=new Z,bx=new Z,xx=new Z,Sx=new Z,Cx=new Z,wx=class extends Ey{constructor(e=new Pb,t=new fx){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),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){xx.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(bx.fromBufferAttribute(s,e),a?xx.addScaledVector(bx,r):xx.addScaledVector(bx.sub(t),r))}t.add(xx)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),hx.copy(n.boundingSphere),hx.applyMatrix4(i),mx.copy(e.ray).recast(e.near),!(hx.containsPoint(mx.origin)===!1&&(mx.intersectSphere(hx,gx)===null||mx.origin.distanceToSquared(gx)>(e.far-e.near)**2))&&(px.copy(i).invert(),mx.copy(e.ray).applyMatrix4(px),(n.boundingBox===null||mx.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,mx)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Ex(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Ex(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}}else if(s!==void 0){if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Ex(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Ex(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}}};function Tx(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Cx.copy(s),Cx.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Cx);return l<n.near||l>n.far?null:{distance:l,point:Cx.clone(),object:e}}function Ex(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,_x),e.getVertexPosition(c,vx),e.getVertexPosition(l,yx);let u=Tx(e,t,n,r,_x,vx,yx,Sx);if(u){let e=new Z;Yy.getBarycoord(Sx,_x,vx,yx,e),i&&(u.uv=Yy.getInterpolatedAttribute(i,s,c,l,e,new X)),a&&(u.uv1=Yy.getInterpolatedAttribute(a,s,c,l,e,new X)),o&&(u.normal=Yy.getInterpolatedAttribute(o,s,c,l,e,new Z),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new Z,materialIndex:0};Yy.getNormal(_x,vx,yx,t.normal),u.face=t,u.barycoord=e}return u}var Dx=class extends qv{constructor(e=null,t=1,n=1,r,i,a,o,s,c=gg,l=gg,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}},Ox=new Eb,kx=new X(.5,.5),Ax=new Z,jx=class{constructor(e=new Hb,t=new Hb,n=new Hb,r=new Hb,i=new Hb,a=new Hb){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=V_,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(),Ox.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ox.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ox)}intersectsSprite(e){return Ox.center.set(0,0,0),Ox.radius=.7071067811865476+kx.distanceTo(e.center),Ox.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ox)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Ax.x=r.normal.x>0?e.max.x:e.min.x,Ax.y=r.normal.y>0?e.max.y:e.min.y,Ax.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ax)<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)}},Mx=new $v,Nx=class e{constructor(){this.coordinateSystem=V_,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e<t.length;e++){let r=t[e];Mx.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[e]===void 0&&(n[e]=new jx),n[e].setFromProjectionMatrix(Mx,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let r=0;r<e._count;r++)t[r]===void 0&&(t[r]=new jx),t[r].copy(n[r]);return this._count=e._count,this}clone(){return new e().copy(this)}},Px=class extends Wb{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new Q(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Fx=new Z,Ix=new Z,Lx=new $v,Rx=new dx,zx=new Eb,Bx=new Z,Vx=new Z,Hx=class extends Ey{constructor(e=new Pb,t=new Px){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)Fx.fromBufferAttribute(t,e-1),Ix.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Fx.distanceTo(Ix);e.setAttribute(`lineDistance`,new Sb(n,1))}else Y_(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),zx.copy(n.boundingSphere),zx.applyMatrix4(r),zx.radius+=i,e.ray.intersectsSphere(zx)===!1)return;Lx.copy(r).invert(),Rx.copy(e.ray).applyMatrix4(Lx);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=Ux(this,e,Rx,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=Ux(this,e,Rx,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=Ux(this,e,Rx,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=Ux(this,e,Rx,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Ux(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(Fx.fromBufferAttribute(s,i),Ix.fromBufferAttribute(s,a),n.distanceSqToSegment(Fx,Ix,Bx,Vx)>r)return;Bx.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(Bx);if(!(c<t.near||c>t.far))return{distance:c,point:Vx.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Wx=class extends Wb{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new Q(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Gx=new $v,Kx=new dx,qx=new Eb,Jx=new Z,Yx=class extends Ey{constructor(e=new Pb,t=new Wx){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),qx.copy(n.boundingSphere),qx.applyMatrix4(r),qx.radius+=i,e.ray.intersectsSphere(qx)===!1)return;Gx.copy(r).invert(),Kx.copy(e.ray).applyMatrix4(Gx);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Jx.fromBufferAttribute(l,n),Xx(Jx,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Jx.fromBufferAttribute(l,a),Xx(Jx,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Xx(e,t,n,r,i,a,o){let s=Kx.distanceSqToPoint(e);if(s<n){let n=new Z;Kx.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Zx=class extends qv{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}},Qx=class extends qv{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},$x=class extends qv{constructor(e,t,n=Dg,r,i,a,o=gg,s=gg,c,l=Rg,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 Uv(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},eS=class extends $x{constructor(e,t=Dg,n=301,r,i,a=gg,o=gg,s,c=Rg){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}},tS=class extends qv{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},nS=class e extends Pb{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 Sb(c,3)),this.setAttribute(`normal`,new Sb(l,3)),this.setAttribute(`uv`,new Sb(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 Z;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},rS=class e extends Pb{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Sb(u,3)),this.setAttribute(`normal`,new Sb(d,3)),this.setAttribute(`uv`,new Sb(f,2));function _(){let a=new Z,_=new Z,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new X,m=new Z,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},iS=new Z,aS=new Z,oS=new Z,sS=new Yy,cS=class extends Pb{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=1e4,r=Math.cos(rv*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u=new Map,d=[];for(let e=0;e<o;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);let{a:t,b:o,c:f}=sS;if(t.fromBufferAttribute(a,s[0]),o.fromBufferAttribute(a,s[1]),f.fromBufferAttribute(a,s[2]),sS.getNormal(oS),l[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,l[1]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,l[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,l[0]!==l[1]&&l[1]!==l[2]&&l[2]!==l[0])for(let e=0;e<3;e++){let t=(e+1)%3,n=l[e],i=l[t],a=sS[c[e]],o=sS[c[t]],f=`${n}_${i}`,p=`${i}_${n}`,m=u.get(p);m?(oS.dot(m.normal)<=r&&(d.push(a.x,a.y,a.z),d.push(o.x,o.y,o.z)),u.set(p,null)):u.has(f)||u.set(f,{index0:s[e],index1:s[t],normal:oS.clone()})}}for(let e of u.values())if(e){let{index0:t,index1:n}=e;iS.fromBufferAttribute(a,t),aS.fromBufferAttribute(a,n),d.push(iS.x,iS.y,iS.z),d.push(aS.x,aS.y,aS.z)}this.setAttribute(`position`,new Sb(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},lS=class e extends Pb{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new Sb(p,3)),this.setAttribute(`normal`,new Sb(m,3)),this.setAttribute(`uv`,new Sb(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},uS=class extends Pb{constructor(e=null){if(super(),this.type=`WireframeGeometry`,this.parameters={geometry:e},e!==null){let t=[],n=new Set,r=new Z,i=new Z;if(e.index!==null){let a=e.attributes.position,o=e.index,s=e.groups;s.length===0&&(s=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,c=s.length;e<c;++e){let c=s[e],l=c.start,u=c.count;for(let e=l,s=l+u;e<s;e+=3)for(let s=0;s<3;s++){let c=o.getX(e+s),l=o.getX(e+(s+1)%3);r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,l),dS(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{let a=e.attributes.position;for(let e=0,o=a.count/3;e<o;e++)for(let o=0;o<3;o++){let s=3*e+o,c=3*e+(o+1)%3;r.fromBufferAttribute(a,s),i.fromBufferAttribute(a,c),dS(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute(`position`,new Sb(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function dS(e,t,n){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}function fS(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(mS(i))i.isRenderTargetTexture?(Y_(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i)){if(mS(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice()}else t[n][r]=i}}return t}function pS(e){let t={};for(let n=0;n<e.length;n++){let r=fS(e[n]);for(let e in r)t[e]=r[e]}return t}function mS(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function hS(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function gS(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Lv.workingColorSpace}var _S={clone:fS,merge:pS},vS=`void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}`,yS=`void main() {\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}`,bS=class extends Wb{constructor(e){super(),this.isShaderMaterial=!0,this.type=`ShaderMaterial`,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=vS,this.fragmentShader=yS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=fS(e.uniforms),this.uniformsGroups=hS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let n in this.uniforms){let r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:`t`,value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:`c`,value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:`v2`,value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:`v3`,value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:`v4`,value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:`m3`,value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:`m4`,value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}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 Q().setHex(r.value);break;case`v2`:this.uniforms[n].value=new X().fromArray(r.value);break;case`v3`:this.uniforms[n].value=new Z().fromArray(r.value);break;case`v4`:this.uniforms[n].value=new Jv().fromArray(r.value);break;case`m3`:this.uniforms[n].value=new Mv().fromArray(r.value);break;case`m4`:this.uniforms[n].value=new $v().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}},xS=class extends bS{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},SS=class extends Wb{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new Q(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 Q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new X(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 ly,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}},CS=class extends SS{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 X(1,1),this.clearcoatNormalMap=null,this.diffuseRoughnessMap=null,this.ior=1.5,Object.defineProperty(this,\"reflectivity\",{get:function(){return ov(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.iridescenceThicknessMinimum=100,this.iridescenceThicknessMaximum=400,this.iridescenceThicknessMap=null,this.sheenColor=new Q(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 Q(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Q(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._diffuseRoughness=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=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 diffuseRoughness(){return this._diffuseRoughness}set diffuseRoughness(e){this._diffuseRoughness>0!=e>0&&this.version++,this._diffuseRoughness=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 retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=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}get iridescenceThicknessRange(){return Z_(`MeshPhysicalMaterial: The \"iridescenceThicknessRange\" property has been replaced by \"iridescenceThicknessMinimum\" and \"iridescenceThicknessMaximum\".`),[this.iridescenceThicknessMinimum,this.iridescenceThicknessMaximum]}set iridescenceThicknessRange(e){Z_(`MeshPhysicalMaterial: The \"iridescenceThicknessRange\" property has been replaced by \"iridescenceThicknessMinimum\" and \"iridescenceThicknessMaximum\".`),this.iridescenceThicknessMinimum=e[0],this.iridescenceThicknessMaximum=e[1]}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.diffuseRoughness=e.diffuseRoughness,this.diffuseRoughnessMap=e.diffuseRoughnessMap,this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum,this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum,this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,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}},wS=class extends Wb{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new X(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}},TS=class extends Wb{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=P_,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}},ES=class extends Wb{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}};function DS(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function OS(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}var kS=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`THREE.Interpolant: Call to abstract method.`)}intervalChanged_(){}},AS=class extends kS{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:j_,endingEnd:j_}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case M_:i=e,o=2*t-n;break;case N_:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case M_:a=e,s=2*n-t;break;case N_:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},jS=class extends kS{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},MS=class extends kS{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},NS=class extends kS{interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let e=(n-t)/(r-t),l=1-e;for(let t=0;t!==o;++t)i[t]=a[c+t]*l+a[s+t]*e;return i}let d=o*2,f=e-1;for(let p=0;p!==o;++p){let o=a[c+p],m=a[s+p],h=f*d+p*2,g=u[h],_=u[h+1],v=e*d+p*2,y=l[v],b=l[v+1],x=IS(n,t,g,y,r);i[p]=PS(x,o,_,b,m)}return i}};function PS(e,t,n,r,i){let a=1-e;return a*a*a*t+3*a*a*e*n+3*a*e*e*r+e*e*e*i}function FS(e,t,n,r,i){let a=1-e;return 3*a*a*(n-t)+6*a*e*(r-n)+3*e*e*(i-r)}function IS(e,t,n,r,i){let a=(e-t)/(i-t);for(let o=0;o<8;o++){let o=PS(a,t,n,r,i)-e;if(Math.abs(o)<1e-10)break;let s=FS(a,t,n,r,i);if(Math.abs(s)<1e-10)break;a=Math.max(0,Math.min(1,a-o/s))}return a}var LS=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=DS(t,this.TimeBufferType),this.values=DS(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:DS(e.times,Array),values:DS(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t),OS(e.settings)&&(n.settings={inTangents:DS(e.settings.inTangents,Array),outTangents:DS(e.settings.outTangents,Array)})}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new MS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new jS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new AS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new NS(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case D_:t=this.InterpolantFactoryMethodDiscrete;break;case O_:t=this.InterpolantFactoryMethodLinear;break;case k_:t=this.InterpolantFactoryMethodSmooth;break;case A_:t=this.InterpolantFactoryMethodBezier}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0){if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t)}return Y_(`KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return D_;case this.InterpolantFactoryMethodLinear:return O_;case this.InterpolantFactoryMethodSmooth:return k_;case this.InterpolantFactoryMethodBezier:return A_}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e;OS(this.settings)&&(RS(this.settings.inTangents,e),RS(this.settings.outTangents,e))}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e;OS(this.settings)&&(zS(this.settings.inTangents,e),zS(this.settings.outTangents,e))}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(X_(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(X_(`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)){X_(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){X_(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&U_(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){X_(`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()===k_,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==e[0])){if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,OS(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function RS(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]+=t}function zS(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]*=t}LS.prototype.ValueTypeName=``,LS.prototype.TimeBufferType=Float32Array,LS.prototype.ValueBufferType=Float32Array,LS.prototype.DefaultInterpolation=O_;var BS=class extends LS{constructor(e,t,n){super(e,t,n)}};BS.prototype.ValueTypeName=`bool`,BS.prototype.ValueBufferType=Array,BS.prototype.DefaultInterpolation=D_,BS.prototype.InterpolantFactoryMethodLinear=void 0,BS.prototype.InterpolantFactoryMethodSmooth=void 0;var VS=class extends LS{constructor(e,t,n,r){super(e,t,n,r)}};VS.prototype.ValueTypeName=`color`;var HS=class extends LS{constructor(e,t,n,r){super(e,t,n,r)}};HS.prototype.ValueTypeName=`number`;var US=class extends kS{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)kv.slerpFlat(i,0,a,c-o,a,c,s);return i}},WS=class extends LS{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new US(this.times,this.values,this.getValueSize(),e)}};WS.prototype.ValueTypeName=`quaternion`,WS.prototype.InterpolantFactoryMethodSmooth=void 0;var GS=class extends LS{constructor(e,t,n){super(e,t,n)}};GS.prototype.ValueTypeName=`string`,GS.prototype.ValueBufferType=Array,GS.prototype.DefaultInterpolation=D_,GS.prototype.InterpolantFactoryMethodLinear=void 0,GS.prototype.InterpolantFactoryMethodSmooth=void 0;var KS=class extends LS{constructor(e,t,n,r){super(e,t,n,r)}};KS.prototype.ValueTypeName=`vector`;var qS={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(JS(e)||(this.files[e]=t))},get:function(e){if(this.enabled!==!1&&!JS(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function JS(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch{return!1}}var YS=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<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||=new AbortController,this._abortController}},XS=class{constructor(e){this.manager=e===void 0?YS:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={},this.priority=`auto`,this.cache=`default`,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}setPriority(e){return this.priority=e,this}setCache(e){return this.cache=e,this}abort(){return this}};XS.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var ZS={},QS=class extends Error{constructor(e,t){super(e),this.response=t}},$S=class extends XS{constructor(e){super(e),this.mimeType=``,this.responseType=``,this._abortController=new AbortController}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=qS.get(`file:${e}`);if(i!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(i),this.manager.itemEnd(e)},0);return}if(ZS[e]!==void 0){ZS[e].push({onLoad:t,onProgress:n,onError:r});return}ZS[e]=[],ZS[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`,priority:this.priority,cache:this.cache,signal:typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&Y_(`FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=ZS[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e<t;e++){let t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(i),t()}},t=>{e.error(t)})}}});return new Response(c)}throw new QS(`fetch for \"${t.url}\" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===``)return e.text();{let t=/charset=\"?([^;\"\\s]*)\"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{qS.add(`file:${e}`,t);let n=ZS[e];delete ZS[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onLoad&&r.onLoad(t)}}).catch(t=>{let n=ZS[e];if(n===void 0)throw this.manager.itemError(e),t;delete ZS[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onError&&r.onError(t)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},eC=new WeakMap,tC=class extends XS{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=qS.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);else{let e=eC.get(a);e===void 0&&(e=[],eC.set(a,e)),e.push({onLoad:t,onError:r})}return a}let o=W_(`img`);function s(){l(),t&&t(this);let n=eC.get(this)||[];for(let e=0;e<n.length;e++){let t=n[e];t.onLoad&&t.onLoad(this)}eC.delete(this),i.manager.itemEnd(e)}function c(t){l(),r&&r(t),qS.remove(`image:${e}`);let n=eC.get(this)||[];for(let e=0;e<n.length;e++){let r=n[e];r.onError&&r.onError(t)}eC.delete(this),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1)}return o.addEventListener(`load`,s,!1),o.addEventListener(`error`,c,!1),e.slice(0,5)!==`data:`&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),qS.add(`image:${e}`,o),i.manager.itemStart(e),o.fetchPriority=this.priority,o.src=e,o}},nC=class extends XS{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new Dx,o=new $S(this.manager);return o.setPriority(this.priority),o.setCache(this.cache),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(i.withCredentials),o.load(e,function(e){let n;try{n=i.parse(e)}catch(e){r===void 0?X_(e):r(e);return}i._applyTexData(a,n),t&&t(a,n)},n,r),a}createDataTexture(e){let t=new Dx;return this._applyTexData(t,this.parse(e)),t}_applyTexData(e,t){t.image===void 0?t.data!==void 0&&(e.image.width=t.width,e.image.height=t.height,e.image.data=t.data):e.image=t.image,e.wrapS=t.wrapS===void 0?mg:t.wrapS,e.wrapT=t.wrapT===void 0?mg:t.wrapT,e.magFilter=t.magFilter===void 0?yg:t.magFilter,e.minFilter=t.minFilter===void 0?yg:t.minFilter,e.anisotropy=t.anisotropy===void 0?1:t.anisotropy,t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.mipmaps!==void 0&&(e.mipmaps=t.mipmaps,e.minFilter=xg),t.mipmapCount===1&&(e.minFilter=yg),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),e.needsUpdate=!0}},rC=class extends XS{constructor(e){super(e)}load(e,t,n,r){let i=new qv,a=new tC(this.manager);return a.setPriority(this.priority),a.setCache(this.cache),a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){i.image=e,i.needsUpdate=!0,t!==void 0&&t(i)},n,r),i}},iC=class extends Ey{static registerNode(e){this.prototype._lightNode=e}constructor(e,t=1){super(),this.isLight=!0,this.type=`Light`,this.color=new Q(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},aC=class extends iC{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type=`HemisphereLight`,this.position.copy(Ey.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Q(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},oC=new $v,sC=new Z,cC=new Z,lC=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new X(512,512),this.mapType=Sg,this.map=null,this.mapPass=null,this.matrix=new $v,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new jx,this._frameExtents=new X(1,1),this._viewportCount=1,this._viewports=[new Jv(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;sC.setFromMatrixPosition(e.matrixWorld),t.position.copy(sC),cC.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(cC),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,r){oC.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(oC,e.coordinateSystem,e.reversedDepth);let i=this._frameExtents,a=r?r.z/i.x:1,o=r?r.w/i.y:1,s=r?r.x/i.x:0,c=r?r.y/i.y:0;e.coordinateSystem===2001||e.reversedDepth?t.set(.5*a,0,0,.5*a+s,0,.5*o,0,.5*o+c,0,0,1,0,0,0,0,1):t.set(.5*a,0,0,.5*a+s,0,.5*o,0,.5*o+c,0,0,.5,.5,0,0,0,1),t.multiply(oC)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.mapType=e.mapType,this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.mapType=this.mapType,e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},uC=new Z,dC=new kv,fC=new Z,pC=class extends Ey{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new $v,this.projectionMatrix=new $v,this.projectionMatrixInverse=new $v,this.coordinateSystem=V_,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(uC,dC,fC),fC.x===1&&fC.y===1&&fC.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(uC,dC,fC.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(uC,dC,fC),fC.x===1&&fC.y===1&&fC.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(uC,dC,fC.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},mC=new Z,hC=new X,gC=new X,_C=class extends pC{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=iv*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(rv*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return iv*2*Math.atan(Math.tan(rv*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){mC.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(mC.x,mC.y).multiplyScalar(-e/mC.z),mC.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(mC.x,mC.y).multiplyScalar(-e/mC.z)}getViewSize(e,t){return this.getViewBounds(e,hC,gC),t.subVectors(gC,hC)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(rv*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},vC=class extends lC{constructor(){super(new _C(90,1,.5,500)),this.isPointLightShadow=!0}},yC=class extends iC{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type=`PointLight`,this.distance=n,this.decay=r,this.shadow=new vC}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},bC=class extends pC{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},xC=class extends lC{constructor(){super(new bC(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},SC=class extends iC{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type=`DirectionalLight`,this.position.copy(Ey.DEFAULT_UP),this.updateMatrix(),this.target=new Ey,this.shadow=new xC}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},CC=class extends iC{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type=`AmbientLight`}},wC=class extends Pb{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type=`InstancedBufferGeometry`,this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},TC=-90,EC=1,DC=class extends Ey{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new _C(TC,EC,e,t);r.layers=this.layers,this.add(r);let i=new _C(TC,EC,e,t);i.layers=this.layers,this.add(i);let a=new _C(TC,EC,e,t);a.layers=this.layers,this.add(a);let o=new _C(TC,EC,e,t);o.layers=this.layers,this.add(o);let s=new _C(TC,EC,e,t);s.layers=this.layers,this.add(s);let c=new _C(TC,EC,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.mipmapsAutoUpdate;n.texture.mipmapsAutoUpdate=!1;let h=!1;h=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(n,0,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,i),e.setRenderTarget(n,1,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,4,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.mipmapsAutoUpdate=m,e.setRenderTarget(n,5,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},OC=class extends _C{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}},kC=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=AC.bind(this),e.addEventListener(`visibilitychange`,this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener(`visibilitychange`,this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e===void 0?performance.now():e)-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function AC(){this._document.hidden===!1&&this.reset()}var jC=`\\\\[\\\\]\\\\.:\\\\/`,MC=RegExp(`[\\\\[\\\\]\\\\.:\\\\/]`,`g`),NC=`[^\\\\[\\\\]\\\\.:\\\\/]`,PC=`[^`+jC.replace(`\\\\.`,``)+`]`,FC=`((?:WC+[\\\\/:])*)`.replace(`WC`,NC),IC=`(WCOD+)?`.replace(`WCOD`,PC),LC=`(?:\\\\.(WC+)(?:\\\\[(.+)\\\\])?)?`.replace(`WC`,NC),RC=`\\\\.(WC+)(?:\\\\[(.+)\\\\])?`.replace(`WC`,NC),zC=RegExp(`^`+FC+IC+LC+RC+`$`),BC=[`material`,`materials`,`bones`,`map`],VC=class{constructor(e,t,n){let r=n||HC.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},HC=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\\s/g,`_`).replace(MC,``)}static parseTrackName(e){let t=zC.exec(e);if(t===null)throw Error(`THREE.PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);BC.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`THREE.PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Y_(`PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){X_(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){X_(`PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){X_(`PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){X_(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){X_(`PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){X_(`PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){X_(`PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;X_(`PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){X_(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){X_(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};HC.Composite=VC,HC.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},HC.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},HC.prototype.GetterByBindingType=[HC.prototype._getValue_direct,HC.prototype._getValue_array,HC.prototype._getValue_arrayElement,HC.prototype._getValue_toArray],HC.prototype.SetterByBindingTypeAndVersioning=[[HC.prototype._setValue_direct,HC.prototype._setValue_direct_setNeedsUpdate,HC.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[HC.prototype._setValue_array,HC.prototype._setValue_array_setNeedsUpdate,HC.prototype._setValue_array_setMatrixWorldNeedsUpdate],[HC.prototype._setValue_arrayElement,HC.prototype._setValue_arrayElement_setNeedsUpdate,HC.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[HC.prototype._setValue_fromArray,HC.prototype._setValue_fromArray_setNeedsUpdate,HC.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var UC=class extends Fb{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},WC=new $v,GC=class{constructor(e,t,n=0,r=1/0){this.ray=new dx(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new uy,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):X_(`Raycaster: Unsupported camera type: `+t.type)}setFromXRController(e){return WC.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(WC),this}intersectObject(e,t=!0,n=[]){return qC(e,this,n,t),n.sort(KC),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)qC(e[r],this,n,t);return n.sort(KC),n}};function KC(e,t){return e.distance-t.distance}function qC(e,t,n,r){let i=!0;if(e.layers.test(t.layers)&&e.raycast(t,n)===!1&&(i=!1),i===!0&&r===!0){let r=e.children;for(let e=0,i=r.length;e<i;e++)qC(r[e],t,n,!0)}}var JC=class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){let e=1e-6;return this.phi=ov(this.phi,e,Math.PI-e),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(ov(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};(class{static{this.prototype.isMatrix2=!0}constructor(e,t,n,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}});var YC=new Z,XC=new Z,ZC=new Z,QC=new Z,$C=new Z,ew=new Z,tw=new Z,nw=class{constructor(e=new Z,t=new Z){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){YC.subVectors(e,this.start),XC.subVectors(this.end,this.start);let n=XC.dot(XC);if(n===0)return 0;let r=XC.dot(YC)/n;return t&&(r=ov(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=ew,n=tw){let r=1e-8*1e-8,i,a,o=this.start,s=e.start,c=this.end,l=e.end;ZC.subVectors(c,o),QC.subVectors(l,s),$C.subVectors(o,s);let u=ZC.dot(ZC),d=QC.dot(QC),f=QC.dot($C);if(u<=r&&d<=r)return t.copy(o),n.copy(s),t.distanceToSquared(n);if(u<=r)i=0,a=f/d,a=ov(a,0,1);else{let e=ZC.dot($C);if(d<=r)a=0,i=ov(-e/u,0,1);else{let t=ZC.dot(QC),n=u*d-t*t;i=n===0?0:ov((t*f-e*d)/n,0,1),a=(t*i+f)/d,a<0?(a=0,i=ov(-e/u,0,1)):a>1&&(a=1,i=ov((t-e)/u,0,1))}}return t.copy(o).addScaledVector(ZC,i),n.copy(s).addScaledVector(QC,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)}},rw=class extends ev{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){this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function iw(e,t,n,r){let i=aw(r);switch(n){case Fg:return e*t;case Bg:return e*t/i.components*i.byteLength;case Vg:return e*t/i.components*i.byteLength;case Hg:return e*t*2/i.components*i.byteLength;case Ug:return e*t*2/i.components*i.byteLength;case Ig:return e*t*3/i.components*i.byteLength;case Lg:return e*t*4/i.components*i.byteLength;case Wg:return e*t*4/i.components*i.byteLength;case Gg:case Kg:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case qg:case Jg:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Xg:case Qg:return Math.max(e,16)*Math.max(t,8)/4;case Yg:case Zg:return Math.max(e,8)*Math.max(t,8)/2;case $g:case e_:case n_:case r_:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case t_:case i_:case a_:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case o_:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case s_:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case c_:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case l_:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case u_:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case d_:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case f_:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case p_:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case m_:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case h_:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case g_:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case __:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case v_:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case y_:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case b_:case x_:case S_:return Math.ceil(e/4)*Math.ceil(t/4)*16;case C_:case w_:return Math.ceil(e/4)*Math.ceil(t/4)*8;case T_:case E_:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function aw(e){switch(e){case Sg:case Cg:return{byteLength:1,components:1};case Tg:case wg:case kg:return{byteLength:2,components:1};case Ag:case jg:return{byteLength:2,components:4};case Dg:case Eg:case Og:return{byteLength:4,components:1};case Ng:case Pg: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:`187`}})),typeof window<`u`&&(window.__THREE__?Y_(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`187`);function ow(){let e=null,t=!1,n=null,r=null;function i(t,a){r=e.requestAnimationFrame(i),n(t,a)}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 sw(e){let t=new WeakMap;function n(t,n){let r=t.array,i=t.usage,a=r.byteLength,o=e.createBuffer();e.bindBuffer(n,o),e.bufferData(n,r,i),t.onUploadCallback();let s;if(r instanceof Float32Array)s=e.FLOAT;else if(typeof Float16Array<`u`&&r instanceof Float16Array)s=e.HALF_FLOAT;else if(r instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)s=e.SHORT;else if(r instanceof Uint32Array)s=e.UNSIGNED_INT;else if(r instanceof Int32Array)s=e.INT;else if(r instanceof Int8Array)s=e.BYTE;else if(r instanceof Uint8Array)s=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)s=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+r);return{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:a}}function r(t,n,r){let i=n.array,a=n.updateRanges;if(e.bindBuffer(r,t),a.length===0)e.bufferSubData(r,0,i);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){let n=a[t],r=a[e];r.start<=n.start+n.count+1?n.count=Math.max(n.count,r.start+r.count-n.start):(++t,a[t]=r)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){let n=a[t];e.bufferSubData(r,n.start*i.BYTES_PER_ELEMENT,i,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)}function a(n){n.isInterleavedBufferAttribute&&(n=n.data);let r=t.get(n);r&&(e.deleteBuffer(r.buffer),t.delete(n))}function o(e,i){if(e.isInterleavedBufferAttribute&&(e=e.data),e.isGLBufferAttribute){let n=t.get(e);(!n||n.version<e.version)&&t.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version});return}let a=t.get(e);if(a===void 0)t.set(e,n(e,i));else if(a.version<e.version){if(a.size!==e.array.byteLength)throw Error(`THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.`);r(a.buffer,e,i),a.version=e.version}}return{get:i,remove:a,update:o}}var cw={alphahash_fragment:`#ifdef USE_ALPHAHASH\n if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif`,alphahash_pars_fragment:`#ifdef USE_ALPHAHASH\n const float ALPHA_HASH_SCALE = 0.05;\n float hash2D( vec2 value ) {\n return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n }\n float hash3D( vec3 value ) {\n return hash2D( vec2( hash2D( value.xy ), value.z ) );\n }\n float getAlphaHashThreshold( vec3 position ) {\n float maxDeriv = max(\n length( dFdx( position.xyz ) ),\n length( dFdy( position.xyz ) )\n );\n float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n vec2 pixScales = vec2(\n exp2( floor( log2( pixScale ) ) ),\n exp2( ceil( log2( pixScale ) ) )\n );\n vec2 alpha = vec2(\n hash3D( floor( pixScales.x * position.xyz ) ),\n hash3D( floor( pixScales.y * position.xyz ) )\n );\n float lerpFactor = fract( log2( pixScale ) );\n float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n float a = min( lerpFactor, 1.0 - lerpFactor );\n vec3 cases = vec3(\n x * x / ( 2.0 * a * ( 1.0 - a ) ),\n ( x - 0.5 * a ) / ( 1.0 - a ),\n 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n );\n float threshold = ( x < ( 1.0 - a ) )\n ? ( ( x < a ) ? cases.x : cases.y )\n : cases.z;\n return clamp( threshold , 1.0e-6, 1.0 );\n }\n#endif`,alphamap_fragment:`#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif`,alphamap_pars_fragment:`#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif`,alphatest_fragment:`#ifdef USE_ALPHATEST\n #ifdef ALPHA_TO_COVERAGE\n diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n if ( diffuseColor.a < alphaTest ) discard;\n #endif\n#endif`,alphatest_pars_fragment:`#ifdef USE_ALPHATEST\n uniform float alphaTest;\n#endif`,aomap_fragment:`#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n #endif\n#endif`,aomap_pars_fragment:`#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif`,batching_pars_vertex:`#ifdef USE_BATCHING\n #if ! defined( GL_ANGLE_multi_draw )\n #define gl_DrawID _gl_DrawID\n uniform int _gl_DrawID;\n #endif\n uniform highp sampler2D batchingTexture;\n uniform highp usampler2D batchingIdTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n float getIndirectIndex( const in int i ) {\n int size = textureSize( batchingIdTexture, 0 ).x;\n int x = i % size;\n int y = i / size;\n return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n }\n#endif\n#ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec4 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n }\n#endif`,batching_vertex:`#ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif`,begin_vertex:`vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n vPosition = vec3( position );\n#endif`,beginnormal_vertex:`vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif`,bsdfs:`float G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( specularColor, 1.0, dotVH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n} // validated`,iridescence_fragment:`#ifdef USE_IRIDESCENCE\n const mat3 XYZ_TO_REC709 = mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n );\n vec3 Fresnel0ToIor( vec3 fresnel0 ) {\n vec3 sqrtF0 = sqrt( fresnel0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n }\n vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n }\n float IorToFresnel0( float transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n }\n vec3 evalSensitivity( float OPD, vec3 shift ) {\n float phase = 2.0 * PI * OPD * 1.0e-9;\n vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n xyz /= 1.0685e-7;\n vec3 rgb = XYZ_TO_REC709 * xyz;\n return rgb;\n }\n vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n vec3 I;\n float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n if ( cosTheta2Sq < 0.0 ) {\n return vec3( 1.0 );\n }\n float cosTheta2 = sqrt( cosTheta2Sq );\n float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n float R12 = F_Schlick( R0, 1.0, cosTheta1 );\n float T121 = 1.0 - R12;\n float phi12 = 0.0;\n if ( iridescenceIOR < outsideIOR ) phi12 = PI;\n float phi21 = PI - phi12;\n vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n vec3 phi23 = vec3( 0.0 );\n if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n vec3 phi = vec3( phi21 ) + phi23;\n vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n vec3 r123 = sqrt( R123 );\n vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n vec3 C0 = R12 + Rs;\n I = C0;\n vec3 Cm = Rs - T121;\n for ( int m = 1; m <= 2; ++ m ) {\n Cm *= r123;\n vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n I += Cm * Sm;\n }\n return max( I, vec3( 0.0 ) );\n }\n#endif`,bumpmap_pars_fragment:`#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vBumpMapUv );\n vec2 dSTdy = dFdy( vBumpMapUv );\n float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif`,clipping_planes_fragment:`#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec4 vColor;\n#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n vColor *= color;\n#elif defined( USE_COLOR )\n vColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif`,common:`#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n 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 );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n 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 );\n}`,envmap_fragment:`#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform mat3 envMapRotation;\n uniform samplerCube envMap;\n #ifdef ENVMAP_TYPE_PMREM\n float roughnessToMip( const in float roughness ) {\n float r = clamp( roughness, 0.0, 1.0 );\n return ENVMAP_MAX_LOD * r * ( 2.0 - r );\n }\n #endif\n#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_PMREM\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 envMapColor = textureLod( envMap, envMapRotation * worldNormal, ENVMAP_MAX_LOD );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_PMREM\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n vec4 envMapColor = textureLod( envMap, envMapRotation * reflectVec, roughnessToMip( roughness ) );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_RETROREFLECTION\n vec3 getIBLRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_PMREM\n vec3 retroVec = normalize( mix( viewDir, normal, pow4( roughness ) ) );\n retroVec = transformDirectionByInverseViewMatrix( retroVec, viewMatrix );\n vec4 envMapColor = textureLod( envMap, envMapRotation * retroVec, roughnessToMip( roughness ) );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_PMREM\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_RETROREFLECTION\n vec3 getIBLAnisotropyRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_PMREM\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRetroRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n #endif\n#endif`,envmap_vertex:`#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif`,fog_vertex:`#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif`,fog_pars_vertex:`#ifdef USE_FOG\n varying float vFogDepth;\n#endif`,fog_fragment:`#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif`,fog_pars_fragment:`#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif`,lights_lambert_fragment:`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid 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 ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin:`uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_SUN_LIGHTS > 0\n struct SunLight {\n vec3 direction;\n vec3 color;\n };\n uniform SunLight sunLights[ NUM_SUN_LIGHTS ];\n void getSunLightInfo( const in SunLight sunLight, out IncidentLight light ) {\n light.color = sunLight.color;\n light.direction = sunLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>`,lights_toon_fragment:`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid 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 ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment:`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid 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 ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment:`PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.045 );\nmaterial.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef USE_DIFFUSE_ROUGHNESS\n float diffuseRoughnessFactor = diffuseRoughness;\n #ifdef USE_DIFFUSE_ROUGHNESSMAP\n diffuseRoughnessFactor *= texture2D( diffuseRoughnessMap, vDiffuseRoughnessMapUv ).r;\n #endif\n material.diffuseRoughness = saturate( diffuseRoughnessFactor );\n#endif\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.045 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_RETROREFLECTION\n material.retroreflectivity = retroreflectivity;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n vec2 dfg;\n vec3 multiScatteringCompensation;\n #ifdef USE_DIFFUSE_ROUGHNESS\n float diffuseRoughness;\n #endif\n #ifdef USE_RETROREFLECTION\n float retroreflectivity;\n #endif\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0Dielectric;\n vec3 iridescenceF0Metallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\n#ifdef USE_DIFFUSE_ROUGHNESS\n const float EON_EPSILON = 1e-7;\n float FON_DirectionalAlbedo( const in float mu, const in float roughness, const in float A ) {\n float muComp = 1.0 - mu;\n float gOverPi = muComp * ( 0.0571085289 + muComp * ( 0.491881867 + muComp * ( - 0.332181442 + muComp * 0.0714429953 ) ) );\n return A * ( 1.0 + roughness * gOverPi );\n }\n vec3 BRDF_EON( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 diffuseColor, const in float roughness ) {\n vec3 rho = saturate( diffuseColor );\n if ( roughness <= EON_EPSILON ) return BRDF_Lambert( rho );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float s = dot( lightDir, viewDir ) - dotNL * dotNV;\n float sOverT = ( s > 0.0 ) ? s / max( max( dotNL, dotNV ), EON_EPSILON ) : s;\n float A = 1.0 / ( 1.0 + ( 0.5 - 2.0 / ( 3.0 * PI ) ) * roughness );\n vec3 singleScatter = rho * RECIPROCAL_PI * A * ( 1.0 + roughness * sOverT );\n float averageAlbedo = A * ( 1.0 + ( 2.0 / 3.0 - 28.0 / ( 15.0 * PI ) ) * roughness );\n float albedoV = FON_DirectionalAlbedo( dotNV, roughness, A );\n float albedoL = FON_DirectionalAlbedo( dotNL, roughness, A );\n vec3 rhoMultiScatter = rho * rho * averageAlbedo / max( vec3( EON_EPSILON ), vec3( 1.0 ) - rho * ( 1.0 - averageAlbedo ) );\n vec3 multiScatter = rhoMultiScatter * RECIPROCAL_PI\n * max( EON_EPSILON, 1.0 - albedoV )\n * max( EON_EPSILON, 1.0 - albedoL )\n / max( EON_EPSILON, 1.0 - averageAlbedo );\n return singleScatter + multiScatter;\n }\n vec3 EON_DirectionalAlbedo( const in vec3 diffuseColor, const in float roughness, const in float dotNV ) {\n vec3 rho = saturate( diffuseColor );\n if ( roughness <= EON_EPSILON ) return rho;\n float A = 1.0 / ( 1.0 + ( 0.5 - 2.0 / ( 3.0 * PI ) ) * roughness );\n float directionalAlbedo = FON_DirectionalAlbedo( dotNV, roughness, A );\n float averageAlbedo = A * ( 1.0 + ( 2.0 / 3.0 - 28.0 / ( 15.0 * PI ) ) * roughness );\n vec3 rhoMultiScatter = rho * rho * averageAlbedo / max( vec3( EON_EPSILON ), vec3( 1.0 ) - rho * ( 1.0 - averageAlbedo ) );\n return rho * directionalAlbedo + rhoMultiScatter * ( 1.0 - directionalAlbedo );\n }\n#endif\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n 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 ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = max( material.clearcoatRoughness, 0.045 );\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = max( material.roughness, 0.045 );\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float alphaT = max( material.alphaT, alpha );\n float V = V_GGX_SmithCorrelated_Anisotropic( alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec2 fab, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec2 fab, const in vec3 specularColor, const in float specularF90, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n 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 ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid 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 ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n vec3 specularBRDF = BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n #ifdef USE_RETROREFLECTION\n vec3 retroViewDir = reflect( - geometryViewDir, geometryNormal );\n vec3 retroSpecularBRDF = BRDF_GGX( directLight.direction, retroViewDir, geometryNormal, material );\n specularBRDF = mix( specularBRDF, retroSpecularBRDF, saturate( material.retroreflectivity ) );\n #endif\n reflectedLight.directSpecular += irradiance * specularBRDF * material.multiScatteringCompensation;\n vec3 halfDir = normalize( directLight.direction + geometryViewDir );\n float dotVH = saturate( dot( geometryViewDir, halfDir ) );\n vec3 F = F_Schlick( material.specularColor, material.specularF90, dotVH );\n #ifdef USE_RETROREFLECTION\n vec3 retroHalfDir = normalize( directLight.direction + retroViewDir );\n float dotRetroVH = saturate( dot( retroViewDir, retroHalfDir ) );\n vec3 retroF = F_Schlick( material.specularColor, material.specularF90, dotRetroVH );\n F = mix( F, retroF, saturate( material.retroreflectivity ) );\n #endif\n #ifdef USE_DIFFUSE_ROUGHNESS\n vec3 diffuseBRDF = BRDF_EON( directLight.direction, geometryViewDir, geometryNormal, material.diffuseColor, material.diffuseRoughness ) * ( 1.0 - material.metalness );\n #else\n vec3 diffuseBRDF = BRDF_Lambert( material.diffuseContribution );\n #endif\n reflectedLight.directDiffuse += irradiance * diffuseBRDF * ( 1.0 - F );\n}\nvoid 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 ) {\n vec3 singleScattering = vec3( 0.0 );\n vec3 multiScattering = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( material.dfg, material.specularColor, material.specularF90, material.iridescence, material.iridescenceF0Dielectric, singleScattering, multiScattering );\n #else\n computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScattering, multiScattering );\n #endif\n #ifdef USE_DIFFUSE_ROUGHNESS\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n vec3 diffuseAlbedo = EON_DirectionalAlbedo( material.diffuseColor, material.diffuseRoughness, dotNV ) * ( 1.0 - material.metalness );\n vec3 diffuse = irradiance * RECIPROCAL_PI * diffuseAlbedo * ( 1.0 - singleScattering - multiScattering );\n #else\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ) * ( 1.0 - singleScattering - multiScattering );\n #endif\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n sheenSpecularIndirect += irradiance * material.sheenColor * sheenAlbedo * RECIPROCAL_PI;\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid 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) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( material.dfg, material.specularColor, material.specularF90, material.iridescence, material.iridescenceF0Dielectric, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( material.dfg, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceF0Metallic, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( material.dfg, material.diffuseColor, material.specularF90, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n #ifdef USE_DIFFUSE_ROUGHNESS\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n vec3 diffuse = EON_DirectionalAlbedo( material.diffuseColor, material.diffuseRoughness, dotNV ) * ( 1.0 - material.metalness ) * ( 1.0 - totalScatteringDielectric );\n #else\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n #endif\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}`,lights_fragment_begin:`\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n vec3 iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n vec3 iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( iridescenceFresnelDielectric, iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0Dielectric = Schlick_to_F0( iridescenceFresnelDielectric, 1.0, dotNVi );\n material.iridescenceF0Metallic = Schlick_to_F0( iridescenceFresnelMetallic, 1.0, dotNVi );\n }\n#endif\n#ifdef STANDARD\n float dotNVms = saturate( dot( geometryNormal, geometryViewDir ) );\n material.dfg = texture2D( dfgLUT, vec2( material.roughness, dotNVms ) ).rg;\n #if ( NUM_SUN_LIGHTS > 0 || NUM_DIR_LIGHTS > 0 || NUM_POINT_LIGHTS > 0 || NUM_SPOT_LIGHTS > 0 )\n float EssMs = material.dfg.x + material.dfg.y;\n material.multiScatteringCompensation = 1.0 + material.specularColorBlended * ( 1.0 / EssMs - 1.0 );\n #endif\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SUN_LIGHTS > 0 ) && defined( RE_Direct )\n SunLight sunLight;\n #if defined( USE_SHADOWMAP ) && NUM_SUN_LIGHT_SHADOWS > 0\n SunLightShadow sunLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SUN_LIGHTS; i ++ ) {\n sunLight = sunLights[ i ];\n getSunLightInfo( sunLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SUN_LIGHT_SHADOWS )\n sunLightShadow = sunLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getSunShadow( sunShadowMap[ i ], sunLightShadow, UNROLLED_LOOP_INDEX ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_LIGHT_PROBE_GRIDS > 0\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n int probeGrid = - 1;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_LIGHT_PROBE_GRIDS; i ++ ) {\n if ( isInsideLightProbeGrid( probeWorldPos, probeWorldNormal, probesMin[ i ], probesMax[ i ], probesResolution[ i ] ) ) probeGrid = UNROLLED_LOOP_INDEX;\n }\n #pragma unroll_loop_end\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_LIGHT_PROBE_GRIDS; i ++ ) {\n if ( probeGrid == UNROLLED_LOOP_INDEX ) irradiance += getLightProbeGridIrradiance( probesSH[ i ], probesMin[ i ], probesMax[ i ], probesResolution[ i ], probeWorldPos, probeWorldNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_PMREM )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n vec3 iblRadiance = getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n vec3 iblRadiance = getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_RETROREFLECTION\n #ifdef USE_ANISOTROPY\n vec3 retroIBLRadiance = getIBLAnisotropyRetroRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n vec3 retroIBLRadiance = getIBLRetroRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n iblRadiance = mix( iblRadiance, retroIBLRadiance, saturate( material.retroreflectivity ) );\n #endif\n radiance += iblRadiance;\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse )\n #if defined( LAMBERT ) || defined( PHONG )\n irradiance += iblIrradiance;\n #endif\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif`,lightprobes_pars_fragment:`#if NUM_LIGHT_PROBE_GRIDS > 0\nuniform highp sampler3D probesSH[ NUM_LIGHT_PROBE_GRIDS ];\nuniform vec3 probesMin[ NUM_LIGHT_PROBE_GRIDS ];\nuniform vec3 probesMax[ NUM_LIGHT_PROBE_GRIDS ];\nuniform vec3 probesResolution[ NUM_LIGHT_PROBE_GRIDS ];\nbool isInsideLightProbeGrid( vec3 worldPos, vec3 worldNormal, vec3 probesMin, vec3 probesMax, vec3 probesResolution ) {\n vec3 spacing = ( probesMax - probesMin ) / probesResolution;\n vec3 samplePos = worldPos + worldNormal * spacing * 0.5;\n vec3 margin = spacing * 0.01;\n return all( greaterThanEqual( samplePos, probesMin - margin ) ) && all( lessThanEqual( samplePos, probesMax + margin ) );\n}\nvec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 probesMax, vec3 probesResolution, vec3 worldPos, vec3 worldNormal ) {\n vec3 res = probesResolution;\n vec3 gridRange = probesMax - probesMin;\n vec3 probeSpacing = gridRange / res;\n vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.5 / res, 1.0 - 0.5 / res );\n float nz = res.z;\n float paddedSlices = nz + 2.0;\n float atlasDepth = 7.0 * paddedSlices;\n float uvZBase = uvw.z * nz + 1.0;\n vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n vec3 c0 = s0.xyz;\n vec3 c1 = vec3( s0.w, s1.xy );\n vec3 c2 = vec3( s1.zw, s2.x );\n vec3 c3 = s2.yzw;\n vec3 c4 = s3.xyz;\n vec3 c5 = vec3( s3.w, s4.xy );\n vec3 c6 = vec3( s4.zw, s5.x );\n vec3 c7 = s5.yzw;\n vec3 c8 = s6.xyz;\n float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n vec3 result = c0 * 0.886227;\n result += c1 * 2.0 * 0.511664 * y;\n result += c2 * 2.0 * 0.511664 * z;\n result += c3 * 2.0 * 0.511664 * x;\n result += c4 * 2.0 * 0.429043 * x * y;\n result += c5 * 2.0 * 0.429043 * y * z;\n result += c6 * ( 0.743125 * z * z - 0.247708 );\n result += c7 * 2.0 * 0.429043 * x * z;\n result += c8 * 0.429043 * ( x * x - y * y );\n return max( result, vec3( 0.0 ) );\n}\n#endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif`,map_fragment:`#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif`,map_pars_fragment:`#ifdef USE_MAP\n uniform sampler2D map;\n#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif`,map_particle_pars_fragment:`#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif`,metalnessmap_fragment:`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif`,morphinstance_vertex:`#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif`,morphcolor_vertex:`#if defined( USE_MORPHCOLORS )\n #if defined( USE_COLOR_ALPHA )\n vColor *= morphTargetBaseInfluence;\n #elif defined( USE_COLOR )\n vColor.rgb *= morphTargetBaseInfluence;\n #endif\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor.rgb += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif`,normal_fragment_begin:`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #ifdef DOUBLE_SIDED\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #ifdef DOUBLE_SIDED\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #if defined( USE_PACKED_NORMALMAP )\n mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n #endif\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif`,normal_vertex:`#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #ifdef FLIP_SIDED\n vBitangent = - vBitangent;\n #endif\n #endif\n#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif`,opaque_fragment:`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n \n return depth * ( far - near ) - far;\n #else\n return depth * ( near - far ) - near;\n #endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n \n #ifdef USE_REVERSED_DEPTH_BUFFER\n return ( near * far ) / ( ( near - far ) * depth - near );\n #else\n return ( near * far ) / ( ( far - near ) * depth - far );\n #endif\n}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,dithering_pars_fragment:`#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif`,roughnessmap_fragment:`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_SUN_LIGHT_SHADOWS > 0\n #define SUN_LIGHT_CASCADES 2\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow sunShadowMap[ NUM_SUN_LIGHT_SHADOWS ];\n #else\n uniform sampler2D sunShadowMap[ NUM_SUN_LIGHT_SHADOWS ];\n #endif\n uniform mat4 sunShadowMatrix[ NUM_SUN_LIGHT_SHADOWS * SUN_LIGHT_CASCADES ];\n uniform vec4 sunShadowCascade[ NUM_SUN_LIGHT_SHADOWS * SUN_LIGHT_CASCADES ];\n varying vec4 vSunShadowWorldPosition;\n varying vec3 vSunShadowWorldNormal;\n struct SunLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SunLightShadow sunLightShadows[ NUM_SUN_LIGHT_SHADOWS ];\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n vec2 radius = shadowRadius * texelSize;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_SUN_LIGHT_SHADOWS > 0\n float getSunShadow(\n #if defined( SHADOWMAP_TYPE_PCF )\n sampler2DShadow shadowMap,\n #else\n sampler2D shadowMap,\n #endif\n SunLightShadow sunLightShadow,\n int shadowIndex\n ) {\n vec4 shadowWorldPosition = vec4( vSunShadowWorldPosition.xyz + vSunShadowWorldNormal * sunLightShadow.shadowNormalBias, 1.0 );\n float viewDepth = vSunShadowWorldPosition.w;\n int cascadeOffset = shadowIndex * SUN_LIGHT_CASCADES;\n float shadow = 1.0;\n for ( int i = SUN_LIGHT_CASCADES - 1; i >= 0; i -- ) {\n vec4 cascade = sunShadowCascade[ cascadeOffset + i ];\n if ( viewDepth >= cascade.x && viewDepth < cascade.y ) {\n float cascadeShadow = getShadow(\n shadowMap,\n sunLightShadow.shadowMapSize,\n sunLightShadow.shadowIntensity,\n sunLightShadow.shadowBias,\n sunLightShadow.shadowRadius,\n sunShadowMatrix[ cascadeOffset + i ] * shadowWorldPosition\n );\n shadow = mix( cascadeShadow, shadow, smoothstep( cascade.z, cascade.y, viewDepth ) );\n }\n }\n return shadow;\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float lightDistance = length( lightToPosition );\n float depthRange = shadowCameraFar - shadowCameraNear;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float depthA = - shadowCameraNear / depthRange - shadowBias;\n float depthB = shadowCameraNear * shadowCameraFar / ( depthRange * lightDistance );\n #else\n float depthA = shadowCameraFar / depthRange + shadowBias;\n float depthB = - shadowCameraNear * shadowCameraFar / ( depthRange * lightDistance );\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = 0.0;\n for ( int i = 0; i < 5; i ++ ) {\n vec2 offset = vogelDiskSample( i, 5, phi );\n vec3 direction = bd3D + ( tangent * offset.x + bitangent * offset.y ) * texelSize;\n vec3 absDirection = abs( direction );\n float dp = depthA + depthB / max( max( absDirection.x, absDirection.y ), absDirection.z );\n shadow += texture( shadowMap, vec4( direction, dp ) );\n }\n shadow *= 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif`,shadowmap_pars_vertex:`#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_SUN_LIGHT_SHADOWS > 0\n varying vec4 vSunShadowWorldPosition;\n varying vec3 vSunShadowWorldNormal;\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_SUN_LIGHT_SHADOWS > 0\n vSunShadowWorldPosition = vec4( worldPosition.xyz, - mvPosition.z );\n vSunShadowWorldNormal = shadowWorldNormal;\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif`,shadowmask_pars_fragment:`float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_SUN_LIGHT_SHADOWS > 0\n SunLightShadow sunLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SUN_LIGHT_SHADOWS; i ++ ) {\n sunLight = sunLightShadows[ i ];\n shadow *= receiveShadow ? getSunShadow( sunShadowMap[ i ], sunLight, UNROLLED_LOOP_INDEX ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}`,skinbase_vertex:`#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif`,skinning_vertex:`#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif`,skinnormal_vertex:`#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif`,specularmap_fragment:`float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,tonemapping_pars_fragment:`#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment:`#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif`,transmission_pars_fragment:`#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif`,uv_pars_fragment:`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_DIFFUSE_ROUGHNESSMAP\n varying vec2 vDiffuseRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_DIFFUSE_ROUGHNESSMAP\n uniform mat3 diffuseRoughnessMapTransform;\n varying vec2 vDiffuseRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif`,uv_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DIFFUSE_ROUGHNESSMAP\n vDiffuseRoughnessMapUv = ( diffuseRoughnessMapTransform * vec3( DIFFUSE_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif`,background_vert:`varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}`,background_frag:`uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n 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 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}`,backgroundCube_vert:`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}`,backgroundCube_frag:`uniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <envmap_common_pars_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_PMREM\n vec4 texColor = textureLod( envMap, backgroundRotation * vWorldDirection, roughnessToMip( backgroundBlurriness ) );\n #else\n vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}`,cube_vert:`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}`,cube_frag:`uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}`,depth_vert:`#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vHighPrecisionZW = gl_Position.zw;\n}`,depth_frag:`#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <logdepthbuf_fragment>\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}`,distance_vert:`#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n vWorldPosition = worldPosition.xyz;\n}`,distance_frag:`#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}`,equirect_vert:`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n}`,equirect_frag:`uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}`,linedashed_vert:`uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n vLineDistance = scale * lineDistance;\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}`,linedashed_frag:`uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}`,meshbasic_vert:`#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <fog_vertex>\n}`,meshbasic_frag:`uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include <aomap_fragment>\n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}`,meshlambert_vert:`#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}`,meshlambert_frag:`#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_lambert_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}`,meshmatcap_vert:`#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n vViewPosition = - mvPosition.xyz;\n}`,meshmatcap_frag:`#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}`,meshnormal_vert:`#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}`,meshnormal_frag:`#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}`,meshphong_vert:`#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}`,meshphong_frag:`#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_phong_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}`,meshphysical_vert:`#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}`,meshphysical_frag:`#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DIFFUSE_ROUGHNESS\n uniform float diffuseRoughness;\n #ifdef USE_DIFFUSE_ROUGHNESSMAP\n uniform sampler2D diffuseRoughnessMap;\n #endif\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_RETROREFLECTION\n uniform float retroreflectivity;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include <transmission_fragment>\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}`,meshtoon_vert:`#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}`,meshtoon_frag:`#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_toon_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}`,points_vert:`uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <fog_vertex>\n}`,points_frag:`uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}`,shadow_vert:`#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}`,shadow_frag:`uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n #include <logdepthbuf_fragment>\n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}`,sprite_vert:`uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}`,sprite_frag:`uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n}`},$={common:{diffuse:{value:new Q(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Mv},alphaMap:{value:null},alphaMapTransform:{value:new Mv},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Mv}},envmap:{envMap:{value:null},envMapRotation:{value:new Mv},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Mv}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Mv}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Mv},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Mv},normalScale:{value:new X(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Mv},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Mv}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Mv}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Mv}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Q(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{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:[]},probesMin:{value:[]},probesMax:{value:[]},probesResolution:{value:[]}},points:{diffuse:{value:new Q(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Mv},alphaTest:{value:0},uvTransform:{value:new Mv}},sprite:{diffuse:{value:new Q(16777215)},opacity:{value:1},center:{value:new X(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Mv},alphaMap:{value:null},alphaMapTransform:{value:new Mv},alphaTest:{value:0}}},lw={basic:{uniforms:pS([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.fog]),vertexShader:cw.meshbasic_vert,fragmentShader:cw.meshbasic_frag},lambert:{uniforms:pS([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.fog,$.lights,{emissive:{value:new Q(0)},envMapIntensity:{value:1}}]),vertexShader:cw.meshlambert_vert,fragmentShader:cw.meshlambert_frag},phong:{uniforms:pS([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.fog,$.lights,{emissive:{value:new Q(0)},specular:{value:new Q(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:cw.meshphong_vert,fragmentShader:cw.meshphong_frag},standard:{uniforms:pS([$.common,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.roughnessmap,$.metalnessmap,$.fog,$.lights,{emissive:{value:new Q(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:cw.meshphysical_vert,fragmentShader:cw.meshphysical_frag},toon:{uniforms:pS([$.common,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.gradientmap,$.fog,$.lights,{emissive:{value:new Q(0)}}]),vertexShader:cw.meshtoon_vert,fragmentShader:cw.meshtoon_frag},matcap:{uniforms:pS([$.common,$.bumpmap,$.normalmap,$.displacementmap,$.fog,{matcap:{value:null}}]),vertexShader:cw.meshmatcap_vert,fragmentShader:cw.meshmatcap_frag},points:{uniforms:pS([$.points,$.fog]),vertexShader:cw.points_vert,fragmentShader:cw.points_frag},dashed:{uniforms:pS([$.common,$.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:cw.linedashed_vert,fragmentShader:cw.linedashed_frag},depth:{uniforms:pS([$.common,$.displacementmap]),vertexShader:cw.depth_vert,fragmentShader:cw.depth_frag},normal:{uniforms:pS([$.common,$.bumpmap,$.normalmap,$.displacementmap,{opacity:{value:1}}]),vertexShader:cw.meshnormal_vert,fragmentShader:cw.meshnormal_frag},sprite:{uniforms:pS([$.sprite,$.fog]),vertexShader:cw.sprite_vert,fragmentShader:cw.sprite_frag},background:{uniforms:{uvTransform:{value:new Mv},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:cw.background_vert,fragmentShader:cw.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Mv}},vertexShader:cw.backgroundCube_vert,fragmentShader:cw.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:cw.cube_vert,fragmentShader:cw.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:cw.equirect_vert,fragmentShader:cw.equirect_frag},distance:{uniforms:pS([$.common,$.displacementmap,{referencePosition:{value:new Z},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:cw.distance_vert,fragmentShader:cw.distance_frag},shadow:{uniforms:pS([$.lights,$.fog,{color:{value:new Q(0)},opacity:{value:1}}]),vertexShader:cw.shadow_vert,fragmentShader:cw.shadow_frag}};lw.physical={uniforms:pS([lw.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Mv},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Mv},clearcoatNormalScale:{value:new X(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Mv},diffuseRoughness:{value:0},diffuseRoughnessMap:{value:null},diffuseRoughnessMapTransform:{value:new Mv},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Mv},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Mv},sheen:{value:0},sheenColor:{value:new Q(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Mv},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Mv},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Mv},transmissionSamplerSize:{value:new X},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Mv},attenuationDistance:{value:0},attenuationColor:{value:new Q(0)},specularColor:{value:new Q(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Mv},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Mv},anisotropyVector:{value:new X},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Mv}}]),vertexShader:cw.meshphysical_vert,fragmentShader:cw.meshphysical_frag};var uw={r:0,b:0,g:0},dw=new $v,fw=new Mv;fw.set(-1,0,0,0,1,0,0,0,1);function pw(e,t,n,r,i,a){let o=new Q(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?(l===void 0&&(l=new wx(new nS(1,1,1),new bS({name:`BackgroundCubeMaterial`,uniforms:fS(lw.backgroundCube.uniforms),vertexShader:lw.backgroundCube.vertexShader,fragmentShader:lw.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(dw.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(fw),l.material.toneMapped=Lv.getTransfer(i.colorSpace)!==R_,(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 wx(new lS(2,2),new bS({name:`BackgroundMaterial`,uniforms:fS(lw.background.uniforms),vertexShader:lw.background.vertexShader,fragmentShader:lw.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=Lv.getTransfer(i.colorSpace)!==R_,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(uw,gS(e)),n.buffers.color.setClear(uw.r,uw.g,uw.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 mw(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e<n;e++)t[e]=0,r[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:i,object:e,attributes:{},index:null}}function p(e,t,n,r){let i=a.attributes,o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function g(e){_(e,0)}function _(t,n){let r=a.newAttributes,i=a.enabledAttributes,o=a.attributeDivisors;r[t]=1,i[t]===0&&(e.enableVertexAttribArray(t),i[t]=1),o[t]!==n&&(e.vertexAttribDivisor(t,n),o[t]=n)}function v(){let t=a.newAttributes,n=a.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function y(t,n,r,i,a,o,s){s===!0?e.vertexAttribIPointer(t,n,r,a,o):e.vertexAttribPointer(t,n,r,i,a,o)}function b(n,r,i,a){h();let o=a.attributes,s=i.getAttributes(),c=r.defaultAttributeValues;for(let r in s){let i=s[r];if(i.location>=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.isInterleavedBuffer===!0?t.stride:t.itemSize,p=s.offset;if(t.isInstancedInterleavedBuffer||t.isInstancedBufferAttribute){for(let e=0;e<i.locationSize;e++)_(i.location+e,t.meshPerAttribute);n.isInstancedMesh!==!0&&a._maxInstanceCount===void 0&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<i.locationSize;e++)g(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,l);for(let e=0;e<i.locationSize;e++)y(i.location+e,o/i.locationSize,u,r,c*d,(p+o/i.locationSize*e)*d,f)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<i.locationSize;e++)_(i.location+e,s.meshPerAttribute);n.isInstancedMesh!==!0&&a._maxInstanceCount===void 0&&(a._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<i.locationSize;e++)g(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,l);for(let e=0;e<i.locationSize;e++)y(i.location+e,o/i.locationSize,u,r,o*d,o/i.locationSize*e*d,f)}}else if(c!==void 0){let t=c[r];if(t!==void 0)switch(t.length){case 2:e.vertexAttrib2fv(i.location,t);break;case 3:e.vertexAttrib3fv(i.location,t);break;case 4:e.vertexAttrib4fv(i.location,t);break;default:e.vertexAttrib1fv(i.location,t)}}}}v()}function x(){T();for(let e in r){let t=r[e];for(let e in t){let n=t[e];for(let e in n){let t=n[e];for(let e in t)u(t[e].object),delete t[e];delete n[e]}}delete r[e]}}function S(e){if(r[e.id]===void 0)return;let t=r[e.id];for(let e in t){let n=t[e];for(let e in n){let t=n[e];for(let e in t)u(t[e].object),delete t[e];delete n[e]}}delete r[e.id]}function C(e){for(let t in r){let n=r[t];for(let t in n){let r=n[t];if(r[e.id]===void 0)continue;let i=r[e.id];for(let e in i)u(i[e].object),delete i[e];delete r[e.id]}}}function w(e){for(let t in r){let n=r[t],i=e.isInstancedMesh===!0?e.id:0,a=n[i];if(a!==void 0){for(let e in a){let t=a[e];for(let e in t)u(t[e].object),delete t[e];delete a[e]}delete n[i],Object.keys(n).length===0&&delete r[t]}}}function T(){E(),o=!0,a!==i&&(a=i,l(a.object))}function E(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:s,reset:T,resetDefaultState:E,dispose:x,releaseStatesOfGeometry:S,releaseStatesOfObject:w,releaseStatesOfProgram:C,initAttributes:h,enableAttribute:g,disableUnusedAttributes:v}}function hw(e,t,n){let r;function i(e){r=e}function a(t,i){e.drawArrays(r,t,i),n.update(i,r,1)}function o(t,i,a){a!==0&&(e.drawArraysInstanced(r,t,i,a),n.update(i,r,a))}function s(e,i,a){if(a===0)return;t.get(`WEBGL_multi_draw`).multiDrawArraysWEBGL(r,e,0,i,0,a);let o=0;for(let e=0;e<a;e++)o+=i[e];n.update(o,r,1)}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=s}function gw(e,t,n,r){let i;function a(){if(i!==void 0)return i;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(t){return t===1023||r.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)}function s(n){let i=n===1016&&(t.has(`EXT_color_buffer_half_float`)||t.has(`EXT_color_buffer_float`));return!(n!==1009&&n!==1015&&!i&&r.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))}function c(t){if(t===`highp`){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(Y_(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`),f=n.logarithmicDepthBuffer===!0&&d===!1;n.reversedDepthBuffer===!0&&d===!1&&Y_(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`),n.logarithmicDepthBuffer===!0&&d===!0&&Y_(`WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.`);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:f,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function _w(e){let t=this,n=null,r=0,i=!1,a=!1,o=new Hb,s=new Mv,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length<t)&&(l=new Float32Array(t));for(let t=0,n=r;t!==a;++t,n+=4)o.copy(e[t]).applyMatrix4(i,s),o.normal.toArray(l,n),l[n+3]=o.constant}c.value=l,c.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,l}}var vw=class extends Xv{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 Zx(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:`\n\n varying vec3 vWorldDirection;\n\n vec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n }\n\n void main() {\n\n vWorldDirection = transformDirection( position, modelMatrix );\n\n #include <begin_vertex>\n #include <project_vertex>\n\n }\n `,fragmentShader:`\n\n uniform sampler2D tEquirect;\n\n varying vec3 vWorldDirection;\n\n #include <common>\n\n void main() {\n\n vec3 direction = normalize( vWorldDirection );\n\n vec2 sampleUV = equirectUv( direction );\n\n gl_FragColor = texture2D( tEquirect, sampleUV );\n\n }\n `},r=new nS(5,5,5),i=new bS({name:`CubemapFromEquirect`,uniforms:fS(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new wx(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=yg),new DC(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)}},yw=256,bw=3,xw=20,Sw=256,Cw=16,ww=3,Tw=new Z,Ew=new Q,Dw=class e{constructor(e){this._renderer=e,this._cubeSize=0,this._sourceTarget=null,this._cubeCamera=new DC(1,10,null),this._boxMesh=new wx(new nS(5,5,5),null),this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null,this._integrationMaterial=null}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=Tw}=i,s=this._renderer;this._setSize(a);let c=this._allocateTarget(),l=this._getSourceTarget(!0);t>0&&(l.texture.mipmapsAutoUpdate=!1);let u=s.autoClear,d=s.autoClearColor,f=s.autoClearDepth,p=s.autoClearStencil,m=e.background;s.autoClear=!0,s.autoClearColor=!0,s.autoClearDepth=!0,s.autoClearStencil=!0,m===null&&(e.background=s.getClearColor(Ew));let h=new DC(n,r,l);return h.position.copy(o),h.update(s,e),s.autoClear=u,s.autoClearColor=d,s.autoClearDepth=f,s.autoClearStencil=p,e.background=m,t>0&&(l.texture.mipmapsAutoUpdate=!0,this._blur(c,t)),this._applyPMREM(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Pw(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Nw(),this._compileMaterial(this._equirectMaterial))}dispose(){this._sourceTarget!==null&&this._sourceTarget.dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._integrationMaterial!==null&&this._integrationMaterial.dispose(),this._boxMesh.geometry.dispose()}static lodToRoughness(e,t){return t>0?1-Math.sqrt(1-e/t):0}_setSize(e){this._cubeSize=Math.max(yw,Cv(e))}_fromTexture(e,t){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?yw:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4);let n=t||this._allocateTarget();return this._textureToCubemap(e),this._applyPMREM(n),n}_allocateTarget(){let e=this._cubeSize,t=Ow(e,!1,!1),n=Math.log2(e)-bw;for(let r=0;r<=n;r++)t.texture.mipmaps.push({width:e>>r,height:e>>r});return t.texture.name=`PMREM`,t.texture.isPMREMTexture=!0,t}_getSourceTarget(e=!1){let t=this._cubeSize,n=this._sourceTarget;return(n===null||n.width!==t||e&&n.depthBuffer===!1)&&(n!==null&&n.dispose(),this._sourceTarget=Ow(t,!0,e)),this._sourceTarget}_compileMaterial(e){this._boxMesh.material=e,this._renderer.compile(this._boxMesh,this._cubeCamera.children[0])}_renderCube(e,t,n){let r=this._boxMesh,i=this._cubeCamera;r.material=n,i.renderTarget=e,i.activeMipmapLevel=t;let a=e.width>>t;e.viewport.set(0,0,a,a),i.update(this._renderer,r),e.viewport.set(0,0,e.width,e.height)}_textureToCubemap(e){let t;e.mapping===301||e.mapping===302?(this._cubemapMaterial===null&&(this._cubemapMaterial=Pw()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=Nw()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(t){this._ggxMaterial===null&&(this._ggxMaterial=Aw(),this._integrationMaterial=jw());let n=this._cubeSize,r=t.texture.mipmaps.length-1,i=this._ggxMaterial.uniforms;i.envMap.value=this._sourceTarget.texture;let a=this._integrationMaterial.uniforms;a.envMap.value=this._sourceTarget.texture,a.sourceLod.value=Math.log2(n/Cw);for(let o=0;o<=r;o++){let s=e.lodToRoughness(o,r);if(o>r-ww)a.roughness.value=s,this._renderCube(t,o,this._integrationMaterial);else{let e=s>0?Math.log2(n)+.5*Math.log2(6/(Sw*s**4))+.5:0;i.roughness.value=s,i.lodBias.value=e,this._renderCube(t,o,this._ggxMaterial)}}}_blur(e,t){this._blurMaterial===null&&(this._blurMaterial=Mw());let n=this._blurMaterial,r=n.uniforms,i=this._sourceTarget;r.sigma.value=Math.min(t,Math.PI)/Math.SQRT2,r.envMap.value=i.texture,this._renderCube(e,0,n),r.envMap.value=e.texture,this._renderCube(i,0,n)}};function Ow(e,t,n){return new vw(e,{minFilter:xg,generateMipmaps:t,type:kg,colorSpace:I_,depthBuffer:n})}function kw(e,t,n){return new bS({name:e,uniforms:t,vertexShader:cw.cube_vert,fragmentShader:n,side:1,blending:0,depthTest:!1,depthWrite:!1})}function Aw(){return kw(`PMREMGGXConvolution`,{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},`\n\n #define GGX_SAMPLES ${Sw}u\n\n varying vec3 vWorldDirection;\n\n uniform samplerCube envMap;\n uniform float roughness;\n uniform float lodBias;\n\n #include <common>\n\n // Van der Corput radical inverse\n float radicalInverse_VdC( uint bits ) {\n\n bits = ( bits << 16u ) | ( bits >> 16u );\n bits = ( ( bits & 0x55555555u ) << 1u ) | ( ( bits & 0xAAAAAAAAu ) >> 1u );\n bits = ( ( bits & 0x33333333u ) << 2u ) | ( ( bits & 0xCCCCCCCCu ) >> 2u );\n bits = ( ( bits & 0x0F0F0F0Fu ) << 4u ) | ( ( bits & 0xF0F0F0F0u ) >> 4u );\n bits = ( ( bits & 0x00FF00FFu ) << 8u ) | ( ( bits & 0xFF00FF00u ) >> 8u );\n return float( bits ) * 2.3283064365386963e-10; // / 0x100000000\n\n }\n\n // Hammersley sequence\n vec2 hammersley( uint i, uint N ) {\n\n return vec2( float( i ) / float( N ), radicalInverse_VdC( i ) );\n\n }\n\n void main() {\n\n vec3 N = normalize( vWorldDirection );\n\n // For very low roughness, just sample the environment directly\n if ( roughness < 0.001 ) {\n\n gl_FragColor = vec4( textureLod( envMap, N, 0.0 ).rgb, 1.0 );\n return;\n\n }\n\n float alpha = roughness * roughness;\n float alpha2 = alpha * alpha;\n\n // Tangent space basis for VNDF sampling\n vec3 up = abs( N.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 );\n vec3 tangent = normalize( cross( up, N ) );\n vec3 bitangent = cross( N, tangent );\n\n vec3 prefilteredColor = vec3( 0.0 );\n float totalWeight = 0.0;\n\n for ( uint i = 0u; i < GGX_SAMPLES; i ++ ) {\n\n vec2 Xi = hammersley( i, GGX_SAMPLES );\n\n // With V = N, sample the reflected direction directly.\n float invQ = 1.0 / ( 1.0 - Xi.x + alpha2 * Xi.x );\n float NdotL = ( 1.0 - Xi.x - alpha2 * Xi.x ) * invQ;\n\n if ( NdotL > 0.0 ) {\n\n float phi = 2.0 * PI * Xi.y;\n float sinTheta = 2.0 * alpha * sqrt( Xi.x * ( 1.0 - Xi.x ) ) * invQ;\n vec3 L = N * NdotL + ( tangent * cos( phi ) + bitangent * sin( phi ) ) * sinTheta;\n\n // Match the source mip to the sample's solid angle. The terms\n // independent of the sample are precomputed in lodBias.\n float d = alpha2 * invQ;\n float lod = max( log2( d ) + lodBias, 0.0 );\n\n // Weight by NdotL for the split-sum approximation\n prefilteredColor += textureLod( envMap, L, lod ).rgb * NdotL;\n totalWeight += NdotL;\n\n }\n\n }\n\n gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 );\n\n }\n `)}function jw(){return kw(`PMREMGGXIntegration`,{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:Cw}},`\n\n varying vec3 vWorldDirection;\n\n uniform samplerCube envMap;\n uniform float roughness;\n uniform float sourceLod;\n uniform int sourceSize;\n\n void main() {\n\n vec3 N = normalize( vWorldDirection );\n\n float alpha = roughness * roughness;\n float alpha2 = alpha * alpha;\n\n float texelSize = 2.0 / float( sourceSize );\n\n vec3 prefilteredColor = vec3( 0.0 );\n float totalWeight = 0.0;\n\n // Pair opposite texels: only the one in N's hemisphere contributes.\n for ( int face = 0; face < 3; face ++ ) {\n\n for ( int y = 0; y < sourceSize; y ++ ) {\n\n for ( int x = 0; x < sourceSize; x ++ ) {\n\n vec2 uv = ( vec2( x, y ) + 0.5 ) * texelSize - 1.0;\n vec3 texelDirection = face == 0 ? vec3( 1.0, uv ) : ( face == 1 ? vec3( uv.x, 1.0, uv.y ) : vec3( uv, 1.0 ) );\n\n float invDistance = inversesqrt( 1.0 + dot( uv, uv ) );\n float NdotL = dot( N, texelDirection );\n texelDirection *= NdotL < 0.0 ? - 1.0 : 1.0;\n NdotL = abs( NdotL ) * invDistance;\n\n // With V = N, NdotH squared is ( 1 + NdotL ) / 2. Common factors\n // in the GGX distribution and texel solid angle cancel when normalized.\n float d = 1.0 + alpha2 + ( alpha2 - 1.0 ) * NdotL;\n float weight = NdotL * invDistance * invDistance * invDistance / ( d * d );\n\n prefilteredColor += textureLod( envMap, texelDirection, sourceLod ).rgb * weight;\n totalWeight += weight;\n\n }\n\n }\n\n }\n\n gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 );\n\n }\n `)}function Mw(){return kw(`PMREMSphericalGaussianBlur`,{envMap:{value:null},sigma:{value:0}},`\n\n #define SAMPLES ${xw}\n #define GOLDEN_ANGLE 2.39996322973\n\n varying vec3 vWorldDirection;\n\n uniform samplerCube envMap;\n uniform float sigma;\n\n #include <common>\n\n void main() {\n\n vec3 outputDirection = normalize( vWorldDirection );\n\n vec3 up = abs( outputDirection.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 );\n vec3 tangent = normalize( cross( up, outputDirection ) );\n vec3 bitangent = cross( outputDirection, tangent );\n\n // Truncate the kernel at three standard deviations or at the antipode.\n float thetaMax = min( 3.0 * sigma, PI );\n float truncation = 1.0 - exp( - 0.5 * thetaMax * thetaMax / ( sigma * sigma ) );\n\n vec3 accumColor = vec3( 0.0 );\n float accumWeight = 0.0;\n\n for ( int i = 0; i < SAMPLES; i ++ ) {\n\n // Stratified inverse-CDF sampling of the Gaussian, placed on a golden-angle spiral.\n float stratum = ( float( i ) + 0.5 ) / float( SAMPLES );\n float theta = sigma * sqrt( - 2.0 * log( 1.0 - stratum * truncation ) );\n float phi = float( i ) * GOLDEN_ANGLE;\n\n vec3 offset = cos( phi ) * tangent + sin( phi ) * bitangent;\n vec3 sampleDirection = cos( theta ) * outputDirection + sin( theta ) * offset;\n\n // Correct the planar sample density to solid angle.\n float weight = sin( theta ) / theta;\n\n accumColor += weight * textureLod( envMap, sampleDirection, 0.0 ).rgb;\n accumWeight += weight;\n\n }\n\n gl_FragColor = vec4( accumColor / accumWeight, 1.0 );\n\n }\n `)}function Nw(){return kw(`PMREMEquirectangularToCubemap`,{envMap:{value:null}},`\n\n varying vec3 vWorldDirection;\n\n uniform sampler2D envMap;\n\n #include <common>\n\n void main() {\n\n // Average four subpixel samples to preserve small, bright features.\n vec3 direction = normalize( vWorldDirection );\n vec3 dx = dFdx( direction ) * 0.25;\n vec3 dy = dFdy( direction ) * 0.25;\n\n vec3 color = textureLod( envMap, equirectUv( normalize( direction - dx - dy ) ), 0.0 ).rgb;\n color += textureLod( envMap, equirectUv( normalize( direction + dx - dy ) ), 0.0 ).rgb;\n color += textureLod( envMap, equirectUv( normalize( direction - dx + dy ) ), 0.0 ).rgb;\n color += textureLod( envMap, equirectUv( normalize( direction + dx + dy ) ), 0.0 ).rgb;\n gl_FragColor = vec4( color * 0.25, 1.0 );\n\n }\n `)}function Pw(){return kw(`PMREMCubemapToCubemap`,{envMap:{value:null},flipEnvMap:{value:-1}},`\n\n varying vec3 vWorldDirection;\n\n uniform samplerCube envMap;\n uniform float flipEnvMap;\n\n void main() {\n\n gl_FragColor = vec4( textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ).rgb, 1.0 );\n\n }\n `)}function Fw(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)}{let r=n.image;if(r&&r.height>0){let i=new vw(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}return null}}}return n}function o(t){if(t&&t.isTexture&&t.isPMREMTexture!==!0){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 Dw(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 Dw(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 Iw(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&&Z_(`WebGLRenderer: `+e+` extension not supported.`),t}}}function Lw(e,t,n,r){let i={},a=new WeakMap,o=new FinalizationRegistry(e=>delete i[e]);function s(e){c(e.target)}function c(e){e.index!==null&&t.remove(e.index);for(let n in e.attributes)t.remove(e.attributes[n]);e.removeEventListener(`dispose`,s),delete i[e.id],o.unregister(e);let c=a.get(e);c&&(t.remove(c),a.delete(e)),r.releaseStatesOfGeometry(e),e.isInstancedBufferGeometry===!0&&delete e._maxInstanceCount,n.memory.geometries--}function l(e,t){return i[t.id]===void 0&&(t.addEventListener(`dispose`,s),i[t.id]=new WeakRef(t),o.register(t,t.id,t),n.memory.geometries++),t}function u(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function d(e){let n=e.index,r=e.attributes.position,i=0;if(r===void 0)return;let o=n===null?r.array.length/3-1:n.array.length,s=new(r.count>=65535?xb:bb)(Math.ceil(o/3)*6,1),c=s.array;if(n!==null){let e=n.array;i=n.version;for(let t=0,n=0;t<o;t+=3){let r=e[t+0],i=e[t+1],a=e[t+2];c[n++]=r,c[n++]=i,c[n++]=i,c[n++]=a,c[n++]=a,c[n++]=r}}else{i=r.version;for(let e=0,t=0;e<o;e+=3){let n=e+0,r=e+1,i=e+2;c[t++]=n,c[t++]=r,c[t++]=r,c[t++]=i,c[t++]=i,c[t++]=n}}s.version=i;let l=a.get(e);l&&t.remove(l),a.set(e,s)}function f(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.version<n.version&&d(e)}else d(e);return a.get(e)}function p(){for(let e in i){let t=i[e].deref();t!==void 0&&c(t)}}return{get:l,update:u,getWireframeAttribute:f,dispose:p}}function Rw(e,t,n){let r;function i(e){r=e}let a,o;function s(e){a=e.type,o=e.bytesPerElement}function c(t,i){e.drawElements(r,i,a,t*o),n.update(i,r,1)}function l(t,i,s){s!==0&&(e.drawElementsInstanced(r,i,a,t*o,s),n.update(i,r,s))}function u(e,i,o){if(o===0)return;t.get(`WEBGL_multi_draw`).multiDrawElementsWEBGL(r,i,0,a,e,0,o);let s=0;for(let e=0;e<o;e++)s+=i[e];n.update(s,r,1)}this.setMode=i,this.setIndex=s,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function zw(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(t,r,i){switch(n.calls++,r){case e.TRIANGLES:n.triangles+=t/3*i;break;case e.LINES:n.lines+=t/2*i;break;case e.LINE_STRIP:n.lines+=i*(t-1);break;case e.LINE_LOOP:n.lines+=i*t;break;case e.POINTS:n.points+=i*t;break;default:X_(`WebGLInfo: Unknown draw mode:`,r)}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:i,update:r}}function Bw(e,t,n){let r=new WeakMap,i=new Jv;function a(a,o,s){let c=a.morphTargetInfluences,l=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=l===void 0?0:l.length,d=r.get(o);if(d===void 0||d.count!==u){d!==void 0&&d.texture.dispose();let e=o.morphAttributes.position!==void 0,n=o.morphAttributes.normal!==void 0,a=o.morphAttributes.color!==void 0,s=o.morphAttributes.position||[],c=o.morphAttributes.normal||[],l=o.morphAttributes.color||[],f=0;e===!0&&(f=1),n===!0&&(f=2),a===!0&&(f=3);let p=o.attributes.position.count*f,m=1;p>t.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new Zv(h,p,m,u);g.type=Og,g.needsUpdate=!0;let _=f*4;for(let t=0;t<u;t++){let r=s[t],o=c[t],u=l[t],d=p*m*4*t;for(let t=0;t<r.count;t++){let s=t*_;e===!0&&(i.fromBufferAttribute(r,t),h[d+s+0]=i.x,h[d+s+1]=i.y,h[d+s+2]=i.z,h[d+s+3]=0),n===!0&&(i.fromBufferAttribute(o,t),h[d+s+4]=i.x,h[d+s+5]=i.y,h[d+s+6]=i.z,h[d+s+7]=0),a===!0&&(i.fromBufferAttribute(u,t),h[d+s+8]=i.x,h[d+s+9]=i.y,h[d+s+10]=i.z,h[d+s+11]=u.itemSize===4?i.w:1)}}d={count:u,texture:g,size:new X(p,m)},r.set(o,d);function v(){g.dispose(),r.delete(o),o.removeEventListener(`dispose`,v)}o.addEventListener(`dispose`,v)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)s.getUniforms().setValue(e,`morphTexture`,a.morphTexture,n);else{let t=0;for(let e=0;e<c.length;e++)t+=c[e];let n=o.morphTargetsRelative?1:1-t;s.getUniforms().setValue(e,`morphTargetBaseInfluence`,n),s.getUniforms().setValue(e,`morphTargetInfluences`,c)}s.getUniforms().setValue(e,`morphTargetsTexture`,d.texture,n),s.getUniforms().setValue(e,`morphTargetsTextureSize`,d.size)}return{update:a}}function Vw(e,t,n,r,i){let a=new WeakMap;function o(r){let o=i.render.frame,s=r.geometry,l=t.get(r,s);if(a.get(l)!==o&&(t.update(l),a.set(l,o)),r.isInstancedMesh&&(r.hasEventListener(`dispose`,c)===!1&&r.addEventListener(`dispose`,c),a.get(r)!==o&&(n.update(r.instanceMatrix,e.ARRAY_BUFFER),r.instanceColor!==null&&n.update(r.instanceColor,e.ARRAY_BUFFER),a.set(r,o))),r.isSkinnedMesh){let e=r.skeleton;a.get(e)!==o&&(e.update(),a.set(e,o))}return l}function s(){a=new WeakMap}function c(e){let t=e.target;t.removeEventListener(`dispose`,c),r.releaseStatesOfObject(t),n.remove(t.instanceMatrix),t.instanceColor!==null&&n.remove(t.instanceColor)}return{update:o,dispose:s}}var Hw={1:`LINEAR_TONE_MAPPING`,2:`REINHARD_TONE_MAPPING`,3:`CINEON_TONE_MAPPING`,4:`ACES_FILMIC_TONE_MAPPING`,6:`AGX_TONE_MAPPING`,7:`NEUTRAL_TONE_MAPPING`,5:`CUSTOM_TONE_MAPPING`};function Uw(e,t,n,r,i,a){let o=new Xv(t,n,{type:e,depthBuffer:i,stencilBuffer:a,samples:r?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),s=null,c=null,l=null,u=new Pb;u.setAttribute(`position`,new Sb([-1,3,0,-1,-1,0,3,-1,0],3)),u.setAttribute(`uv`,new Sb([0,2,0,0,2,0],2));let d=new xS({uniforms:{tDiffuse:{value:null}},vertexShader:`\n precision highp float;\n\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }`,fragmentShader:`\n precision highp float;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n #include <tonemapping_pars_fragment>\n #include <colorspace_pars_fragment>\n\n void main() {\n gl_FragColor = texture2D( tDiffuse, vUv );\n\n #ifdef LINEAR_TONE_MAPPING\n gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n #elif defined( REINHARD_TONE_MAPPING )\n gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n #elif defined( CINEON_TONE_MAPPING )\n gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n #elif defined( ACES_FILMIC_TONE_MAPPING )\n gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n #elif defined( AGX_TONE_MAPPING )\n gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n #elif defined( NEUTRAL_TONE_MAPPING )\n gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n #elif defined( CUSTOM_TONE_MAPPING )\n gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n #endif\n\n #ifdef SRGB_TRANSFER\n gl_FragColor = sRGBTransferOETF( gl_FragColor );\n #endif\n }`,depthTest:!1,depthWrite:!1}),f=new wx(u,d),p=new bC(-1,1,1,-1,0,1),m=null,h=null,g=!1,_,v=null,y=[],b=!1;this.setSize=function(e,t){o.setSize(e,t),s!==null&&s.setSize(e,t),c!==null&&c.setSize(e,t);for(let n=0;n<y.length;n++){let r=y[n];r.setSize&&r.setSize(e,t)}},this.setEffects=function(e){y=e,b=y.length>0&&y[0].isRenderPass===!0;let t=o.width,n=o.height;y.length>0&&s===null&&(s=new Xv(t,n,{type:kg,depthBuffer:!1,stencilBuffer:!1}),c=new Xv(t,n,{type:kg,depthBuffer:!1,stencilBuffer:!1}));let r=i===!0&&y.some(e=>e.needsDepthTexture===!0);r!==(o.depthTexture!==null)&&(r===!0&&l===null&&(l=new $x(t,n),a===!0&&(l.format=zg,l.type=Mg)),o.dispose(),o.depthTexture=r?l:null,o.resolveDepthBuffer=r,o.storeMultisampledDepthBuffer=r);for(let e=0;e<y.length;e++){let i=y[e];i.setSize&&i.setSize(t,n),r&&i.needsDepthTexture===!0&&i.setDepthTexture&&i.setDepthTexture(l)}},this.begin=function(e,t){if(g||e.toneMapping===0&&y.length===0)return!1;if(v=t,t!==null){let e=t.width,n=t.height;(o.width!==e||o.height!==n)&&this.setSize(e,n)}return b===!1&&e.setRenderTarget(o),_=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return b},this.end=function(e,t){e.toneMapping=_,g=!0;let n=o,r=s;for(let i=0;i<y.length;i++){let a=y[i];a.enabled!==!1&&(a.render(e,r,n,t),a.needsSwap!==!1&&(n=r,r=r===s?c:s))}if(m!==e.outputColorSpace||h!==e.toneMapping){m=e.outputColorSpace,h=e.toneMapping,d.defines={},Lv.getTransfer(m)===`srgb`&&(d.defines.SRGB_TRANSFER=``);let t=Hw[h];t&&(d.defines[t]=``),d.needsUpdate=!0}d.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(v),e.render(f,p),v=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){o.dispose(),s!==null&&s.dispose(),c!==null&&c.dispose(),u.dispose(),d.dispose()}}var Ww=new qv,Gw=new $x(1,1),Kw=new eS(1),qw=new Zv,Jw=new Qv,Yw=new Zx,Xw=[],Zw=[],Qw=new Float32Array(16),$w=new Float32Array(9),eT=new Float32Array(4);function tT(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=Xw[i];if(a===void 0&&(a=new Float32Array(i),Xw[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 nT(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function rT(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function iT(e,t){let n=Zw[t];n===void 0&&(n=new Int32Array(t),Zw[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function aT(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function oT(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(nT(n,t))return;e.uniform2fv(this.addr,t),rT(n,t)}}function sT(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(t.r!==void 0)(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(nT(n,t))return;e.uniform3fv(this.addr,t),rT(n,t)}}function cT(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(nT(n,t))return;e.uniform4fv(this.addr,t),rT(n,t)}}function lT(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(nT(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),rT(n,t)}else{if(nT(n,r))return;eT.set(r),e.uniformMatrix2fv(this.addr,!1,eT),rT(n,r)}}function uT(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(nT(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),rT(n,t)}else{if(nT(n,r))return;$w.set(r),e.uniformMatrix3fv(this.addr,!1,$w),rT(n,r)}}function dT(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(nT(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),rT(n,t)}else{if(nT(n,r))return;Qw.set(r),e.uniformMatrix4fv(this.addr,!1,Qw),rT(n,r)}}function fT(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function pT(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(nT(n,t))return;e.uniform2iv(this.addr,t),rT(n,t)}}function mT(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(nT(n,t))return;e.uniform3iv(this.addr,t),rT(n,t)}}function hT(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(nT(n,t))return;e.uniform4iv(this.addr,t),rT(n,t)}}function gT(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function _T(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(nT(n,t))return;e.uniform2uiv(this.addr,t),rT(n,t)}}function vT(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(nT(n,t))return;e.uniform3uiv(this.addr,t),rT(n,t)}}function yT(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(nT(n,t))return;e.uniform4uiv(this.addr,t),rT(n,t)}}function bT(e){return e.version===0&&(e.compareFunction=519,e.needsUpdate=!0),e}function xT(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i);let a;a=this.type===e.SAMPLER_2D_SHADOW?bT(Gw):Ww,n.setTexture2D(t||a,i)}function ST(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||Jw,i)}function CT(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i);let a;a=this.type===e.SAMPLER_CUBE_SHADOW?bT(Kw):Yw,n.setTextureCube(t||a,i)}function wT(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||qw,i)}function TT(e){switch(e){case 5126:return aT;case 35664:return oT;case 35665:return sT;case 35666:return cT;case 35674:return lT;case 35675:return uT;case 35676:return dT;case 5124:case 35670:return fT;case 35667:case 35671:return pT;case 35668:case 35672:return mT;case 35669:case 35673:return hT;case 5125:return gT;case 36294:return _T;case 36295:return vT;case 36296:return yT;case 35678:case 36198:case 36298:case 36306:case 35682:return xT;case 35679:case 36299:case 36307:return ST;case 35680:case 36300:case 36308:case 36293:return CT;case 36289:case 36303:case 36311:case 36292:return wT}}function ET(e,t){e.uniform1fv(this.addr,t)}function DT(e,t){let n=tT(t,this.size,2);e.uniform2fv(this.addr,n)}function OT(e,t){let n=tT(t,this.size,3);e.uniform3fv(this.addr,n)}function kT(e,t){let n=tT(t,this.size,4);e.uniform4fv(this.addr,n)}function AT(e,t){let n=tT(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function jT(e,t){let n=tT(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function MT(e,t){let n=tT(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function NT(e,t){e.uniform1iv(this.addr,t)}function PT(e,t){e.uniform2iv(this.addr,t)}function FT(e,t){e.uniform3iv(this.addr,t)}function IT(e,t){e.uniform4iv(this.addr,t)}function LT(e,t){e.uniform1uiv(this.addr,t)}function RT(e,t){e.uniform2uiv(this.addr,t)}function zT(e,t){e.uniform3uiv(this.addr,t)}function BT(e,t){e.uniform4uiv(this.addr,t)}function VT(e,t,n){let r=this.cache,i=t.length,a=iT(n,i);nT(r,a)||(e.uniform1iv(this.addr,a),rT(r,a));let o;o=this.type===e.SAMPLER_2D_SHADOW?bT(Gw):Ww;for(let e=0;e!==i;++e)n.setTexture2D(t[e]||o,a[e])}function HT(e,t,n){let r=this.cache,i=t.length,a=iT(n,i);nT(r,a)||(e.uniform1iv(this.addr,a),rT(r,a));for(let e=0;e!==i;++e)n.setTexture3D(t[e]||Jw,a[e])}function UT(e,t,n){let r=this.cache,i=t.length,a=iT(n,i);nT(r,a)||(e.uniform1iv(this.addr,a),rT(r,a));let o;o=this.type===e.SAMPLER_CUBE_SHADOW?bT(Kw):Yw;for(let e=0;e!==i;++e)n.setTextureCube(t[e]||o,a[e])}function WT(e,t,n){let r=this.cache,i=t.length,a=iT(n,i);nT(r,a)||(e.uniform1iv(this.addr,a),rT(r,a));for(let e=0;e!==i;++e)n.setTexture2DArray(t[e]||qw,a[e])}function GT(e){switch(e){case 5126:return ET;case 35664:return DT;case 35665:return OT;case 35666:return kT;case 35674:return AT;case 35675:return jT;case 35676:return MT;case 5124:case 35670:return NT;case 35667:case 35671:return PT;case 35668:case 35672:return FT;case 35669:case 35673:return IT;case 5125:return LT;case 36294:return RT;case 36295:return zT;case 36296:return BT;case 35678:case 36198:case 36298:case 36306:case 35682:return VT;case 35679:case 36299:case 36307:return HT;case 35680:case 36300:case 36308:case 36293:return UT;case 36289:case 36303:case 36311:case 36292:return WT}}var KT=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=TT(t.type)}},qT=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=GT(t.type)}},JT=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let r=this.seq;for(let i=0,a=r.length;i!==a;++i){let a=r[i];a.setValue(e,t[a.id],n)}}},YT=/(\\w+)(\\])?(\\[|\\.)?/g;function XT(e,t){e.seq.push(t),e.map[t.id]=t}function ZT(e,t,n){let r=e.name,i=r.length;for(YT.lastIndex=0;;){let a=YT.exec(r),o=YT.lastIndex,s=a[1],c=a[2]===`]`,l=a[3];if(c&&(s|=0),l===void 0||l===`[`&&o+2===i){XT(n,l===void 0?new KT(s,e,t):new qT(s,e,t));break}{let e=n.map[s];e===void 0&&(e=new JT(s),XT(n,e)),n=e}}}var QT=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let n=e.getActiveUniform(t,r);ZT(n,e.getUniformLocation(t,n.name),this)}let r=[],i=[];for(let t of this.seq)t.type===e.SAMPLER_2D_SHADOW||t.type===e.SAMPLER_CUBE_SHADOW||t.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(t):i.push(t);r.length>0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function $T(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var eE=37297,tE=0;function nE(e,t){let n=e.split(`\n`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e<a;e++){let i=e+1;r.push(`${i===t?`>`:` `} ${i}: ${n[e]}`)}return r.join(`\n`)}var rE=new Mv;function iE(e){Lv._getMatrix(rE,Lv.workingColorSpace,e);let t=`mat3( ${rE.elements.map(e=>e.toFixed(4))} )`;switch(Lv.getTransfer(e)){case L_:return[t,`LinearTransferOETF`];case R_:return[t,`sRGBTransferOETF`];default:return Y_(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function aE(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()+`\n\n`+i+`\n\n`+nE(e.getShaderSource(t),r)}return i}function oE(e,t){let n=iE(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( ${n[0]} * value.rgb, value.a ) );`,`}`].join(`\n`)}var sE={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function cE(e,t){let n=sE[t];return n===void 0?(Y_(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var lE=new Z;function uE(){return Lv.getLuminanceCoefficients(lE),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${lE.x.toFixed(4)}, ${lE.y.toFixed(4)}, ${lE.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(`\n`)}function dE(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(mE).join(`\n`)}function fE(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(`\n`)}function pE(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){let r=e.getActiveAttrib(t,i),a=r.name,o=1;r.type===e.FLOAT_MAT2&&(o=2),r.type===e.FLOAT_MAT3&&(o=3),r.type===e.FLOAT_MAT4&&(o=4),n[a]={type:r.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function mE(e){return e!==``}function hE(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows).replace(/NUM_LIGHT_PROBE_GRIDS/g,t.numLightProbeGrids)}function gE(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var _E=/^[ \\t]*#include +<([\\w\\d./]+)>/gm;function vE(e){return e.replace(_E,yE)}function yE(e,t){let n=cw[t];if(n===void 0)throw Error(`THREE.WebGLProgram: Can not resolve #include <`+t+`>`);return vE(n)}var bE=/#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 xE(e){return e.replace(bE,SE)}function SE(e,t,n,r){let i=``;for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\\[\\s*i\\s*\\]/g,`[ `+e+` ]`).replace(/UNROLLED_LOOP_INDEX/g,e);return i}function CE(e){let t=`precision ${e.precision} float;\n precision ${e.precision} int;\n precision ${e.precision} sampler2D;\n precision ${e.precision} samplerCube;\n precision ${e.precision} sampler3D;\n precision ${e.precision} sampler2DArray;\n precision ${e.precision} sampler2DShadow;\n precision ${e.precision} samplerCubeShadow;\n precision ${e.precision} sampler2DArrayShadow;\n precision ${e.precision} isampler2D;\n precision ${e.precision} isampler3D;\n precision ${e.precision} isamplerCube;\n precision ${e.precision} isampler2DArray;\n precision ${e.precision} usampler2D;\n precision ${e.precision} usampler3D;\n precision ${e.precision} usamplerCube;\n precision ${e.precision} usampler2DArray;\n `;return e.precision===`highp`?t+=`\n#define HIGH_PRECISION`:e.precision===`mediump`?t+=`\n#define MEDIUM_PRECISION`:e.precision===`lowp`&&(t+=`\n#define LOW_PRECISION`),t}var wE={1:`SHADOWMAP_TYPE_PCF`,3:`SHADOWMAP_TYPE_VSM`};function TE(e){return wE[e.shadowMapType]||`SHADOWMAP_TYPE_BASIC`}var EE={302:`ENVMAP_MODE_REFRACTION`};function DE(e){return e.envMap===!1?`ENVMAP_MODE_REFLECTION`:EE[e.envMapMode]||`ENVMAP_MODE_REFLECTION`}var OE={0:`ENVMAP_BLENDING_MULTIPLY`,1:`ENVMAP_BLENDING_MIX`,2:`ENVMAP_BLENDING_ADD`};function kE(e){return e.envMap===!1?`ENVMAP_BLENDING_NONE`:OE[e.combine]||`ENVMAP_BLENDING_NONE`}function AE(e,t,n,r){let i=e.getContext(),a=n.defines,o=n.vertexShader,s=n.fragmentShader,c=TE(n),l=n.envMapPMREM===!0?`ENVMAP_TYPE_PMREM`:`ENVMAP_TYPE_CUBE`,u=DE(n),d=kE(n),f=dE(n),p=fE(a),m=i.createProgram(),h,g,_=n.glslVersion?`#version `+n.glslVersion+`\n`:``;n.isRawShaderMaterial?(h=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,p].filter(mE).join(`\n`),h.length>0&&(h+=`\n`),g=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,p].filter(mE).join(`\n`),g.length>0&&(g+=`\n`)):(h=[CE(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,p,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.diffuseRoughnessMap?`#define USE_DIFFUSE_ROUGHNESSMAP`:``,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.diffuseRoughnessMapUv?`#define DIFFUSE_ROUGHNESSMAP_UV `+n.diffuseRoughnessMapUv:``,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`,`\n`].filter(mE).join(`\n`),g=[CE(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,p,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:``,n.envMapPMREM?`#define ENVMAP_MAX_LOD `+n.envMapMaxLod+`.0`:``,n.envMapPMREM?`#define ENVMAP_SIZE `+n.envMapSize+`.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.diffuseRoughness?`#define USE_DIFFUSE_ROUGHNESS`:``,n.diffuseRoughnessMap?`#define USE_DIFFUSE_ROUGHNESSMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.retroreflection?`#define USE_RETROREFLECTION`:``,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.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?``:cw.tonemapping_pars_fragment,n.toneMapping===0?``:cE(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,cw.colorspace_pars_fragment,oE(`linearToOutputTexel`,n.outputColorSpace),uE(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,`\n`].filter(mE).join(`\n`)),o=vE(o),o=hE(o,n),o=gE(o,n),s=vE(s),s=hE(s,n),s=gE(s,n),o=xE(o),s=xE(s),n.isRawShaderMaterial!==!0&&(_=`#version 300 es\n`,h=[f,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(`\n`)+`\n`+h,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(`\n`)+`\n`+g);let v=_+h+o,y=_+g+s,b=$T(i,i.VERTEX_SHADER,v),x=$T(i,i.FRAGMENT_SHADER,y);i.attachShader(m,b),i.attachShader(m,x),n.index0AttributeName===void 0?n.hasPositionAttribute===!0&&i.bindAttribLocation(m,0,`position`):i.bindAttribLocation(m,0,n.index0AttributeName),i.linkProgram(m);function S(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(m)||``,r=i.getShaderInfoLog(b)||``,a=i.getShaderInfoLog(x)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(m,i.LINK_STATUS)===!1){if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,m,b,x);else{let e=aE(i,b,`vertex`),n=aE(i,x,`fragment`);X_(`WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(m,i.VALIDATE_STATUS)+`\n\nMaterial Name: `+t.name+`\nMaterial Type: `+t.type+`\n\nProgram Info Log: `+o+`\n`+e+`\n`+n)}}else o===``?(s===``||c===``)&&(u=!1):Y_(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:h},fragmentShader:{log:c,prefix:g}})}i.deleteShader(b),i.deleteShader(x),C=new QT(i,m),w=pE(i,m)}let C;this.getUniforms=function(){return C===void 0&&S(this),C};let w;this.getAttributes=function(){return w===void 0&&S(this),w};let T=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=i.getProgramParameter(m,eE)),T},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=tE++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=b,this.fragmentShader=x,this}var jE=0,ME=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 NE(e),t.set(e,n)),n}},NE=class{constructor(e){this.id=jE++,this.code=e,this.usedTimes=0}};function PE(e){return e===1030||e===37490||e===36285}function FE(e,t,n,r,i,a){let o=new uy,s=new ME,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f={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 p(e){return c.add(e),e===0?`uv`:`uv${e}`}function m(i,o,l,u,m,h){let g=u.fog,_=m.geometry,v=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,b=t.get(i.envMap||v,y),x=f[i.type],S=r.precision;i.precision!==null&&(S=r.getMaxPrecision(i.precision),S!==i.precision&&Y_(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,S,`instead.`));let C=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,w=C===void 0?0:C.length,T=0;_.morphAttributes.position!==void 0&&(T=1),_.morphAttributes.normal!==void 0&&(T=2),_.morphAttributes.color!==void 0&&(T=3);let E,D,O,k;if(x){let e=lw[x];E=e.vertexShader,D=e.fragmentShader}else{E=i.vertexShader,D=i.fragmentShader;let e=s.getVertexShaderStage(i),t=s.getFragmentShaderStage(i);s.update(i,e,t),O=e.id,k=t.id}let A=e.getRenderTarget(),j=e.state.buffers.depth.getReversed(),M=m.isInstancedMesh===!0,N=m.isBatchedMesh===!0,P=!!i.map,ee=!!i.matcap,te=!!b,ne=te&&b.isPMREMTexture===!0,re=!!i.aoMap,ie=!!i.lightMap,ae=!!i.bumpMap&&i.wireframe===!1,oe=!!i.normalMap,se=!!i.displacementMap,ce=!!i.emissiveMap,le=!!i.metalnessMap,ue=!!i.roughnessMap,de=i.anisotropy>0,fe=i.clearcoat>0,pe=i.diffuseRoughness>0,me=i.dispersion>0,he=i.retroreflectivity>0,ge=i.iridescence>0,_e=i.sheen>0,ve=i.transmission>0,ye=de&&!!i.anisotropyMap,be=fe&&!!i.clearcoatMap,xe=fe&&!!i.clearcoatNormalMap,Se=fe&&!!i.clearcoatRoughnessMap,Ce=pe&&!!i.diffuseRoughnessMap,F=ge&&!!i.iridescenceMap,we=ge&&!!i.iridescenceThicknessMap,Te=_e&&!!i.sheenColorMap,Ee=_e&&!!i.sheenRoughnessMap,I=!!i.specularMap,De=!!i.specularColorMap,L=!!i.specularIntensityMap,R=ve&&!!i.transmissionMap,Oe=ve&&!!i.thicknessMap,ke=!!i.gradientMap,Ae=!!i.alphaMap,je=i.alphaTest>0,Me=!!i.alphaHash,Ne=!!i.extensions,Pe=0;i.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Pe=e.toneMapping);let Fe=ne?b.isCompressedCubeTexture?b.image[0].mipmaps:b.mipmaps:null,Ie={shaderID:x,shaderType:i.type,shaderName:i.name,vertexShader:E,fragmentShader:D,defines:i.defines,customVertexShaderID:O,customFragmentShaderID:k,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:S,batching:N,batchingColor:N&&m._colorsTexture!==null,instancing:M,instancingColor:M&&m.instanceColor!==null,instancingMorph:M&&m.morphTexture!==null,outputColorSpace:A===null?e.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Lv.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:P,matcap:ee,envMap:te,envMapMode:te&&b.mapping,envMapPMREM:ne,envMapMaxLod:ne?Fe.length-1:null,envMapSize:ne?Fe[0].width:null,aoMap:re,lightMap:ie,bumpMap:ae,normalMap:oe,displacementMap:se,emissiveMap:ce,normalMapObjectSpace:oe&&i.normalMapType===1,normalMapTangentSpace:oe&&i.normalMapType===0,packedNormalMap:oe&&i.normalMapType===0&&PE(i.normalMap.format),metalnessMap:le,roughnessMap:ue,anisotropy:de,anisotropyMap:ye,clearcoat:fe,clearcoatMap:be,clearcoatNormalMap:xe,clearcoatRoughnessMap:Se,diffuseRoughness:pe,diffuseRoughnessMap:Ce,dispersion:me,retroreflection:he,iridescence:ge,iridescenceMap:F,iridescenceThicknessMap:we,sheen:_e,sheenColorMap:Te,sheenRoughnessMap:Ee,specularMap:I,specularColorMap:De,specularIntensityMap:L,transmission:ve,transmissionMap:R,thicknessMap:Oe,gradientMap:ke,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:Ae,alphaTest:je,alphaHash:Me,combine:i.combine,mapUv:P&&p(i.map.channel),aoMapUv:re&&p(i.aoMap.channel),lightMapUv:ie&&p(i.lightMap.channel),bumpMapUv:ae&&p(i.bumpMap.channel),normalMapUv:oe&&p(i.normalMap.channel),displacementMapUv:se&&p(i.displacementMap.channel),emissiveMapUv:ce&&p(i.emissiveMap.channel),metalnessMapUv:le&&p(i.metalnessMap.channel),roughnessMapUv:ue&&p(i.roughnessMap.channel),anisotropyMapUv:ye&&p(i.anisotropyMap.channel),clearcoatMapUv:be&&p(i.clearcoatMap.channel),clearcoatNormalMapUv:xe&&p(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Se&&p(i.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:Ce&&p(i.diffuseRoughnessMap.channel),iridescenceMapUv:F&&p(i.iridescenceMap.channel),iridescenceThicknessMapUv:we&&p(i.iridescenceThicknessMap.channel),sheenColorMapUv:Te&&p(i.sheenColorMap.channel),sheenRoughnessMapUv:Ee&&p(i.sheenRoughnessMap.channel),specularMapUv:I&&p(i.specularMap.channel),specularColorMapUv:De&&p(i.specularColorMap.channel),specularIntensityMapUv:L&&p(i.specularIntensityMap.channel),transmissionMapUv:R&&p(i.transmissionMap.channel),thicknessMapUv:Oe&&p(i.thicknessMap.channel),alphaMapUv:Ae&&p(i.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(oe||de),vertexNormals:!!_.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!_.attributes.color&&_.attributes.color.itemSize===4,pointsUvs:m.isPoints===!0&&!!_.attributes.uv&&(P||Ae),fog:!!g,useFog:i.fog===!0,fogExp2:!!g&&g.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||_.attributes.normal===void 0&&oe===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:j,skinning:m.isSkinnedMesh===!0,hasPositionAttribute:_.attributes.position!==void 0,morphTargets:_.morphAttributes.position!==void 0,morphNormals:_.morphAttributes.normal!==void 0,morphColors:_.morphAttributes.color!==void 0,morphTargetsCount:w,morphTextureStride:T,numSunLights:o.sun.length,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numSunLightShadows:o.sunShadowMap.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:h.filter(e=>e.texture!==null).length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:Pe,decodeVideoTexture:P&&i.map.isVideoTexture===!0&&Lv.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:ce&&i.emissiveMap.isVideoTexture===!0&&Lv.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:Ne&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(Ne&&i.extensions.multiDraw===!0||N)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ie.vertexUv1s=c.has(1),Ie.vertexUv2s=c.has(2),Ie.vertexUv3s=c.has(3),c.clear(),Ie}function h(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&&(g(n,t),_(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function g(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapPMREM),e.push(t.envMapMaxLod),e.push(t.envMapSize),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.diffuseRoughnessMapUv),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.numSunLights),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.numSunLightShadows),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.numLightProbeGrids),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function _(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.retroreflection&&o.enable(24),t.diffuseRoughness&&o.enable(25),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 v(e){let t=f[e.type],n;if(t){let e=lw[t];n=_S.clone(e.uniforms)}else n=e.uniforms;return n}function y(t,n){let r=u.get(n);return r===void 0?(r=new AE(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function b(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 x(e){s.remove(e)}function S(){s.dispose()}return{getParameters:m,getProgramCacheKey:h,getUniforms:v,acquireProgram:y,releaseProgram:b,releaseShaderCache:x,programs:l,dispose:S}}function IE(){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 LE(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 RE(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 zE(){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,u){u.reversedDepth===!0&&(c=-c);let d=s(e,t,a,o,c,l);a.transmission>0?r.push(d):a.transparent===!0?i.push(d):n.push(d)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||LE),r.length>1&&r.sort(t||RE),i.length>1&&i.sort(t||RE)}function d(){for(let n=t,r=e.length;n<r;n++){let t=e[n];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:c,unshift:l,finish:d,sort:u}}function BE(){let e=new WeakMap;function t(t,n){let r=e.get(t),i;return r===void 0?(i=new zE,e.set(t,[i])):n>=r.length?(i=new zE,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function VE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={direction:new Z,color:new Q};break;case`SpotLight`:n={position:new Z,direction:new Z,color:new Q,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new Z,color:new Q,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new Z,skyColor:new Q,groundColor:new Q};break;case`RectAreaLight`:n={color:new Q,position:new Z,halfWidth:new Z,halfHeight:new Z}}return e[t.id]=n,n}}}function HE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new X};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new X};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new X,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var UE=0;function WE(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function GE(e){let t=new VE,n=HE(),r={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 Z);let i=new Z,a=new $v,o=new $v;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,y=0,b=0,x=0;i.sort(WE);for(let e=0,S=i.length;e<S;e++){let S=i[e],C=S.color,w=S.intensity,T=S.distance,E=null;if(S.shadow&&S.shadow.map&&(E=S.shadow.map.texture.format===1030?S.shadow.map.texture:S.shadow.map.depthTexture||S.shadow.map.texture),S.isAmbientLight)a+=C.r*w,o+=C.g*w,s+=C.b*w;else if(S.isLightProbe){for(let e=0;e<9;e++)r.probe[e].addScaledVector(S.sh.coefficients[e],w);x++}else if(S.isSunLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize.copy(e.mapSize).multiply(e.getFrameExtents()),r.sunShadow[l]=t,r.sunShadowMap[l]=E;let i=e.getViewportCount();for(let t=0;t<i;t++)r.sunShadowMatrix[u+t]=e.getMatrix(t),r.sunShadowCascade[u+t]=e._cascadeData[t];u+=i,l++}r.sun[c]=e,c++}else if(S.isDirectionalLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,r.directionalShadow[d]=t,r.directionalShadowMap[d]=E,r.directionalShadowMatrix[d]=S.shadow.matrix,g++}r.directional[d]=e,d++}else if(S.isSpotLight){let e=t.get(S);e.position.setFromMatrixPosition(S.matrixWorld),e.color.copy(C).multiplyScalar(w),e.distance=T,e.coneCos=Math.cos(S.angle),e.penumbraCos=Math.cos(S.angle*(1-S.penumbra)),e.decay=S.decay,r.spot[p]=e;let i=S.shadow;if(S.map&&(r.spotLightMap[y]=S.map,y++,i.updateMatrices(S),S.castShadow&&b++),r.spotLightMatrix[p]=i.matrix,S.castShadow){let e=n.get(S);e.shadowIntensity=i.intensity,e.shadowBias=i.bias,e.shadowNormalBias=i.normalBias,e.shadowRadius=i.radius,e.shadowMapSize=i.mapSize,r.spotShadow[p]=e,r.spotShadowMap[p]=E,v++}p++}else if(S.isRectAreaLight){let e=t.get(S);e.color.copy(C).multiplyScalar(w),e.halfWidth.set(S.width*.5,0,0),e.halfHeight.set(0,S.height*.5,0),r.rectArea[m]=e,m++}else if(S.isPointLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),e.distance=S.distance,e.decay=S.decay,S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,r.pointShadow[f]=t,r.pointShadowMap[f]=E,r.pointShadowMatrix[f]=S.shadow.matrix,_++}r.point[f]=e,f++}else if(S.isHemisphereLight){let e=t.get(S);e.skyColor.copy(S.color).multiplyScalar(w),e.groundColor.copy(S.groundColor).multiplyScalar(w),r.hemi[h]=e,h++}}m>0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=$.LTC_FLOAT_1,r.rectAreaLTC2=$.LTC_FLOAT_2):(r.rectAreaLTC1=$.LTC_HALF_1,r.rectAreaLTC2=$.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let S=r.hash;(S.sunLength!==c||S.directionalLength!==d||S.pointLength!==f||S.spotLength!==p||S.rectAreaLength!==m||S.hemiLength!==h||S.numSunShadows!==l||S.numDirectionalShadows!==g||S.numPointShadows!==_||S.numSpotShadows!==v||S.numSpotMaps!==y||S.numLightProbes!==x)&&(r.sun.length=c,r.directional.length=d,r.spot.length=p,r.rectArea.length=m,r.point.length=f,r.hemi.length=h,r.sunShadow.length=l,r.sunShadowMap.length=l,r.sunShadowMatrix.length=u,r.sunShadowCascade.length=u,r.directionalShadow.length=g,r.directionalShadowMap.length=g,r.directionalShadowMatrix.length=g,r.pointShadow.length=_,r.pointShadowMap.length=_,r.pointShadowMatrix.length=_,r.spotShadow.length=v,r.spotShadowMap.length=v,r.spotLightMatrix.length=v+y-b,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=b,r.numLightProbes=x,S.sunLength=c,S.directionalLength=d,S.pointLength=f,S.spotLength=p,S.rectAreaLength=m,S.hemiLength=h,S.numSunShadows=l,S.numDirectionalShadows=g,S.numPointShadows=_,S.numSpotShadows=v,S.numSpotMaps=y,S.numLightProbes=x,r.version=UE++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=0,f=t.matrixWorldInverse;for(let t=0,p=e.length;t<p;t++){let p=e[t];if(p.isSunLight){let e=r.sun[n];e.direction.setFromMatrixPosition(p.matrixWorld),e.direction.transformDirection(f),n++}else if(p.isDirectionalLight){let e=r.directional[s];e.direction.setFromMatrixPosition(p.matrixWorld),i.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(f),s++}else if(p.isSpotLight){let e=r.spot[l];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),e.direction.setFromMatrixPosition(p.matrixWorld),i.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(f),l++}else if(p.isRectAreaLight){let e=r.rectArea[u];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),o.identity(),a.copy(p.matrixWorld),a.premultiply(f),o.extractRotation(a),e.halfWidth.set(p.width*.5,0,0),e.halfHeight.set(0,p.height*.5,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),u++}else if(p.isPointLight){let e=r.point[c];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),c++}else if(p.isHemisphereLight){let e=r.hemi[d];e.direction.setFromMatrixPosition(p.matrixWorld),e.direction.transformDirection(f),d++}}}return{setup:s,setupView:c,state:r}}function KE(e){let t=new GE(e),n=[],r=[],i=[];function a(e){u.camera=e,n.length=0,r.length=0,i.length=0}function o(e){e.isLightProbeGrid?i.push(e):n.push(e)}function s(e){r.push(e)}function c(){t.setup(n),i.sort((e,t)=>e.priority-t.priority||e.id-t.id)}function l(e){t.setupView(n,e)}let u={lightsArray:n,shadowsArray:r,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:u,setupLights:c,setupLightsView:l,pushLight:o,pushShadow:s}}function qE(e){let t=new WeakMap;function n(n,r=0){let i=t.get(n),a;return i===void 0?(a=new KE(e),t.set(n,[a])):r>=i.length?(a=new KE(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var JE=`void main() {\n gl_Position = vec4( position, 1.0 );\n}`,YE=`uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}`,XE=[new Z(1,0,0),new Z(-1,0,0),new Z(0,1,0),new Z(0,-1,0),new Z(0,0,1),new Z(0,0,-1)],ZE=[new Z(0,-1,0),new Z(0,-1,0),new Z(0,0,1),new Z(0,0,-1),new Z(0,-1,0),new Z(0,-1,0)],QE=new $v,$E=new Z,eD=new Z;function tD(e,t,n){let r=new jx,i=new X,a=new X,o=new Jv,s=new TS,c=new ES,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new bS({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new X},radius:{value:4}},vertexShader:JE,fragmentShader:YE}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Pb;m.setAttribute(`position`,new yb(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new wx(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&&(Y_(`WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;c<l;c++){let l=t[c],d=l.shadow;if(d===void 0){Y_(`WebGLShadowMap:`,l,`has no shadow.`);continue}if(d.autoUpdate===!1&&d.needsUpdate===!1)continue;i.copy(d.mapSize);let m=d.getFrameExtents();i.multiply(m),a.copy(d.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){Y_(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new Xv(i.x,i.y,{format:Hg,type:kg,minFilter:yg,magFilter:yg,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new $x(i.x,i.y,Og),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=Rg,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=gg,d.map.depthTexture.magFilter=gg}else l.isPointLight?(d.map=new vw(i.x),d.map.depthTexture=new eS(i.x,Dg)):(d.map=new Xv(i.x,i.y),d.map.depthTexture=new $x(i.x,i.y,Dg)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=Rg,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=yg,d.map.depthTexture.magFilter=yg):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=gg,d.map.depthTexture.magFilter=gg);d.camera.updateProjectionMatrix()}d.map.isWebGLCubeRenderTarget!==!0&&(d.map.width!==i.x||d.map.height!==i.y)&&d.map.setSize(i.x,i.y);let g=d.map.isWebGLCubeRenderTarget?6:d.getViewportCount();l.isPointLight!==!0&&d.updateMatrices(l,s);let _=d.camera.layers.mask&4294967294?d.camera.layers:s.layers;for(let t=0;t<g;t++){let i=d.getCamera(t);if(l.isPointLight){let e=d.camera,n=d.matrix,r=l.distance||e.far;r!==e.far&&(e.far=r,e.updateProjectionMatrix()),$E.setFromMatrixPosition(l.matrixWorld),e.position.copy($E),eD.copy(e.position),eD.add(XE[t]),e.up.copy(ZE[t]),e.lookAt(eD),e.updateMatrixWorld(),n.makeTranslation(-$E.x,-$E.y,-$E.z),QE.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),d._frustum.setFromProjectionMatrix(QE,e.coordinateSystem,e.reversedDepth)}if(d.map.isWebGLCubeRenderTarget)e.setRenderTarget(d.map,t),e.clear();else{t===0&&(e.setRenderTarget(d.map),e.clear());let n=d.getViewport(t);o.set(a.x*n.x,a.y*n.y,a.x*n.z,a.y*n.w),f.viewport(o)}r=d.getFrustum(t),b(n,s,i,l,_,this.type)}d.isPointLightShadow!==!0&&this.type===3&&v(d,s),d.needsUpdate=!1}_=this.type,g.needsUpdate=!1,e.setRenderTarget(c,l,d)};function v(n,r){let a=t.update(h);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),n.mapPass===null?n.mapPass=new Xv(i.x,i.y,{format:Hg,type:kg}):(n.mapPass.width!==n.map.width||n.mapPass.height!==n.map.height)&&n.mapPass.setSize(n.map.width,n.map.height),f.uniforms.shadow_pass.value=n.map.depthTexture,f.uniforms.resolution.value.set(n.map.width,n.map.height),f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,a,f,h,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value.set(n.map.width,n.map.height),p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,a,p,h,null)}function y(t,n,r,i){let a=null,o=r.isPointLight===!0?t.customDistanceMaterial:t.customDepthMaterial;if(o!==void 0)a=o;else if(a=r.isPointLight===!0?c:s,e.localClippingEnabled&&n.clipShadows===!0&&Array.isArray(n.clippingPlanes)&&n.clippingPlanes.length!==0||n.displacementMap&&n.displacementScale!==0||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s,c){if(n.visible===!1)return;if(n.layers.test(s)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&c===3)&&(!n.frustumCulled||n.intersectsFrustum(r))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),s=n.material;if(Array.isArray(s)){let t=r.groups;for(let l=0,u=t.length;l<u;l++){let u=t[l],d=s[u.materialIndex];if(d&&d.visible){let t=y(n,d,o,c);n.onBeforeShadow(e,n,i,a,r,t,u),e.renderBufferDirect(a,null,r,t,n,u),n.onAfterShadow(e,n,i,a,r,t,u)}}}else if(s.visible){let t=y(n,s,o,c);n.onBeforeShadow(e,n,i,a,r,t,null),e.renderBufferDirect(a,null,r,t,n,null),n.onAfterShadow(e,n,i,a,r,t,null)}}let l=n.children;for(let e=0,t=l.length;e<t;e++)b(l[e],i,a,o,s,c)}function x(e){e.target.removeEventListener(`dispose`,x);for(let t in l){let n=l[t],r=e.target.uuid;r in n&&(n[r].dispose(),delete n[r])}}}function nD(e,t){function n(){let t=!1,n=new Jv,r=null,i=new Jv(0,0,0,0);return{setMask:function(n){r!==n&&!t&&(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){s===!0&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),i.equals(n)===!1&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}}function r(){let n=!1,r=!1,i=null,a=null,o=null;return{setReversed:function(e){if(r!==e){let n=t.get(`EXT_clip_control`);e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),r=e;let i=o;o=null,this.setClear(i)}},getReversed:function(){return r},setTest:function(t){t?le(e.DEPTH_TEST):ue(e.DEPTH_TEST)},setMask:function(t){i!==t&&!n&&(e.depthMask(t),i=t)},setFunc:function(t){if(r&&(t=$_[t]),a!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(o=t,r&&(t=1-t),e.clearDepth(t))},reset:function(){n=!1,i=null,a=null,o=null,r=!1}}}function i(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(n){t||(n?le(e.STENCIL_TEST):ue(e.STENCIL_TEST))},setMask:function(r){n!==r&&!t&&(e.stencilMask(r),n=r)},setFunc:function(t,n,o){(r!==t||i!==n||a!==o)&&(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){(o!==t||s!==n||c!==r)&&(e.stencilOp(t,n,r),o=t,s=n,c=r)},setLocked:function(e){t=e},setClear:function(t){l!==t&&(e.clearStencil(t),l=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}}let a=new n,o=new r,s=new i,c={},l=new WeakMap,u={},d={},f={},p=new WeakMap,m=[],h=null,g=!1,_=null,v=null,y=null,b=null,x=null,S=null,C=null,w=new Q(0,0,0),T=0,E=!1,D=null,O=null,k=null,A=null,j=null,M=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),N=!1,P=0,ee=e.getParameter(e.VERSION);ee.indexOf(`WebGL`)===-1?ee.indexOf(`OpenGL ES`)!==-1&&(P=parseFloat(/^OpenGL ES (\\d)/.exec(ee)[1]),N=P>=2):(P=parseFloat(/^WebGL (\\d)/.exec(ee)[1]),N=P>=1);let te=null,ne={},re=e.getParameter(e.SCISSOR_BOX),ie=e.getParameter(e.VIEWPORT),ae=new Jv().fromArray(re),oe=new Jv().fromArray(ie);function se(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<r;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,i,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}let ce={};ce[e.TEXTURE_2D]=se(e.TEXTURE_2D,e.TEXTURE_2D,1),ce[e.TEXTURE_CUBE_MAP]=se(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),ce[e.TEXTURE_2D_ARRAY]=se(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),ce[e.TEXTURE_3D]=se(e.TEXTURE_3D,e.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),s.setClear(0),le(e.DEPTH_TEST),o.setFunc(3),ve(!1),ye(1),le(e.CULL_FACE),ge(0);function le(t){u[t]!==!0&&(e.enable(t),u[t]=!0)}function ue(t){u[t]!==!1&&(e.disable(t),u[t]=!1)}function de(t,n){return f[t]!==n&&(e.bindFramebuffer(t,n),f[t]=n,t===e.DRAW_FRAMEBUFFER&&(f[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(f[e.DRAW_FRAMEBUFFER]=n),!0)}function fe(t,n){let r=m,i=!1;if(t){r=p.get(n),r===void 0&&(r=[],p.set(n,r));let a=t.textures;if(r.length!==a.length||r[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)r[t]=e.COLOR_ATTACHMENT0+t;r.length=a.length,i=!0}}else r[0]!==e.BACK&&(r[0]=e.BACK,i=!0);i&&e.drawBuffers(r)}function pe(t){return h!==t&&(e.useProgram(t),h=t,!0)}let me={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT};me[103]=e.MIN,me[104]=e.MAX;let he={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA,211:e.CONSTANT_COLOR,212:e.ONE_MINUS_CONSTANT_COLOR,213:e.CONSTANT_ALPHA,214:e.ONE_MINUS_CONSTANT_ALPHA};function ge(t,n,r,i,a,o,s,c,l,u){if(t===0)g===!0&&(ue(e.BLEND),g=!1);else if(g===!1&&(le(e.BLEND),g=!0),t!==5){if(t!==_||u!==E){if((v!==100||x!==100)&&(e.blendEquation(e.FUNC_ADD),v=100,x=100),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:X_(`WebGLState: Invalid blending: `,t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:X_(`WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true`);break;case 4:X_(`WebGLState: MultiplyBlending requires material.premultipliedAlpha = true`);break;default:X_(`WebGLState: Invalid blending: `,t)}y=null,b=null,S=null,C=null,w.set(0,0,0),T=0,_=t,E=u}}else a||=n,o||=r,s||=i,(n!==v||a!==x)&&(e.blendEquationSeparate(me[n],me[a]),v=n,x=a),(r!==y||i!==b||o!==S||s!==C)&&(e.blendFuncSeparate(he[r],he[i],he[o],he[s]),y=r,b=i,S=o,C=s),(c.equals(w)===!1||l!==T)&&(e.blendColor(c.r,c.g,c.b,l),w.copy(c),T=l),_=t,E=!1}function _e(t,n){t.side===2?ue(e.CULL_FACE):le(e.CULL_FACE);let r=t.side===1;n&&(r=!r),ve(r),t.blending===1&&t.transparent===!1?ge(0):ge(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),o.setFunc(t.depthFunc),o.setTest(t.depthTest),o.setMask(t.depthWrite),a.setMask(t.colorWrite);let i=t.stencilWrite;s.setTest(i),i&&(s.setMask(t.stencilWriteMask),s.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),s.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),xe(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),t.alphaToCoverage===!0?le(e.SAMPLE_ALPHA_TO_COVERAGE):ue(e.SAMPLE_ALPHA_TO_COVERAGE)}function ve(t){D!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),D=t)}function ye(t){t===0?ue(e.CULL_FACE):(le(e.CULL_FACE),t!==O&&(t===1?e.cullFace(e.BACK):t===2?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))),O=t}function be(t){t!==k&&(N&&e.lineWidth(t),k=t)}function xe(t,n,r){t?(le(e.POLYGON_OFFSET_FILL),(A!==n||j!==r)&&(A=n,j=r,o.getReversed()&&(n=-n,r=-r),e.polygonOffset(n,r))):ue(e.POLYGON_OFFSET_FILL)}function Se(t){t?le(e.SCISSOR_TEST):ue(e.SCISSOR_TEST)}function Ce(t){t===void 0&&(t=e.TEXTURE0+M-1),te!==t&&(e.activeTexture(t),te=t)}function F(t,n,r){r===void 0&&(r=te===null?e.TEXTURE0+M-1:te);let i=ne[r];i===void 0&&(i={type:void 0,texture:void 0},ne[r]=i),(i.type!==t||i.texture!==n)&&(te!==r&&(e.activeTexture(r),te=r),e.bindTexture(t,n||ce[t]),i.type=t,i.texture=n)}function we(){let t=ne[te];t!==void 0&&t.type!==void 0&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)}function Te(){try{e.compressedTexImage2D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function Ee(){try{e.compressedTexImage3D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function I(){try{e.texSubImage2D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function De(){try{e.texSubImage3D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function L(){try{e.compressedTexSubImage2D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function R(){try{e.compressedTexSubImage3D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function Oe(){try{e.texStorage2D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function ke(){try{e.texStorage3D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function Ae(){try{e.texImage2D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function je(){try{e.texImage3D(...arguments)}catch(e){X_(`WebGLState:`,e)}}function Me(t){return d[t]===void 0?e.getParameter(t):d[t]}function Ne(t,n){d[t]!==n&&(e.pixelStorei(t,n),d[t]=n)}function Pe(t){ae.equals(t)===!1&&(e.scissor(t.x,t.y,t.z,t.w),ae.copy(t))}function Fe(t){oe.equals(t)===!1&&(e.viewport(t.x,t.y,t.z,t.w),oe.copy(t))}function Ie(t,n){let r=l.get(n);r===void 0&&(r=new WeakMap,l.set(n,r));let i=r.get(t);i===void 0&&(i=e.getUniformBlockIndex(n,t.name),e.uniformBlockBinding(n,i,i),r.set(t,i))}function Le(t,n,r){let i=l.get(n).get(t);c[i]!==r&&(e.bindBufferBase(e.UNIFORM_BUFFER,i,r),c[i]=r)}function z(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},te=null,ne={},f={},c={},p=new WeakMap,m=[],h=null,g=!1,_=null,v=null,y=null,b=null,x=null,S=null,C=null,w=new Q(0,0,0),T=0,E=!1,D=null,O=null,k=null,A=null,j=null,ae.set(0,0,e.canvas.width,e.canvas.height),oe.set(0,0,e.canvas.width,e.canvas.height),a.reset(),o.reset(),s.reset()}return{buffers:{color:a,depth:o,stencil:s},enable:le,disable:ue,bindFramebuffer:de,drawBuffers:fe,useProgram:pe,setBlending:ge,setMaterial:_e,setFlipSided:ve,setCullFace:ye,setLineWidth:be,setPolygonOffset:xe,setScissorTest:Se,activeTexture:Ce,bindTexture:F,unbindTexture:we,compressedTexImage2D:Te,compressedTexImage3D:Ee,texImage2D:Ae,texImage3D:je,pixelStorei:Ne,getParameter:Me,updateUBOMapping:Ie,uniformBlockBinding:Le,texStorage2D:Oe,texStorage3D:ke,texSubImage2D:I,texSubImage3D:De,compressedTexSubImage2D:L,compressedTexSubImage3D:R,scissor:Pe,viewport:Fe,reset:z}}function rD(e,t,n,r,i,a,o){let s=t.has(`WEBGL_multisampled_render_to_texture`)?t.get(`WEBGL_multisampled_render_to_texture`):null,c=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new X,u=new WeakMap,d=new Set,f,p=new WeakMap,m=new Set,h=new FinalizationRegistry(e=>m.delete(e)),g=!1;try{g=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function _(e,t){return g?new OffscreenCanvas(e,t):W_(`canvas`)}function v(e,t,n){let r=1,i=Oe(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=_(n,a));let o=t?_(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),Y_(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}return`data`in e&&Y_(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e}return e}function y(e){return e.generateMipmaps}function b(t){e.generateMipmap(t)}function x(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 S(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];Y_(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||Y_(`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?L_:Lv.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 C(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,Y_(`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 w(e,t){return y(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function T(e){let t=new WeakRef(e);r.get(e).__ref=t,m.add(t),h.register(e,t,t)}function E(e){let t=r.get(e).__ref;t!==void 0&&(m.delete(t),h.unregister(t))}function D(e){k(e.target)}function O(e){A(e.target)}function k(e){e.removeEventListener(`dispose`,D),E(e),M(e),e.isVideoTexture&&u.delete(e),e.isHTMLTexture&&d.delete(e)}function A(e){e.removeEventListener(`dispose`,O),E(e),P(e)}function j(){for(let e of m){let t=e.deref();t!==void 0&&(t.isRenderTarget===!0?A(t):k(t))}m.clear(),d.clear()}function M(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&&N(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function N(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 P(t){let n=r.get(t);n.__depthDisposeCallback&&n.__depthDisposeCallback();let i=t.depthTexture;if(i&&i.renderTarget===t&&k(i),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r<n.__webglFramebuffer[t].length;r++)e.deleteFramebuffer(n.__webglFramebuffer[t][r]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}let a=t.textures;for(let t=0,n=a.length;t<n;t++){let n=r.get(a[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),o.memory.textures--),r.remove(a[t])}r.remove(t)}let ee=0;function te(){ee=0}function ne(){return ee}function re(e){ee=e}function ie(){let e=ee;return e>=i.maxTextures&&Y_(`WebGLTextures: Trying to use `+(e+1)+` texture units while this GPU supports only `+i.maxTextures),ee+=1,e}function ae(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.mipmapsAutoUpdate),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function oe(t,i){let a=r.get(t);if(t.isVideoTexture&&L(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)Y_(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)Y_(`WebGLRenderer: Texture marked for update but image is incomplete`);else{_e(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 se(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?_e(a,t,i):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i))}function ce(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?_e(a,t,i):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function le(t,i){let a=r.get(t);t.version>0&&a.__version!==t.version?ve(a,t,i):n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let ue={[pg]:e.REPEAT,[mg]:e.CLAMP_TO_EDGE,[hg]:e.MIRRORED_REPEAT},de={[gg]:e.NEAREST,[_g]:e.NEAREST_MIPMAP_NEAREST,[vg]:e.NEAREST_MIPMAP_LINEAR,[yg]:e.LINEAR,[bg]:e.LINEAR_MIPMAP_NEAREST,[xg]:e.LINEAR_MIPMAP_LINEAR},fe={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 pe(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)&&Y_(`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,ue[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,ue[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,ue[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,de[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,de[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,fe[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 me(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,D),T(n));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=ae(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&&N(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function he(e,t,n){return Math.floor(Math.floor(e/n)/t)}function ge(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e<o.length;e++){let t=o[s],n=o[e],i=t.start+t.count,a=he(n.start,r.width,4),c=he(t.start,r.width,4);n.start<=i+1&&a===c&&he(n.start+n.count-1,r.width,4)===a?t.count=Math.max(t.count,n.start+n.count-t.start):(++s,o[s]=n)}o.length=s+1;let c=n.getParameter(e.UNPACK_ROW_LENGTH),l=n.getParameter(e.UNPACK_SKIP_PIXELS),u=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,r.width);for(let t=0,s=o.length;t<s;t++){let s=o[t],c=Math.floor(s.start/4),l=Math.ceil(s.count/4),u=c%r.width,d=Math.floor(c/r.width),f=l;n.pixelStorei(e.UNPACK_SKIP_PIXELS,u),n.pixelStorei(e.UNPACK_SKIP_ROWS,d),n.texSubImage2D(e.TEXTURE_2D,0,u,d,f,1,i,a,r.data)}t.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,c),n.pixelStorei(e.UNPACK_SKIP_PIXELS,l),n.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}function _e(t,o,s){let c=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(c=e.TEXTURE_3D);let l=me(t,o),u=o.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+s);let f=r.get(u);if(u.version!==f.__version||l===!0){if(n.activeTexture(e.TEXTURE0+s),!(typeof ImageBitmap<`u`&&o.image instanceof ImageBitmap)){let t=Lv.getPrimaries(Lv.workingColorSpace),r=o.colorSpace===``?null:Lv.getPrimaries(o.colorSpace),i=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,i)}n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment);let t=v(o.image,!1,i.maxTextureSize);t=R(o,t);let r=a.convert(o.format,o.colorSpace),p=a.convert(o.type),m=S(o.internalFormat,r,p,o.normalized,o.colorSpace,o.isVideoTexture);pe(c,o);let h,g=o.mipmaps,_=o.isVideoTexture!==!0,x=f.__version===void 0||l===!0,T=u.dataReady,E=w(o,t);if(o.isDepthTexture)m=C(o.format===zg,o.type),x&&(_?n.texStorage2D(e.TEXTURE_2D,1,m,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,r,p,null));else if(o.isDataTexture){if(g.length>0){_&&x&&n.texStorage2D(e.TEXTURE_2D,E,m,g[0].width,g[0].height);for(let t=0,i=g.length;t<i;t++)h=g[t],_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,p,h.data):n.texImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,r,p,h.data);o.generateMipmaps=!1}else _?(x&&n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height),T&&ge(o,t,r,p)):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,r,p,t.data)}else if(o.isCompressedTexture){if(o.isCompressedArrayTexture){_&&x&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,g[0].width,g[0].height,t.depth);for(let i=0,a=g.length;i<a;i++)if(h=g[i],o.format!==1023){if(r!==null){if(_){if(T){if(o.layerUpdates.size>0){let t=iw(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)}}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 Y_(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`)}else _?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);o.layerUpdates.size>0&&o.clearLayerUpdates()}else{_&&x&&n.texStorage2D(e.TEXTURE_2D,E,m,g[0].width,g[0].height);for(let t=0,i=g.length;t<i;t++)h=g[t],o.format===1023?_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,p,h.data):n.texImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,r,p,h.data):r===null?Y_(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`):_?T&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,h.data):n.compressedTexImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,h.data)}}else if(o.isDataArrayTexture){if(_){if(x&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,t.width,t.height,t.depth),T){if(o.layerUpdates.size>0){let i=iw(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)_?(x&&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(x){if(_)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t<E;t++)n.texImage2D(e.TEXTURE_2D,t,m,i,a,0,r,p,null),i>>=1,a>>=1}}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}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(g.length>0){if(_&&x){let t=Oe(g[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=g.length;t<i;t++)h=g[t],_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,r,p,h):n.texImage2D(e.TEXTURE_2D,t,m,r,p,h);o.generateMipmaps=!1}else if(_){if(x){let r=Oe(t);n.texStorage2D(e.TEXTURE_2D,E,m,r.width,r.height)}T&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,r,p,t)}else n.texImage2D(e.TEXTURE_2D,0,m,r,p,t);y(o)&&o.mipmapsAutoUpdate===!0&&b(c),f.__version=u.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function ve(t,o,s){if(o.image.length!==6)return;let c=me(t,o),l=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=r.get(l);if(l.version!==u.__version||c===!0){n.activeTexture(e.TEXTURE0+s);let t=Lv.getPrimaries(Lv.workingColorSpace),r=o.colorSpace===``?null:Lv.getPrimaries(o.colorSpace),d=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let f=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,m=[];for(let e=0;e<6;e++)!f&&!p?m[e]=v(o.image[e],!0,i.maxCubemapSize):m[e]=p?o.image[e].image:o.image[e],m[e]=R(o,m[e]);let h=m[0],g=a.convert(o.format,o.colorSpace),_=a.convert(o.type),x=S(o.internalFormat,g,_,o.normalized,o.colorSpace),T=o.isVideoTexture!==!0,E=u.__version===void 0||c===!0,D=l.dataReady,O=w(o,h);pe(e.TEXTURE_CUBE_MAP,o);let k;if(o.isDepthTexture){if(x=C(o.format===zg,o.type),E){if(T)n.texStorage2D(e.TEXTURE_CUBE_MAP,1,x,h.width,h.height);else for(let t=0;t<6;t++)n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,h.width,h.height,0,g,_,null)}}else if(f){T&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,O,x,h.width,h.height);for(let t=0;t<6;t++){k=m[t].mipmaps;for(let r=0;r<k.length;r++){let i=k[r];o.format===1023?T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,g,_,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,x,i.width,i.height,0,g,_,i.data):g===null?Y_(`WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()`):T?D&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,g,i.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,x,i.width,i.height,0,i.data)}}}else{if(k=o.mipmaps,T&&E){k.length>0&&O++;let t=Oe(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,O,x,t.width,t.height)}for(let t=0;t<6;t++)if(p){T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,g,_,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,m[t].width,m[t].height,0,g,_,m[t].data);for(let r=0;r<k.length;r++){let i=k[r].image[t].image;T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,i.width,i.height,g,_,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,x,i.width,i.height,0,g,_,i.data)}}else{T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,_,m[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,g,_,m[t]);for(let r=0;r<k.length;r++){let i=k[r];T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,g,_,i.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,x,g,_,i.image[t])}}}y(o)&&o.mipmapsAutoUpdate===!0&&b(e.TEXTURE_CUBE_MAP),u.__version=l.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function ye(t,i,o,c,l,u){let d=a.convert(o.format,o.colorSpace),f=a.convert(o.type),p=S(o.internalFormat,d,f,o.normalized,o.colorSpace),m=r.get(i),h=r.get(o);if(h.__renderTarget=i,!m.__hasExternalTextures){let t=Math.max(1,i.width>>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),De(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,I(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 be(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=C(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;De(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,I(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,I(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i<t.length;i++){let o=t[i],c=a.convert(o.format,o.colorSpace),l=a.convert(o.type),u=S(o.internalFormat,c,l,o.normalized,o.colorSpace);De(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,I(n),u,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,I(n),u,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,u,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function xe(t,i,a){let o=i.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,t),!(i.depthTexture&&i.depthTexture.isDepthTexture))throw Error(`THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.`);let c=r.get(i.depthTexture);c.__renderTarget=i;let l=o?i.depthTexture.image[0]:i.depthTexture.image;c.__webglTexture&&l.width===i.width&&l.height===i.height||(l.width=i.width,l.height=i.height,i.depthTexture.needsUpdate=!0),o?le(i.depthTexture,0):oe(i.depthTexture,0);let u=c.__webglTexture,d=I(i),f=o?e.TEXTURE_CUBE_MAP_POSITIVE_X+a:e.TEXTURE_2D,p=i.depthTexture.format===1027?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(i.depthTexture.format===1026)De(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,u,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,u,0);else if(i.depthTexture.format===1027)De(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,u,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,u,0);else throw Error(`THREE.WebGLTextures: Unknown depthTexture format.`)}function Se(t){let i=r.get(t),a=t.isWebGLCubeRenderTarget===!0;if(i.__boundDepthTexture!==t.depthTexture){let e=t.depthTexture;if(i.__depthDisposeCallback&&i.__depthDisposeCallback(),e){let t=()=>{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)for(let e=0;e<6;e++)xe(i.__webglFramebuffer[e],t,e);else t.texture.mipmaps.length>0?xe(i.__webglFramebuffer[0],t,0):xe(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(),be(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 if(t.texture.mipmaps.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),be(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&&ye(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&Se(t)}function F(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,O),T(t);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.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n<i.mipmaps.length;n++)s.__webglFramebuffer[t][n]=e.createFramebuffer()}else s.__webglFramebuffer[t]=e.createFramebuffer()}else{if(i.mipmaps.length>0){s.__webglFramebuffer=[];for(let t=0;t<i.mipmaps.length;t++)s.__webglFramebuffer[t]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(d)for(let t=0,n=l.length;t<n;t++){let n=r.get(l[t]);n.__webglTexture===void 0&&(n.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&De(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n<l.length;n++){let r=l[n];s.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[n]);let i=a.convert(r.format,r.colorSpace),o=a.convert(r.type),c=S(r.internalFormat,i,o,r.normalized,r.colorSpace,t.isXRRenderTarget===!0),u=I(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,c,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,s.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),be(s.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),pe(e.TEXTURE_CUBE_MAP,i);for(let n=0;n<6;n++)if(i.mipmaps.length>0)for(let r=0;r<i.mipmaps.length;r++)ye(s.__webglFramebuffer[n][r],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,r);else ye(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);y(i)?b(e.TEXTURE_CUBE_MAP):i.mipmaps.length>0&&e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAX_LEVEL,i.mipmaps.length-1),n.unbindTexture()}else if(d){for(let i=0,a=l.length;i<a;i++){let a=l[i],o=r.get(a),c=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(c=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(c,o.__webglTexture),pe(c,a),ye(s.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+i,c,0),y(a)&&b(c)}n.unbindTexture()}else{let r=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(r,c.__webglTexture),pe(r,i),i.mipmaps.length>0)for(let n=0;n<i.mipmaps.length;n++)ye(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,r,n);else ye(s.__webglFramebuffer,t,i,e.COLOR_ATTACHMENT0,r,0);y(i)?b(r):i.mipmaps.length>0&&e.texParameteri(r,e.TEXTURE_MAX_LEVEL,i.mipmaps.length-1),n.unbindTexture()}t.depthBuffer&&Se(t)}function we(e){let t=e.textures;for(let i=0,a=t.length;i<a;i++){let a=t[i];if(y(a)&&a.mipmapsAutoUpdate===!0){let t=x(e),i=r.get(a).__webglTexture;n.bindTexture(t,i),b(t),n.unbindTexture()}}}let Te=[];function Ee(t){if(t.samples>0){if(De(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t<i.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.texture.mipmaps.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<i.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),d){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]);let t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),c===!0&&(Te.length=0,Te.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&t.storeMultisampledDepthBuffer===!1&&Te.push(l),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,Te))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),d)for(let t=0;t<i.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);let a=r.get(i[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&t.storeMultisampledDepthBuffer===!1&&c){let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}}}function I(e){return Math.min(i.maxSamples,e.samples)}function De(e){let n=r.get(e);return e.samples>0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function L(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function R(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(Lv.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&Y_(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):X_(`WebGLTextures: Unsupported texture color space:`,n)),t}function Oe(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=ie,this.resetTextureUnits=te,this.getTextureUnits=ne,this.setTextureUnits=re,this.setTexture2D=oe,this.setTexture2DArray=se,this.setTexture3D=ce,this.setTextureCube=le,this.rebindTextures=Ce,this.setupRenderTarget=F,this.updateRenderTargetMipmap=we,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=Se,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=De,this.dispose=j}function iD(e,t){function n(n,r=``){let i,a=Lv.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 aD=`\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}`,oD=`\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n if ( coord.x >= 1.0 ) {\n\n gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n } else {\n\n gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n }\n\n}`,sD=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new tS(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 bS({vertexShader:aD,fragmentShader:oD,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new wx(new lS(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},cD=class extends ev{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 sD,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new X,C=null,w=null,T=new _C;T.viewport=new Jv;let E=new _C;E.viewport=new Jv;let D=[T,E],O=new OC,k=null,A=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new ky,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new ky,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new ky,b[e]=t),t.getHandSpace()};function j(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 M(){r.removeEventListener(`select`,j),r.removeEventListener(`selectstart`,j),r.removeEventListener(`selectend`,j),r.removeEventListener(`squeeze`,j),r.removeEventListener(`squeezestart`,j),r.removeEventListener(`squeezeend`,j),r.removeEventListener(`end`,M),r.removeEventListener(`inputsourceschange`,N);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}k=null,A=null,h.reset();for(let e in g)delete g[e];if(e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,re.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),w!==null){let e=w.camera;e.fov=w.fov,e.zoom=w.zoom,e.updateProjectionMatrix(),w=null}n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&Y_(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&Y_(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,j),r.addEventListener(`selectstart`,j),r.addEventListener(`selectend`,j),r.addEventListener(`squeeze`,j),r.addEventListener(`squeezestart`,j),r.addEventListener(`squeezeend`,j),r.addEventListener(`end`,M),r.addEventListener(`inputsourceschange`,N),_.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?zg:Rg,a=_.stencil?Mg:Dg);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new Xv(d.textureWidth,d.textureHeight,{format:Lg,type:Sg,depthTexture:new $x(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Xv(f.framebufferWidth,f.framebufferHeight,{format:Lg,type:Sg,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),re.setContext(r),re.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function N(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}function P(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)),O.near=E.near=T.near=t,O.far=E.far=T.far=n,(k!==O.near||A!==O.far)&&(r.updateRenderState({depthNear:O.near,depthFar:O.far}),k=O.near,A=O.far),O.layers.mask=e.layers.mask|6,T.layers.mask=O.layers.mask&-5,E.layers.mask=O.layers.mask&-3;let i=e.parent,a=O.cameras;P(O,i);for(let e=0;e<a.length;e++)P(a[e],i);O.projectionMatrix.copy(T.projectionMatrix),O.projectionMatrixInverse.copy(T.projectionMatrixInverse),w===null&&e.isPerspectiveCamera&&(w={camera:e,fov:e.fov,zoom:e.zoom}),ee(e,O,i)};function ee(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=iv*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(d!==null||f!==null)return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(O)},this.getCameraTexture=function(e){return g[e]};let te=null;function ne(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==O.cameras.length&&(O.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=D[n];o===void 0&&(o=new _C,o.layers.enable(n),o.viewport=new Jv,D[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(O.matrix.copy(o.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),i===!0&&O.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&m){u=n.getBinding();let e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&h.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&m){e.state.unbindTexture(),u=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new tS,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}te&&te(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let re=new ow;re.setAnimationLoop(ne),this.setAnimationLoop=function(e){te=e},this.dispose=function(){}}},lD=new $v,uD=new Mv;uD.set(-1,0,0,0,1,0,0,0,1);function dD(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,gS(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isNodeMaterial?t.uniformsNeedUpdate=!1:t.isMeshBasicMaterial?a(e,t):t.isMeshLambertMaterial?(a(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(lD.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(uD),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.diffuseRoughness>0&&(e.diffuseRoughness.value=t.diffuseRoughness,t.diffuseRoughnessMap&&(e.diffuseRoughnessMap.value=t.diffuseRoughnessMap,n(t.diffuseRoughnessMap,e.diffuseRoughnessMapTransform))),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.retroreflectivity>0&&(e.retroreflectivity.value=t.retroreflectivity),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessMinimum,e.iridescenceThicknessMaximum.value=t.iridescenceThicknessMaximum,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 fD(e,t,n,r){let i={},a={};function o(e,t){let n=t.program;r.uniformBlockBinding(e,n,i[e.id])}function s(e,n){let o=i[e.id];o===void 0&&(m(e),o=c(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let u=t.render.frame;a[e.id]!==u&&(l(e),a[e.id]=u)}function c(t){let n=e.createBuffer(),r=t.__size,i=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,n),e.bufferData(e.UNIFORM_BUFFER,r,i),e.bindBuffer(e.UNIFORM_BUFFER,null),n}function l(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let e=0,t=r.length;e<t;e++){let t=r[e];if(Array.isArray(t))for(let n=0,r=t.length;n<r;n++)u(t[n],e,n,a);else u(t,e,0,a)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function u(t,n,r,i){if(f(t,n,r,i)===!0){let n=t.__offset,r=t.value;if(Array.isArray(r)){let e=0;for(let n=0;n<r.length;n++){let i=r[n],a=h(i,!0);d(i,t.__data,e),e+=a.storage/Float32Array.BYTES_PER_ELEMENT}}else d(r,t.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,n,t.__data)}}function d(e,t,n){typeof e==`number`||typeof e==`boolean`?t[n]=e:e.isMatrix3?(t[n]=e.elements[0],t[n+1]=e.elements[1],t[n+2]=e.elements[2],t[n+3]=0,t[n+4]=e.elements[3],t[n+5]=e.elements[4],t[n+6]=e.elements[5],t[n+7]=0,t[n+8]=e.elements[6],t[n+9]=e.elements[7],t[n+10]=e.elements[8],t[n+11]=0):ArrayBuffer.isView(e)?t.set(e.subarray(0,t.length-n),n):e.toArray(t,n)}function f(e,t,n,r){let i=e.value,a=t+`_`+n;if(Array.isArray(i)){r[a]===void 0&&(r[a]=[]);let e=r[a],t=!1;for(let n=0;n<i.length;n++)p(i[n],e,n)===!0&&(t=!0);return t}return p(i,r,a)}function p(e,t,n){if(t[n]===void 0)return t[n]=typeof e==`number`||typeof e==`boolean`?e:ArrayBuffer.isView(e)?e.slice():e.clone(),!0;{let r=t[n];if(typeof e==`number`||typeof e==`boolean`){if(r!==e)return t[n]=e,!0}else if(ArrayBuffer.isView(e))return!0;else if(r.equals(e)===!1)return r.copy(e),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let i=0,a=r.length;i<a;i++){let a=r[i],o=Array.isArray(a.value)?a.value:[a.value],s=Array.isArray(t[e])||Array.isArray(a.value),c=n;for(let e=0,t=o.length;e<t;e++){let t=o[e],r=h(t,s),i=n%16,a=i%r.boundary,l=i+a;n+=a,l!==0&&16-l<r.storage&&(n+=16-l),e===0&&(c=n),n+=r.storage}a.__data=new(a.type===`int`?Int32Array:a.type===`uint`?Uint32Array:Float32Array)((n-c)/Float32Array.BYTES_PER_ELEMENT),a.__offset=c}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e,t){let n={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(n.boundary=4,n.storage=4):e.isVector2?(n.boundary=8,n.storage=8):e.isVector3||e.isColor?(n.boundary=16,n.storage=12):e.isVector4?(n.boundary=16,n.storage=16):e.isMatrix3?(n.boundary=16,n.storage=48):e.isMatrix4?(n.boundary=16,n.storage=64):e.isTexture?Y_(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(n.boundary=16,n.storage=e.byteLength):Y_(`WebGLRenderer: Unsupported uniform value type.`,e),t===!0&&(n.boundary=16,n.storage=Math.ceil(n.storage/16)*16),n}function g(t){let n=t.target;n.removeEventListener(`dispose`,g),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);i={},a={}}return{bind:o,update:s,dispose:_}}var pD=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]),mD=null;function hD(){return mD===null&&(mD=new Dx(pD,16,16,Hg,kg),mD.name=`DFG_LUT`,mD.minFilter=yg,mD.magFilter=yg,mD.wrapS=mg,mD.wrapT=mg,mD.generateMipmaps=!1,mD.needsUpdate=!0),mD}var gD=class{constructor(e={}){let{canvas:t=G_(),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=Sg}=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([Wg,Ug,Vg]),g=new Set([Sg,Dg,Tg,Mg,Ag,jg]),_=new Uint32Array(4),v=new Int32Array(4),y={textures:[],min:[],max:[],resolution:[]},b=null,x=null,S=[],C=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},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=F_;let j=0,M=0,N=null,P=-1,ee=null,te=new Jv,ne=new Jv,re=null,ie=new Q(0),ae=0,oe=t.width,se=t.height,ce=1,le=null,ue=null,de=new Jv(0,0,oe,se),fe=new Jv(0,0,oe,se),pe=!1,me=new jx,he=new Nx,ge=!1,_e=!1,ve=new $v,ye=new Z,be=new Jv,xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Se=!1;function Ce(){return N===null?ce:1}let F=n;function we(e,n){return t.getContext(e,n)}let Te,Ee,I,De,L,R,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,z,Re,ze,Be,Ve,He,Ue;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 r187`),t.addEventListener(`webglcontextlost`,Ke,!1),t.addEventListener(`webglcontextrestored`,qe,!1),t.addEventListener(`webglcontextcreationerror`,Je,!1),F===null){let t=`webgl2`;if(F=we(t,e),F===null)throw we(t)?Error(`THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.`):Error(`THREE.WebGLRenderer: Error creating WebGL context.`)}We()}catch(e){throw t.removeEventListener(`webglcontextlost`,Ke,!1),t.removeEventListener(`webglcontextrestored`,qe,!1),t.removeEventListener(`webglcontextcreationerror`,Je,!1),X_(`WebGLRenderer: `+e.message),e}function We(){Te=new Iw(F),Te.init(),Ve=new iD(F,Te),Ee=new gw(F,Te,e,Ve),I=new nD(F,Te),Ee.reversedDepthBuffer&&d&&I.buffers.depth.setReversed(!0),O=F.createFramebuffer(),k=F.createFramebuffer(),A=F.createFramebuffer(),De=new zw(F),L=new IE,R=new rD(F,Te,I,L,Ee,Ve,De),Oe=new Fw(T),ke=new sw(F),He=new mw(F,ke),Ae=new Lw(F,ke,De,He),je=new Vw(F,Ae,ke,He,De),Re=new Bw(F,Ee,R),Ie=new _w(L),Me=new FE(T,Oe,Te,Ee,He,Ie),Ne=new dD(T,L),Pe=new BE,Fe=new qE(Te),z=new pw(T,Oe,I,je,p,s),Le=new tD(T,je,Ee),Ue=new fD(F,De,Ee,I),ze=new hw(F,Te,De),Be=new Rw(F,Te,De),De.programs=Me.programs,T.capabilities=Ee,T.extensions=Te,T.properties=L,T.renderLists=Pe,T.shadowMap=Le,T.state=I,T.info=De}m!==1009&&(w=new Uw(m,t.width,t.height,o,r,i));let Ge=new cD(T,F);this.xr=Ge,this.getContext=function(){return F},this.getContextAttributes=function(){return F.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 ce},this.setPixelRatio=function(e){e!==void 0&&(ce=e,this.setSize(oe,se,!1))},this.getSize=function(e){return e.set(oe,se)},this.setSize=function(e,n,r=!0){Ge.isPresenting?Y_(`WebGLRenderer: Can't change size while VR device is presenting.`):(oe=e,se=n,t.width=Math.floor(e*ce),t.height=Math.floor(n*ce),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(oe*ce,se*ce).floor()},this.setDrawingBufferSize=function(e,n,r){oe=e,se=n,ce=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)X_(`WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);else{if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){Y_(`WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}w.setEffects(e||[])}},this.getCurrentViewport=function(e){return e.copy(te)},this.getViewport=function(e){return e.copy(de)},this.setViewport=function(e,t,n,r){e.isVector4?de.set(e.x,e.y,e.z,e.w):de.set(e,t,n,r),I.viewport(te.copy(de).multiplyScalar(Ce()).round())},this.getScissor=function(e){return e.copy(fe)},this.setScissor=function(e,t,n,r){e.isVector4?fe.set(e.x,e.y,e.z,e.w):fe.set(e,t,n,r),I.scissor(ne.copy(fe).multiplyScalar(Ce()).round())},this.getScissorTest=function(){return pe},this.setScissorTest=function(e){I.setScissorTest(pe=e)},this.setOpaqueSort=function(e){le=e},this.setTransparentSort=function(e){ue=e},this.getClearColor=function(e){return e.copy(z.getClearColor())},this.setClearColor=function(){z.setClearColor(...arguments)},this.getClearAlpha=function(){return z.getClearAlpha()},this.setClearAlpha=function(){z.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(N!==null){let t=N.texture.format;e=h.has(t)}if(e){let e=N.texture.type,t=g.has(e),n=z.getClearColor(),r=z.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,F.clearBufferuiv(F.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,F.clearBufferiv(F.COLOR,0,v))}else r|=F.COLOR_BUFFER_BIT}t&&(r|=F.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(r|=F.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&F.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(e){e.setRenderer(this),D=e},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Ke,!1),t.removeEventListener(`webglcontextrestored`,qe,!1),t.removeEventListener(`webglcontextcreationerror`,Je,!1),z.dispose(),Pe.dispose(),Fe.dispose(),R.dispose(),L.dispose(),Oe.dispose(),je.dispose(),Ae.dispose(),He.dispose(),Ue.dispose(),Me.dispose(),Ge.dispose(),Ge.removeEventListener(`sessionstart`,tt),Ge.removeEventListener(`sessionend`,nt),rt.stop()};function Ke(e){e.preventDefault(),q_(`WebGLRenderer: Context Lost.`),E=!0}function qe(){q_(`WebGLRenderer: Context Restored.`),E=!1;let e=De.autoReset,t=Le.enabled,n=Le.autoUpdate,r=Le.needsUpdate,i=Le.type;We(),De.autoReset=e,Le.enabled=t,Le.autoUpdate=n,Le.needsUpdate=r,Le.type=i}function Je(e){X_(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Ye(e){let t=e.target;t.removeEventListener(`dispose`,Ye),Xe(t)}function Xe(e){Ze(e),L.remove(e)}function Ze(e){let t=L.get(e).programs;t!==void 0&&(t.forEach(function(e){Me.releaseProgram(e)}),e.isShaderMaterial&&Me.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=xe);let o=i.isMesh&&i.matrixWorld.determinantAffine()<0,s=mt(e,t,n,r,i);I.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=Ae.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;He.setup(i,r,s,n,c);let h,g=ze;if(c!==null&&(h=ke.get(c),g=Be,g.setIndex(h)),i.isMesh)r.wireframe===!0?(I.setLineWidth(r.wireframeLinewidth*Ce()),g.setMode(F.LINES)):g.setMode(F.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),I.setLineWidth(e*Ce()),i.isLineSegments?g.setMode(F.LINES):i.isLineLoop?g.setMode(F.LINE_LOOP):g.setMode(F.LINE_STRIP)}else i.isPoints?g.setMode(F.POINTS):i.isSprite&&g.setMode(F.TRIANGLES);if(i.isBatchedMesh){if(Te.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?ke.get(c).bytesPerElement:1,o=L.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(F,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Qe(e,t,n,r){D!==null&&e.isNodeMaterial&&D.setObject(r,e),ge===!0&&Ie.setState(e,n,!1),e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,ut(e,t,r),e.side=0,e.needsUpdate=!0,ut(e,t,r),e.side=2):ut(e,t,r)}this.compile=function(e,t,n=null){n===null&&(n=e),D!==null&&D.renderStart(e,t,n),x=Fe.get(n),x.init(t),C.push(x),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),x.setupLights(),D!==null&&D.updateLights(x.state.lightsArray),_e=this.localClippingEnabled,ge=Ie.init(this.clippingPlanes,_e),ge===!0&&Ie.setGlobalState(this.clippingPlanes,t),D!==null&&Le.render(x.state.shadowsArray,n,t);let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let i=e.material;if(i){if(Array.isArray(i))for(let a=0;a<i.length;a++){let o=i[a];Qe(o,n,t,e),r.add(o)}else Qe(i,n,t,e),r.add(i)}}),x=C.pop(),D!==null&&D.renderEnd(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){r.forEach(function(e){let t=L.get(e).currentProgram;(t===void 0||t.isReady())&&r.delete(e)}),r.size===0?t(e):setTimeout(n,10)}Te.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let $e=null;function et(e){$e&&$e(e)}function tt(){rt.stop()}function nt(){rt.start()}let rt=new ow;rt.setAnimationLoop(et),typeof self<`u`&&rt.setContext(self),this.setAnimationLoop=function(e){$e=e,Ge.setAnimationLoop(e),e===null?rt.stop():rt.start()},Ge.addEventListener(`sessionstart`,tt),Ge.addEventListener(`sessionend`,nt),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){X_(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=Ge.enabled===!0&&Ge.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(),Ge.enabled===!0&&Ge.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Ge.cameraAutoUpdate===!0&&Ge.updateCamera(t),t=Ge.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,N),x=Fe.get(e,C.length),x.init(t),x.state.textureUnits=R.getTextureUnits(),C.push(x),ve.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),t.isArrayCamera?he.setFromArrayCamera(t):me.setFromProjectionMatrix(ve,V_,t.reversedDepth),_e=this.localClippingEnabled,ge=Ie.init(this.clippingPlanes,_e),b=Pe.get(e,S.length),b.init(),S.push(b),this.info.render.frame++,Ge.enabled===!0&&Ge.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&it(e,t,-1/0,T.sortObjects)}it(e,t,0,T.sortObjects),b.finish(),D!==null&&D.updateLights(x.state.lightsArray),T.sortObjects===!0&&b.sort(le,ue),Se=Ge.enabled===!1||Ge.isPresenting===!1||Ge.hasDepthSensing()===!1,Se&&z.addToRenderList(b,e),this.info.autoReset===!0&&this.info.reset(),ge===!0&&Ie.beginShadows();let i=x.state.shadowsArray;if(Le.render(i,e,t),ge===!0&&Ie.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;t<a;t++){let a=i[t];ot(n,r,e,a)}Se&&z.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];at(b,e,n,n.viewport)}}else r.length>0&&ot(n,r,e,t),Se&&z.render(e),at(b,e,t)}N!==null&&M===0&&(R.updateMultisampleRenderTarget(N),R.updateRenderTargetMipmap(N)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),He.resetDefaultState(),P=-1,ee=null,C.pop(),C.length>0?(x=C[C.length-1],R.setTextureUnits(x.state.textureUnits),ge===!0&&Ie.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function it(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.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){let i=t.isArrayCamera?he:me;if(!e.frustumCulled||e.intersectsFrustum(i)){r&&be.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ve);let i=je.update(e),a=e.material;a.visible&&b.push(e,i,a,n,be.z,null,t)}}else if(e.isMesh||e.isLine||e.isPoints){let i=t.isArrayCamera?he:me;if(!e.frustumCulled||e.intersectsFrustum(i)){let i=je.update(e),a=e.material;if(r&&(e.boundingSphere===void 0?(i.boundingSphere===null&&i.computeBoundingSphere(),be.copy(i.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),be.copy(e.boundingSphere.center)),be.applyMatrix4(e.matrixWorld).applyMatrix4(ve)),Array.isArray(a)){let r=i.groups;for(let o=0,s=r.length;o<s;o++){let s=r[o],c=a[s.materialIndex];c&&c.visible&&b.push(e,i,c,n,be.z,s,t)}}else a.visible&&b.push(e,i,a,n,be.z,null,t)}}}let i=e.children;for(let e=0,a=i.length;e<a;e++)it(i[e],t,n,r)}function at(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;x.setupLightsView(n),ge===!0&&Ie.setGlobalState(T.clippingPlanes,n),r&&I.viewport(te.copy(r)),i.length>0&&st(i,t,n),a.length>0&&st(a,t,n),o.length>0&&st(o,t,n),I.buffers.depth.setTest(!0),I.buffers.depth.setMask(!0),I.buffers.color.setMask(!0),I.setPolygonOffset(!1)}function ot(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 Xv(1,1,{generateMipmaps:!0,type:e?kg:Sg,minFilter:xg,samples:Math.max(4,Ee.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Lv.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||te;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(ie),ae=T.getClearAlpha(),ae<1&&T.setClearColor(16777215,.5),T.clear(),Se&&z.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),ge===!0&&Ie.setGlobalState(T.clippingPlanes,r),st(e,n,r),R.updateMultisampleRenderTarget(a),R.updateRenderTargetMipmap(a),Te.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let{object:a,geometry:o,material:s,group:c}=t[i];if(s.side===2&&a.layers.test(r.layers)){let t=s.side;s.side=1,s.needsUpdate=!0,ct(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(R.updateMultisampleRenderTarget(a),R.updateRenderTargetMipmap(a))}T.setRenderTarget(s,c,l),T.setClearColor(ie,ae),d!==void 0&&(r.viewport=d),T.toneMapping=u}function st(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],{object:o,geometry:s,group:c}=a,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&ct(o,t,n,s,l,c)}}function ct(e,t,n,r,i,a){D!==null&&i.isNodeMaterial&&D.setObject(e,i),e.onBeforeRender(T,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(T,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,T.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,T.renderBufferDirect(n,t,r,i,e,a),i.side=2):T.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(T,t,n,r,i,a)}function lt(e){let t=0;for(let n of e)n.texture!==null&&t++;return t}function ut(e,t,n){t.isScene!==!0&&(t=xe);let r=L.get(e),i=x.state.lights,a=x.state.shadowsArray,o=i.state.version,s=Me.getParameters(e,i.state,a,t,n,x.state.lightProbeGridArray),c=Me.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,r.fog=t.fog;let u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;r.envMap=Oe.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Ye),l=new Map,r.programs=l,r.programVariants=new Map);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return pt(e,s),d}else s.uniforms=Me.getUniforms(e),D!==null&&e.isNodeMaterial&&D.build(e,n,s),e.onBeforeCompile(s,T),d=Me.acquireProgram(s,c),l.set(c,d),r.uniforms=s.uniforms;let f=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(f.clippingPlanes=Ie.uniform),pt(e,s),r.needsLights=gt(e),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.sunLights.value=i.state.sun,f.sunLightShadows.value=i.state.sunShadow,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.sunShadowMatrix.value=i.state.sunShadowMatrix,f.sunShadowCascade.value=i.state.sunShadowCascade,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotLightMatrix.value=i.state.spotLightMatrix,f.spotLightMap.value=i.state.spotLightMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix),r.numLightProbeGrids=lt(x.state.lightProbeGridArray),r.currentProgram=d,r.uniformsList=null,d}function dt(e,t,n,r,i){let a=L.get(e),o=a.currentProgram.id+`,`+r+`,`+i,s=a.programVariants.get(o);return s===void 0?(s=ut(e,t,n),a.programVariants.set(o,s)):(a.currentProgram=s,a.uniformsList=null,a.outputColorSpace=r,a.toneMapping=i),s}function ft(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=QT.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function pt(e,t){let n=L.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 mt(e,t,n,r,i){t.isScene!==!0&&(t=xe),R.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?t.environment:null,s=N===null?T.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Lv.workingColorSpace,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=Oe.get(r.envMap||o,c),u=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(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=L.get(r),b=x.state.lights;if(ge===!0&&(_e===!0||e!==ee)){let t=e===ee&&r.id===P;Ie.setState(r,e,t)}let S=!1,C=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==b.state.version||i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i._colorsTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i._colorsTexture!==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?S=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ie.numPlanes||v.numIntersection!==Ie.numIntersection)?S=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.morphTargetsCount===_&&v.numLightProbeGrids===lt(x.state.lightProbeGridArray)?(v.outputColorSpace!==s||v.toneMapping!==h)&&(C=!0):S=!0:S=!0:(S=!0,v.__version=r.version);let w=v.currentProgram;(S===!0||C===!0)&&(w=C===!0?dt(r,t,i,s,h):ut(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,w,v));let E=!1,O=!1,k=!1,A=w.getUniforms(),j=v.uniforms;if(I.useProgram(w.program)&&(E=!0,O=!0,k=!0),r.id!==P&&(P=r.id,O=!0),E||ee!==e){I.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),A.setValue(F,`projectionMatrix`,e.projectionMatrix),A.setValue(F,`viewMatrix`,e.matrixWorldInverse);let t=A.map.cameraPosition;t!==void 0&&t.setValue(F,ye.setFromMatrixPosition(e.matrixWorld)),Ee.logarithmicDepthBuffer&&A.setValue(F,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&A.setValue(F,`isOrthographic`,e.isOrthographicCamera===!0),ee!==e&&(ee=e,O=!0,k=!0)}if(v.needsLights&&(b.state.sunShadowMap.length>0&&A.setValue(F,`sunShadowMap`,b.state.sunShadowMap,R),b.state.directionalShadowMap.length>0&&A.setValue(F,`directionalShadowMap`,b.state.directionalShadowMap,R),b.state.spotShadowMap.length>0&&A.setValue(F,`spotShadowMap`,b.state.spotShadowMap,R),b.state.pointShadowMap.length>0&&A.setValue(F,`pointShadowMap`,b.state.pointShadowMap,R)),i.isSkinnedMesh){A.setOptional(F,i,`bindMatrix`),A.setOptional(F,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),A.setValue(F,`boneTexture`,e.boneTexture,R))}i.isBatchedMesh&&(A.setOptional(F,i,`batchingTexture`),A.setValue(F,`batchingTexture`,i._matricesTexture,R),A.setOptional(F,i,`batchingIdTexture`),A.setValue(F,`batchingIdTexture`,i._indirectTexture,R),A.setOptional(F,i,`batchingColorTexture`),i._colorsTexture!==null&&A.setValue(F,`batchingColorTexture`,i._colorsTexture,R));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&Re.update(i,n,w),(O||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,A.setValue(F,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=hD()),O){if(A.setValue(F,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&ht(j,k),a&&r.fog===!0&&Ne.refreshFogUniforms(j,a),Ne.refreshMaterialUniforms(j,r,ce,se,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.numLightProbeGrids>0){let e=y,t=0;for(let n of x.state.lightProbeGridArray)n.texture!==null&&(e.textures[t]=n.texture,e.min[t]=n.boundingBox.min,e.max[t]=n.boundingBox.max,e.resolution[t]=n.resolution,t++);for(let n in e)e[n].length=t;j.probesSH.value=e.textures,j.probesMin.value=e.min,j.probesMax.value=e.max,j.probesResolution.value=e.resolution}QT.upload(F,ft(v),j,R)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(QT.upload(F,ft(v),j,R),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&A.setValue(F,`center`,i.center),A.setValue(F,`modelViewMatrix`,i.modelViewMatrix),A.setValue(F,`normalMatrix`,i.normalMatrix),A.setValue(F,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Ue.update(n,w),Ue.bind(n,w)}}return w}function ht(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.sunLights.needsUpdate=t,e.sunLightShadows.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function gt(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(e,t,n){let r=L.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),L.get(e.texture).__webglTexture=t,L.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=L.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0},this.setRenderTarget=function(e,t=0,n=0){N=e,j=t,M=n;let r=null,i=!1,a=!1;if(e){let o=L.get(e);if(o.__useDefaultFramebuffer!==void 0){I.bindFramebuffer(F.FRAMEBUFFER,o.__webglFramebuffer),te.copy(e.viewport),ne.copy(e.scissor),re=e.scissorTest,I.viewport(te),I.scissor(ne),I.setScissorTest(re),P=-1;return}if(o.__webglFramebuffer===void 0)R.setupRenderTarget(e);else if(o.__hasExternalTextures)R.rebindTextures(e,L.get(e.texture).__webglTexture,L.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&L.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.`);R.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=L.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&R.useMultisampledRTT(e)===!1?L.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,te.copy(e.viewport),ne.copy(e.scissor),re=e.scissorTest}else te.copy(de).multiplyScalar(ce).floor(),ne.copy(fe).multiplyScalar(ce).floor(),re=pe;if(n!==0&&(r=O),I.bindFramebuffer(F.FRAMEBUFFER,r)&&I.drawBuffers(e,r),I.viewport(te),I.scissor(ne),I.setScissorTest(re),i){let r=L.get(e.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=L.get(e.textures[t]);F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=L.get(e.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,t.__webglTexture,n)}P=-1};function _t(e){let t=L.get(e);return(t.__readFormat!==e.format||t.__readType!==e.type)&&(t.__readFormat=e.format,t.__readType=e.type,t.__formatReadable=Ee.textureFormatReadable(e.format),t.__typeReadable=Ee.textureTypeReadable(e.type)),t}this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){X_(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=L.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o],Array.isArray(c)&&(c=c[0])),c){I.bindFramebuffer(F.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;e.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+s);let u=_t(o);if(u.__formatReadable===!1){X_(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(u.__typeReadable===!1){X_(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&F.readPixels(t,n,r,i,Ve.convert(c),Ve.convert(l),a)}finally{let e=N===null?null:L.get(N).__webglFramebuffer;I.bindFramebuffer(F.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=L.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o],Array.isArray(c)&&(c=c[0])),c){if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){I.bindFramebuffer(F.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;e.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+s);let d=_t(o);if(d.__formatReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(d.__typeReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let f=F.createBuffer();F.bindBuffer(F.PIXEL_PACK_BUFFER,f),F.bufferData(F.PIXEL_PACK_BUFFER,a.byteLength,F.STREAM_READ),F.readPixels(t,n,r,i,Ve.convert(l),Ve.convert(u),0),F.bindBuffer(F.PIXEL_PACK_BUFFER,null);let p=N===null?null:L.get(N).__webglFramebuffer;I.bindFramebuffer(F.FRAMEBUFFER,p);let m=F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);return F.flush(),await Q_(F,m,4),F.bindBuffer(F.PIXEL_PACK_BUFFER,f),F.getBufferSubData(F.PIXEL_PACK_BUFFER,0,a),F.bindBuffer(F.PIXEL_PACK_BUFFER,null),F.deleteBuffer(f),F.deleteSync(m),a}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;R.setTexture2D(e,0),F.copyTexSubImage2D(F.TEXTURE_2D,n,0,0,o,s,i,a),I.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=Ve.convert(t.format),_=Ve.convert(t.type),v;t.isData3DTexture?(R.setTexture3D(t,0),v=F.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(R.setTexture2DArray(t,0),v=F.TEXTURE_2D_ARRAY):(R.setTexture2D(t,0),v=F.TEXTURE_2D),I.activeTexture(F.TEXTURE0),I.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,t.flipY),I.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),I.pixelStorei(F.UNPACK_ALIGNMENT,t.unpackAlignment);let y=I.getParameter(F.UNPACK_ROW_LENGTH),b=I.getParameter(F.UNPACK_IMAGE_HEIGHT),x=I.getParameter(F.UNPACK_SKIP_PIXELS),S=I.getParameter(F.UNPACK_SKIP_ROWS),C=I.getParameter(F.UNPACK_SKIP_IMAGES);I.pixelStorei(F.UNPACK_ROW_LENGTH,h.width),I.pixelStorei(F.UNPACK_IMAGE_HEIGHT,h.height),I.pixelStorei(F.UNPACK_SKIP_PIXELS,l),I.pixelStorei(F.UNPACK_SKIP_ROWS,u),I.pixelStorei(F.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=L.get(e),r=L.get(t),h=L.get(n.__renderTarget),g=L.get(r.__renderTarget);I.bindFramebuffer(F.READ_FRAMEBUFFER,h.__webglFramebuffer),I.bindFramebuffer(F.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,L.get(e).__webglTexture,i,d+n),F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,L.get(t).__webglTexture,a,m+n)),F.blitFramebuffer(l,u,l+o,u+s,f,p,f+o,p+s,F.DEPTH_BUFFER_BIT,F.NEAREST);I.bindFramebuffer(F.READ_FRAMEBUFFER,null),I.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||L.has(e)){let n=L.get(e),r=L.get(t);I.bindFramebuffer(F.READ_FRAMEBUFFER,k),I.bindFramebuffer(F.DRAW_FRAMEBUFFER,A);for(let e=0;e<c;e++)w?F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):F.framebufferTexture2D(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,n.__webglTexture,i),T?F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):F.framebufferTexture2D(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,r.__webglTexture,a),i===0?T?F.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):F.copyTexSubImage2D(v,a,f,p,l,u,o,s):F.blitFramebuffer(l,u,l+o,u+s,f,p,f+o,p+s,F.COLOR_BUFFER_BIT,F.NEAREST);I.bindFramebuffer(F.READ_FRAMEBUFFER,null),I.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?F.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?F.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):F.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):F.texSubImage2D(F.TEXTURE_2D,a,f,p,o,s,g,_,h);I.pixelStorei(F.UNPACK_ROW_LENGTH,y),I.pixelStorei(F.UNPACK_IMAGE_HEIGHT,b),I.pixelStorei(F.UNPACK_SKIP_PIXELS,x),I.pixelStorei(F.UNPACK_SKIP_ROWS,S),I.pixelStorei(F.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps===!0&&t.mipmapsAutoUpdate===!0&&F.generateMipmap(v),I.unbindTexture()},this.initRenderTarget=function(e){L.get(e).__webglFramebuffer===void 0&&R.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?R.setTextureCube(e,0):e.isData3DTexture?R.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?R.setTexture2DArray(e,0):R.setTexture2D(e,0),I.unbindTexture()},this.resetState=function(){j=0,M=0,N=null,I.reset(),He.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return V_}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Lv._getDrawingBufferColorSpace(e),t.unpackColorSpace=Lv._getUnpackColorSpace()}},_D={VALIDATION_ERROR:`VALIDATION_ERROR`,INVALID_STATE:`INVALID_STATE`,ENVIRONMENT_ERROR:`ENVIRONMENT_ERROR`,INVALID_CONFIG:`INVALID_CONFIG`,ENCODING_ERROR:`ENCODING_ERROR`,UNKNOWN_ERROR:`UNKNOWN_ERROR`},vD=class extends Error{code;context;originalError;constructor(e,t=_D.UNKNOWN_ERROR,n){super(e),this.name=`VisualizationError`,this.code=t,this.context=n?.context,this.originalError=n?.originalError,n?.originalError&&(this.cause=n.originalError)}},yD=new class{debug(){}info(){}warn(){}error(){}};function bD(){return yD}var xD={studio:{toneMapping:4,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:.85,hemisphereIntensity:.5,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:1.6},technical:{toneMapping:7,toneMappingExposure:1,envMapIntensity:.55,environmentIntensity:.6,hemisphereIntensity:.25,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.2},showcase:{toneMapping:4,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1,hemisphereIntensity:.2,ambientIntensity:.1,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.6},arctic:{toneMapping:7,toneMappingExposure:1.05,envMapIntensity:.85,environmentIntensity:1.1,hemisphereIntensity:.3,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2,materialOverride:{color:15659509,metalness:0,roughness:.75,emissiveIntensity:0}},xray:{toneMapping:7,toneMappingExposure:1.3,envMapIntensity:.4,environmentIntensity:.8,hemisphereIntensity:.6,ambientIntensity:.6,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:.6,materialOverride:{color:10470632,metalness:0,roughness:.9,emissiveIntensity:0,opacity:.28,depthWrite:!1,side:2}},lineart:{toneMapping:7,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.6,ambientIntensity:3.2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,requiresEdges:!0,materialOverride:{color:16251130,metalness:0,roughness:1,emissiveIntensity:0}},night:{toneMapping:4,toneMappingExposure:1,envMapIntensity:.12,metalReflection:.05,environmentIntensity:.04,hemisphereIntensity:.06,ambientIntensity:.02,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:.03,background:658962,emissiveLightScale:3,bloom:{strength:.2,radius:.3,threshold:1.8},emissiveLights:!0,lowPower:{ambientOcclusion:!1,bloom:void 0,maxEmissiveLights:1,maxPixelRatio:1.5}},wireframe:{toneMapping:7,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.4,ambientIntensity:2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,materialOverride:{color:2830648,metalness:0,roughness:1,emissiveIntensity:0,wireframe:!0,side:2}}};function SD(e,t=!1){let n=xD[e];return t?{...n,...n.lowPower}:n}var CD=`selvaEmissive`,wD=`selvaEmissiveLight`,TD=`selvaEnvMapIntensity`;function ED(e,t,n=1){return e+(n-e)*Math.min(1,Math.max(0,t))}function DD(e){let t=xD[e];return{envMapIntensity:t.envMapIntensity,metalReflection:t.metalReflection,cullBackfaces:t.cullBackfaces}}function OD(e){if(!e||typeof e!=`string`)return bD().warn(`Invalid color input: ${e}, using white`),new Q(16777215);let t=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(t))try{return new Q(t.startsWith(`#`)?t:`#${t}`)}catch{return bD().warn(`Invalid hex color: ${e}, using white`),new Q(16777215)}if(t.includes(`,`)){let e=t.split(`,`).map(e=>parseInt(e.trim(),10));if(e.length===3&&e.every(e=>!isNaN(e)&&e>=0&&e<=255))return new Q(e[0]/255,e[1]/255,e[2]/255)}let n=t.toLowerCase();return n in Q.NAMES?new Q(Q.NAMES[n]):(bD().warn(`Invalid color string: ${e}, using white`),new Q(16777215))}function kD(e,t,n=`z`){e.forEach(e=>{e.position[n]-=t})}function AD(e){let t=new Xy;return e.length===0||e.forEach(e=>{e.updateMatrixWorld(!0);let n=new Xy().setFromObject(e);t.union(n)}),t}var jD=new Set,MD=1;function ND(e){let t=Math.max(1,e);if(t!==MD){MD=t;for(let e of jD)e(t)}}function PD(e){return jD.add(e),e(MD),()=>jD.delete(e)}var FD=`selvaGlass`;function ID(e){return e?Array.isArray(e)?e.some(e=>e.userData[FD]===!0):e.userData[FD]===!0:!1}function LD(e){let t=[];return e.traverse(e=>{e.visible&&ID(e.material)&&(e.visible=!1,t.push(e))}),()=>{for(let e of t)e.visible=!0}}function RD(e){if(rg(e)){for(let[t,n]of Object.entries(e))t!==`envMap`&&n instanceof qv&&n.dispose();e.dispose()}}function zD(e){e&&(Array.isArray(e)?e.forEach(RD):RD(e))}function BD(e,t={}){let{materials:n=!0,keepUploaded:r}=t;e.traverse(e=>{let t=e;(t.geometry||t.material)&&(t.geometry&&VD(t.geometry,r),n&&zD(t.material))})}function VD(e,t){let n=ug(e);if(n!==e){if(n){e.setIndex(null);for(let t of Object.keys(e.attributes))e.deleteAttribute(t)}e.dispose()}n&&t&&!t.has(n)&&n.dispose()}var HD=new Xy,UD=new Z,WD=class extends wC{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 Sb([-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 Sb([-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 UC(t,6,1);return this.setAttribute(`instanceStart`,new Rb(n,3,0)),this.setAttribute(`instanceEnd`,new Rb(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 UC(t,6,1);return this.setAttribute(`instanceColorStart`,new Rb(n,3,0)),this.setAttribute(`instanceColorEnd`,new Rb(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 uS(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Xy);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),HD.setFromBufferAttribute(t),this.boundingBox.union(HD))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Eb),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i<a;i++)UD.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(UD)),UD.fromBufferAttribute(t,i),r=Math.max(r,n.distanceToSquared(UD));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}};$.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new X},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},lw.line={uniforms:_S.merge([$.common,$.fog,$.line]),vertexShader:`\n #include <common>\n #include <color_pars_vertex>\n #include <fog_pars_vertex>\n #include <logdepthbuf_pars_vertex>\n #include <clipping_planes_pars_vertex>\n\n uniform float linewidth;\n uniform vec2 resolution;\n\n attribute vec3 instanceStart;\n attribute vec3 instanceEnd;\n\n attribute vec3 instanceColorStart;\n attribute vec3 instanceColorEnd;\n\n #ifdef WORLD_UNITS\n\n varying vec4 worldPos;\n varying vec3 worldStart;\n varying vec3 worldEnd;\n\n #ifdef USE_DASH\n\n varying vec2 vUv;\n\n #endif\n\n #else\n\n varying vec2 vUv;\n\n #endif\n\n #ifdef USE_DASH\n\n uniform float dashScale;\n attribute float instanceDistanceStart;\n attribute float instanceDistanceEnd;\n varying float vLineDistance;\n\n #endif\n\n float trimSegmentAlpha( const in vec4 start, const in vec4 end ) {\n\n // compute the interpolation factor needed to trim the segment so it terminates\n // between the camera plane and the near plane\n\n // conservative estimate of the near plane\n float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\n // we need different nearEstimate formula for reversed and default depth buffer\n // a is positive with a reversed depth buffer so it can be used for controlling the code flow\n float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a );\n\n return ( nearEstimate - start.z ) / ( end.z - start.z );\n\n }\n\n void main() {\n\n #ifdef USE_COLOR\n\n vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n #endif\n\n float aspect = resolution.x / resolution.y;\n\n // camera space\n vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n #ifdef USE_DASH\n\n float lineDistanceStart = dashScale * instanceDistanceStart;\n float lineDistanceEnd = dashScale * instanceDistanceEnd;\n\n #endif\n\n #ifdef WORLD_UNITS\n\n worldStart = start.xyz;\n worldEnd = end.xyz;\n\n #else\n\n vUv = uv;\n\n #endif\n\n // special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n // but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n // perhaps there is a more elegant solution -- WestLangley\n\n bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n if ( perspective ) {\n\n if ( start.z < 0.0 && end.z >= 0.0 ) {\n\n float alpha = trimSegmentAlpha( start, end );\n end.xyz = mix( start.xyz, end.xyz, alpha );\n\n #ifdef USE_DASH\n\n lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha );\n\n #endif\n\n } else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n float alpha = trimSegmentAlpha( end, start );\n start.xyz = mix( end.xyz, start.xyz, alpha );\n\n #ifdef USE_DASH\n\n lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha );\n\n #endif\n\n }\n\n }\n\n #ifdef USE_DASH\n\n vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd;\n vUv = uv;\n\n #endif\n\n // clip space\n vec4 clipStart = projectionMatrix * start;\n vec4 clipEnd = projectionMatrix * end;\n\n // ndc space\n vec3 ndcStart = clipStart.xyz / clipStart.w;\n vec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n // direction\n vec2 dir = ndcEnd.xy - ndcStart.xy;\n\n // account for clip-space aspect ratio\n dir.x *= aspect;\n dir = normalize( dir );\n\n #ifdef WORLD_UNITS\n\n vec3 worldDir = normalize( end.xyz - start.xyz );\n vec3 tmpFwd = perspective ? normalize( mix( start.xyz, end.xyz, 0.5 ) ) : vec3( 0.0, 0.0, - 1.0 );\n vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n vec3 worldFwd = cross( worldDir, worldUp );\n worldPos = position.y < 0.5 ? start: end;\n\n // height offset\n float hw = linewidth * 0.5;\n worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n // don't extend the line if we're rendering dashes because we\n // won't be rendering the endcaps\n #ifndef USE_DASH\n\n // cap extension\n worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n // add width to the box\n worldPos.xyz += worldFwd * hw;\n\n // endcaps\n if ( position.y > 1.0 || position.y < 0.0 ) {\n\n worldPos.xyz -= worldFwd * 2.0 * hw;\n\n }\n\n #endif\n\n // project the worldpos\n vec4 clip = projectionMatrix * worldPos;\n\n // shift the depth of the projected points so the line\n // segments overlap neatly\n vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\n // only shift the depth of vertices in front of the camera (#35137)\n if ( clip.w > 0.0 ) clip.z = clipPose.z * clip.w;\n\n #else\n\n vec2 offset = vec2( dir.y, - dir.x );\n // undo aspect ratio adjustment\n dir.x /= aspect;\n offset.x /= aspect;\n\n // sign flip\n if ( position.x < 0.0 ) offset *= - 1.0;\n\n // endcaps\n if ( position.y < 0.0 ) {\n\n offset += - dir;\n\n } else if ( position.y > 1.0 ) {\n\n offset += dir;\n\n }\n\n // adjust for linewidth\n offset *= linewidth;\n\n // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n offset /= resolution.y;\n\n // select end\n vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n // back to clip space\n offset *= clip.w;\n\n clip.xy += offset;\n\n #endif\n\n gl_Position = clip;\n\n vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n\n }\n `,fragmentShader:`\n uniform vec3 diffuse;\n uniform float opacity;\n uniform float linewidth;\n\n #ifdef USE_DASH\n\n uniform float dashOffset;\n uniform float dashSize;\n uniform float gapSize;\n\n #endif\n\n varying float vLineDistance;\n\n #ifdef WORLD_UNITS\n\n varying vec4 worldPos;\n varying vec3 worldStart;\n varying vec3 worldEnd;\n\n #ifdef USE_DASH\n\n varying vec2 vUv;\n\n #endif\n\n #else\n\n varying vec2 vUv;\n\n #endif\n\n #include <common>\n #include <color_pars_fragment>\n #include <fog_pars_fragment>\n #include <logdepthbuf_pars_fragment>\n #include <clipping_planes_pars_fragment>\n\n vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n float mua;\n float mub;\n\n vec3 p13 = p1 - p3;\n vec3 p43 = p4 - p3;\n\n vec3 p21 = p2 - p1;\n\n float d1343 = dot( p13, p43 );\n float d4321 = dot( p43, p21 );\n float d1321 = dot( p13, p21 );\n float d4343 = dot( p43, p43 );\n float d2121 = dot( p21, p21 );\n\n float denom = d2121 * d4343 - d4321 * d4321;\n\n float numer = d1343 * d4321 - d1321 * d4343;\n\n mua = numer / denom;\n mua = clamp( mua, 0.0, 1.0 );\n mub = ( d1343 + d4321 * ( mua ) ) / d4343;\n mub = clamp( mub, 0.0, 1.0 );\n\n return vec2( mua, mub );\n\n }\n\n void main() {\n\n float alpha = opacity;\n vec4 diffuseColor = vec4( diffuse, alpha );\n\n #include <clipping_planes_fragment>\n\n #ifdef USE_DASH\n\n if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n #endif\n\n #ifdef WORLD_UNITS\n\n float len;\n\n if ( isOrthographic ) {\n\n // View rays are parallel to the z axis so the distance reduces to camera-space XY\n vec2 lineDir = worldEnd.xy - worldStart.xy;\n float t = clamp( dot( worldPos.xy - worldStart.xy, lineDir ) / dot( lineDir, lineDir ), 0.0, 1.0 );\n len = length( worldStart.xy + lineDir * t - worldPos.xy );\n\n } else {\n\n // Find the closest points on the view ray and the line segment\n vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n vec3 lineDir = worldEnd - worldStart;\n vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n vec3 p1 = worldStart + lineDir * params.x;\n vec3 p2 = rayEnd * params.y;\n vec3 delta = p1 - p2;\n len = length( delta );\n\n }\n\n float norm = len / linewidth;\n\n #ifndef USE_DASH\n\n #ifdef USE_ALPHA_TO_COVERAGE\n\n float dnorm = fwidth( norm );\n alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n #else\n\n if ( norm > 0.5 ) {\n\n discard;\n\n }\n\n #endif\n\n #endif\n\n #else\n\n #ifdef USE_ALPHA_TO_COVERAGE\n\n // artifacts appear on some hardware if a derivative is taken within a conditional\n float a = vUv.x;\n float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n float len2 = a * a + b * b;\n float dlen = fwidth( len2 );\n\n if ( abs( vUv.y ) > 1.0 ) {\n\n alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n }\n\n #else\n\n if ( abs( vUv.y ) > 1.0 ) {\n\n float a = vUv.x;\n float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n float len2 = a * a + b * b;\n\n if ( len2 > 1.0 ) discard;\n\n }\n\n #endif\n\n #endif\n\n #include <logdepthbuf_fragment>\n #include <color_fragment>\n\n gl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n\n }\n `};var GD=class extends bS{constructor(e){super({type:`LineMaterial`,uniforms:_S.clone(lw.line.uniforms),vertexShader:lw.line.vertexShader,fragmentShader:lw.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)}},KD=new Jv,qD=new Z,JD=new Z,YD=new Jv,XD=new Jv,ZD=new Jv,QD=new Z,$D=new $v,eO=new nw,tO=new Z,nO=new Xy,rO=new Eb,iO=new Jv,aO,oO;function sO(e,t,n){return iO.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),iO.multiplyScalar(1/iO.w),iO.x=oO/n.width,iO.y=oO/n.height,iO.applyMatrix4(e.projectionMatrixInverse),iO.multiplyScalar(1/iO.w),Math.abs(Math.max(iO.x,iO.y))}function cO(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;r<s;r++){eO.start.fromBufferAttribute(i,r),eO.end.fromBufferAttribute(a,r),eO.applyMatrix4(n);let o=new Z,s=new Z;aO.distanceSqToSegment(eO.start,eO.end,s,o),s.distanceTo(o)<oO*.5&&t.push({point:s,pointOnLine:o,distance:aO.origin.distanceTo(s),object:e,face:null,faceIndex:r,uv:null,uv1:null})}}function lO(e,t,n){let r=t.projectionMatrix,i=e.material.resolution,a=e.matrixWorld,o=e.geometry,s=o.attributes.instanceStart,c=o.attributes.instanceEnd,l=Math.min(o.instanceCount,s.count),u=-t.near;aO.at(1,ZD),ZD.w=1,ZD.applyMatrix4(t.matrixWorldInverse),ZD.applyMatrix4(r),ZD.multiplyScalar(1/ZD.w),ZD.x*=i.x/2,ZD.y*=i.y/2,ZD.z=0,QD.copy(ZD),$D.multiplyMatrices(t.matrixWorldInverse,a);for(let t=0,o=l;t<o;t++){if(YD.fromBufferAttribute(s,t),XD.fromBufferAttribute(c,t),YD.w=1,XD.w=1,YD.applyMatrix4($D),XD.applyMatrix4($D),YD.z>u&&XD.z>u)continue;if(YD.z>u){let e=YD.z-XD.z,t=(YD.z-u)/e;YD.lerp(XD,t)}else if(XD.z>u){let e=XD.z-YD.z,t=(XD.z-u)/e;XD.lerp(YD,t)}YD.applyMatrix4(r),XD.applyMatrix4(r),YD.multiplyScalar(1/YD.w),XD.multiplyScalar(1/XD.w),YD.x*=i.x/2,YD.y*=i.y/2,XD.x*=i.x/2,XD.y*=i.y/2,eO.start.copy(YD),eO.start.z=0,eO.end.copy(XD),eO.end.z=0;let o=eO.closestPointToPointParameter(QD,!0);eO.at(o,tO);let l=Ov.lerp(YD.z,XD.z,o),d=l>=-1&&l<=1,f=QD.distanceTo(tO)<oO*.5;if(d&&f){eO.start.fromBufferAttribute(s,t),eO.end.fromBufferAttribute(c,t),eO.start.applyMatrix4(a),eO.end.applyMatrix4(a);let r=new Z,i=new Z;aO.distanceSqToSegment(eO.start,eO.end,i,r),n.push({point:i,pointOnLine:r,distance:aO.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}var uO=class extends wx{constructor(e=new WD,t=new GD({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,a=t.count;e<a;e++,i+=2)qD.fromBufferAttribute(t,e),JD.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+qD.distanceTo(JD);let i=new UC(r,2,1);return e.setAttribute(`instanceDistanceStart`,new Rb(i,1,0)),e.setAttribute(`instanceDistanceEnd`,new Rb(i,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;if(r===null&&!n&&console.error(`LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`),n===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;aO=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;oO=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),rO.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?oO*.5:sO(r,Math.max(r.near,rO.distanceToPoint(aO.origin)),s.resolution),rO.radius+=c,aO.intersectsSphere(rO)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),nO.copy(o.boundingBox).applyMatrix4(a);let l;l=n?oO*.5:sO(r,Math.max(r.near,nO.distanceToPoint(aO.origin)),s.resolution),nO.expandByScalar(l),aO.intersectsBox(nO)!==!1&&(n?cO(this,t):lO(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(KD),this.material.uniforms.resolution.value.set(KD.z,KD.w))}},dO=class extends WD{constructor(){super(),this.isLineGeometry=!0,this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}setFromPoints(e){let t=e.length-1,n=new Float32Array(6*t);for(let r=0;r<t;r++)n[6*r]=e[r].x,n[6*r+1]=e[r].y,n[6*r+2]=e[r].z||0,n[6*r+3]=e[r+1].x,n[6*r+4]=e[r+1].y,n[6*r+5]=e[r+1].z||0;return super.setPositions(n),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},fO=class extends uO{constructor(e=new dO,t=new GD({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},pO={},mO=(function(e,t,n,r,i){var a=new Worker(pO[t]||(pO[t]=URL.createObjectURL(new Blob([e+`;addEventListener(\"error\",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})`],{type:`text/javascript`}))));return a.onmessage=function(e){var t=e.data,n=t.$e$;if(n){var r=Error(n[0]);r.code=n[1],r.stack=n[2],i(r,null)}else i(null,t)},a.postMessage(n,r),a}),hO=Uint8Array,gO=Uint16Array,_O=Int32Array,vO=new hO([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),yO=new hO([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),bO=new hO([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xO=function(e,t){for(var n=new gO(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new _O(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},SO=xO(vO,2),CO=SO.b,wO=SO.r;CO[28]=258,wO[258]=28;var TO=xO(yO,0),EO=TO.b;TO.r;for(var DO=new gO(32768),OO=0;OO<32768;++OO){var kO=(OO&43690)>>1|(OO&21845)<<1;kO=(kO&52428)>>2|(kO&13107)<<2,kO=(kO&61680)>>4|(kO&3855)<<4,DO[OO]=((kO&65280)>>8|(kO&255)<<8)>>1}for(var AO=(function(e,t,n){for(var r=e.length,i=0,a=new gO(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new gO(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new gO(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[DO[d]>>c]=l}else for(s=new gO(r),i=0;i<r;++i)e[i]&&(s[i]=DO[o[e[i]-1]++]>>15-e[i]);return s}),jO=new hO(288),OO=0;OO<144;++OO)jO[OO]=8;for(var OO=144;OO<256;++OO)jO[OO]=9;for(var OO=256;OO<280;++OO)jO[OO]=7;for(var OO=280;OO<288;++OO)jO[OO]=8;for(var MO=new hO(32),OO=0;OO<32;++OO)MO[OO]=5;var NO=AO(jO,9,1),PO=AO(MO,5,1),FO=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},IO=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},LO=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},RO=function(e){return(e+7)/8|0},zO=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new hO(e.subarray(t,n))},BO=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],VO=function(e,t,n){var r=Error(t||BO[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,VO),!n)throw r;return r},HO=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new hO(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new hO(i*3));var l=function(e){var t=n.length;if(e>t){var r=new hO(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=IO(e,d,1);var v=IO(e,d+1,3);if(d+=3,!v){var y=RO(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&VO(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=NO,m=PO,h=9,g=5;else if(v==2){var S=IO(e,d,31)+257,C=IO(e,d+10,15)+4,w=S+IO(e,d+5,31)+1;d+=14;for(var T=new hO(w),E=new hO(19),D=0;D<C;++D)E[bO[D]]=IO(e,d+D*3,7);d+=C*3;for(var O=FO(E),k=(1<<O)-1,A=AO(E,O,1),D=0;D<w;){var j=A[IO(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+IO(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+IO(e,d,7),d+=3):y==18&&(N=11+IO(e,d,127),d+=7);N--;)T[D++]=M}}var P=T.subarray(0,S),ee=T.subarray(S);h=FO(P),g=FO(ee),p=AO(P,h,1),m=AO(ee,g,1)}else VO(1);if(d>_){c&&VO(0);break}}s&&l(f+131072);for(var te=(1<<h)-1,ne=(1<<g)-1,re=d;;re=d){var M=p[LO(e,d)&te],ie=M>>4;if(d+=M&15,d>_){c&&VO(0);break}if(M||VO(2),ie<256)n[f++]=ie;else if(ie==256){re=d,p=null;break}else{var ae=ie-254;if(ie>264){var D=ie-257,oe=vO[D];ae=IO(e,d,(1<<oe)-1)+CO[D],d+=oe}var se=m[LO(e,d)&ne],ce=se>>4;se||VO(3),d+=se&15;var ee=EO[ce];if(ce>3){var oe=yO[ce];ee+=LO(e,d)&(1<<oe)-1,d+=oe}if(d>_){c&&VO(0);break}s&&l(f+131072);var le=f+ae;if(f<ee){var ue=a-ee,de=Math.min(ee,le);for(ue+f<0&&VO(3);f<de;++f)n[f]=r[ue+f]}for(;f<le;++f)n[f]=n[f-ee]}}t.l=p,t.p=re,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?zO(n,0,f):n.subarray(0,f)},UO=new hO(0),WO=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},GO=function(e,t,n){for(var r=e(),i=e.toString(),a=i.slice(i.indexOf(`[`)+1,i.lastIndexOf(`]`)).replace(/\\s+/g,``).split(`,`),o=0;o<r.length;++o){var s=r[o],c=a[o];if(typeof s==`function`){t+=`;`+c+`=`;var l=s.toString();if(s.prototype){if(l.indexOf(`[native code]`)!=-1){var u=l.indexOf(` `,8)+1;t+=l.slice(u,l.indexOf(`(`,u))}else for(var d in t+=l,s.prototype)t+=`;`+c+`.prototype.`+d+`=`+s.prototype[d].toString()}else t+=l}else n[c]=s}return t},KO=[],qO=function(e){var t=[];for(var n in e)e[n].buffer&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t},JO=function(e,t,n,r){if(!KO[n]){for(var i=``,a={},o=e.length-1,s=0;s<o;++s)i=GO(e[s],i,a);KO[n]={c:GO(e[o],i,a),e:a}}var c=WO({},KO[n].e);return mO(KO[n].c+`;onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=`+t.toString()+`}`,n,c,qO(c),r)},YO=function(){return[hO,gO,_O,vO,yO,bO,CO,EO,NO,PO,DO,BO,AO,FO,IO,LO,RO,zO,VO,HO,ek,XO,ZO]},XO=function(e){return postMessage(e,[e.buffer])},ZO=function(e){return e&&{out:e.size&&new hO(e.size),dictionary:e.dictionary}},QO=function(e,t,n,r,i,a){var o=JO(n,r,i,function(e,t){o.terminate(),a(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}};function $O(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&VO(7),QO(e,t,[YO],function(e){return XO(ek(e.data[0],ZO(e.data[1])))},1,n)}function ek(e,t){return HO(e,{i:2},t&&t.out,t&&t.dictionary)}var tk=typeof TextDecoder<`u`&&new TextDecoder;try{tk.decode(UO,{stream:!0})}catch{}function nk(){let e=globalThis.Buffer;return typeof e==`function`?e:void 0}function rk(e){let t=e.replace(/[\\t\\n\\f\\r ]/g,``);return t.length%4==0&&(t=t.replace(/={1,2}$/,``)),t.length%4==1?null:t}function ik(e){let t=rk(e),n=t===null?null:ak(t);if(n===null)throw new vD(`Invalid base64 input.`,_D.ENCODING_ERROR,{context:{inputLength:e.length}});return n}function ak(e){let t=nk();if(t){if(t.byteLength(e,`utf8`)!==e.length||e.includes(`-`)||e.includes(`_`))return null;let n=t.from(e,`base64`);return n.length===Math.floor(e.length*3/4)?n.byteOffset===0&&n.buffer.byteLength===n.length?new Uint8Array(n.buffer,0,n.length):new Uint8Array(n):null}if(typeof globalThis.atob==`function`){let t;try{t=globalThis.atob(e)}catch{return null}let n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}throw new vD(`Base64 decoding not supported in this environment.`,_D.INVALID_STATE,{context:{environmentInfo:`atob or Buffer not available`}})}function ok(e,t){let n=t??1;return{color:new Q(e??`#ffffff`),transparent:n<1,opacity:n}}var sk=2,ck=6;function lk(e){let t=uk(e);if(!t)return null;let n=new dO;n.setPositions(t);let r=ok(e.color,e.opacity),i=new GD({color:r.color}),a=i;a.linewidth=e.width??sk,a.transparent=r.transparent,a.opacity=r.opacity;let o=new fO(n,i);return o.computeLineDistances(),o.name=e.name,o.userData={source:`compute`,id:e.id,layer:e.layer,kind:`curve`,metadata:e.metadata},o}function uk(e){if(!e.points)throw new vD(`Curve display item '${e.id}' has no tessellated points. It was produced by an outdated Display component — upgrade it in Grasshopper (Solution → Upgrade obsolete components) and re-save the definition.`,_D.INVALID_CONFIG,{context:{itemId:e.id,kind:e.kind}});return e.points.length>=ck?e.points:null}function dk(e){let{position:t}=e;if(!t||typeof t.X!=`number`||!Number.isFinite(t.X)||typeof t.Y!=`number`||!Number.isFinite(t.Y)||typeof t.Z!=`number`||!Number.isFinite(t.Z))return bD().warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let n=new Pb;n.setAttribute(`position`,new Sb([t.X,t.Y,t.Z],3));let r=new Yx(n,new Wx({...ok(e.color,e.opacity),size:6,sizeAttenuation:!1}));return r.name=e.name,r.userData={source:`compute`,id:e.id,layer:e.layer,kind:`point`,metadata:e.metadata},r}function fk(e){if(!e||e.length===0)return[];let t=[];for(let n of e)switch(n.kind){case`curve`:{let e=lk(n);e&&t.push(e);break}case`point`:{let e=dk(n);e&&t.push(e);break}default:{let e=n;bD().warn(`Skipping unknown display item kind: ${String(e.kind)}`);break}}return t}var pk=1096174675,mk=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function hk(e){return typeof e==`string`?ik(e):e instanceof Uint8Array?e:new Uint8Array(e)}function gk(e){return e.byteLength>=8&&new DataView(e.buffer,e.byteOffset,8).getUint32(0,!0)===1515605075}function _k(e){return gk(e)?new DataView(e.buffer,e.byteOffset,8).getUint32(4,!0):0}function vk(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(4,!0),n=e.subarray(8),r=Math.max(n.byteLength*1032+1024,1<<20);if(t>r)throw Ik(`SLVZ header declares an implausible uncompressed length`,{uncompressedLen:t,deflatedBytes:n.byteLength,maxPlausibleLen:r});return{deflated:n,uncompressedLen:t}}function yk(e,t){return Ik(`Failed to inflate SLVZ blob: ${e instanceof Error?e.message:String(e)}`,{uncompressedLen:t.uncompressedLen,deflatedBytes:t.deflated.byteLength})}function bk(e,t){if(e.byteLength!==t.uncompressedLen)throw Ik(`SLVZ payload inflated to a different size than the header declares.`,{declaredLen:t.uncompressedLen,actualLen:e.byteLength,deflatedBytes:t.deflated.byteLength});return e}function xk(e){if(!gk(e))return e;let t=vk(e),n;try{n=ek(t.deflated,{out:new Uint8Array(t.uncompressedLen+1)})}catch(e){throw yk(e,t)}return bk(n,t)}function Sk(e){return new Promise((t,n)=>{let r=vk(e);try{$O(r.deflated,{size:r.uncompressedLen+1},(e,i)=>{if(e)n(yk(e,r));else try{t(bk(i,r))}catch(e){n(e)}})}catch(e){n(yk(e,r))}})}function Ck(e){if(typeof TextDecoder<`u`)return new TextDecoder(`utf-8`).decode(e);if(globalThis.Buffer!==void 0)return globalThis.Buffer.from(e).toString(`utf-8`);throw new vD(`No UTF-8 decoder available in this environment.`,_D.INVALID_STATE)}function wk(e,t,n){if(n===0)return new Int16Array;if(t%2==0)return new Int16Array(e,t,n);let r=new Uint8Array(n*2);return r.set(new Uint8Array(e,t,n*2)),new Int16Array(r.buffer)}function Tk(e,t,n){if(n===0)return new Float32Array;if(t%4==0)return new Float32Array(e,t,n);let r=new Uint8Array(n*4);return r.set(new Uint8Array(e,t,n*4)),new Float32Array(r.buffer)}function Ek(e,t,n){if(n===0)return new Uint16Array;if(t%2==0)return new Uint16Array(e,t,n);let r=new Uint8Array(n*2);return r.set(new Uint8Array(e,t,n*2)),new Uint16Array(r.buffer)}function Dk(e,t,n){if(n===0)return new Uint32Array;if(t%4==0)return new Uint32Array(e,t,n);let r=new Uint8Array(n*4);return r.set(new Uint8Array(e,t,n*4)),new Uint32Array(r.buffer)}function Ok(e,t){if(e.length!==0&&!(e instanceof Uint16Array&&t>65535)){for(let n=0;n<e.length;n++)if(e[n]>=t)throw Ik(`Index out of range of vertexCount.`,{indexPosition:n,indexValue:e[n],vertexCount:t})}}function kk(e){return e>>>1^-(e&1)}function Ak(e){let t=new Int16Array(e.length),n=0,r=0,i=0;for(let a=0;a<e.length;a+=3)n=n+kk(e[a])<<16>>16,r=r+kk(e[a+1])<<16>>16,i=i+kk(e[a+2])<<16>>16,t[a]=n,t[a+1]=r,t[a+2]=i;return t}function jk(e,t){let n=new Int16Array(t*3),r=t,i=0,a=0,o=0;for(let t=0;t<r;t++)i=i+kk(e[t]|e[r*3+t]<<8)<<16>>16,a=a+kk(e[r+t]|e[r*4+t]<<8)<<16>>16,o=o+kk(e[r*2+t]|e[r*5+t]<<8)<<16>>16,n[t*3]=i,n[t*3+1]=a,n[t*3+2]=o;return n}function Mk(e,t){let n=new Uint16Array(t),r=0;for(let i=0;i<t;i++)r=r+kk(e[i]|e[t+i]<<8)&65535,n[i]=r;return n}function Nk(e,t){let n=new Uint32Array(t),r=0;for(let i=0;i<t;i++){let a=(e[i]|e[t+i]<<8|e[t*2+i]<<16|e[t*3+i]<<24)>>>0;r=r+kk(a)>>>0,n[i]=r}return n}function Pk(e){let t=new Uint16Array(e.length),n=0;for(let r=0;r<e.length;r++)n=n+kk(e[r])&65535,t[r]=n;return t}function Fk(e){let t=new Uint32Array(e.length),n=0;for(let r=0;r<e.length;r++)n=n+kk(e[r])>>>0,t[r]=n;return t}function Ik(e,t){return new vD(e,_D.VALIDATION_ERROR,{context:t})}var Lk=36;function Rk(e,t,n,r,i,a=!1){if(n+Lk>e.byteLength)throw Ik(`Insufficient data to read UV chunk header.`,{expectedBytes:Lk,availableBytes:e.byteLength-n,offset:n});let o=t.getUint32(n,!0);n+=4;let s=t.getFloat64(n,!0);n+=8;let c=t.getFloat64(n,!0);n+=8;let l=t.getFloat64(n,!0);n+=8;let u=t.getFloat64(n,!0);n+=8;let d=r*2,f=o===1,p=d*(f?4:2);if(n+p>e.byteLength)throw Ik(`Insufficient data to read UV chunk.`,{expectedBytes:p,availableBytes:e.byteLength-n,offset:n,uvFormat:o,vertexCount:r});let m=e.byteOffset+n,h;if(f)h=Tk(e.buffer,m,d).slice();else if(a){let t=e.subarray(n,n+p),i=r;h=new Float32Array(d);let a=0,o=0;for(let e=0;e<i;e++)a=a+kk(t[e]|t[i*2+e]<<8)&65535,o=o+kk(t[i+e]|t[i*3+e]<<8)&65535,h[e*2]=s+a*l,h[e*2+1]=c+o*u}else{let t=Ek(e.buffer,m,d);h=new Float32Array(d);let n=0,r=0;for(let e=0;e<d;e+=2)i?(n=n+kk(t[e])&65535,r=r+kk(t[e+1])&65535):(n=t[e],r=t[e+1]),h[e]=s+n*l,h[e+1]=c+r*u}return{uvs:h,offset:n+p}}function zk(e,t,n,r){let i=n*3;if(t+i>e.byteLength)throw Ik(`Insufficient data to read vertex-color chunk.`,{expectedBytes:i,availableBytes:e.byteLength-t,offset:t,vertexCount:n});let a=e.subarray(t,t+i);if(!r)return a.slice();let o=new Uint8Array(i),s=0,c=0,l=0;for(let e=0;e<i;e+=3)s=s+kk(a[e])&255,c=c+kk(a[e+1])&255,l=l+kk(a[e+2])&255,o[e]=s,o[e+1]=c,o[e+2]=l;return o}var Bk=1297040711,Vk=1279410516,Hk=1280590157,Uk=1381516628,Wk=1146309699,Gk=`id`,Kk=`slvm:tex:`,qk=0,Jk=1,Yk=2;function Xk(e){return e.byteLength>=4&&new DataView(e.buffer,e.byteOffset,4).getUint32(0,!0)===1297501267}function Zk(e){let t=Qk(e),n=null,r=null,i=null,a=null,o=[];for(let{type:e,payload:s}of t)switch(e){case Bk:n=s;break;case Vk:r=xk(s);break;case Hk:i=Ck(s);break;case Uk:o.push(s);break;case Wk:a=xk(s)}if(n===null)throw Ik(`SLVM container has no GEOM chunk.`,{chunkCount:t.length});if(r===null)throw Ik(`SLVM container has no TABL chunk.`,{chunkCount:t.length});let{groups:s}=tA(r,a),c=nA(i,o);return{geometryBlob:n,metadata:{materials:c,groups:s}}}function Qk(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<12||t.getUint32(0,!0)!==1297501267)throw Ik(`Not an SLVM container (bad magic).`,{byteLength:e.byteLength});let n=t.getUint32(4,!0);if(n!==3)throw Ik(`Unsupported SLVM version: ${n}`,{expectedVersion:3});let r=t.getUint32(8,!0),i=[],a=12;for(let n=0;n<r;n++){if(a+8>e.byteLength)throw Ik(`Truncated SLVM chunk header.`,{offset:a,chunkIndex:n});let r=t.getUint32(a,!0),o=t.getUint32(a+4,!0);if(a+=8,a+o>e.byteLength)throw Ik(`Truncated SLVM chunk payload.`,{offset:a,chunkIndex:n,byteLen:o});i.push({type:r,payload:e.subarray(a,a+o)}),a+=o+(4-o%4)%4}return i}function $k(e){let t=0,n=0;for(;;){if(e.pos>=e.bytes.byteLength||n>28)throw Ik(`Malformed varint in SLVM table.`,{pos:e.pos});let r=e.bytes[e.pos++];if(t|=(r&127)<<n,!(r&128))return t>>>0;n+=7}}function eA(e,t,n){let r=e.bytes[e.pos++],i=Array(t);switch(r){case qk:i.fill(``);break;case Jk:for(let e=0;e<t;e++)i[e]=String(e+1);break;case Yk:for(let r=0;r<t;r++)i[r]=n[$k(e)]??``;break;default:throw Ik(`Unknown SLVM string column mode: ${r}`,{pos:e.pos})}return i}function tA(e,t){let n={bytes:e,pos:0},r=$k(n),i=$k(n),a=$k(n),o=r+i+a,s=$k(n),c=Array(s);for(let t=0;t<s;t++){let r=$k(n);c[t]=Ck(e.subarray(n.pos,n.pos+r)),n.pos+=r}let l=Array(r),u=Array(r);for(let e=0;e<r;e++)l[e]=$k(n),u[e]=$k(n);for(let e=0;e<i;e++)$k(n);let d=$k(n),f=[];for(let e=0;e<d;e++)f.push({materialId:$k(n),meshCount:$k(n)});let p=eA(n,o,c),m=eA(n,o,c),h=Array(o),g=$k(n);for(let e=0;e<g;e++){let e=c[$k(n)]??``,t=$k(n),r=Array(t),i=0;for(let e=0;e<t;e++)i+=$k(n),r[e]=i;for(let i=0;i<t;i++){let t=c[$k(n)]??``,a=r[i];(h[a]??={})[e]=t}}let _=f.length>0||r===0?f:[{materialId:0,meshCount:r}],v=[],y=0,b=0,x=0;for(let e of _){let n=[];for(let i=0;i<e.meshCount&&y<r;i++,y++){let e=h[y],r=e?.[Gk];e!==void 0&&delete e[Gk];let i={id:r,name:p[y],layer:m[y],vertexCount:l[y],indexCount:u[y]*3,vertexStart:b,indexStart:x,metadata:e??{}},a=t?.[y];(a===1||a===2)&&(i.closed=a===2),n.push(i),b+=l[y],x+=u[y]*3}v.push({materialId:e.materialId,meshes:n})}return{groups:v}}function nA(e,t){if(e===null)return[];let n;try{n=JSON.parse(e).materials??[]}catch(t){throw Ik(`Failed to parse SLVM materials JSON: ${t instanceof Error?t.message:String(t)}`,{byteLength:e.length})}for(let e of n)for(let n of rA){let r=e[n];if(r?.startsWith(Kk)){let i=t[Number(r.slice(9))];i!==void 0&&(e[n]=iA(i))}}return n}var rA=[`map`,`roughnessMap`,`normalMap`];function iA(e){let t={bytes:e,pos:0},n=$k(t),r=Ck(e.subarray(t.pos,t.pos+n)),i=e.subarray(t.pos+n),a=``,o=32768;for(let e=0;e<i.byteLength;e+=o)a+=String.fromCharCode(...i.subarray(e,e+o));return`data:${r};base64,${btoa(a)}`}function aA(e,t){return new vD(e,_D.VALIDATION_ERROR,{context:t})}var oA=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function sA(e,t,n,r){if(!Array.isArray(e))throw aA(`Batch materials must be an array.`,{materials:typeof e});let i=e.findIndex(e=>!oA(e));if(i!==-1)throw aA(`Each material entry must be an object.`,{materialIndex:i});let a=e.length;if(!Array.isArray(t))throw aA(`Batch groups must be an array.`,{groups:typeof t});t.forEach((e,t)=>{if(!oA(e)||!Array.isArray(e.meshes))throw aA(`Each group must be an object with a meshes array.`,{groupIndex:t});if(!e.meshes.every(oA))throw aA(`Each mesh entry must be an object.`,{groupIndex:t})});for(let e of t){if(!Number.isInteger(e.materialId)||e.materialId<0||e.materialId>=a)throw aA(`Group materialId out of range of the materials array.`,{materialId:e.materialId,materialCount:a});for(let t of e.meshes){let e={vertexStart:t.vertexStart,vertexCount:t.vertexCount,indexStart:t.indexStart,indexCount:t.indexCount};for(let[n,r]of Object.entries(e))if(!Number.isInteger(r)||r<0)throw aA(`Mesh metadata field \"${n}\" must be a non-negative integer.`,{meshName:t.name,field:n,value:r});if(t.vertexStart+t.vertexCount>n)throw aA(`Mesh vertex window exceeds the batch vertex buffer.`,{meshName:t.name,vertexStart:t.vertexStart,vertexCount:t.vertexCount,totalVertexCount:n});if(t.indexStart+t.indexCount>r)throw aA(`Mesh index window exceeds the batch index buffer.`,{meshName:t.name,indexStart:t.indexStart,indexCount:t.indexCount,totalIndexCount:r})}}}function cA(e,t){return aA(`Index references a vertex outside its mesh's vertex window.`,{meshName:t.name,indexValue:e,vertexStart:t.vertexStart,vertexCount:t.vertexCount})}function lA(e,t,n){let r=new Float32Array(e.length),i=t[0],a=t[1],o=t[2],s=n[0],c=n[1],l=n[2];for(let t=0;t<e.length;t+=3)r[t]=i+(e[t]+32767)*s,r[t+1]=a+(e[t+1]+32767)*c,r[t+2]=o+(e[t+2]+32767)*l;return r}function uA(e){let t;t=e.isFloat32?e.vertexData:e.planarByteSplit?jk(e.vertexData,e.vertexCount):e.deltaEncoded?Ak(e.vertexData):e.vertexData;let n;if(e.planarByteSplit){let t=e.indexData;n=e.uint16Indices?Mk(t,t.length/2):Nk(t,t.length/4)}else n=e.deltaEncoded?e.indexData instanceof Uint16Array?Pk(e.indexData):Fk(e.indexData):e.indexData;return Ok(n,e.vertexCount),{metadata:e.metadata,flags:e.flags,vertices:t,indices:n,origin:e.origin,scale:e.scale,uvs:e.uvs,colors:e.colors}}function dA(e){if(!mk)throw new vD(`SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.`,_D.ENVIRONMENT_ERROR);let t=hk(e);if(Xk(t)){let e=Zk(t),n=dA(e.geometryBlob);return n.metadata=e.metadata,n}let n=xk(t),r=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<12)throw Ik(`Blob too small to contain SLVA header.`,{expectedBytes:12,availableBytes:n.byteLength});let i=0,a=r.getUint32(i,!0);if(i+=4,a!==1096174675)throw Ik(`Invalid SLVA magic: 0x${a.toString(16)}`,{expectedMagic:`0x${pk.toString(16)}`,actualMagic:`0x${a.toString(16)}`});let o=r.getUint32(i,!0);if(i+=4,o<1||o>4)throw Ik(`Unsupported SLVA version: ${o}`,{minSupportedVersion:1,maxSupportedVersion:4,actualVersion:o});let s=r.getUint32(i,!0);if(i+=4,i+s>n.byteLength)throw Ik(`Insufficient data to read metadata JSON.`,{expectedBytes:s,availableBytes:n.byteLength-i,offset:i});let c=n.subarray(i,i+s);i+=s;let l;try{l=s===0?{}:JSON.parse(Ck(c))}catch(e){throw Ik(`Failed to parse metadata JSON: ${e instanceof Error?e.message:String(e)}`,{metadataLen:s})}if(!fA(l))throw Ik(`Metadata JSON must be an object whose materials and groups are arrays.`,{metadataLen:s});if(i+56>n.byteLength)throw Ik(`Insufficient data to read geometry header.`,{expectedBytes:56,availableBytes:n.byteLength-i,offset:i});let u=r.getUint32(i,!0);i+=4;let d=r.getFloat64(i,!0);i+=8;let f=r.getFloat64(i,!0);i+=8;let p=r.getFloat64(i,!0);i+=8;let m=r.getFloat64(i,!0);i+=8;let h=r.getFloat64(i,!0);i+=8;let g=r.getFloat64(i,!0);i+=8;let _=r.getUint32(i,!0);i+=4;let v=!!(u&1),y=!!(u&4),b=!!(u&32),x=_*3,S=x*(v?4:2);if(i+S>n.byteLength)throw Ik(`Insufficient data to read vertices.`,{expectedBytes:S,availableBytes:n.byteLength-i,offset:i,useFloat32:v,vertexCount:_});let C=n.byteOffset+i,w;if(w=v?Tk(n.buffer,C,x):b?n.subarray(i,i+S):y?Ek(n.buffer,C,x):wk(n.buffer,C,x),i+=S,i+4>n.byteLength)throw Ik(`Insufficient data to read index count.`,{expectedBytes:4,availableBytes:n.byteLength-i,offset:i});let T=r.getUint32(i,!0);i+=4;let E=!!(u&2),D=T*(E?2:4);if(i+D>n.byteLength)throw Ik(`Insufficient data to read indices.`,{expectedBytes:D,availableBytes:n.byteLength-i,offset:i,indexCount:T,useUint16Indices:E});let O=b?n.subarray(i,i+D):E?Ek(n.buffer,n.byteOffset+i,T):Dk(n.buffer,n.byteOffset+i,T);i+=D;let k=null;if(u&8){let e=Rk(n,r,i,_,y,b);k=e.uvs,i=e.offset}let A=null;return u&16&&(A=zk(n,i,_,y)),{metadata:l,flags:u,vertexData:w,indexData:O,isFloat32:v,deltaEncoded:y,planarByteSplit:b,uint16Indices:E,vertexCount:_,origin:[d,f,p],scale:[m,h,g],uvs:k,colors:A}}function fA(e){if(!oA(e))return!1;let{materials:t,groups:n}=e;return(t===void 0||Array.isArray(t))&&(n===void 0||Array.isArray(n))}function pA(e,t,n){if(n.length===0)return!1;let r=e=>{let t=16;for(;t<e*2;)t*=2;return t},i=e.length/3,a=new Int32Array(i),o=new Int32Array(i),s=new Int32Array,c=new Int32Array,l=new Int32Array,u=new Int32Array,d=new Int32Array,f=new Int32Array,p=new Int32Array,m=new Int32Array,h=new Int32Array,g=(e,t)=>e.length>=t?e:new Int32Array(t),_=(n,i,_)=>{if(_<12||_%3!=0)return!1;let v=2*n+1,y=v+1,b=0,x=0;for(let n=0;n<_;n++){let r=t[i+n];a[r]!==v&&(a[r]=v,x++,b=Math.max(b,Math.abs(e[r*3]),Math.abs(e[r*3+1]),Math.abs(e[r*3+2])))}if(!(b>0)||!Number.isFinite(b))return!1;let S=1/(2*2**(Math.floor(Math.log2(b))-23)),C=r(x),w=C-1;s=g(s,C),s.fill(-1,0,C),c=g(c,C),l=g(l,C),u=g(u,C);let T=(e,t,n)=>{let r=Math.imul(e,2654435761)^Math.imul(t,2246822519)^Math.imul(n,3266489917);for(r=(r^r>>>15)&w;s[r]!==-1&&(c[r]!==e||l[r]!==t||u[r]!==n);)r=r+1&w;return r},E=(e,t)=>{let n=e-t;return n>.25?t+1:n<-.25?t-1:t};d=g(d,_),f=g(f,x);let D=0;for(let n=0;n<_;n++){let r=t[i+n];if(a[r]===y){d[n]=o[r];continue}let p=e[r*3]*S,m=e[r*3+1]*S,h=e[r*3+2]*S,g=Math.round(p),_=Math.round(m),v=Math.round(h),b=E(p,g),x=E(m,_),C=E(h,v),w=-1,O=-1;for(let e=0;e<8&&w===-1;e++){if(e&1&&b===g||e&2&&x===_||e&4&&C===v)continue;let t=T(e&1?b:g,e&2?x:_,e&4?C:v);e===0&&(O=t),s[t]!==-1&&(w=s[t])}if(w===-1){let e=O;w=D++,s[e]=w,c[e]=g,l[e]=_,u[e]=v,f[w]=r}a[r]=y,o[r]=w,d[n]=w}p=g(p,D+1),p.fill(0,0,D+1);let O=0;for(let e=0;e<_;e+=3){let t=d[e],n=d[e+1],r=d[e+2];t!==n&&n!==r&&r!==t&&(p[t+1]+=1,p[n+1]+=1,p[r+1]+=1,O++)}if(O<4)return!1;for(let e=0;e<D;e++)p[e+1]+=p[e];m=g(m,p[D]),h=g(h,D),h.set(p.subarray(0,D));for(let e=0;e<_;e+=3){let t=d[e],n=d[e+1],r=d[e+2];t!==n&&n!==r&&r!==t&&(m[h[t]]=n,h[t]+=1,m[h[n]]=r,h[n]+=1,m[h[r]]=t,h[r]+=1)}for(let e=0;e<D;e++){let t=p[e],n=p[e+1];for(let r=t;r<n;r++){let n=m[r];for(let e=t;e<r;e++)if(m[e]===n)return!1;let i=!1;for(let t=p[n],r=p[n+1];t<r&&!i;t++)i=m[t]===e;if(!i)return!1}}let k=f[d[0]]*3,A=e[k],j=e[k+1],M=e[k+2],N=0;for(let t=0;t<_;t+=3){let n=f[d[t]]*3,r=f[d[t+1]]*3,i=f[d[t+2]]*3,a=e[n]-A,o=e[n+1]-j,s=e[n+2]-M,c=e[r]-A,l=e[r+1]-j,u=e[r+2]-M,p=e[i]-A,m=e[i+1]-j,h=e[i+2]-M;N+=a*(l*h-u*m)+o*(u*p-c*h)+s*(c*m-l*p)}return N>0},v=0;for(let e=0;e<n.length;e++){let t=n[e];if(!_(e,v,t))return!1;v+=t}return!0}function mA(e,t,n,r){let i=Math.cos(30*Math.PI/180),a=e.length/3,o=t.length,s=o/3,c=new Uint32Array;{let i=new Uint32Array(e.buffer,e.byteOffset,e.length),s=n?new Uint32Array(n.buffer,n.byteOffset,n.length):null,l=(e,t)=>e[t]===2147483648?0:e[t],u=16;for(;u<a*2;)u*=2;let d=u-1,f=new Int32Array(u).fill(-1),p=new Uint32Array(a),m=!1;for(let e=0;e<a;e++){let t=l(i,e*3),n=l(i,e*3+1),a=l(i,e*3+2),o=Math.imul(t,2654435761)^Math.imul(n,2246822519)^Math.imul(a,3266489917);for(o=(o^o>>>15)&d;;){let c=f[o];if(c===-1){f[o]=e,p[e]=e;break}if(l(i,c*3)===t&&l(i,c*3+1)===n&&l(i,c*3+2)===a&&(!r||r[c*3]===r[e*3]&&r[c*3+1]===r[e*3+1]&&r[c*3+2]===r[e*3+2])&&(!s||s[c*2]===s[e*2]&&s[c*2+1]===s[e*2+1])){p[e]=c,m=!0;break}o=o+1&d}}if(m){for(let e=0;e<o;e++)t[e]=p[t[e]];let e=0;for(let t=0;t<a;t++)p[t]!==t&&e++;c=new Uint32Array(e);for(let e=0,t=0;e<a;e++)p[e]!==e&&(c[t++]=e)}}let l=new Float32Array(s*3),u=new Float32Array(s);for(let n=0;n<s;n++){let r=t[n*3]*3,i=t[n*3+1]*3,a=t[n*3+2]*3,o=e[i]-e[r],s=e[i+1]-e[r+1],c=e[i+2]-e[r+2],d=e[a]-e[r],f=e[a+1]-e[r+1],p=e[a+2]-e[r+2],m=s*p-c*f,h=c*d-o*p,g=o*f-s*d,_=Math.sqrt(m*m+h*h+g*g);_!==0&&(l[n*3]=m/_,l[n*3+1]=h/_,l[n*3+2]=g/_,u[n]=_)}let d=new Uint32Array(a+1);for(let e=0;e<o;e++)d[t[e]+1]+=1;for(let e=0;e<a;e++)d[e+1]+=d[e];let f=new Uint32Array(o),p=d.slice(0,a);for(let e=0;e<o;e++){let n=t[e];f[p[n]]=e,p[n]+=1}let m=0;for(let e=0;e<a;e++)m=Math.max(m,d[e+1]-d[e]);let h=new Uint32Array(o),g=new Uint32Array(a),_=new Float32Array(Math.max(1,m)*3);for(let e=0;e<a;e++){let t=0;for(let n=d[e];n<d[e+1];n++){let e=f[n],r=Math.floor(e/3)*3,a=l[r],o=l[r+1],s=l[r+2],c=-1;if(a===0&&o===0&&s===0)c=0;else for(let e=0;e<t;e++)if(_[e*3]*a+_[e*3+1]*o+_[e*3+2]*s>=i){c=e;break}c===-1&&(c=t,_[t*3]=a,_[t*3+1]=o,_[t*3+2]=s,t++),h[e]=c}g[e]=Math.max(1,t)}let v=new Uint32Array(a+1);for(let e=0;e<a;e++)v[e+1]=v[e]+g[e]-1;let y=v[a],b=a+Math.max(0,y-c.length),x=new Uint32Array(y);for(let e=0;e<y;e++)x[e]=e<c.length?c[e]:a+e-c.length;let S=e,C=n,w=r;if(y>0){S=new Float32Array(b*3),S.set(e),C=n?new Float32Array(b*2):null,C&&n&&C.set(n),w=r?new Uint8Array(b*3):null,w&&r&&w.set(r);for(let t=0;t<a;t++)for(let i=1;i<g[t];i++){let a=x[v[t]+i-1];S[a*3]=e[t*3],S[a*3+1]=e[t*3+1],S[a*3+2]=e[t*3+2],C&&n&&(C[a*2]=n[t*2],C[a*2+1]=n[t*2+1]),w&&r&&(w[a*3]=r[t*3],w[a*3+1]=r[t*3+1],w[a*3+2]=r[t*3+2])}}let T=new Float32Array(b*3);for(let e=0;e<s;e++){let n=u[e],r=l[e*3]*n,i=l[e*3+1]*n,a=l[e*3+2]*n;for(let n=e*3;n<e*3+3;n++){let e=t[n],o=h[n];o!==0&&(e=x[v[e]+o-1],t[n]=e),T[e*3]+=r,T[e*3+1]+=i,T[e*3+2]+=a}}for(let e=0;e<T.length;e+=3){let t=T[e],n=T[e+1],r=T[e+2],i=Math.sqrt(t*t+n*n+r*r)||1;T[e]=t/i,T[e+1]=n/i,T[e+2]=r/i}return{positions:S,normals:T,indices:t,uvs:C,colors:w}}function hA(e,t,n,r){let i=e.length/3,a=new Float32Array(i*3),o=new Float32Array(i*3);for(let t=0;t<n.length;t+=3){let i=n[t],s=n[t+1],c=n[t+2],l=e[s*3]-e[i*3],u=e[s*3+1]-e[i*3+1],d=e[s*3+2]-e[i*3+2],f=e[c*3]-e[i*3],p=e[c*3+1]-e[i*3+1],m=e[c*3+2]-e[i*3+2],h=u*m-d*p,g=d*f-l*m,_=l*p-u*f,v=Math.sqrt(h*h+g*g+_*_);if(v===0)continue;let y=(p*_-m*g)/v,b=(m*h-f*_)/v,x=(f*g-p*h)/v,S=(g*d-_*u)/v,C=(_*l-h*d)/v,w=(h*u-g*l)/v,T=r[s*2]-r[i*2],E=r[c*2]-r[i*2],D=r[s*2+1]-r[i*2+1],O=r[c*2+1]-r[i*2+1],k=T*y+E*S,A=T*b+E*C,j=T*x+E*w,M=D*y+O*S,N=D*b+O*C,P=D*x+O*w;for(let e=0;e<3;e++){let r=n[t+e];a[r*3]+=k,a[r*3+1]+=A,a[r*3+2]+=j,o[r*3]+=M,o[r*3+1]+=N,o[r*3+2]+=P}}let s=new Float32Array(i*4);for(let e=0;e<i;e++){let n=t[e*3],r=t[e*3+1],i=t[e*3+2],c=a[e*3]*n+a[e*3+1]*r+a[e*3+2]*i,l=a[e*3]-c*n,u=a[e*3+1]-c*r,d=a[e*3+2]-c*i,f=Math.sqrt(l*l+u*u+d*d);if(!(f>1e-12)){let e=+(Math.abs(n)<.9),t=1-e;l=t*i,u=-e*i,d=e*r-t*n,f=Math.sqrt(l*l+u*u+d*d)||1}l/=f,u/=f,d/=f;let p=r*d-i*u,m=i*l-n*d,h=n*u-r*l,g=p*o[e*3]+m*o[e*3+1]+h*o[e*3+2];s[e*4]=l,s[e*4+1]=u,s[e*4+2]=d,s[e*4+3]=g<0?-1:1}return s}function gA(e,t){let n=t.every(e=>typeof e.closed==`boolean`)?t.length>0&&t.every(e=>e.closed):pA(e.positions,e.indices,t.map(e=>e.indexCount)),r=mA(e.positions,e.indices,e.uvs,e.colors),i=r.uvs?hA(r.positions,r.normals,r.indices,r.uvs):null;return{...r,closed:n,tangents:i}}function _A(e){let{isFloat32:t,deltaEncoded:n,planarByteSplit:r,uint16Indices:i,origin:a,scale:o,uvs:s,colors:c,jobs:l}=e,u=e=>e>>>1^-(e&1),d;if(t)d=e.vertexData;else{let t;if(r){let n=e.vertexData,r=n.length/6;t=new Int16Array(r*3);let i=0,a=0,o=0;for(let e=0;e<r;e++)i=i+u(n[e]|n[r*3+e]<<8)<<16>>16,a=a+u(n[r+e]|n[r*4+e]<<8)<<16>>16,o=o+u(n[r*2+e]|n[r*5+e]<<8)<<16>>16,t[e*3]=i,t[e*3+1]=a,t[e*3+2]=o}else if(n){let n=e.vertexData;t=new Int16Array(n.length);let r=0,i=0,a=0;for(let e=0;e<n.length;e+=3)r=r+u(n[e])<<16>>16,i=i+u(n[e+1])<<16>>16,a=a+u(n[e+2])<<16>>16,t[e]=r,t[e+1]=i,t[e+2]=a}else t=e.vertexData;d=new Float32Array(t.length);let i=a[0],s=a[1],c=a[2],l=o[0],f=o[1],p=o[2];for(let e=0;e<t.length;e+=3)d[e]=i+(t[e]+32767)*l,d[e+1]=s+(t[e+1]+32767)*f,d[e+2]=c+(t[e+2]+32767)*p}let f;if(r){let t=e.indexData;if(i){let e=t.length/2,n=new Uint16Array(e),r=0;for(let i=0;i<e;i++)r=r+u(t[i]|t[e+i]<<8)&65535,n[i]=r;f=n}else{let e=t.length/4,n=new Uint32Array(e),r=0;for(let i=0;i<e;i++){let a=(t[i]|t[e+i]<<8|t[e*2+i]<<16|t[e*3+i]<<24)>>>0;r=r+u(a)>>>0,n[i]=r}f=n}}else if(n){let t=e.indexData;if(t instanceof Uint16Array){let e=new Uint16Array(t.length),n=0;for(let r=0;r<t.length;r++)n=n+u(t[r])&65535,e[r]=n;f=e}else{let e=new Uint32Array(t.length),n=0;for(let r=0;r<t.length;r++)n=n+u(t[r])>>>0,e[r]=n;f=e}}else f=e.indexData;let p=d.length/3;for(let e=0;e<f.length;e++)if(f[e]>=p)throw Error(`Index ${f[e]} out of range of vertexCount ${p}`);let m=[];for(let e of l){let t=0,n=0;for(let r of e.windows)t+=r.vertexCount,n+=r.indexCount;let r=new Float32Array(t*3),i=new Uint32Array(n),a=s?new Float32Array(t*2):null,o=c?new Uint8Array(t*3):null,l=0,u=0;for(let t of e.windows){let e=t.vertexStart*3;r.set(d.subarray(e,e+t.vertexCount*3),l*3),a&&s&&a.set(s.subarray(t.vertexStart*2,(t.vertexStart+t.vertexCount)*2),l*2),o&&c&&o.set(c.subarray(e,e+t.vertexCount*3),l*3);let n=t.vertexStart,p=t.vertexStart+t.vertexCount,m=l-t.vertexStart;for(let e=0;e<t.indexCount;e++){let r=f[t.indexStart+e];if(r<n||r>=p)throw Error(`Index ${r} outside vertex window [${n}, ${p})`);i[u+e]=r+m}l+=t.vertexCount,u+=t.indexCount}m.push({positions:r,indices:i,uvs:a,colors:o})}return m}function vA(){return[`const assemble = ${_A.toString()};`,`const isClosedSolid = ${pA.toString()};`,`const splitCreases = ${mA.toString()};`,`const grainTangents = ${hA.toString()};`,`self.onmessage = (event) => {`,` const { id, input } = event.data;`,` try {`,` const geometries = assemble(input).map((g, i) => {`,` const windows = input.jobs[i].windows;`,` const known = windows.every((w) => typeof w.closed === 'boolean');`,` const closed = known`,` ? windows.length > 0 && windows.every((w) => w.closed)`,` : isClosedSolid(g.positions, g.indices, windows.map((w) => w.indexCount));`,` const c = splitCreases(g.positions, g.indices, g.uvs, g.colors);`,` const tangents = c.uvs ? grainTangents(c.positions, c.normals, c.indices, c.uvs) : null;`,` return { ...c, closed, tangents };`,` });`,` const transfer = [];`,` for (const g of geometries) {`,` transfer.push(g.positions.buffer, g.normals.buffer, g.indices.buffer);`,` if (g.uvs) transfer.push(g.uvs.buffer);`,` if (g.tangents) transfer.push(g.tangents.buffer);`,` if (g.colors) transfer.push(g.colors.buffer);`,` }`,` self.postMessage({ id, geometries }, transfer);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`\n`)}var yA,bA=new Map,xA=1;function SA(){if(yA!==void 0)return yA;if(typeof Worker>`u`||typeof Blob>`u`||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return yA=null,null;try{let e=URL.createObjectURL(new Blob([vA()],{type:`text/javascript`})),t=new Worker(e);t.onmessage=e=>{let{id:t,geometries:n,error:r}=e.data,i=bA.get(t);i&&(bA.delete(t),n?i.resolve(n):i.reject(Error(r??`mesh assembly failed in worker`)))},t.onerror=()=>{for(let e of bA.values())e.reject(Error(`mesh assembly worker crashed`));bA.clear(),t.terminate(),yA=null},yA=t}catch{yA=null}return yA}function CA(e,t,n){return new Promise((r,i)=>{let a=xA++;bA.set(a,{resolve:r,reject:i}),e.postMessage({id:a,input:t},n)})}var wA=1;function TA(e){wA=Math.max(1,e)}PD(TA);function EA(e,t,n,r){typeof document<`u`&&new rC().load(t,t=>{if(t.colorSpace=n===`map`?F_:``,t.anisotropy=wA,r){let e=t.image,n=e?.width&&e.height?e.height/e.width:1;t.wrapS=pg,t.wrapT=pg,t.repeat.set(1/r,1/(r*n))}e[n]=t,e.needsUpdate=!0},void 0,e=>{bD().warn(`Failed to load material ${n} ${t}:`,e)})}var DA=e=>e.toFixed(4),OA=120,kA=120,AA=160,jA=.7,MA=.0105,NA=.14,PA=.35,FA=.3,IA=.4,LA=FA*.7*.42,RA=e=>`( ( ${e} ) + ( selvaHash( vec2( ${e}, 6.0 ) ) - 0.5 ) * ${DA(jA)} ) * ${DA(AA)}`,zA=({ring:e,latewood:t,band:n,pores:r,streaks:i})=>`\n float cell = floor( uv.y / ${DA(AA)} );\n float plank = cell + ( uv.y < ${RA(`cell`)} ? -1.0 : ( uv.y >= ${RA(`cell + 1.0`)} ? 1.0 : 0.0 ) );\n float lo = ${RA(`plank`)};\n float hi = ${RA(`plank + 1.0`)};\n // Each plank starts somewhere else along its log.\n float along = uv.x + selvaHash( vec2( plank, 9.0 ) ) * 5000.0;\n // The pith lies anywhere under the plank, sometimes past its edge, which leaves straight\n // rift grain on that side.\n float heart = mix( lo, hi, selvaHash( vec2( plank, 3.0 ) ) * 1.6 - 0.3 );\n heart += ( selvaNoise( vec2( along * 0.0006, plank * 7.0 ) ) - 0.5 ) * 50.0;\n float s = uv.y - heart;\n float pith = ${DA(OA)} + selvaHash( vec2( plank, 2.0 ) ) * ${DA(kA)};\n pith += ( selvaFbm( vec2( along * 0.0004, plank * 5.0 + 1.0 ) ) - 0.5 ) * ${DA(50)};\n float lean = ${DA(MA)} * ( 0.5 + selvaHash( vec2( plank, 8.0 ) ) );\n // Rings wander a few mm and vary in spacing, as growth does from year to year.\n float wander = ( selvaFbm( vec2( along * 0.003, uv.y * 0.008 ) ) - 0.5 ) * ${DA(e*2)};\n float r = sqrt( pith * pith + s * s ) + along * lean + wander;\n r += selvaFbm( vec2( r * 0.02, plank ) ) * ${DA(e*3)} + selvaHash( vec2( plank, 1.0 ) ) * ${DA(e*20)};\n float year = fract( r / ${DA(e)} );\n float late = smoothstep( ${DA(1-n)}, ${DA(1-n*.4)}, year ) * ( 1.0 - smoothstep( 0.95, 1.0, year ) );\n // Open-pored wood shows its rings as a broken band of pores, not a clean line.\n float broken = 1.0 - smoothstep( 0.3, 0.7, selvaNoise( uv * vec2( 0.25, 2.0 ) ) );\n late *= 1.0 - ${DA(r*.45)} * mix( 0.5, broken, selvaDetail( 0.5 ) );\n late *= selvaDetail( ${DA(e)} );\n float fibre = ( selvaNoise( uv * vec2( 0.04, 1.6 ) ) - 0.5 ) * selvaDetail( 1.0 );\n // Pores: thin dashes along the grain, most of each row empty. Smaller than a pixel they\n // show as their average shade, or they would be static.\n float poreRow = floor( uv.y / ${DA(PA)} );\n float poreAlong = uv.x / mix( 1.5, 5.0, selvaHash( vec2( poreRow, 11.0 ) ) ) + selvaHash( vec2( poreRow, 12.0 ) );\n float poreT = fract( poreAlong );\n float pore = step( ${DA(.7)}, selvaHash( vec2( poreRow, 13.0 + 1.618 * floor( poreAlong ) ) ) );\n pore *= smoothstep( 0.0, 0.3, poreT ) * smoothstep( 1.0, 0.7, poreT );\n pore *= 1.0 - smoothstep( 0.12, 0.3, abs( fract( uv.y / ${DA(PA)} ) - 0.5 ) );\n pore = mix( ${DA(LA)}, pore, selvaDetail( ${DA(PA)} ) ) * ${DA(r)} * ( 1.0 - 0.6 * late );\n float streak = ( selvaFbm( vec2( along * 0.0015, uv.y * 0.012 ) ) - 0.5 ) * ${DA(i)};\n float shade = 1.0 + ${DA(t*n)} - late * ${DA(t)} + fibre * 0.1 - pore * ${DA(IA)} + streak * 0.6;\n float board = ( selvaHash( vec2( plank, 4.0 ) ) - 0.5 ) * selvaDetail( ${DA(AA*.5)} );\n float warmth = ( selvaHash( vec2( plank, 5.0 ) ) - 0.5 ) * selvaDetail( ${DA(AA*.5)} );\n tone = vec3( shade ) * ( 1.0 + board * ${DA(NA)} ) * vec3( 1.0 + warmth * 0.06, 1.0, 1.0 - warmth * 0.06 );\n gloss = 1.0 + late * 0.08 + pore * 0.4 - fibre * 0.2;\n // No relief from pores: a bump from screen derivatives beads any dash under a few pixels wide.\n height = fibre * 0.00008 * selvaDetail( 0.6 );`,BA={wood:zA({ring:4,latewood:.3,band:.4,pores:.4,streaks:.35}),walnut:zA({ring:5,latewood:.2,band:.4,pores:1,streaks:.45}),oak:zA({ring:3,latewood:.3,band:.35,pores:.9,streaks:.25}),maple:zA({ring:3,latewood:.2,band:.1,pores:0,streaks:.12}),wenge:zA({ring:1.5,latewood:.7,band:.5,pores:.6,streaks:.4}),concrete:`\n float cloud = ( selvaFbm( uv * 0.002 ) - 0.5 ) * selvaDetail( 80.0 );\n float mottle = ( selvaFbm( uv * 0.018 + vec2( 5.0, 1.0 ) ) - 0.5 ) * selvaDetail( 15.0 );\n float sand = ( selvaNoise( uv * 0.5 ) - 0.5 ) * selvaDetail( 2.5 );\n vec3 pore = selvaCell( uv / 30.0 );\n // One cell in ten holds a hole 2 to 5 mm across.\n float radius = mix( 1.0, 2.5, selvaHash( vec2( pore.z, 4.0 ) ) ) / 30.0;\n float hole = 1.0 - smoothstep( radius * 0.5, radius, pore.x );\n hole *= step( 0.9, selvaHash( vec2( pore.z, 2.0 ) ) ) * selvaDetail( 4.0 );\n tone = vec3( 1.0 + cloud * 0.18 + mottle * 0.07 + sand * 0.03 - hole * 0.3 );\n gloss = 1.0 + cloud * 0.15 + hole * 0.1;\n height = -hole * 0.0003;`,plaster:`\n float trowel = 0.5 + ( selvaFbm( uv * 0.05 ) - 0.5 ) * selvaDetail( 6.0 );\n tone = vec3( 1.0 + ( trowel - 0.5 ) * 0.07 );\n gloss = 1.0 + ( trowel - 0.5 ) * 0.2;\n height = trowel * 0.0007;`,brick:`\n vec2 course = vec2( 225.0, 75.0 );\n float row = floor( uv.y / course.y );\n vec2 laid = vec2( uv.x + mod( row, 2.0 ) * course.x * 0.5, uv.y );\n vec2 id = floor( laid / course );\n vec2 edge = abs( fract( laid / course ) - 0.5 ) * course;\n float joint = 1.0 - smoothstep( 0.0, 1.5, min( course.x * 0.5 - 5.0 - edge.x, course.y * 0.5 - 5.0 - edge.y ) );\n joint *= selvaDetail( 10.0 );\n float face = 1.0 + ( ( selvaHash( id ) - 0.5 ) * 0.48 + ( selvaFbm( uv * 0.05 ) - 0.5 ) * 0.25 ) * selvaDetail( 65.0 );\n tone = mix( vec3( face ), vec3( 1.5, 1.7, 1.8 ), joint );\n gloss = 1.0 + joint * 0.15;\n height = -joint * 0.005;`,limestone:`\n float cloud = ( selvaFbm( uv * 0.004 ) - 0.5 ) * selvaDetail( 60.0 );\n float mottle = ( selvaFbm( uv * 0.025 + vec2( 3.0, 7.0 ) ) - 0.5 ) * selvaDetail( 12.0 );\n float bed = ( selvaNoise( vec2( uv.x * 0.003, uv.y * 0.05 ) ) - 0.5 ) * selvaDetail( 10.0 );\n float fleck = smoothstep( 0.8, 0.9, selvaNoise( uv * 0.5 ) ) * selvaDetail( 2.0 );\n vec3 fossil = selvaCell( uv / 14.0 );\n float shell = ( 1.0 - smoothstep( 0.08, 0.16, fossil.x ) ) * step( 0.85, fossil.z ) * selvaDetail( 6.0 );\n tone = vec3( 1.0 + cloud * 0.14 + mottle * 0.1 + bed * 0.03 - fleck * 0.12 - shell * 0.1 );\n gloss = 1.0 + cloud * 0.1;\n height = -( fleck + shell ) * 0.00005;`,travertine:`\n float band = selvaFbm( vec2( uv.x * 0.002, uv.y * 0.012 ) );\n float layer = ( band - 0.5 ) * selvaDetail( 25.0 );\n float pocket = selvaNoise( uv * vec2( 0.025, 0.15 ) ) * 0.7 + selvaNoise( uv * vec2( 0.08, 0.4 ) ) * 0.3;\n float voids = smoothstep( 0.68, 0.78, pocket ) * smoothstep( 0.35, 0.6, band ) * selvaDetail( 4.0 );\n float grain = ( selvaNoise( uv * 0.6 ) - 0.5 ) * selvaDetail( 1.5 );\n tone = vec3( 1.0 + layer * 0.2 + grain * 0.04 ) * mix( vec3( 1.0 ), vec3( 0.62, 0.56, 0.48 ), voids );\n gloss = 1.0 + voids * 0.3;\n height = -voids * 0.002;`,granite:`\n vec3 crystal = selvaCell( uv / 4.0 );\n // Feldspar, quartz and biotite in about the shares of a grey granite. The dark crystals\n // gather in clusters, which is what still reads as granite from a few metres.\n float cluster = selvaFbm( uv * 0.04 ) - 0.5;\n float dark = 0.2 + cluster * 0.2;\n float mineral = crystal.z < dark ? 0.35 : ( crystal.z < dark + 0.3 ? 1.35 : 1.0 );\n mineral *= 1.0 + ( selvaHash( vec2( crystal.z, 3.0 ) ) - 0.5 ) * 0.15;\n mineral = mix( 1.0 - cluster * 0.25 * selvaDetail( 15.0 ), mineral, selvaDetail( 4.0 ) );\n float cloud = ( selvaFbm( uv * 0.005 ) - 0.5 ) * selvaDetail( 50.0 );\n tone = vec3( mineral + cloud * 0.06 );\n gloss = 1.0 - ( mineral - 1.0 ) * 0.15;\n height = ( selvaNoise( uv * 0.8 ) - 0.5 ) * 0.0002 * selvaDetail( 1.2 );`,marble:`\n vec2 w = vec2( uv.x * 0.7 + uv.y * 0.7, uv.y * 0.7 - uv.x * 0.7 ) * vec2( 0.0012, 0.004 );\n w += vec2( selvaFbm( w * 2.0 ), selvaFbm( w * 2.0 + vec2( 4.0, 2.0 ) ) ) * 0.6;\n float feather = smoothstep( 0.3, 0.7, selvaFbm( uv * 0.006 + vec2( 2.0, 5.0 ) ) );\n float major = 1.0 - smoothstep( 0.0, 0.05, abs( selvaFbm( w ) - 0.5 ) );\n float fine = 1.0 - smoothstep( 0.0, 0.02, abs( selvaFbm( w * 3.0 + vec2( 9.0, 1.0 ) ) - 0.5 ) );\n float cloud = ( selvaFbm( uv * 0.003 ) - 0.5 ) * selvaDetail( 60.0 );\n float vein = ( major * 0.35 * selvaDetail( 6.0 ) + fine * 0.2 * selvaDetail( 2.0 ) ) * feather;\n tone = vec3( 1.0 + cloud * 0.06 - vein - feather * 0.04 );\n gloss = 1.0 + vein * 0.3;`,slate:`\n float cleft = selvaFbm( uv * vec2( 0.012, 0.02 ) );\n float flake = mix( cleft, floor( cleft * 4.0 ) / 4.0, 0.6 );\n float seen = selvaDetail( 6.0 );\n float glint = ( selvaNoise( uv * 0.3 ) - 0.5 ) * selvaDetail( 3.0 );\n tone = vec3( 1.0 + ( flake - 0.5 ) * 0.18 * seen + glint * 0.06 );\n gloss = 1.0 - ( flake - 0.5 ) * 0.3 * seen + glint * 0.2;\n height = flake * 0.0015 * seen;`,terrazzo:`\n vec3 chipCell = selvaCell( uv / 9.0 );\n float chip = smoothstep( 0.1, 0.16, chipCell.y - chipCell.x ) * step( 0.12, selvaHash( vec2( chipCell.z, 5.0 ) ) );\n float k = selvaHash( vec2( chipCell.z, 7.0 ) );\n vec3 stone = k < 0.6 ? vec3( 1.1 ) : k < 0.75 ? vec3( 0.65 ) : k < 0.85 ? vec3( 0.22 ) : k < 0.9 ? vec3( 0.85, 0.69, 0.44 ) : k < 0.95 ? vec3( 0.64, 0.35, 0.28 ) : vec3( 0.93, 0.72, 0.66 );\n vec3 gritCell = selvaCell( uv / 2.5 );\n float grit = smoothstep( 0.1, 0.2, gritCell.y - gritCell.x ) * step( 0.6, selvaHash( vec2( gritCell.z, 2.0 ) ) );\n float g = selvaHash( vec2( gritCell.z, 9.0 ) ) < 0.5 ? 0.4 : 1.1;\n vec3 near = mix( vec3( 1.0 ), stone, chip );\n near = mix( near, vec3( g ), grit * ( 1.0 - chip ) * selvaDetail( 2.5 ) );\n // From afar the chips average to a slightly darker matrix.\n tone = mix( vec3( 0.92 ), near, selvaDetail( 9.0 ) );\n gloss = 1.0 + chip * 0.1;`,paving:`\n vec2 size = vec2( 600.0, 400.0 );\n float row = floor( uv.y / size.y );\n vec2 laid = vec2( uv.x + mod( row, 2.0 ) * size.x * 0.5, uv.y );\n vec2 id = floor( laid / size );\n vec2 edge = abs( fract( laid / size ) - 0.5 ) * size;\n float inset = min( size.x * 0.5 - edge.x, size.y * 0.5 - edge.y );\n float joint = ( 1.0 - smoothstep( 2.5, 3.5, inset ) ) * selvaDetail( 5.0 );\n float chamfer = ( 1.0 - smoothstep( 2.5, 6.0, inset ) ) * selvaDetail( 4.0 );\n float slab = ( selvaHash( id ) - 0.5 ) * 0.12 * selvaDetail( 100.0 );\n float blotch = ( selvaFbm( uv * 0.006 ) - 0.5 ) * 0.12 * selvaDetail( 40.0 );\n float speck = ( selvaNoise( uv * 0.7 ) - 0.5 ) * 0.06 * selvaDetail( 1.5 );\n tone = vec3( 1.0 + slab + blotch + speck ) * mix( 1.0, 0.55, joint );\n gloss = 1.0 + joint * 0.1;\n height = -chamfer * 0.002 - joint * 0.003;`,setts:`\n vec2 size = vec2( 110.0, 100.0 );\n vec2 warped = uv + ( vec2( selvaNoise( uv * 0.03 ), selvaNoise( uv * 0.03 + vec2( 3.0, 8.0 ) ) ) - 0.5 ) * 10.0;\n float row = floor( warped.y / size.y );\n vec2 laid = vec2( warped.x + selvaHash( vec2( row, 4.0 ) ) * size.x, warped.y );\n vec2 id = floor( laid / size );\n vec2 edge = abs( fract( laid / size ) - 0.5 ) * size;\n float inset = min( size.x * 0.5 - edge.x, size.y * 0.5 - edge.y );\n float joint = ( 1.0 - smoothstep( 4.0, 6.0, inset ) ) * selvaDetail( 10.0 );\n float dome = smoothstep( 4.0, 25.0, inset );\n vec3 crystal = selvaCell( uv / 4.0 );\n // Feldspar, quartz and biotite in about the shares of a grey granite. The dark crystals\n // gather in clusters, which is what still reads as granite from a few metres.\n float cluster = selvaFbm( uv * 0.04 ) - 0.5;\n float dark = 0.2 + cluster * 0.2;\n float mineral = crystal.z < dark ? 0.35 : ( crystal.z < dark + 0.3 ? 1.35 : 1.0 );\n mineral *= 1.0 + ( selvaHash( vec2( crystal.z, 3.0 ) ) - 0.5 ) * 0.15;\n mineral = mix( 1.0 - cluster * 0.25 * selvaDetail( 15.0 ), mineral, selvaDetail( 4.0 ) );\n float tint = selvaHash( id + vec2( 5.0, 2.0 ) ) - 0.5;\n vec3 sett = ( 1.0 + ( selvaHash( id ) - 0.5 ) * 0.16 ) * ( 1.0 + vec3( 0.05, 0.0, -0.06 ) * tint * 2.0 );\n sett = mix( vec3( 1.0 ), sett, selvaDetail( 100.0 ) );\n tone = mix( sett * mineral, vec3( 1.05, 0.97, 0.82 ), joint );\n gloss = 1.0 + joint * 0.1;\n height = ( dome * 0.006 + ( selvaNoise( uv * 0.15 ) - 0.5 ) * 0.001 ) * selvaDetail( 10.0 );`,gravel:`\n vec3 pebble = selvaCell( uv / 12.0 );\n float gap = 1.0 - smoothstep( 0.04, 0.18, pebble.y - pebble.x );\n float dome = sqrt( clamp( 1.0 - pebble.x * 1.4, 0.0, 1.0 ) );\n float k = selvaHash( vec2( pebble.z, 3.0 ) );\n vec3 stone = k < 0.3 ? vec3( 1.13, 1.14, 1.11 ) : k < 0.55 ? vec3( 0.96, 0.85, 0.71 ) : k < 0.7 ? vec3( 0.84, 0.64, 0.59 ) : k < 0.9 ? vec3( 0.74, 0.8, 0.89 ) : vec3( 0.47, 0.5, 0.56 );\n stone *= 1.0 + ( selvaHash( vec2( pebble.z, 8.0 ) ) - 0.5 ) * 0.15;\n float seen = selvaDetail( 12.0 );\n tone = mix( vec3( 0.85 ), stone * mix( 1.0, 0.35, gap ) * ( 0.85 + 0.15 * dome ), seen );\n gloss = 1.0 + gap * 0.1 - dome * 0.1;\n height = dome * 0.004 * seen;`,molded:`\n float pit = selvaNoise( uv * 1.6 );\n float mottle = selvaNoise( uv * 0.5 + vec2( 7.0, 3.0 ) );\n float grit = ( pit * 0.65 + mottle * 0.35 ) - 0.5;\n float seen = selvaDetail( 0.6 );\n tone = vec3( 1.0 + grit * 0.1 * seen );\n gloss = 1.0 + grit * 0.9 * seen;\n height = ( grit + 0.5 ) * 0.00008 * seen;`,corten:`\n float bloom = 0.5 + ( selvaFbm( uv * vec2( 0.006, 0.0025 ) ) - 0.5 ) * selvaDetail( 25.0 );\n float scale = 0.5 + ( selvaFbm( uv * 0.06 ) - 0.5 ) * selvaDetail( 8.0 );\n tone = mix( vec3( 0.62, 0.52, 0.46 ), vec3( 1.28, 1.08, 0.9 ), smoothstep( 0.32, 0.68, bloom ) );\n tone *= 1.0 + ( scale - 0.5 ) * 0.3;\n gloss = 1.0 + ( scale - 0.5 ) * 0.25;\n height = scale * 0.0004;`};function VA(e,t){let n=BA[e];return!n||!(t>0)?null:{key:`surface:${e}:${DA(t)}`,patch:e=>{e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n float selvaFootprint;\n // Hash without sine: sin() loses precision on the large arguments mm UVs produce.\n float selvaHash( vec2 p ) {\n vec3 p3 = fract( vec3( p.xyx ) * 0.1031 );\n p3 += dot( p3, p3.yzx + 33.33 );\n return fract( ( p3.x + p3.y ) * p3.z );\n }\n float selvaNoise( vec2 p ) {\n vec2 i = floor( p );\n vec2 f = fract( p );\n vec2 s = f * f * ( 3.0 - 2.0 * f );\n return mix(\n mix( selvaHash( i ), selvaHash( i + vec2( 1.0, 0.0 ) ), s.x ),\n mix( selvaHash( i + vec2( 0.0, 1.0 ) ), selvaHash( i + vec2( 1.0, 1.0 ) ), s.x ),\n s.y\n );\n }\n float selvaFbm( vec2 p ) {\n float sum = 0.0;\n float amplitude = 0.5;\n for ( int i = 0; i < 4; i ++ ) {\n sum += amplitude * selvaNoise( p );\n p = p * 2.03 + vec2( 17.0, 9.0 );\n amplitude *= 0.5;\n }\n return sum / 0.9375;\n }\n // Cellular noise: distance to the nearest and second-nearest jittered point, and the\n // nearest one's id. y - x is small along a cell border.\n vec3 selvaCell( vec2 p ) {\n vec2 i = floor( p );\n vec2 fp = fract( p );\n float f1 = 8.0;\n float f2 = 8.0;\n float id = 0.0;\n for ( int y = -1; y <= 1; y ++ ) {\n for ( int x = -1; x <= 1; x ++ ) {\n vec2 g = vec2( float( x ), float( y ) );\n vec2 o = vec2( selvaHash( i + g ), selvaHash( i + g + vec2( 19.0, 7.0 ) ) );\n float d = length( g + o * 0.8 + 0.1 - fp );\n if ( d < f1 ) {\n f2 = f1;\n f1 = d;\n id = selvaHash( i + g + vec2( 3.0, 11.0 ) );\n } else if ( d < f2 ) {\n f2 = d;\n }\n }\n }\n return vec3( f1, f2, id );\n }\n float selvaDetail( float featureMm ) {\n return 1.0 - smoothstep( 0.5, 1.5, selvaFootprint / featureMm );\n }`).replace(`#include <color_fragment>`,`#include <color_fragment>\n selvaFootprint = max( max( fwidth( vUv.x ), fwidth( vUv.y ) ), 1e-6 );\n vec2 uv = vUv;\n vec3 tone = vec3( 1.0 );\n float gloss = 1.0;\n float height = 0.0;\n ${n}\n diffuseColor.rgb *= mix( vec3( 1.0 ), tone, ${DA(t)} );`).replace(`#include <roughnessmap_fragment>`,`#include <roughnessmap_fragment>\n roughnessFactor = clamp( roughnessFactor * mix( 1.0, gloss, ${DA(t)} ), 0.0, 1.0 );`).replace(`#include <normal_fragment_maps>`,`#include <normal_fragment_maps>\n {\n // Bump from screen derivatives, as three's perturbNormalArb.\n vec3 dx = dFdx( - vViewPosition );\n vec3 dy = dFdy( - vViewPosition );\n vec3 r1 = cross( dy, normal );\n vec3 r2 = cross( normal, dx );\n float det = dot( dx, r1 ) * faceDirection;\n vec3 grad = sign( det ) * ( dFdx( height ) * r1 + dFdy( height ) * r2 ) * ${DA(t)};\n normal = normalize( abs( det ) * normal - grad );\n }`)}}}var HA={brushed:{fibres:[{pitch:.04,length:[2,12],depth:.3},{pitch:.25,length:[5,40],depth:.18}],bands:[]},rolled:{fibres:[{pitch:.3,length:[80,600],depth:.07}],bands:[{width:20,length:1500,depth:.05}]}},UA=.6,WA=.35,GA=16,KA=e=>e.toFixed(4);function qA(e,t){let n=HA[e];if(!n)return VA(e,t);if(!(t>0))return null;let r=n.fibres.map((e,t)=>`selvaFibres( vUv, footprint, ${KA(e.pitch)}, vec2( ${KA(e.length[0])}, ${KA(e.length[1])} ), ${KA(e.depth)}, ${KA(t*31+3)} )`).join(` + `)||`0.0`,i=n.bands.map(e=>`selvaBand( vUv, footprint, vec2( ${KA(e.length)}, ${KA(e.width)} ), ${KA(e.depth)} )`).join(` + `)||`0.0`;return{key:`finish:${e}:${KA(t)}`,patch:e=>{e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n // Hash without sine: sin() loses precision on the large arguments mm UVs produce.\n float selvaHash( vec2 p ) {\n vec3 p3 = fract( vec3( p.xyx ) * 0.1031 );\n p3 += dot( p3, p3.yzx + 33.33 );\n return fract( ( p3.x + p3.y ) * p3.z );\n }\n float selvaNoise( vec2 p ) {\n vec2 i = floor( p );\n vec2 f = fract( p );\n vec2 s = f * f * ( 3.0 - 2.0 * f );\n return mix(\n mix( selvaHash( i ), selvaHash( i + vec2( 1.0, 0.0 ) ), s.x ),\n mix( selvaHash( i + vec2( 0.0, 1.0 ) ), selvaHash( i + vec2( 1.0, 1.0 ) ), s.x ),\n s.y\n );\n }\n // One row of fibres per pitch, hard-edged across the grain, each fibre its own depth and\n // tapered at both ends. A depth per row instead drew every row as one streak the height\n // of the part. depth * |depth| keeps most fibres faint and a few deep.\n float selvaFibreRow( vec2 uv, float pitch, vec2 len, float seed ) {\n float row = floor( uv.y / pitch );\n // A coarse cell stays a streak: as wide as it is long it reads as speckle, not grain.\n float l = max( mix( len.x, len.y, selvaHash( vec2( row, seed + 1.0 ) ) ), pitch * ${KA(GA)} );\n float along = uv.x / l + selvaHash( vec2( row, seed + 2.0 ) );\n float seg = floor( along );\n float depth = selvaHash( vec2( row, seed + 3.0 + 1.618 * seg ) ) * 2.0 - 1.0;\n float t = along - seg;\n return depth * abs( depth ) * smoothstep( 0.0, 0.2, t ) * smoothstep( 1.0, 0.8, t );\n }\n // Below pixel size a cell 2^n rows wide stands for the rows it covers, at a reduced\n // spread: distance keeps the grain's texture without the shimmer of sampling single\n // fibres. Two levels blend so nothing pops while zooming.\n float selvaFibres( vec2 uv, float footprint, float pitch, vec2 len, float depth, float seed ) {\n float level = clamp( log2( footprint / pitch ) + 0.5, 0.0, 14.0 );\n float l0 = floor( level );\n float a = selvaFibreRow( uv, pitch * exp2( l0 ), len, seed + 7.0 * l0 ) * exp2( -${KA(WA)} * l0 );\n float b = selvaFibreRow( uv, pitch * exp2( l0 + 1.0 ), len, seed + 7.0 * l0 + 7.0 )\n * exp2( -${KA(WA)} * ( l0 + 1.0 ) );\n return depth * mix( a, b, level - l0 );\n }\n float selvaBand( vec2 uv, float footprint, vec2 size, float depth ) {\n float fade = 1.0 - smoothstep( 0.5, 1.0, footprint / size.y );\n return depth * fade * ( selvaNoise( uv / size ) * 2.0 - 1.0 );\n }`).replace(`#include <color_fragment>`,`#include <color_fragment>\n float footprint = max( fwidth( vUv.y ), 1e-6 );\n float selvaFibre = ( ${r} ) * ${KA(t)};\n float selvaStreak = selvaFibre + ( ${i} ) * ${KA(t)};\n diffuseColor.rgb *= 1.0 + 0.5 * selvaStreak;`).replace(`#include <roughnessmap_fragment>`,`#include <roughnessmap_fragment>\n roughnessFactor = clamp( roughnessFactor * ( 1.0 + selvaStreak ), 0.0, 1.0 );`).replace(`#include <normal_fragment_maps>`,`#include <normal_fragment_maps>\n #ifdef USE_ANISOTROPY\n vec3 selvaAcross = tbn[ 1 ];\n #else\n // V's direction from screen derivatives, as three's getTangentFrame.\n vec3 selvaQ0 = dFdx( - vViewPosition );\n vec3 selvaQ1 = dFdy( - vViewPosition );\n vec3 selvaAcross = cross( selvaQ1, normal ) * dFdx( vUv ).y + cross( normal, selvaQ0 ) * dFdy( vUv ).y;\n selvaAcross *= inversesqrt( max( dot( selvaAcross, selvaAcross ), 1e-12 ) );\n #endif\n normal = normalize( normal + ${KA(UA)} * selvaFibre * selvaAcross );`)}}}var JA=.25;function YA(e,t){return t?.appearance?.cullBackfaces?!0:(t?.closed??!1)&&!e.transparent&&e.opacity>=1}var XA=.2;function ZA(e){return(e.transmission??0)>0&&!((e.thickness??0)>0)&&e.roughness<XA}function QA(e,t){let n=new Map;return(r,i)=>{let a=e[r],o=YA(a,{...t,closed:i}),s=`${r}:${o}`,c=n.get(s);return c||(c=$A(a,{...t,closed:o}),n.set(s,c)),c}}function $A(e,t){let n=OD(e.color),r=t?.vertexColors??!1,i=t?.appearance,a=new CS({color:n,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:r,side:YA(e,t)?0:2,polygonOffset:!0,polygonOffsetFactor:JA,polygonOffsetUnits:0,depthWrite:!(e.transparent||e.opacity<1),depthTest:!0});e.envMapIntensity==null?i?.envMapIntensity!=null&&(a.envMapIntensity=ED(i.envMapIntensity,e.metalness,i.metalReflection)):(a.envMapIntensity=e.envMapIntensity,a.userData[TD]=e.envMapIntensity),e.emissive!=null&&(a.emissive.set(e.emissive),a.emissiveIntensity=e.emissiveIntensity??1,a.userData[CD]=!0,e.emissiveLight!=null&&(a.userData[wD]=e.emissiveLight)),e.clearcoat!=null&&(a.clearcoat=e.clearcoat,a.clearcoatRoughness=e.clearcoatRoughness??0),e.sheen!=null&&e.sheen>0&&(a.sheen=e.sheen,a.sheenColor.set(e.sheenColor??`#ffffff`),a.sheenRoughness=e.sheenRoughness??.5),e.anisotropy!=null&&e.anisotropy>0&&t?.hasUvs&&(a.anisotropy=e.anisotropy,a.anisotropyRotation=(e.anisotropyRotation??0)+Math.PI/2),e.ior!=null&&(a.ior=e.ior),e.transmission!=null&&e.transmission>0&&ij(a,e),e.metalness>0&&rj(a),r&&oj(a);let o=e.finish&&t?.hasUvs?qA(e.finish,e.finishStrength??1):null;o&&(a.defines={...a.defines,USE_UV:``},aj(a,o.key,o.patch));let{mapSize:s}=e;return e.map&&EA(a,e.map,`map`,s),e.roughnessMap&&EA(a,e.roughnessMap,`roughnessMap`,s),e.normalMap&&EA(a,e.normalMap,`normalMap`,s),a}var ej=.1,tj=`#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )`,nj=`#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )`;function rj(e){aj(e,`sun-on-metal`,e=>{e.fragmentShader=e.fragmentShader.replace(`#include <lights_fragment_begin>`,cw.lights_fragment_begin.replace(tj,`vec3 specularBeforeSun = reflectedLight.directSpecular;\n${tj}`).replace(nj,`reflectedLight.directSpecular = specularBeforeSun + ( reflectedLight.directSpecular - specularBeforeSun ) * mix( 1.0, ${ej.toFixed(2)}, metalnessFactor );\n${nj}`))})}function ij(e,t){let n=Math.min(1,t.transmission);if(e.userData[FD]=!0,!ZA(t)){let r=t.thickness??0;e.transmission=n,e.thickness=r,t.attenuationColor&&r>0&&(e.attenuationColor.set(t.attenuationColor),e.attenuationDistance=r,aj(e,`glass-attenuation`,e=>{e.fragmentShader=e.fragmentShader.replace(`#include <transmission_fragment>`,cw.transmission_fragment.replace(`material.attenuationDistance = attenuationDistance;`,`material.attenuationDistance = attenuationDistance * length( modelMatrix[ 0 ].xyz );`))}))}else e.transparent=!0,e.opacity=t.opacity*(1-n*.96),e.depthWrite=!1,e.blending=5,e.blendSrc=201,e.blendDst=205,aj(e,`glass-pane`,e=>{e.fragmentShader=e.fragmentShader.replace(`#include <opaque_fragment>`,`vec3 paneSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n gl_FragColor = vec4( ( outgoingLight - paneSpecular ) * diffuseColor.a + paneSpecular, diffuseColor.a );`)})}function aj(e,t,n){let r=e.onBeforeCompile,i=e.customProgramCacheKey.bind(e);e.onBeforeCompile=(t,i)=>{r.call(e,t,i),n(t)},e.customProgramCacheKey=()=>`${i()}|${t}`}function oj(e){aj(e,`srgb-vertex-colors`,e=>{e.vertexShader=e.vertexShader.replace(`#include <color_vertex>`,`#include <color_vertex>\n #if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n vColor.rgb = mix(\n vColor.rgb / 12.92,\n pow( ( vColor.rgb + 0.055 ) / 1.055, vec3( 2.4 ) ),\n step( vec3( 0.04045 ), vColor.rgb )\n );\n #endif`)})}function sj(e){let t=new Map;for(let n of e.meshes){let e=n.layer??``,r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}return[...t.values()].map(t=>({materialId:e.materialId,meshes:t}))}function cj(e){let t=new Map;for(let n of e){let e=t.get(n.materialId);if(e)for(let t of n.meshes)e.push(t);else t.set(n.materialId,n.meshes.slice())}return[...t].flatMap(([e,t])=>sj({materialId:e,meshes:t}))}function lj(e,t,n,r,i=null,a=null){let o=0,s=0;for(let t of e.meshes)o+=t.vertexCount,s+=t.indexCount;let c=new Float32Array(o*3),l=new Uint32Array(s),u=i?new Float32Array(o*2):null,d=a?new Uint8Array(o*3):null,f=0,p=0;for(let r of e.meshes){let e=r.vertexStart*3,o=r.vertexCount*3;if(c.set(t.subarray(e,e+o),f*3),u&&i){let e=r.vertexStart*2;u.set(i.subarray(e,e+r.vertexCount*2),f*2)}d&&a&&d.set(a.subarray(e,e+o),f*3);let s=n.subarray(r.indexStart,r.indexStart+r.indexCount),m=f-r.vertexStart,h=r.vertexStart,g=r.vertexStart+r.vertexCount;for(let e=0;e<s.length;e++){let t=s[e];if(t<h||t>=g)throw cA(t,r);l[p+e]=t+m}f+=r.vertexCount,p+=r.indexCount}let m=gA({positions:c,indices:l,uvs:u,colors:d},e.meshes);return fj(uj(m),e,r(e.materialId,m.closed))}function uj(e){let t=new Pb;return t.setAttribute(`position`,new yb(e.positions,3)),t.setAttribute(`normal`,new yb(e.normals,3)),t.setIndex(new yb(e.indices,1)),e.uvs&&t.setAttribute(`uv`,new yb(e.uvs,2)),e.tangents&&t.setAttribute(`tangent`,new yb(e.tangents,4)),e.colors&&t.setAttribute(`color`,new yb(e.colors,3,!0)),t}function dj(e){let t=[],n=0;for(let r of e.meshes)t.push({trackingKey:r.id,name:r.name,layer:r.layer,metadata:r.metadata??{},indexStart:n,indexCount:r.indexCount}),n+=r.indexCount;return t}function fj(e,t,n){let r=new wx(e,n),i=t.meshes[0],a=t.meshes.map(e=>e.name).filter(e=>e&&e.length>0);return r.name=a.length>0?a[0]:`merged_material_${t.materialId}`,r.castShadow=!ID(n),r.receiveShadow=!0,r.userData={source:`compute`,name:r.name,layer:i?.layer??``,metadata:i?.metadata??{},members:dj(t)},r}function pj(e,t,n,r,i=null,a=null){let o=[];for(let s of e.meshes){let c=s.vertexStart*3,l=s.vertexCount*3,u=t.slice(c,c+l),d=n.subarray(s.indexStart,s.indexStart+s.indexCount),f=new Uint32Array(d.length),p=s.vertexStart,m=s.vertexStart+s.vertexCount;for(let e=0;e<d.length;e++){let t=d[e];if(t<p||t>=m)throw cA(t,s);f[e]=t-p}let h=s.vertexStart*2,g=gA({positions:u,indices:f,uvs:i?i.slice(h,h+s.vertexCount*2):null,colors:a?a.slice(c,c+l):null},[s]);o.push(mj(uj(g),s,r(e.materialId,g.closed)))}return o}function mj(e,t,n){let r=new wx(e,n);return r.name=t.name,r.userData={source:`compute`,name:t.name,layer:t.layer??``,trackingKey:t.id,metadata:t.metadata??{}},r.castShadow=!ID(n),r.receiveShadow=!0,r}var hj=268435456,gj=new Map,_j=0;function vj(e,t){let n=Cj(t),r=wj(e,n),i=gj.get(r);return!i||!Tj(i.jobShape,n)||!Ej(i.geometryBytes,e)?null:(gj.delete(r),gj.set(r,i),i)}function yj(e){let{geometries:t,...n}=e;return{...n,buffers:t.map(uj),closed:t.map(e=>e.closed)}}function bj(e,t,n){let r=yj(n),i=e.byteLength;for(let e of n.geometries)i+=e.positions.byteLength+e.normals.byteLength+e.indices.byteLength,i+=(e.uvs?.byteLength??0)+(e.colors?.byteLength??0)+(e.tangents?.byteLength??0);if(i>hj)return r;let a=Cj(t),o=wj(e,a),s=gj.get(o);s&&(gj.delete(o),Sj(s)),r.buffers.forEach(ag),gj.set(o,{...r,geometryBytes:e.slice(),jobShape:a,bytes:i}),_j+=i;for(let[e,t]of gj){if(_j<=hj)break;gj.delete(e),Sj(t)}return r}function xj(){gj.forEach(Sj),gj.clear()}function Sj(e){_j-=e.bytes;for(let t of e.buffers)og(t),t.dispose()}function Cj(e){let t=0;for(let n of e)t+=2+4*n.windows.length;let n=new Int32Array(t),r=0;for(let t of e){n[r++]=+(t.kind===`merged`),n[r++]=t.windows.length;for(let e of t.windows)n[r++]=e.vertexStart,n[r++]=e.vertexCount,n[r++]=e.indexStart,n[r++]=e.indexCount}return n}function wj(e,t){let n=e.length,r=Math.max(1,Math.floor(n/1024)),i=2166136261;for(let t=0;t<n;t+=r)i=Math.imul(i^e[t],16777619);let a=2166136261;for(let e=0;e<t.length;e++)a=Math.imul(a^t[e],16777619);return`${n}:${i>>>0}:${t.length}:${a>>>0}`}function Tj(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ej(e,t){if(e.length!==t.length)return!1;let n=0;if(e.byteOffset%4==0&&t.byteOffset%4==0){let r=e.length>>>2,i=new Uint32Array(e.buffer,e.byteOffset,r),a=new Uint32Array(t.buffer,t.byteOffset,r);for(;n<r;n++)if(i[n]!==a[n])return!1;n=r<<2}for(;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}async function Dj(e,t,n){let{mergeByMaterial:r=!0,debug:i=!1,material:a}=t??{},{parseTime:o=0,perfStart:s=i?performance.now():0}=n??{};if(!e.compressedData)return[];let c=performance.now(),l={mergeByMaterial:r,debug:i,material:a,fallback:{materials:e.materials,groups:e.groups}},u=await Mj(e.compressedData,l);return u.meshes?u.meshes:await Lj(u,l)||jj(uA(u.raw),{mergeByMaterial:r,debug:i,material:a,parseTime:o,decodeTime:performance.now()-c,perfStart:s,blobBytes:i?Vj(e.compressedData):0,fallback:{materials:e.materials,groups:e.groups}})}var Oj=1e3,kj=!1;function Aj(e,t){if(e||kj)return;let n=0;for(let e of t)n+=e.meshes.length;n<Oj||(kj=!0,bD().warn(`Parsing ${n} meshes with mergeByMaterial: false — each becomes its own THREE object, and render cost scales with object count. Drop the option to merge by material (the default); per-object identity survives it via userData.members.`))}function jj(e,t){let{mergeByMaterial:n,debug:r,material:i,parseTime:a,decodeTime:o,perfStart:s,blobBytes:c,fallback:l}=t,u=e.metadata.materials??l?.materials??[],d=e.metadata.groups??l?.groups??[],f=!!(e.flags&1);sA(u,d,e.vertices.length/3,e.indices.length);let p=f?e.vertices:lA(e.vertices,e.origin,e.scale);if(r){let t=e.vertices.byteLength+e.indices.byteLength;bD().debug(`Mesh Batch Stats:`),bD().debug(` Materials: ${u.length} | Groups: ${d.length}`),bD().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),bD().debug(` Format: ${f?`float32`:`int16 quantized`}`),bD().debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(t/1024/1024).toFixed(2)} MB`)}Aj(n,d);let m=performance.now(),h=QA(u,{vertexColors:e.colors!=null,hasUvs:e.uvs!=null,appearance:i}),g=[],_=n?cj(d):d;for(let t of _)if(n&&t.meshes.length>1){let n=lj(t,p,e.indices,h,e.uvs,e.colors);g.push(n)}else{let n=pj(t,p,e.indices,h,e.uvs,e.colors);for(let e of n)g.push(e)}let v=performance.now()-m;if(r){let e=performance.now()-s;bD().debug(`Performance:`),a>0&&bD().debug(` Parse JSON: ${a.toFixed(2)}ms`),bD().debug(` Decode binary: ${o.toFixed(2)}ms`),bD().debug(` Create Meshes: ${v.toFixed(2)}ms`),bD().debug(` Total: ${e.toFixed(2)}ms`)}return Promise.resolve(g)}async function Mj(e,t){let n=hk(e);if(!Xk(n))return{raw:dA(n),geometryBytes:null,source:n,reparse:()=>dA(n)};let r=Zk(n),i=Fj(r,t);if(i)return{meshes:i};let a=r.geometryBlob,o=()=>{let e=dA(a);return e.metadata=r.metadata,e},s=await Pj(r),c=s?dA(s):o();return c.metadata=r.metadata,{raw:c,geometryBytes:a,source:a,reparse:o}}var Nj=4194304;async function Pj(e){if(_k(e.geometryBlob)<Nj||!SA())return null;try{return await Sk(e.geometryBlob)}catch{return null}}function Fj(e,t){let n=e.metadata.materials??t.fallback?.materials??[],r=e.metadata.groups??t.fallback?.groups??[],{jobs:i,jobRefs:a}=Ij(r,t.mergeByMaterial),o=vj(e.geometryBlob,i);return o?(sA(n,r,o.vertexCount,o.indexCount),Bj(o,a,n,t.material)):null}function Ij(e,t){let n=e=>({vertexStart:e.vertexStart,vertexCount:e.vertexCount,indexStart:e.indexStart,indexCount:e.indexCount,closed:e.closed}),r=[],i=[],a=t?cj(e):e;for(let e of a)if(t&&e.meshes.length>1)r.push({kind:`merged`,windows:e.meshes.map(n)}),i.push({kind:`merged`,group:e});else for(let t of e.meshes)r.push({kind:`single`,windows:[n(t)]}),i.push({kind:`single`,group:e,meshMeta:t});return{jobs:r,jobRefs:i}}async function Lj(e,t){let{raw:n,geometryBytes:r}=e,i=n.planarByteSplit?n.indexData.length/(n.uint16Indices?2:4):n.indexData.length;if(i/3<5e4)return null;let a=n.metadata.materials??t.fallback?.materials??[],o=n.metadata.groups??t.fallback?.groups??[];sA(a,o,n.vertexCount,i);let{jobs:s,jobRefs:c}=Ij(o,t.mergeByMaterial),l=await zj(n,s,e.source);if(!l)return Rj(n,e.source)&&(e.raw=e.reparse()),null;let u={geometries:l,hasUvs:n.uvs!=null,hasColors:n.colors!=null,vertexCount:n.vertexCount,indexCount:i},d=r?bj(r,s,u):yj(u);return t.debug&&bD().debug(`Mesh batch assembled: ${l.length} geometries, ${i/3} triangles`),Bj(d,c,a,t.material)}function Rj(e,t){return e.vertexData.buffer!==t.buffer&&e.indexData.buffer!==t.buffer}async function zj(e,t,n){let r=SA(),i={vertexData:e.vertexData,isFloat32:e.isFloat32,deltaEncoded:e.deltaEncoded,planarByteSplit:e.planarByteSplit,uint16Indices:e.uint16Indices,origin:e.origin,scale:e.scale,indexData:e.indexData,uvs:e.uvs,colors:e.colors,jobs:t};if(!r){let e;try{e=_A(i)}catch(e){throw new vD(e instanceof Error?e.message:String(e),_D.VALIDATION_ERROR,{originalError:e instanceof Error?e:void 0})}return e.map((e,n)=>gA(e,t[n].windows))}Rj(e,n)||(i.vertexData=e.vertexData.slice(),i.indexData=e.indexData.slice(),i.uvs=e.uvs?.slice()??null,i.colors=e.colors?.slice()??null);let a=new Set([i.vertexData.buffer,i.indexData.buffer]);i.uvs&&a.add(i.uvs.buffer),i.colors&&a.add(i.colors.buffer);try{let e=await CA(r,i,[...a]);return e.length===t.length?e:null}catch(e){return bD().warn(`Mesh assembly worker failed; falling back to main-thread parse.`,e),null}}function Bj(e,t,n,r){let i=QA(n,{vertexColors:e.hasColors,hasUvs:e.hasUvs,appearance:r}),a=[];for(let n=0;n<e.buffers.length;n++){let r=e.buffers[n],o=t[n],s=i(o.group.materialId,e.closed[n]),c=o.kind===`merged`?fj(r,o.group,s):mj(r,o.meshMeta,s);a.push(c)}return a}function Vj(e){return Math.floor(e.length*3/4)}var Hj={Angstroms:1e-10,Nanometers:1e-9,Microns:1e-6,Millimeters:.001,Centimeters:.01,Decimeters:.1,Meters:1,Dekameters:10,Hectometers:100,Kilometers:1e3,Megameters:1e6,Gigameters:1e9,Microinches:2.54e-8,Mils:254e-7,Inches:.0254,Feet:.3048,Yards:.9144,Miles:1609.344,NauticalMiles:1852},Uj=`Display`,Wj=`DisplayBatch`;function Gj(e){let t=e.split(`.`);return t.includes(Uj)||t.includes(Wj)}var Kj=new Set;async function qj(e,t){let n=performance.now(),r=[],{allowScaling:i=!0,allowAutoPosition:a=!1,groundAxis:o=`z`,debug:s=!1,parsing:c={}}=t??{};try{return await Yj(e,r,i?Jj(e.modelunits):1,c,s),a&&$j(r,o),r}catch(e){throw eM(e,r),e}finally{s&&nM(n)}}function Jj(e){let t=Hj[e];return t===void 0?(Kj.has(e)||(Kj.add(e),bD().warn(`Unknown Rhino model unit \"${e}\" — geometry will not be scaled (factor 1). Known units: ${Object.keys(Hj).join(`, `)}.`)),1):t}async function Yj(e,t,n,r,i){for(let a of e.values){let e=a.InnerTree;for(let a in e){let o=e[a];o&&await Xj(o,t,n,r,i)}}}async function Xj(e,t,n,r,i){for(let a of e){if(!Gj(a.type))continue;let e={debug:!1,...r,mergeByMaterial:r.mergeByMaterial??!0},o=Zj(a.data);if(!o){bD().error(`Error parsing display batch envelope: invalid JSON`);continue}let s=await Dj(o,e),c=fk(o.items),l=[...s,...c];if(n!==1)for(let e of l)e.scale.set(n,n,n);for(let e of l)t.push(e);i&&bD().debug(`Extracted ${s.length} meshes and ${c.length} items from batch`)}}function Zj(e){return typeof e==`string`?Qj(e):e}function Qj(e){try{return JSON.parse(e)}catch{return}}function $j(e,t){e.length!==0&&kD(e,AD(e).min[t],t)}function eM(e,t){bD().error(`An unexpected error occurred:`,e),tM(t)}function tM(e){for(let t of e)BD(t)}function nM(e){let t=performance.now()-e;bD().info(`Time to process meshes:`,`${t.toFixed(2)}ms`)}var rM=new WeakMap,iM=new WeakMap,aM=new WeakMap,oM=new Set;function sM(e){let t=e.userData?.members;return!Array.isArray(t)||t.length===0||t.some(e=>e.indexStart==null||e.indexCount==null)?null:t}function cM(e){let t=rM.get(e);return t||(t={base:Array.isArray(e.material)?e.material[0]:e.material,hidden:oM,selection:null,hover:null},rM.set(e,t)),t}function lM(e){let t=e.geometry;if(!sg(t))return t;let n=new Pb;n.setIndex(t.index);for(let[e,r]of Object.entries(t.attributes))n.setAttribute(e,r);return n.boundingBox=t.boundingBox?.clone()??null,n.boundingSphere=t.boundingSphere?.clone()??null,lg(n,t),e.geometry=n,n}function uM(e,t,n){let r=lM(e);r.clearGroups();let{selection:i,hover:a}=n;if(n.hidden.size===0&&!i&&!a){e.material=n.base,rM.delete(e);return}let o=[n.base],s=i?o.push(i.material)-1:0,c=a?o.push(a.material)-1:0,l=-1,u=0,d=0,f=()=>{l>=0&&r.addGroup(l,u-l,d),l=-1};for(let e=0;e<t.length;e++){if(n.hidden.has(e)){f();continue}let{indexStart:r,indexCount:o}=t[e],p=i?.members.has(e)?s:a?.members.has(e)?c:0;(l<0||p!==d||r!==u)&&(f(),l=r,d=p),u=r+o}f(),e.material=o}function dM(e,t){let n=sM(e);if(!n)return;let r=cM(e);t(r),uM(e,n,r),iM.get(e)?.forEach(e=>e())}function fM(e){return rM.get(e)?.hidden??oM}function pM(e){let t=rM.get(e)?.base??(Array.isArray(e.material)?e.material[0]:e.material);return aM.get(t)??t}function mM(e){let t=e.clone();return aM.set(t,aM.get(e)??e),t}function hM(e,t,n,r=`selection`){dM(e,e=>{e[r]={members:t,material:n}})}function gM(e,t=`selection`){rM.get(e)?.[t]&&dM(e,e=>{e[t]=null})}function _M(e,t){let n=iM.get(e);return n||iM.set(e,n=new Set),n.add(t),()=>n.delete(t)}var vM=class extends Ey{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new X(.5,.5),this.rotation2D=0,this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this.rotation2D=e.rotation2D,this}},yM=new Z,bM=new $v,xM=new $v,SM=new Z,CM=new Z,wM=class{constructor(e={}){let t=this,n,r,i,a,o={objects:new WeakMap},s=e.element===void 0?document.createElement(`div`):e.element;s.style.overflow=`hidden`,this.domElement=s,this.sortObjects=!0,this.getSize=function(){return{width:n,height:r}},this.render=function(e,t){e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),bM.copy(t.matrixWorldInverse),xM.multiplyMatrices(t.projectionMatrix,bM),l(e,e,t),this.sortObjects&&f(e)},this.setSize=function(e,t){n=e,r=t,i=n/2,a=r/2,s.style.width=e+`px`,s.style.height=t+`px`};function c(e){e.isCSS2DObject&&(e.element.style.display=`none`);for(let t=0,n=e.children.length;t<n;t++)c(e.children[t])}function l(e,n,r){if(e.visible===!1)c(e);else{if(e.isCSS2DObject){yM.setFromMatrixPosition(e.matrixWorld),yM.applyMatrix4(xM);let c=yM.z>=-1&&yM.z<=1&&e.layers.test(r.layers)===!0,l=e.element;if(l.style.display=c===!0?``:`none`,c===!0){e.onBeforeRender(t,n,r);let o=100*e.center.x,c=100*e.center.y;l.style.transformOrigin=`${o}% ${c}%`;let u=-e.rotation2D,d=yM.x*i+i,f=-yM.y*a+a;l.style.transform=`translate(${-o}%, ${-c}%) translate(${d}px, ${f}px) rotate(${u}rad)`,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<i;t++)l(e.children[t],n,r)}}function u(e,t){return SM.setFromMatrixPosition(e.matrixWorld),CM.setFromMatrixPosition(t.matrixWorld),SM.distanceToSquared(CM)}function d(e){let t=[];return e.traverseVisible(function(e){e.isCSS2DObject&&t.push(e)}),t}function f(e){let t=d(e).sort(function(e,t){return e.renderOrder===t.renderOrder?o.objects.get(e).distanceToCameraSquared-o.objects.get(t).distanceToCameraSquared:t.renderOrder-e.renderOrder}),n=t.length;for(let e=0,r=t.length;e<r;e++)t[e].element.style.zIndex=n-e}}},TM=1.25,EM=65535,DM=2**-24,OM=Symbol(`SKIP_GENERATION`),kM={strategy:0,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[OM]:!1};function AM(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function jM(e){let t=-1,n=-1/0;for(let r=0;r<3;r++){let i=e[r+3]-e[r];i>n&&(n=i,t=r)}return t}function MM(e,t,n){for(let r=0;r<3;r++){let i=t[e+2*r],a=t[e+2*r+1],o=i-a,s=i+a;o<n[r]&&(n[r]=o),s>n[r+3]&&(n[r+3]=s)}}function NM(e){let t=e[3]-e[0],n=e[4]-e[1],r=e[5]-e[2];return 2*(t*n+n*r+r*t)}function PM(e,t){return t[e+15]===EM}function FM(e,t){return t[e+6]}function IM(e,t){return t[e+14]}function LM(e){return e+8}function RM(e,t){return e+t[e+6]*8}function zM(e,t){return t[e+7]}function BM(e){return e}function VM(e,t,n,r,i){let a=1/0,o=1/0,s=1/0,c=-1/0,l=-1/0,u=-1/0,d=1/0,f=1/0,p=1/0,m=-1/0,h=-1/0,g=-1/0,_=e.offset||0;for(let r=(t-_)*6,i=(t+n-_)*6;r<i;r+=6){let t=e[r+0],n=e[r+1],i=t-n,_=t+n;i<a&&(a=i),_>c&&(c=_),t<d&&(d=t),t>m&&(m=t);let v=e[r+2],y=e[r+3],b=v-y,x=v+y;b<o&&(o=b),x>l&&(l=x),v<f&&(f=v),v>h&&(h=v);let S=e[r+4],C=e[r+5],w=S-C,T=S+C;w<s&&(s=w),T>u&&(u=T),S<p&&(p=S),S>g&&(g=S)}r[0]=a,r[1]=o,r[2]=s,r[3]=c,r[4]=l,r[5]=u,i[0]=d,i[1]=f,i[2]=p,i[3]=m,i[4]=h,i[5]=g}var HM=8,UM=8,WM=new Int32Array(HM),GM=new Float32Array(48),KM=new Float32Array(48),qM=new Float32Array(6),JM=new Float32Array(6),YM=new Int32Array(UM),XM=new Float32Array(48);function ZM(e,t,n,r){for(let i=0;i<3;i++){let a=t[e+2*i],o=t[e+2*i+1],s=a-o,c=a+o;s<n[r+i]&&(n[r+i]=s),c>n[r+i+3]&&(n[r+i+3]=c)}}function QM(e,t){let n=e[t+3]-e[t],r=e[t+4]-e[t+1],i=e[t+5]-e[t+2];return 2*(n*r+r*i+i*n)}function $M(e,t,n,r,i,a){let o=-1,s=0;if(a===0)o=jM(t),o!==-1&&(s=(t[o]+t[o+3])/2);else if(a===1)o=jM(e),o!==-1&&(s=eN(n,r,i,o));else if(a===2){let a=NM(e),c=TM*i,l=n.offset||0,u=(r-l)*6,d=(r+i-l)*6;for(let e=0;e<3;e++){let r=t[e],l=(t[e+3]-r)/HM;if(i<UM){for(let t=0;t<i;t++){let r=u+t*6,i=n[r+2*e],a=t;for(;a>0&&n[YM[a-1]+2*e]>i;)YM[a]=YM[a-1],a--;YM[a]=r}for(let e=0;e<3;e++)qM[e]=1/0,qM[e+3]=-1/0,JM[e]=1/0,JM[e+3]=-1/0;for(let e=i-1;e>=0;e--)MM(YM[e],n,JM),XM.set(JM,e*6);for(let t=0;t<i-1;t++){MM(YM[t],n,qM);let r=n[YM[t+1]+2*e];if(n[YM[t]+2*e]===r)continue;let l=t+1,u=i-l,d=NM(qM)/a,f=QM(XM,l*6)/a,p=1+TM*(d*l+f*u);p<c&&(o=e,c=p,s=r)}}else{for(let e=0;e<HM;e++){WM[e]=0;for(let t=0;t<3;t++)GM[e*6+t]=1/0,GM[e*6+t+3]=-1/0}for(let t=u;t<d;t+=6){let i=~~((n[t+2*e]-r)/l);i>=HM&&(i=7),WM[i]++,ZM(t,n,GM,i*6)}for(let e=0;e<6;e++)KM[42+e]=GM[42+e];for(let e=6;e>=0;e--){let t=e*6,n=t+6;for(let e=0;e<3;e++)KM[t+e]=Math.min(GM[t+e],KM[n+e]),KM[t+e+3]=Math.max(GM[t+e+3],KM[n+e+3])}let t=0;for(let n=0;n<7;n++){let u=n*6,d=WM[n];if(d!==0)for(let e=0;e<3;e++)t===0?(qM[e]=GM[u+e],qM[e+3]=GM[u+e+3]):(qM[e]=Math.min(qM[e],GM[u+e]),qM[e+3]=Math.max(qM[e+3],GM[u+e+3]));t+=d;let f=0,p=0;t!==0&&(f=NM(qM)/a);let m=i-t;m!==0&&(p=QM(KM,u+6)/a);let h=1+TM*(f*t+p*m);h<c&&(o=e,c=h,s=r+l+n*l)}}}}else console.warn(`BVH: Invalid build strategy value ${a} used.`);return{axis:o,pos:s}}function eN(e,t,n,r){let i=0,a=e.offset;for(let o=t,s=t+n;o<s;o++)i+=e[(o-a)*6+r*2];return i/n}function tN(e,t,n,r,i,a){let o=r,s=r+i-1,c=a.pos,l=a.axis*2,u=n.offset||0;for(;;){for(;o<=s&&n[(o-u)*6+l]<c;)o++;for(;o<=s&&n[(s-u)*6+l]>=c;)s--;if(o<s){for(let n=0;n<t;n++){let r=e[o*t+n];e[o*t+n]=e[s*t+n],e[s*t+n]=r}for(let e=0;e<6;e++){let t=o-u,r=s-u,i=n[t*6+e];n[t*6+e]=n[r*6+e],n[r*6+e]=i}o++,s--}else return o}}var nN=2**32,rN=new Float32Array(6),iN=new Float32Array(6);function aN(e,t,n,r,i,a){let{maxDepth:o,verbose:s,targetLeafSize:c,_strictLeafSize:l=1/0,strategy:u,onProgress:d,useSharedArrayBuffer:f=!1}=i,p=e.primitiveBuffer,m=e.primitiveBufferStride,h=new(f?SharedArrayBuffer:ArrayBuffer)(32*Math.max(1,2*Math.ceil(r)-1)),g=new Float32Array(h),_=new Uint32Array(h),v=new Uint16Array(h),y=0,b=!1;return VM(t,n,r,rN,iN),C(n,r,0),h.slice(0,y*32);function x(e){d&&d((e-a.offset)/a.count)}function S(e,t,n){let r=e*2;_[e+6]=t,v[r+14]=n,v[r+15]=EM,x(t+n)}function C(e,n,r){let i=y++,a=i*8;g.set(rN,a),!b&&r>=o&&(b=!0,s&&console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`));let d=n>l;if(n<=c&&!d||r>=o){S(a,e,n);return}let f=$M(rN,iN,t,e,n,u),h=f.axis===-1?-1:tN(p,m,t,e,n,f);if(f.axis===-1||h===e||h===e+n){if(!d){S(a,e,n);return}f.axis=Math.max(0,jM(rN)),h=e+Math.max(1,Math.floor(n/2))}_[a+7]=f.axis;let v=h-e;VM(t,e,v,rN,iN),C(e,v,r+1);let x=y-i;if(x>nN)throw Error(`MeshBVH: Cannot store relative child node offset greater than 32 bits.`);_[a+6]=x;let w=n-v;VM(t,h,w,rN,iN),C(h,w,r+1)}}function oN(e,t){let n=e.getRootRanges(t.range),r=n[0],i=n[n.length-1],a={offset:r.offset,count:i.offset+i.count-r.offset},o=new Float32Array(6*a.count);o.offset=a.offset,e.computePrimitiveBounds(a.offset,a.count,o),e._roots=n.map(n=>aN(e,o,n.offset,n.count,t,a))}var sN=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}},cN=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;let e=[],t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}},lN,uN,dN=[],fN=new sN(()=>new Xy);function pN(e,t,n,r,i,a){lN=fN.getPrimitive(),uN=fN.getPrimitive(),dN.push(lN,uN),cN.setBuffer(e._roots[t]);let o=mN(0,e.geometry,n,r,i,a);cN.clearBuffer(),fN.releasePrimitive(lN),fN.releasePrimitive(uN),dN.pop(),dN.pop();let s=dN.length;return s>0&&(uN=dN[s-1],lN=dN[s-2]),o}function mN(e,t,n,r,i=null,a=0,o=0){let{float32Array:s,uint16Array:c,uint32Array:l}=cN,u=e*2;if(PM(u,c)){let t=FM(e,l),n=IM(u,c);return AM(BM(e),s,lN),r(t,n,!1,o,a+e/8,lN)}{let u=LM(e),d=RM(e,l),f=u,p=d,m,h,g,_;if(i&&(g=lN,_=uN,AM(BM(f),s,g),AM(BM(p),s,_),m=i(g),h=i(_),h<m)){f=d,p=u;let e=m;m=h,h=e,g=_}g||(g=lN,AM(BM(f),s,g));let v=PM(f*2,c),y=n(g,v,m,o+1,a+f/8),b;if(y===2){let e=w(f);b=r(e,T(f)-e,!0,o+1,a+f/8,g)}else b=y&&mN(f,t,n,r,i,a,o+1);if(b)return!0;_=uN,AM(BM(p),s,_);let x=PM(p*2,c),S=n(_,x,h,o+1,a+p/8),C;if(S===2){let e=w(p);C=r(e,T(p)-e,!0,o+1,a+p/8,_)}else C=S&&mN(p,t,n,r,i,a,o+1);return!!C;function w(e){let{uint16Array:t,uint32Array:n}=cN,r=e*2;for(;!PM(r,t);)e=LM(e),r=e*2;return FM(e,n)}function T(e){let{uint16Array:t,uint32Array:n}=cN,r=e*2;for(;!PM(r,t);)e=RM(e,n),r=e*2;return FM(e,n)+IM(r,t)}}}var hN=new cN.constructor,gN=new cN.constructor,_N=new sN(()=>new Xy),vN=new Xy,yN=new Xy,bN=new Xy,xN=new Xy,SN=!1;function CN(e,t,n,r){if(SN)throw Error(`MeshBVH: Recursive calls to bvhcast not supported.`);SN=!0;let i=e._roots,a=t._roots,o,s=0,c=0,l=new $v().copy(n).invert();for(let e=0,t=i.length;e<t;e++){hN.setBuffer(i[e]),c=0;let t=_N.getPrimitive();AM(BM(0),hN.float32Array,t),t.applyMatrix4(l);for(let e=0,i=a.length;e<i&&(gN.setBuffer(a[e]),o=wN(0,0,n,l,r,s,c,0,0,t),gN.clearBuffer(),c+=a[e].byteLength/32,!o);e++);if(_N.releasePrimitive(t),hN.clearBuffer(),s+=i[e].byteLength/32,o)break}return SN=!1,o}function wN(e,t,n,r,i,a=0,o=0,s=0,c=0,l=null,u=!1){let d,f;u?(d=gN,f=hN):(d=hN,f=gN);let p=d.float32Array,m=d.uint32Array,h=d.uint16Array,g=f.float32Array,_=f.uint32Array,v=f.uint16Array,y=e*2,b=t*2,x=PM(y,h),S=PM(b,v),C=!1;if(S&&x)C=u?i(FM(t,_),IM(t*2,v),FM(e,m),IM(e*2,h),c,o+t/8,s,a+e/8):i(FM(e,m),IM(e*2,h),FM(t,_),IM(t*2,v),s,a+e/8,c,o+t/8);else if(S){let l=_N.getPrimitive();AM(BM(t),g,l),l.applyMatrix4(n);let d=LM(e),f=RM(e,m);AM(BM(d),p,vN),AM(BM(f),p,yN);let h=l.intersectsBox(vN),_=l.intersectsBox(yN);C=h&&wN(t,d,r,n,i,o,a,c,s+1,l,!u)||_&&wN(t,f,r,n,i,o,a,c,s+1,l,!u),_N.releasePrimitive(l)}else{let d=LM(t),f=RM(t,_);AM(BM(d),g,bN),AM(BM(f),g,xN);let h=l.intersectsBox(bN),v=l.intersectsBox(xN);if(h&&v)C=wN(e,d,n,r,i,a,o,s,c+1,l,u)||wN(e,f,n,r,i,a,o,s,c+1,l,u);else if(h){if(x)C=wN(e,d,n,r,i,a,o,s,c+1,l,u);else{let t=_N.getPrimitive();t.copy(bN).applyMatrix4(n);let l=LM(e),f=RM(e,m);AM(BM(l),p,vN),AM(BM(f),p,yN);let h=t.intersectsBox(vN),g=t.intersectsBox(yN);C=h&&wN(d,l,r,n,i,o,a,c,s+1,t,!u)||g&&wN(d,f,r,n,i,o,a,c,s+1,t,!u),_N.releasePrimitive(t)}}else if(v){if(x)C=wN(e,f,n,r,i,a,o,s,c+1,l,u);else{let t=_N.getPrimitive();t.copy(xN).applyMatrix4(n);let l=LM(e),d=RM(e,m);AM(BM(l),p,vN),AM(BM(d),p,yN);let h=t.intersectsBox(vN),g=t.intersectsBox(yN);C=h&&wN(f,l,r,n,i,o,a,c,s+1,t,!u)||g&&wN(f,d,r,n,i,o,a,c,s+1,t,!u),_N.releasePrimitive(t)}}}return C}var TN=new class{constructor(){let e=null,t=null,n=null,r=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(i,a)=>{if(r)throw Error(`BVHTraversalHelper: cannot call setBVH during an active traversal.`);this.root=a,this.buffer=e=i._roots[a],this.uint16Array=n=new Uint16Array(e),this.uint32Array=t=new Uint32Array(e)},this.reset=()=>{this.root=null,this.buffer=e=null,this.uint16Array=n=null,this.uint32Array=t=null},this.getRangeStart=e=>{let r=e*2;for(;!PM(r,n);)e=LM(e),r=e*2;return FM(e,t)},this.getRangeEnd=e=>{let r=e*2;for(;!PM(r,n);)e=RM(e,t),r=e*2;return FM(e,t)+IM(r,n)};let i=(e,r,a)=>{let o=PM(r*2,n);if(!e(a,o,r)&&!o){let n=LM(r),o=RM(r,t);i(e,n,a+1),i(e,o,a+1)}};this.traverseBuffer=e=>{if(r)throw Error(`BVHTraversalHelper: cannot start a traversal during an active traversal.`);r=!0;try{i(e,0,0)}finally{r=!1}},this.traverse=r=>{this.traverseBuffer((i,a,o)=>{if(a){let s=o*2,c=t[o+6],l=n[s+14];return r(i,a,new Float32Array(e,o*4,6),c,l)}{let n=zM(o,t);return r(i,a,new Float32Array(e,o*4,6),n)}})}}},EN=new Xy,DN=new Float32Array(6),ON=class{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...kM,...e},`maxLeafSize`in e&&(console.warn(`BVH: \"maxLeafSize\" option has been deprecated. Use \"targetLeafSize\", instead.`),e={...e,targetLeafSize:e.maxLeafSize}),oN(this,e)}getRootRanges(){throw Error(`BVH: getRootRanges() not implemented`)}writePrimitiveBounds(){throw Error(`BVH: writePrimitiveBounds() not implemented`)}writePrimitiveRangeBounds(e,t,n,r){let i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,l=-1/0;for(let n=e,r=e+t;n<r;n++){this.writePrimitiveBounds(n,DN,0);let[e,t,r,u,d,f]=DN;e<i&&(i=e),u>s&&(s=u),t<a&&(a=t),d>c&&(c=d),r<o&&(o=r),f>l&&(l=f)}return n[r+0]=i,n[r+1]=a,n[r+2]=o,n[r+3]=s,n[r+4]=c,n[r+5]=l,n}computePrimitiveBounds(e,t,n){let r=n.offset||0;for(let i=e,a=e+t;i<a;i++){this.writePrimitiveBounds(i,DN,0);let[e,t,a,o,s,c]=DN,l=(e+o)/2,u=(t+s)/2,d=(a+c)/2,f=(o-e)/2,p=(s-t)/2,m=(c-a)/2,h=(i-r)*6;n[h+0]=l,n[h+1]=f+(Math.abs(l)+f)*DM,n[h+2]=u,n[h+3]=p+(Math.abs(u)+p)*DM,n[h+4]=d,n[h+5]=m+(Math.abs(d)+m)*DM}return n}shiftPrimitiveOffsets(e){let t=this._indirectBuffer;if(t)for(let n=0,r=t.length;n<r;n++)t[n]+=e;else{let t=this._roots;for(let n=0;n<t.length;n++){let r=t[n],i=new Uint32Array(r),a=new Uint16Array(r),o=r.byteLength/32;for(let t=0;t<o;t++){let n=8*t;PM(2*n,a)&&(i[n+6]+=e)}}}}traverse(e,t=0){TN.setBVH(this,t),TN.traverse(e),TN.reset()}refit(){let e=this._roots;for(let t=0,n=e.length;t<n;t++){let n=e[t],r=new Uint32Array(n),i=new Uint16Array(n),a=new Float32Array(n),o=n.byteLength/32;for(let e=o-1;e>=0;e--){let t=e*8,n=t*2;if(PM(n,i)){let e=FM(t,r),o=IM(n,i);this.writePrimitiveRangeBounds(e,o,DN,0),a.set(DN,t)}else{let e=LM(t),n=RM(t,r);for(let r=0;r<3;r++){let i=a[e+r],o=a[e+r+3],s=a[n+r],c=a[n+r+3];a[t+r]=i<s?i:s,a[t+r+3]=o>c?o:c}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{AM(0,new Float32Array(t),EN),e.union(EN)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:r,intersectsPrimitive:i,scratchPrimitive:a,iterate:o}=e;if(r&&i){let e=r;r=(t,n,r,s,c)=>e(t,n,r,s,c)?!0:o(t,n,this,i,r,s,a)}else r||=i?(e,t,n,r)=>o(e,t,this,i,n,r,a):(e,t,n)=>n;let s=!1,c=0,l=this._roots;for(let e=0,i=l.length;e<i;e++){let i=l[e];if(s=pN(this,e,n,r,t,c),s)break;c+=i.byteLength/32}return s}bvhcast(e,t,n){let{intersectsRanges:r}=n;return CN(this,e,t,r)}};function kN(){return typeof SharedArrayBuffer<`u`}function AN(e){return e.index?e.index.count:e.attributes.position.count}function jN(e){return AN(e)/3}function MN(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}function NN(e,t){if(!e.index){let n=e.attributes.position.count,r=MN(n,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new yb(r,1));for(let e=0;e<n;e++)r[e]=e}}function PN(e,t,n){let r=AN(e)/n,i=t||e.drawRange,a=i.start/n,o=(i.start+i.count)/n,s=Math.max(0,a),c=Math.min(r,o)-s;return{offset:Math.floor(s),count:Math.floor(c)}}function FN(e,t){return e.groups.map(e=>({offset:e.start/t,count:e.count/t}))}function IN(e,t,n){let r=PN(e,t,n),i=FN(e,n);if(!i.length)return[r];let a=[],o=r.offset,s=r.offset+r.count,c=AN(e)/n,l=[];for(let e of i){let{offset:t,count:n}=e,r=t,i=t+(isFinite(n)?n:c-t);r<s&&i>o&&(l.push({pos:Math.max(o,r),isStart:!0}),l.push({pos:Math.min(s,i),isStart:!1}))}l.sort((e,t)=>e.pos===t.pos?e.type===`end`?-1:1:e.pos-t.pos);let u=0,d=null;for(let e of l){let t=e.pos;u!==0&&t!==d&&a.push({offset:d,count:t-d}),u+=e.isStart?1:-1,d=t}return a}function LN(e,t){let n=e[e.length-1],r=n.offset+n.count>2**16,i=e.reduce((e,t)=>e+t.count,0),a=r?4:2,o=t?new SharedArrayBuffer(i*a):new ArrayBuffer(i*a),s=r?new Uint32Array(o):new Uint16Array(o),c=0;for(let t=0;t<e.length;t++){let{offset:n,count:r}=e[t];for(let e=0;e<r;e++)s[c+e]=n+e;c+=r}return s}var RN=class extends ON{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(!e.isBufferGeometry)throw Error(`BVH: Only BufferGeometries are supported.`);if(e.index&&e.index.isInterleavedBufferAttribute)throw Error(`BVH: InterleavedBufferAttribute is not supported for the index attribute.`);if(t.useSharedArrayBuffer&&!kN())throw Error(`BVH: SharedArrayBuffer is not available.`);super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?e=>this._indirectBuffer[e]:e=>e,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...kM,...t},t[OM]||this.init(t)}init(e){let{geometry:t,primitiveStride:n}=this;if(e.indirect){let r=LN(IN(t,e.range,n),e.useSharedArrayBuffer);this._indirectBuffer=r}else NN(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Xy))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:IN(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw Error(`BVH: raycastObject3D() not implemented`)}},zN=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,r=-1/0;for(let i=0,a=e.length;i<a;i++){let a=e[i][t];n=a<n?a:n,r=a>r?a:r}this.min=n,this.max=r}setFromPoints(e,t){let n=1/0,r=-1/0;for(let i=0,a=t.length;i<a;i++){let a=t[i],o=e.dot(a);n=o<n?o:n,r=o>r?o:r}this.min=n,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};zN.prototype.setFromBox=(function(){let e=new Z;return function(t,n){let r=n.min,i=n.max,a=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let s=0;s<=1;s++)for(let c=0;c<=1;c++){e.x=r.x*n+i.x*(1-n),e.y=r.y*s+i.y*(1-s),e.z=r.z*c+i.z*(1-c);let l=t.dot(e);a=Math.min(l,a),o=Math.max(l,o)}this.min=a,this.max=o}})();var BN=(function(){let e=new Z,t=new Z,n=new Z;return function(r,i,a){let o=r.start,s=e,c=i.start,l=t;n.subVectors(o,c),e.subVectors(r.end,r.start),t.subVectors(i.end,i.start);let u=n.dot(l),d=l.dot(s),f=l.dot(l),p=n.dot(s),m=s.dot(s)*f-d*d,h,g;h=m===0?0:(u*d-p*f)/m,g=(u+h*d)/f,a.x=h,a.y=g}})(),VN=(function(){let e=new X,t=new Z,n=new Z;return function(r,i,a,o){BN(r,i,e);let s=e.x,c=e.y;if(s>=0&&s<=1&&c>=0&&c<=1)r.at(s,a),i.at(c,o);else if(s>=0&&s<=1)c<0?i.at(0,o):i.at(1,o),r.closestPointToPoint(o,!0,a);else if(c>=0&&c<=1)s<0?r.at(0,a):r.at(1,a),i.closestPointToPoint(a,!0,o);else{let e;e=s<0?r.start:r.end;let l;l=c<0?i.start:i.end;let u=t,d=n;if(r.closestPointToPoint(l,!0,t),i.closestPointToPoint(e,!0,n),u.distanceToSquared(l)<=d.distanceToSquared(e)){a.copy(u),o.copy(l);return}a.copy(e),o.copy(d);return}}})(),HN=(function(){let e=new Z,t=new Z,n=new Hb,r=new nw;return function(i,a){let{radius:o,center:s}=i,{a:c,b:l,c:u}=a;if(r.start=c,r.end=l,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o||(r.start=c,r.end=u,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o)||(r.start=l,r.end=u,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o))return!0;let d=a.getPlane(n);if(Math.abs(d.distanceToPoint(s))<=o){let e=d.projectPoint(s,t);if(a.containsPoint(e))return!0}return!1}})(),UN=[`x`,`y`,`z`],WN=1e-15,GN=WN*WN;function KN(e){return Math.abs(e)<WN}var qN=class extends Yy{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=[,,,,].fill().map(()=>new Z),this.satBounds=[,,,,].fill().map(()=>new zN),this.points=[this.a,this.b,this.c],this.plane=new Hb,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new nw,this.needsUpdate=!0}intersectsSphere(e){return HN(e,this)}update(){let e=this.a,t=this.b,n=this.c,r=this.points,i=this.satAxes,a=this.satBounds,o=i[0],s=a[0];this.getNormal(o),s.setFromPoints(o,r);let c=i[1],l=a[1];c.subVectors(e,t),l.setFromPoints(c,r);let u=i[2],d=a[2];u.subVectors(t,n),d.setFromPoints(u,r);let f=i[3],p=a[3];f.subVectors(n,e),p.setFromPoints(f,r);let m=c.length(),h=u.length(),g=f.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<WN?h<WN||g<WN?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):h<WN?g<WN?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):g<WN&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}};qN.prototype.closestPointToSegment=(function(){let e=new Z,t=new Z,n=new nw;return function(r,i=null,a=null){this.needsUpdate&&this.update();let{start:o,end:s}=r,c=this.points,l,u=1/0;if(this.plane.distanceToPoint(o)*this.plane.distanceToPoint(s)<0&&this.plane.intersectLine(r,e)!==null&&this.containsPoint(e))return i&&i.copy(e),a&&a.copy(e),0;for(let o=0;o<3;o++){let s=(o+1)%3;n.start.copy(c[o]),n.end.copy(c[s]),VN(n,r,e,t),l=e.distanceToSquared(t),l<u&&(u=l,i&&i.copy(e),a&&a.copy(t))}return this.closestPointToPoint(o,e),l=o.distanceToSquared(e),l<u&&(u=l,i&&i.copy(e),a&&a.copy(o)),this.closestPointToPoint(s,e),l=s.distanceToSquared(e),l<u&&(u=l,i&&i.copy(e),a&&a.copy(s)),Math.sqrt(u)}})(),qN.prototype.intersectsTriangle=(function(){let e=new qN,t=new zN,n=new zN,r=new Z,i=new Z,a=new Z,o=new Z,s=new nw,c=new nw,l=new Z,u=new X,d=new X;function f(e,i,a,s){let c=r;!e.isDegenerateIntoPoint&&!e.isDegenerateIntoSegment?c.copy(e.plane.normal):c.copy(i.plane.normal);let l=e.satBounds,u=e.satAxes;for(let r=1;r<4;r++){let a=l[r],s=u[r];if(t.setFromPoints(s,i.points),a.isSeparated(t)||(o.copy(c).cross(s),t.setFromPoints(o,e.points),n.setFromPoints(o,i.points),t.isSeparated(n)))return!1}let d=i.satBounds,f=i.satAxes;for(let r=1;r<4;r++){let a=d[r],s=f[r];if(t.setFromPoints(s,e.points),a.isSeparated(t)||(o.crossVectors(c,s),t.setFromPoints(o,e.points),n.setFromPoints(o,i.points),t.isSeparated(n)))return!1}return a&&(s||console.warn(`ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0.`),a.start.set(0,0,0),a.end.set(0,0,0)),!0}function p(e,t,n,r,i,a,o,s,c,l,u){let d=o/(o-s);l.x=r+(i-r)*d,u.start.subVectors(t,e).multiplyScalar(d).add(e),d=o/(o-c),l.y=r+(a-r)*d,u.end.subVectors(n,e).multiplyScalar(d).add(e)}function m(e,t,n,r,i,a,o,s,c,l,u){if(i>0)p(e.c,e.a,e.b,r,t,n,c,o,s,l,u);else if(a>0)p(e.b,e.a,e.c,n,t,r,s,o,c,l,u);else if(s*c>0||o!=0)p(e.a,e.b,e.c,t,n,r,o,s,c,l,u);else if(s!=0)p(e.b,e.a,e.c,n,t,r,s,o,c,l,u);else if(c!=0)p(e.c,e.a,e.b,r,t,n,c,o,s,l,u);else return!0;return!1}function h(e,t,n,i){let a=t.degenerateSegment,o=e.plane.distanceToPoint(a.start),s=e.plane.distanceToPoint(a.end);return KN(o)?KN(s)?f(e,t,n,i):(n&&(n.start.copy(a.start),n.end.copy(a.start)),e.containsPoint(a.start)):KN(s)?(n&&(n.start.copy(a.end),n.end.copy(a.end)),e.containsPoint(a.end)):e.plane.intersectLine(a,r)!=null&&(n&&(n.start.copy(r),n.end.copy(r)),e.containsPoint(r))}function g(e,t,n){let r=t.a;return KN(e.plane.distanceToPoint(r))&&e.containsPoint(r)?(n&&(n.start.copy(r),n.end.copy(r)),!0):!1}function _(e,t,n){let i=e.degenerateSegment,a=t.a;return i.closestPointToPoint(a,!0,r),a.distanceToSquared(r)<GN&&(n&&(n.start.copy(a),n.end.copy(a)),!0)}function v(e,t,n,o){if(e.isDegenerateIntoSegment){if(t.isDegenerateIntoSegment){let o=e.degenerateSegment,s=t.degenerateSegment,c=i,l=a;o.delta(c),s.delta(l);let u=r.subVectors(s.start,o.start),d=c.x*l.y-c.y*l.x;if(KN(d))return!1;let f=(u.x*l.y-u.y*l.x)/d,p=-(c.x*u.y-c.y*u.x)/d;return f<0||f>1||p<0||p>1?!1:KN(o.start.z+c.z*f-(s.start.z+l.z*p))?(n&&(n.start.copy(o.start).addScaledVector(c,f),n.end.copy(o.start).addScaledVector(c,f)),!0):!1}return t.isDegenerateIntoPoint?_(e,t,n):h(t,e,n,o)}if(e.isDegenerateIntoPoint)return t.isDegenerateIntoPoint?t.a.distanceToSquared(e.a)<GN&&(n&&(n.start.copy(e.a),n.end.copy(e.a)),!0):t.isDegenerateIntoSegment?_(t,e,n):g(t,e,n);if(t.isDegenerateIntoPoint)return g(e,t,n);if(t.isDegenerateIntoSegment)return h(e,t,n,o)}return function(t,n=null,r=!1){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);let o=v(this,t,n,r);if(o!==void 0)return o;let p=this.plane,h=t.plane,g=h.distanceToPoint(this.a),_=h.distanceToPoint(this.b),y=h.distanceToPoint(this.c);KN(g)&&(g=0),KN(_)&&(_=0),KN(y)&&(y=0);let b=g*_,x=g*y;if(b>0&&x>0)return!1;let S=p.distanceToPoint(t.a),C=p.distanceToPoint(t.b),w=p.distanceToPoint(t.c);KN(S)&&(S=0),KN(C)&&(C=0),KN(w)&&(w=0);let T=S*C,E=S*w;if(T>0&&E>0)return!1;i.copy(p.normal),a.copy(h.normal);let D=i.cross(a),O=0,k=Math.abs(D.x),A=Math.abs(D.y);A>k&&(k=A,O=1),Math.abs(D.z)>k&&(O=2);let j=UN[O],M=this.a[j],N=this.b[j],P=this.c[j],ee=t.a[j],te=t.b[j],ne=t.c[j];if(m(this,M,N,P,b,x,g,_,y,u,s)||m(t,ee,te,ne,T,E,S,C,w,d,c))return f(this,t,n,r);if(u.y<u.x){let e=u.y;u.y=u.x,u.x=e,l.copy(s.start),s.start.copy(s.end),s.end.copy(l)}if(d.y<d.x){let e=d.y;d.y=d.x,d.x=e,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<d.x||d.y<u.x?!1:(n&&(d.x>u.x?n.start.copy(c.start):n.start.copy(s.start),d.y<u.y?n.end.copy(c.end):n.end.copy(s.end)),!0)}})(),qN.prototype.distanceToPoint=(function(){let e=new Z;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}})(),qN.prototype.distanceToTriangle=(function(){let e=new Z,t=new Z,n=[`a`,`b`,`c`],r=new nw,i=new nw;return function(a,o=null,s=null){let c=o||s?r:null;if(this.intersectsTriangle(a,c,!0))return(o||s)&&(o&&c.getCenter(o),s&&c.getCenter(s)),0;let l=1/0;for(let t=0;t<3;t++){let r,i=n[t],c=a[i];this.closestPointToPoint(c,e),r=c.distanceToSquared(e),r<l&&(l=r,o&&o.copy(e),s&&s.copy(c));let u=this[i];a.closestPointToPoint(u,e),r=u.distanceToSquared(e),r<l&&(l=r,o&&o.copy(u),s&&s.copy(e))}for(let c=0;c<3;c++){let u=n[c],d=n[(c+1)%3];r.set(this[u],this[d]);for(let c=0;c<3;c++){let u=n[c],d=n[(c+1)%3];i.set(a[u],a[d]),VN(r,i,e,t);let f=e.distanceToSquared(t);f<l&&(l=f,o&&o.copy(e),s&&s.copy(t))}}return Math.sqrt(l)}})();var JN=class{constructor(e,t,n){this.isOrientedBox=!0,this.min=new Z,this.max=new Z,this.matrix=new $v,this.invMatrix=new $v,this.points=Array(8).fill().map(()=>new Z),this.satAxes=[,,,].fill().map(()=>new Z),this.satBounds=[,,,].fill().map(()=>new zN),this.alignedSatBounds=[,,,].fill().map(()=>new zN),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};JN.prototype.update=(function(){return function(){let e=this.matrix,t=this.min,n=this.max,r=this.points;for(let i=0;i<=1;i++)for(let a=0;a<=1;a++)for(let o=0;o<=1;o++){let s=r[1*i|2*a|4*o];s.x=i?n.x:t.x,s.y=a?n.y:t.y,s.z=o?n.z:t.z,s.applyMatrix4(e)}let i=this.satBounds,a=this.satAxes,o=r[0];for(let e=0;e<3;e++){let t=a[e],n=i[e],s=r[1<<e];t.subVectors(o,s),n.setFromPoints(t,r)}let s=this.alignedSatBounds;s[0].setFromPointsField(r,`x`),s[1].setFromPointsField(r,`y`),s[2].setFromPointsField(r,`z`),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),JN.prototype.intersectsBox=(function(){let e=new zN;return function(t){this.needsUpdate&&this.update();let n=t.min,r=t.max,i=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=r.x,o[0].isSeparated(e)||(e.min=n.y,e.max=r.y,o[1].isSeparated(e))||(e.min=n.z,e.max=r.z,o[2].isSeparated(e)))return!1;for(let n=0;n<3;n++){let r=a[n],o=i[n];if(e.setFromBox(r,t),o.isSeparated(e))return!1}return!0}})(),JN.prototype.intersectsTriangle=(function(){let e=new qN,t=[,,,],n=new zN,r=new zN,i=new Z;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let o=this.satBounds,s=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let e=0;e<3;e++){let r=o[e],i=s[e];if(n.setFromPoints(i,t),r.isSeparated(n))return!1}let c=a.satBounds,l=a.satAxes,u=this.points;for(let e=0;e<3;e++){let t=c[e],r=l[e];if(n.setFromPoints(r,u),t.isSeparated(n))return!1}for(let e=0;e<3;e++){let a=s[e];for(let e=0;e<4;e++){let o=l[e];if(i.crossVectors(a,o),n.setFromPoints(i,t),r.setFromPoints(i,u),n.isSeparated(r))return!1}}return!0}})(),JN.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),JN.prototype.distanceToPoint=(function(){let e=new Z;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}})(),JN.prototype.distanceToBox=(function(){let e=[`x`,`y`,`z`],t=Array(12).fill().map(()=>new nw),n=Array(12).fill().map(()=>new nw),r=new Z,i=new Z;return function(a,o=0,s=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(s||c)&&(a.getCenter(i),this.closestPointToPoint(i,r),a.closestPointToPoint(r,i),s&&s.copy(r),c&&c.copy(i)),0;let l=o*o,u=a.min,d=a.max,f=this.points,p=1/0;for(let e=0;e<8;e++){let t=f[e];i.copy(t).clamp(u,d);let n=t.distanceToSquared(i);if(n<p&&(p=n,s&&s.copy(t),c&&c.copy(i),n<l))return Math.sqrt(n)}let m=0;for(let r=0;r<3;r++)for(let i=0;i<=1;i++)for(let a=0;a<=1;a++){let o=(r+1)%3,s=(r+2)%3,c=i<<o|a<<s,l=1<<r|i<<o|a<<s,p=f[c],h=f[l];t[m].set(p,h);let g=e[r],_=e[o],v=e[s],y=n[m],b=y.start,x=y.end;b[g]=u[g],b[_]=i?u[_]:d[_],b[v]=a?u[v]:d[v],x[g]=d[g],x[_]=i?u[_]:d[_],x[v]=a?u[v]:d[v],m++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){i.x=e?d.x:u.x,i.y=t?d.y:u.y,i.z=n?d.z:u.z,this.closestPointToPoint(i,r);let a=i.distanceToSquared(r);if(a<p&&(p=a,s&&s.copy(r),c&&c.copy(i),a<l))return Math.sqrt(a)}for(let e=0;e<12;e++){let a=t[e];for(let e=0;e<12;e++){let t=n[e];VN(a,t,r,i);let o=r.distanceToSquared(i);if(o<p&&(p=o,s&&s.copy(r),c&&c.copy(i),o<l))return Math.sqrt(o)}}return Math.sqrt(p)}})();var YN=new class extends sN{constructor(){super(()=>new qN)}},XN=new Z,ZN=new Z;function QN(e,t,n={},r=0,i=1/0){let a=r*r,o=i*i,s=1/0,c=null;if(e.shapecast({boundsTraverseOrder:e=>(XN.copy(t).clamp(e.min,e.max),XN.distanceToSquared(t)),intersectsBounds:(e,t,n)=>n<s&&n<o,intersectsTriangle:(e,n)=>{e.closestPointToPoint(t,XN);let r=t.distanceToSquared(XN);return r<s&&(ZN.copy(XN),s=r,c=n),r<a}}),s===1/0)return null;let l=Math.sqrt(s);return n.point?n.point.copy(ZN):n.point=ZN.clone(),n.distance=l,n.faceIndex=c,n}var $N=!0,eP=new Z,tP=new Z,nP=new Z,rP=new X,iP=new X,aP=new X,oP=new Z,sP=new Z,cP=new Z,lP=new Z;function uP(e,t,n,r,i,a,o,s){let c;if(c=a===1?e.intersectTriangle(r,n,t,!0,i):e.intersectTriangle(t,n,r,a!==2,i),c===null)return null;let l=e.origin.distanceTo(i);return l<o||l>s?null:{distance:l,point:i.clone()}}function dP(e,t,n,r,i,a,o,s,c,l,u){eP.fromBufferAttribute(t,a),tP.fromBufferAttribute(t,o),nP.fromBufferAttribute(t,s);let d=uP(e,eP,tP,nP,lP,c,l,u);if(d){if(r){rP.fromBufferAttribute(r,a),iP.fromBufferAttribute(r,o),aP.fromBufferAttribute(r,s),d.uv=new X;let e=Yy.getInterpolation(lP,eP,tP,nP,rP,iP,aP,d.uv);$N||(d.uv=e)}if(i){rP.fromBufferAttribute(i,a),iP.fromBufferAttribute(i,o),aP.fromBufferAttribute(i,s),d.uv1=new X;let e=Yy.getInterpolation(lP,eP,tP,nP,rP,iP,aP,d.uv1);$N||(d.uv1=e)}if(n){oP.fromBufferAttribute(n,a),sP.fromBufferAttribute(n,o),cP.fromBufferAttribute(n,s),d.normal=new Z;let t=Yy.getInterpolation(lP,eP,tP,nP,oP,sP,cP,d.normal);d.normal.dot(e.direction)>0&&d.normal.multiplyScalar(-1),$N||(d.normal=t)}let t={a,b:o,c:s,normal:new Z,materialIndex:0};if(Yy.getNormal(eP,tP,nP,t.normal),d.face=t,d.faceIndex=a,$N){let e=new Z;Yy.getBarycoord(lP,eP,tP,nP,e),d.barycoord=e}}return d}function fP(e){return e&&e.isMaterial?e.side:e}function pP(e,t,n,r,i,a,o){let s=r*3,c=s+0,l=s+1,u=s+2,{index:d,groups:f}=e;e.index&&(c=d.getX(c),l=d.getX(l),u=d.getX(u));let{position:p,normal:m,uv:h,uv1:g}=e.attributes;if(Array.isArray(t)){let e=r*3;for(let s=0,d=f.length;s<d;s++){let{start:d,count:_,materialIndex:v}=f[s];if(e>=d&&e<d+_){let e=fP(t[v]),s=dP(n,p,m,h,g,c,l,u,e,a,o);if(s){if(s.faceIndex=r,s.face.materialIndex=v,i)i.push(s);else return s}}}}else{let e=fP(t),s=dP(n,p,m,h,g,c,l,u,e,a,o);if(s){if(s.faceIndex=r,s.face.materialIndex=0,i)i.push(s);else return s}}return null}function mP(e,t,n,r){let i=e.a,a=e.b,o=e.c,s=t,c=t+1,l=t+2;n&&(s=n.getX(s),c=n.getX(c),l=n.getX(l)),i.x=r.getX(s),i.y=r.getY(s),i.z=r.getZ(s),a.x=r.getX(c),a.y=r.getY(c),a.z=r.getZ(c),o.x=r.getX(l),o.y=r.getY(l),o.z=r.getZ(l)}function hP(e,t,n,r,i,a,o,s){let{geometry:c,_indirectBuffer:l}=e;for(let e=r,l=r+i;e<l;e++)pP(c,t,n,e,a,o,s)}function gP(e,t,n,r,i,a,o){let{geometry:s,_indirectBuffer:c}=e,l=1/0,u=null;for(let e=r,c=r+i;e<c;e++){let r;r=pP(s,t,n,e,null,a,o),r&&r.distance<l&&(u=r,l=r.distance)}return u}function _P(e,t,n,r,i,a,o){let{geometry:s}=n,{index:c}=s,l=s.attributes.position;for(let n=e,s=t+e;n<s;n++){let e;if(e=n,mP(o,e*3,c,l),o.needsUpdate=!0,r(o,e,i,a))return!0}return!1}function vP(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));let n=e.geometry,r=n.index?n.index.array:null,i=n.attributes.position,a,o,s,c,l=0,u=e._roots;for(let e=0,t=u.length;e<t;e++)a=u[e],o=new Uint32Array(a),s=new Uint16Array(a),c=new Float32Array(a),d(0,l),l+=a.byteLength;function d(e,n,a=!1){let l=e*2;if(PM(l,s)){let t=FM(e,o),n=IM(l,s),a=1/0,u=1/0,d=1/0,f=-1/0,p=-1/0,m=-1/0;for(let e=3*t,o=3*(t+n);e<o;e++){let t=r[e],n=i.getX(t),o=i.getY(t),s=i.getZ(t);n<a&&(a=n),n>f&&(f=n),o<u&&(u=o),o>p&&(p=o),s<d&&(d=s),s>m&&(m=s)}return c[e+0]!==a||c[e+1]!==u||c[e+2]!==d||c[e+3]!==f||c[e+4]!==p||c[e+5]!==m?(c[e+0]=a,c[e+1]=u,c[e+2]=d,c[e+3]=f,c[e+4]=p,c[e+5]=m,!0):!1}{let r=LM(e),i=RM(e,o),s=a,l=!1,u=!1;if(t){if(!s){let e=r/8+n/32,a=i/8+n/32;l=t.has(e),u=t.has(a),s=!l&&!u}}else l=!0,u=!0;let f=s||l,p=s||u,m=!1;f&&(m=d(r,n,s));let h=!1;p&&(h=d(i,n,s));let g=m||h;if(g)for(let t=0;t<3;t++){let n=r+t,a=i+t,o=c[n],s=c[n+3],l=c[a],u=c[a+3];c[e+t]=o<l?o:l,c[e+t+3]=s>u?s:u}return g}}}function yP(e,t,n,r,i){let a,o,s,c,l,u,d=1/n.direction.x,f=1/n.direction.y,p=1/n.direction.z,m=n.origin.x,h=n.origin.y,g=n.origin.z,_=t[e],v=t[e+3],y=t[e+1],b=t[e+3+1],x=t[e+2],S=t[e+3+2];return d>=0?(a=(_-m)*d,o=(v-m)*d):(a=(v-m)*d,o=(_-m)*d),f>=0?(s=(y-h)*f,c=(b-h)*f):(s=(b-h)*f,c=(y-h)*f),a>c||s>o||((s>a||isNaN(a))&&(a=s),(c<o||isNaN(o))&&(o=c),p>=0?(l=(x-g)*p,u=(S-g)*p):(l=(S-g)*p,u=(x-g)*p),a>u||l>o)?!1:((l>a||a!==a)&&(a=l),(u<o||o!==o)&&(o=u),a<=i&&o>=r)}function bP(e,t,n,r,i,a,o,s){let{geometry:c,_indirectBuffer:l}=e;for(let e=r,u=r+i;e<u;e++)pP(c,t,n,l?l[e]:e,a,o,s)}function xP(e,t,n,r,i,a,o){let{geometry:s,_indirectBuffer:c}=e,l=1/0,u=null;for(let e=r,d=r+i;e<d;e++){let r;r=pP(s,t,n,c?c[e]:e,null,a,o),r&&r.distance<l&&(u=r,l=r.distance)}return u}function SP(e,t,n,r,i,a,o){let{geometry:s}=n,{index:c}=s,l=s.attributes.position;for(let s=e,u=t+e;s<u;s++){let e;if(e=n.resolveTriangleIndex(s),mP(o,e*3,c,l),o.needsUpdate=!0,r(o,e,i,a))return!0}return!1}function CP(e,t,n,r,i,a,o){cN.setBuffer(e._roots[t]),yP(0,cN.float32Array,r,a,o)&&wP(0,e,n,r,i,a,o),cN.clearBuffer()}function wP(e,t,n,r,i,a,o){let{float32Array:s,uint16Array:c,uint32Array:l}=cN,u=e*2;if(PM(u,c))hP(t,n,r,FM(e,l),IM(u,c),i,a,o);else{let c=LM(e);yP(c,s,r,a,o)&&wP(c,t,n,r,i,a,o);let u=RM(e,l);yP(u,s,r,a,o)&&wP(u,t,n,r,i,a,o)}}var TP=[`x`,`y`,`z`];function EP(e,t,n,r,i,a){cN.setBuffer(e._roots[t]);let o=null;return yP(0,cN.float32Array,r,i,a)&&(o=DP(0,e,n,r,i,a)),cN.clearBuffer(),o}function DP(e,t,n,r,i,a){let{float32Array:o,uint16Array:s,uint32Array:c}=cN,l=e*2;if(PM(l,s))return gP(t,n,r,FM(e,c),IM(l,s),i,a);{let s=zM(e,c),l=TP[s],u=r.direction[l]>=0,d,f;u?(d=LM(e),f=RM(e,c)):(d=RM(e,c),f=LM(e));let p=yP(d,o,r,i,a)?DP(d,t,n,r,i,a):null;if(p){let e=p.point[l];if(u?e<=o[f+s]:e>=o[f+s+3])return p}let m=yP(f,o,r,i,a)?DP(f,t,n,r,i,a):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}var OP=new Xy,kP=new qN,AP=new qN,jP=new $v,MP=new JN,NP=new JN;function PP(e,t,n,r){cN.setBuffer(e._roots[t]);let i=FP(0,e,n,r);return cN.clearBuffer(),i}function FP(e,t,n,r,i=null){let{float32Array:a,uint16Array:o,uint32Array:s}=cN,c=e*2;if(i===null&&(n.boundingBox||n.computeBoundingBox(),MP.set(n.boundingBox.min,n.boundingBox.max,r),i=MP),PM(c,o)){let i=t.geometry,l=i.index,u=i.attributes.position,d=n.index,f=n.attributes.position,p=FM(e,s),m=IM(c,o);if(jP.copy(r).invert(),n.boundsTree)return AM(BM(e),a,NP),NP.matrix.copy(jP),NP.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:e=>NP.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.needsUpdate=!0;for(let t=p*3,n=(m+p)*3;t<n;t+=3)if(mP(AP,t,l,u),AP.needsUpdate=!0,e.intersectsTriangle(AP))return!0;return!1}});{let e=jN(n);for(let t=p*3,n=(m+p)*3;t<n;t+=3){mP(kP,t,l,u),kP.a.applyMatrix4(jP),kP.b.applyMatrix4(jP),kP.c.applyMatrix4(jP),kP.needsUpdate=!0;for(let t=0,n=e*3;t<n;t+=3)if(mP(AP,t,d,f),AP.needsUpdate=!0,kP.intersectsTriangle(AP))return!0}}}else{let o=LM(e),c=RM(e,s);return AM(BM(o),a,OP),!!(i.intersectsBox(OP)&&FP(o,t,n,r,i)||(AM(BM(c),a,OP),i.intersectsBox(OP)&&FP(c,t,n,r,i)))}}var IP=new $v,LP=new JN,RP=new JN,zP=new Z,BP=new Z,VP=new Z,HP=new Z;function UP(e,t,n,r={},i={},a=0,o=1/0){t.boundingBox||t.computeBoundingBox(),LP.set(t.boundingBox.min,t.boundingBox.max,n),LP.needsUpdate=!0;let s=e.geometry,c=s.attributes.position,l=s.index,u=t.attributes.position,d=t.index,f=YN.getPrimitive(),p=YN.getPrimitive(),m=zP,h=BP,g=null,_=null;i&&(g=VP,_=HP);let v=1/0,y=null,b=null;return IP.copy(n).invert(),RP.matrix.copy(IP),e.shapecast({boundsTraverseOrder:e=>LP.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o&&(t&&(RP.min.copy(e.min),RP.max.copy(e.max),RP.needsUpdate=!0),!0),intersectsRange:(e,r)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:e=>RP.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o,intersectsRange:(t,i)=>{for(let o=t,s=t+i;o<s;o++){mP(p,3*o,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let t=e,n=e+r;t<n;t++){mP(f,3*t,l,c),f.needsUpdate=!0;let e=f.distanceToTriangle(p,m,g);if(e<v&&(h.copy(m),_&&_.copy(g),v=e,y=t,b=o),e<a)return!0}}}});{let i=jN(t);for(let t=0,o=i;t<o;t++){mP(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let n=e,i=e+r;n<i;n++){mP(f,3*n,l,c),f.needsUpdate=!0;let e=f.distanceToTriangle(p,m,g);if(e<v&&(h.copy(m),_&&_.copy(g),v=e,y=n,b=t),e<a)return!0}}}}}),YN.releasePrimitive(f),YN.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(h):r.point=h.clone(),r.distance=v,r.faceIndex=y,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(IP),h.applyMatrix4(IP),i.distance=h.sub(i.point).length(),i.faceIndex=b),r)}function WP(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));let n=e.geometry,r=n.index?n.index.array:null,i=n.attributes.position,a,o,s,c,l=0,u=e._roots;for(let e=0,t=u.length;e<t;e++)a=u[e],o=new Uint32Array(a),s=new Uint16Array(a),c=new Float32Array(a),d(0,l),l+=a.byteLength;function d(n,a,l=!1){let u=n*2;if(PM(u,s)){let t=FM(n,o),a=IM(u,s),l=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,h=-1/0;for(let n=t,o=t+a;n<o;n++){let t=3*e.resolveTriangleIndex(n);for(let e=0;e<3;e++){let n=t+e;n=r?r[n]:n;let a=i.getX(n),o=i.getY(n),s=i.getZ(n);a<l&&(l=a),a>p&&(p=a),o<d&&(d=o),o>m&&(m=o),s<f&&(f=s),s>h&&(h=s)}}return c[n+0]!==l||c[n+1]!==d||c[n+2]!==f||c[n+3]!==p||c[n+4]!==m||c[n+5]!==h?(c[n+0]=l,c[n+1]=d,c[n+2]=f,c[n+3]=p,c[n+4]=m,c[n+5]=h,!0):!1}{let e=LM(n),r=RM(n,o),i=l,s=!1,u=!1;if(t){if(!i){let n=e/8+a/32,o=r/8+a/32;s=t.has(n),u=t.has(o),i=!s&&!u}}else s=!0,u=!0;let f=i||s,p=i||u,m=!1;f&&(m=d(e,a,i));let h=!1;p&&(h=d(r,a,i));let g=m||h;if(g)for(let t=0;t<3;t++){let i=e+t,a=r+t,o=c[i],s=c[i+3],l=c[a],u=c[a+3];c[n+t]=o<l?o:l,c[n+t+3]=s>u?s:u}return g}}}function GP(e,t,n,r,i,a,o){cN.setBuffer(e._roots[t]),yP(0,cN.float32Array,r,a,o)&&KP(0,e,n,r,i,a,o),cN.clearBuffer()}function KP(e,t,n,r,i,a,o){let{float32Array:s,uint16Array:c,uint32Array:l}=cN,u=e*2;if(PM(u,c))bP(t,n,r,FM(e,l),IM(u,c),i,a,o);else{let c=LM(e);yP(c,s,r,a,o)&&KP(c,t,n,r,i,a,o);let u=RM(e,l);yP(u,s,r,a,o)&&KP(u,t,n,r,i,a,o)}}var qP=[`x`,`y`,`z`];function JP(e,t,n,r,i,a){cN.setBuffer(e._roots[t]);let o=null;return yP(0,cN.float32Array,r,i,a)&&(o=YP(0,e,n,r,i,a)),cN.clearBuffer(),o}function YP(e,t,n,r,i,a){let{float32Array:o,uint16Array:s,uint32Array:c}=cN,l=e*2;if(PM(l,s))return xP(t,n,r,FM(e,c),IM(l,s),i,a);{let s=zM(e,c),l=qP[s],u=r.direction[l]>=0,d,f;u?(d=LM(e),f=RM(e,c)):(d=RM(e,c),f=LM(e));let p=yP(d,o,r,i,a)?YP(d,t,n,r,i,a):null;if(p){let e=p.point[l];if(u?e<=o[f+s]:e>=o[f+s+3])return p}let m=yP(f,o,r,i,a)?YP(f,t,n,r,i,a):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}var XP=new Xy,ZP=new qN,QP=new qN,$P=new $v,eF=new JN,tF=new JN;function nF(e,t,n,r){cN.setBuffer(e._roots[t]);let i=rF(0,e,n,r);return cN.clearBuffer(),i}function rF(e,t,n,r,i=null){let{float32Array:a,uint16Array:o,uint32Array:s}=cN,c=e*2;if(i===null&&(n.boundingBox||n.computeBoundingBox(),eF.set(n.boundingBox.min,n.boundingBox.max,r),i=eF),PM(c,o)){let i=t.geometry,l=i.index,u=i.attributes.position,d=n.index,f=n.attributes.position,p=FM(e,s),m=IM(c,o);if($P.copy(r).invert(),n.boundsTree)return AM(BM(e),a,tF),tF.matrix.copy($P),tF.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:e=>tF.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.needsUpdate=!0;for(let n=p,r=m+p;n<r;n++)if(mP(QP,3*t.resolveTriangleIndex(n),l,u),QP.needsUpdate=!0,e.intersectsTriangle(QP))return!0;return!1}});{let e=jN(n);for(let n=p,r=m+p;n<r;n++){mP(ZP,3*t.resolveTriangleIndex(n),l,u),ZP.a.applyMatrix4($P),ZP.b.applyMatrix4($P),ZP.c.applyMatrix4($P),ZP.needsUpdate=!0;for(let t=0,n=e*3;t<n;t+=3)if(mP(QP,t,d,f),QP.needsUpdate=!0,ZP.intersectsTriangle(QP))return!0}}}else{let o=LM(e),c=RM(e,s);return AM(BM(o),a,XP),!!(i.intersectsBox(XP)&&rF(o,t,n,r,i)||(AM(BM(c),a,XP),i.intersectsBox(XP)&&rF(c,t,n,r,i)))}}var iF=new $v,aF=new JN,oF=new JN,sF=new Z,cF=new Z,lF=new Z,uF=new Z;function dF(e,t,n,r={},i={},a=0,o=1/0){t.boundingBox||t.computeBoundingBox(),aF.set(t.boundingBox.min,t.boundingBox.max,n),aF.needsUpdate=!0;let s=e.geometry,c=s.attributes.position,l=s.index,u=t.attributes.position,d=t.index,f=YN.getPrimitive(),p=YN.getPrimitive(),m=sF,h=cF,g=null,_=null;i&&(g=lF,_=uF);let v=1/0,y=null,b=null;return iF.copy(n).invert(),oF.matrix.copy(iF),e.shapecast({boundsTraverseOrder:e=>aF.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o&&(t&&(oF.min.copy(e.min),oF.max.copy(e.max),oF.needsUpdate=!0),!0),intersectsRange:(r,i)=>{if(t.boundsTree){let s=t.boundsTree;return s.shapecast({boundsTraverseOrder:e=>oF.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o,intersectsRange:(t,o)=>{for(let x=t,S=t+o;x<S;x++){let t=s.resolveTriangleIndex(x);mP(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let t=r,n=r+i;t<n;t++){let n=e.resolveTriangleIndex(t);mP(f,3*n,l,c),f.needsUpdate=!0;let r=f.distanceToTriangle(p,m,g);if(r<v&&(h.copy(m),_&&_.copy(g),v=r,y=t,b=x),r<a)return!0}}}})}{let o=jN(t);for(let t=0,s=o;t<s;t++){mP(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let n=r,o=r+i;n<o;n++){let r=e.resolveTriangleIndex(n);mP(f,3*r,l,c),f.needsUpdate=!0;let i=f.distanceToTriangle(p,m,g);if(i<v&&(h.copy(m),_&&_.copy(g),v=i,y=n,b=t),i<a)return!0}}}}}),YN.releasePrimitive(f),YN.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(h):r.point=h.clone(),r.distance=v,r.faceIndex=y,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(iF),h.applyMatrix4(iF),i.distance=h.sub(i.point).length(),i.faceIndex=b),r)}function fF(e,t,n){return e===null?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e)}var pF=new JN,mF=new dx,hF=new Z,gF=new $v,_F=new Z,vF=[`getX`,`getY`,`getZ`],yF=class e extends RN{static serialize(e,t={}){t={cloneBuffers:!0,...t};let n=e.geometry,r=e._roots,i=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=r.map(e=>e.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=i?i.slice():null):(o.roots=r,o.index=a?a.array:null,o.indirectBuffer=i),o}static deserialize(t,n,r={}){r={setIndex:!0,indirect:!!t.indirectBuffer,...r};let{index:i,roots:a,indirectBuffer:o}=t;t.version||(console.warn(`MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data.`),c(a));let s=new e(n,{...r,[OM]:!0});if(s._roots=a,s._indirectBuffer=o||null,r.setIndex){let e=n.getIndex();if(e===null){let e=new yb(t.index,1,!1);n.setIndex(e)}else e.array!==i&&(e.array.set(i),e.needsUpdate=!0)}return s;function c(e){for(let t=0;t<e.length;t++){let n=e[t],r=new Uint32Array(n),i=new Uint16Array(n);for(let e=0,t=n.byteLength/32;e<t;e++){let t=8*e;PM(2*t,i)||(r[t+6]=r[t+6]/8-e)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn(`MeshBVH: \"maxLeafTris\" option has been deprecated. Use \"targetLeafSize\", instead.`),t={...t,targetLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){let r=this.geometry,i=this._indirectBuffer,a=r.attributes.position,o=r.index?r.index.array:null,s=(i?i[e]:e)*3,c=s+0,l=s+1,u=s+2;o&&(c=o[c],l=o[l],u=o[u]);for(let e=0;e<3;e++){let r=a[vF[e]](c),i=a[vF[e]](l),o=a[vF[e]](u),s=r;i<s&&(s=i),o<s&&(s=o);let d=r;i>d&&(d=i),o>d&&(d=o),t[n+e]=s,t[n+e+3]=d}return t}computePrimitiveBounds(e,t,n){let r=this.geometry,i=this._indirectBuffer,a=r.attributes.position,o=r.index?r.index.array:null,s=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw Error(`MeshBVH: compute triangle bounds range is invalid.`);let c=a.array,l=a.offset||0,u=3;a.isInterleavedBufferAttribute&&(u=a.data.stride);let d=[`getX`,`getY`,`getZ`],f=n.offset;for(let r=e,p=e+t;r<p;r++){let e=(i?i[r]:r)*3,t=(r-f)*6,p=e+0,m=e+1,h=e+2;o&&(p=o[p],m=o[m],h=o[h]),s||(p=p*u+l,m=m*u+l,h=h*u+l);for(let e=0;e<3;e++){let r,i,o;s?(r=a[d[e]](p),i=a[d[e]](m),o=a[d[e]](h)):(r=c[p+e],i=c[m+e],o=c[h+e]);let l=r;i<l&&(l=i),o<l&&(l=o);let u=r;i>u&&(u=i),o>u&&(u=o);let f=(u-l)/2,g=e*2;n[t+g+0]=l+f,n[t+g+1]=f+(Math.abs(l)+f)*DM}}return n}raycastObject3D(e,t,n=[]){let{material:r}=e;if(r===void 0)return;gF.copy(e.matrixWorld).invert(),mF.copy(t.ray).applyMatrix4(gF),_F.setFromMatrixScale(e.matrixWorld),hF.copy(mF.direction).multiply(_F);let i=hF.length(),a=t.near/i,o=t.far/i;if(t.firstHitOnly===!0){let i=this.raycastFirst(mF,r,a,o);i=fF(i,e,t),i&&n.push(i)}else{let i=this.raycast(mF,r,a,o);for(let r=0,a=i.length;r<a;r++){let a=fF(i[r],e,t);a&&n.push(a)}}return n}refit(e=null){return(this.indirect?WP:vP)(this,e)}raycast(e,t=0,n=0,r=1/0){let i=this._roots,a=[],o=this.indirect?GP:CP;for(let s=0,c=i.length;s<c;s++)o(this,s,t,e,a,n,r);return a}raycastFirst(e,t=0,n=0,r=1/0){let i=this._roots,a=null,o=this.indirect?JP:EP;for(let s=0,c=i.length;s<c;s++){let i=o(this,s,t,e,n,r);i!=null&&(a==null||i.distance<a.distance)&&(a=i)}return a}intersectsGeometry(e,t){let n=!1,r=this._roots,i=this.indirect?nF:PP;for(let a=0,o=r.length;a<o&&(n=i(this,a,e,t),!n);a++);return n}shapecast(e){let t=YN.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?SP:_P});return YN.releasePrimitive(t),n}bvhcast(t,n,r){let{intersectsRanges:i,intersectsTriangles:a}=r,o=YN.getPrimitive(),s=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?e=>{let t=this.resolveTriangleIndex(e);mP(o,t*3,s,c)}:e=>{mP(o,e*3,s,c)},u=YN.getPrimitive(),d=t.geometry.index,f=t.geometry.attributes.position,p=t.indirect?e=>{let n=t.resolveTriangleIndex(e);mP(u,n*3,d,f)}:e=>{mP(u,e*3,d,f)};if(a){if(!(t instanceof e))throw Error(`MeshBVH: \"intersectsTriangles\" callback can only be used with another MeshBVH.`);let r=(e,t,r,i,s,c,d,f)=>{for(let m=r,h=r+i;m<h;m++){p(m),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let n=e,r=e+t;n<r;n++)if(l(n),o.needsUpdate=!0,a(o,u,n,m,s,c,d,f))return!0}return!1};if(i){let e=i;i=function(t,n,i,a,o,s,c,l){return e(t,n,i,a,o,s,c,l)?!0:r(t,n,i,a,o,s,c,l)}}else i=r}return super.bvhcast(t,n,{intersectsRanges:i})}intersectsBox(e,t){return pF.set(e.min,e.max,t),pF.needsUpdate=!0,this.shapecast({intersectsBounds:e=>pF.intersectsBox(e),intersectsTriangle:e=>pF.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},r={},i=0,a=1/0){return(this.indirect?dF:UP)(this,e,t,n,r,i,a)}closestPointToPoint(e,t={},n=0,r=1/0){return QN(this,e,t,n,r)}},bF=class extends Ey{constructor(e,t){super(),this.isViewHelper=!0,this.camera=e,this.animating=!1,this.center=new Z,this.location={top:null,right:0,bottom:0,left:null};let n=new Q(`#ff4466`),r=new Q(`#88ff44`),i=new Q(`#4488ff`),a=new Q(`#000000`),o={},s=this,c=[],l=new GC,u=new X,d=new Ey,f=new bC(-2,2,2,-2,0,4);f.position.set(0,0,2);let p=new rS(.04,.04,.8,5).rotateZ(-Math.PI/2).translate(.4,0,0),m=new wx(p,te(n)),h=new wx(p,te(r)),g=new wx(p,te(i));h.rotation.z=Math.PI/2,g.rotation.y=-Math.PI/2,this.add(m),this.add(g),this.add(h);let _=ie(n),v=ie(r),y=ie(i),b=ie(a),x=new ax(_),S=new ax(v),C=new ax(y),w=new ax(b),T=new ax(b),E=new ax(b);x.position.x=1,S.position.y=1,C.position.z=1,w.position.x=-1,T.position.y=-1,E.position.z=-1,w.material.opacity=.2,T.material.opacity=.2,E.material.opacity=.2,x.userData.type=`posX`,S.userData.type=`posY`,C.userData.type=`posZ`,w.userData.type=`negX`,T.userData.type=`negY`,E.userData.type=`negZ`,this.add(x),this.add(S),this.add(C),this.add(w),this.add(T),this.add(E),c.push(x),c.push(S),c.push(C),c.push(w),c.push(T),c.push(E);let D=new Z,O=2*Math.PI;this.render=function(e){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld(),D.set(0,0,1),D.applyQuaternion(this.camera.quaternion);let n=this.location,r,i;r=n.left===null?t.offsetWidth-128-n.right:n.left,i=n.top===null?e.isWebGPURenderer?t.offsetHeight-128-n.bottom:n.bottom:e.isWebGPURenderer?n.top:t.offsetHeight-128-n.top,e.clearDepth(),e.getViewport(N),e.setViewport(r,i,128,128),e.render(this,f),e.setViewport(N.x,N.y,N.z,N.w)};let k=new Z,A=new kv,j=new kv,M=new kv,N=new Jv,P=0;this.handleClick=function(e){if(this.animating===!0)return!1;let n=t.getBoundingClientRect(),r=this.location,i,a;i=r.left===null?n.left+t.offsetWidth-128-r.right:n.left+r.left,a=r.top===null?n.top+t.offsetHeight-128-r.bottom:n.top+r.top,u.x=(e.clientX-i)/128*2-1,u.y=-((e.clientY-a)/128)*2+1,l.setFromCamera(u,f);let o=l.intersectObjects(c);if(o.length>0){let e=o[0].object;return ee(e,this.center),this.animating=!0,!0}return!1},this.setLabels=function(e,t,n){o.labelX=e,o.labelY=t,o.labelZ=n,ae()},this.setLabelStyle=function(e,t,n){o.font=e,o.color=t,o.radius=n,ae()},this.update=function(e){let t=e*O;j.rotateTowards(M,t),this.camera.position.set(0,0,1).applyQuaternion(j).multiplyScalar(P).add(this.center),this.camera.quaternion.rotateTowards(A,t),j.angleTo(M)===0&&(this.animating=!1)},this.dispose=function(){p.dispose(),m.material.dispose(),h.material.dispose(),g.material.dispose(),x.material.map.dispose(),S.material.map.dispose(),C.material.map.dispose(),w.material.map.dispose(),T.material.map.dispose(),E.material.map.dispose(),x.material.dispose(),S.material.dispose(),C.material.dispose(),w.material.dispose(),T.material.dispose(),E.material.dispose()};function ee(e,t){switch(e.userData.type){case`posX`:k.set(1,0,0),A.setFromEuler(new ly(0,Math.PI*.5,0));break;case`posY`:k.set(0,1,0),A.setFromEuler(new ly(-Math.PI*.5,0,0));break;case`posZ`:k.set(0,0,1),A.setFromEuler(new ly);break;case`negX`:k.set(-1,0,0),A.setFromEuler(new ly(0,-Math.PI*.5,0));break;case`negY`:k.set(0,-1,0),A.setFromEuler(new ly(Math.PI*.5,0,0));break;case`negZ`:k.set(0,0,-1),A.setFromEuler(new ly(0,Math.PI,0));break;default:console.error(`ViewHelper: Invalid axis.`)}P=s.camera.position.distanceTo(t),k.multiplyScalar(P).add(t),d.position.copy(t),d.lookAt(s.camera.position),j.copy(d.quaternion),d.lookAt(k),M.copy(d.quaternion)}function te(e){return new fx({color:e,toneMapped:!1})}function ne(){let e=!1;try{e=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}return e}function re(e,t){let n;return ne()?n=new OffscreenCanvas(e,t):(n=document.createElement(`canvas`),n.width=e,n.height=t),n}function ie(e,t){let{font:n=`24px Arial`,color:r=`#000000`,radius:i=14}=o,a=re(64,64),s=a.getContext(`2d`);s.beginPath(),s.arc(32,32,i,0,2*Math.PI),s.closePath(),s.fillStyle=e.getStyle(),s.fill(),t&&(s.font=n,s.textAlign=`center`,s.fillStyle=r,s.fillText(t,32,41));let c=new Qx(a);return c.colorSpace=F_,new Gb({map:c,toneMapped:!1})}function ae(){x.material.map.dispose(),S.material.map.dispose(),C.material.map.dispose(),x.material.dispose(),S.material.dispose(),C.material.dispose(),x.material=ie(n,o.labelX),S.material=ie(r,o.labelY),C.material=ie(i,o.labelZ)}}},xF={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }`,fragmentShader:`\n\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n vec4 texel = texture2D( tDiffuse, vUv );\n gl_FragColor = opacity * texel;\n\n\n }`},SF=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(){}},CF=new bC(-1,1,1,-1,0,1),wF=new class extends Pb{constructor(){super(),this.setAttribute(`position`,new Sb([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Sb([0,2,0,0,2,0],2))}},TF=class{constructor(e){this._mesh=new wx(wF,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,CF)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},EF=class extends SF{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof bS?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=_S.clone(e.uniforms),this.material=new bS({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 TF(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()}},DF=class extends SF{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)}},OF=class extends SF{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},kF=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new X);this._width=n.width,this._height=n.height,t=new Xv(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:kg}),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 EF(xF),this.copyPass.material.blending=0,this.timer=new kC}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let t=0,r=this.passes.length;t<r;t++){let r=this.passes[t];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.needsSwap){if(n){let t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}DF!==void 0&&(r instanceof DF?n=!0:r instanceof OF&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new X);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},AF=class extends SF{constructor(e,t,n=null,r=null,i=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=i,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new Q}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let i,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(i=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==1&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(i),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}},jF={name:`GTAOShader`,defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new X},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new $v},cameraProjectionMatrixInverse:{value:new $v},cameraWorldMatrix:{value:new $v},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new Z(-1,-1,-1)},sceneBoxMax:{value:new Z(1,1,1)}},vertexShader:`\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }`,fragmentShader:`\n varying vec2 vUv;\n uniform highp sampler2D tNormal;\n uniform highp sampler2D tDepth;\n uniform sampler2D tNoise;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraProjectionMatrixInverse;\n uniform mat4 cameraWorldMatrix;\n uniform float radius;\n uniform float distanceExponent;\n uniform float thickness;\n uniform float distanceFallOff;\n uniform float scale;\n #if SCENE_CLIP_BOX == 1\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n #endif\n\n #include <common>\n #include <packing>\n\n #ifndef FRAGMENT_OUTPUT\n #define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n #endif\n\n vec3 getViewPosition( const in vec2 screenPosition, const in float depth ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n vec4 clipSpacePosition = vec4( vec2( screenPosition ) * 2.0 - 1.0, depth, 1.0 );\n #else\n vec4 clipSpacePosition = vec4( vec3( screenPosition, depth ) * 2.0 - 1.0, 1.0 );\n #endif\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n }\n\n float getDepth(const vec2 uv) {\n return textureLod(tDepth, uv.xy, 0.0).r;\n }\n\n float fetchDepth(const ivec2 uv) {\n return texelFetch(tDepth, uv.xy, 0).r;\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n }\n\n vec3 getViewNormal(const vec2 uv) {\n #if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n #elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n #else\n return computeNormalFromDepth(uv);\n #endif\n }\n\n vec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n float sampleSceneDepth = getDepth(sampleUv);\n return vec3(sampleUv, sampleSceneDepth);\n }\n\n void main() {\n float depth = getDepth(vUv.xy);\n\n #ifdef USE_REVERSED_DEPTH_BUFFER\n if (depth <= 0.0) {\n discard;\n return;\n }\n #else\n if (depth >= 1.0) {\n discard;\n return;\n }\n #endif\n \n vec3 viewPos = getViewPosition(vUv, depth);\n vec3 viewNormal = getViewNormal(vUv);\n\n float radiusToUse = radius;\n float distanceFalloffToUse = thickness;\n #if SCREEN_SPACE_RADIUS == 1\n float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n radiusToUse *= radiusScale;\n distanceFalloffToUse *= radiusScale;\n #endif\n\n #if SCENE_CLIP_BOX == 1\n vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n if (boxDistance > radiusToUse) {\n discard;\n return;\n }\n #endif\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n vec3 tangent = normalize(vec3(randomVec.xy, 0.));\n vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\n const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n float ao = 0.0;\n for (int i = 0; i < DIRECTIONS; ++i) {\n\n float angle = float(i) / float(DIRECTIONS) * PI;\n vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);\n sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n #if PERSPECTIVE_CAMERA == 1\n vec3 viewDir = normalize(-viewPos.xyz);\n #else\n vec3 viewDir = vec3(0., 0., 1.);\n #endif\n vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n vec3 sliceTangent = cross(sliceBitangent, viewDir);\n vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\n vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\n for (int j = 0; j < STEPS; ++j) {\n vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n\n vec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);\n vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n vec3 viewDelta = sampleSceneViewPos - viewPos;\n if (abs(viewDelta.z) < thickness) {\n float sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));\n }\n\n sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n viewDelta = sampleSceneViewPos - viewPos;\n if (abs(viewDelta.z) < thickness) {\n float sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));\n }\n }\n\n vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n float nx = dot(normalInSlice, sliceTangent);\n float ny = dot(normalInSlice, viewDir);\n float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n float occlusion = nx * nxb + ny * nyb;\n ao += occlusion;\n }\n\n ao = clamp(ao / float(DIRECTIONS), 0., 1.);\n #if SCENE_CLIP_BOX == 1\n ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n #endif\n ao = pow(ao, scale);\n\n gl_FragColor = FRAGMENT_OUTPUT;\n }`},MF={name:`GTAODepthShader`,defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }`,fragmentShader:`\n uniform sampler2D tDepth;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n\n #include <packing>\n\n float getLinearDepth( const in vec2 screenPosition ) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D( tDepth, screenPosition ).x;\n float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n #else\n return texture2D( tDepth, screenPosition ).x;\n #endif\n }\n\n void main() {\n float depth = getLinearDepth( vUv );\n gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n }`},NF={name:`GTAOBlendShader`,uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }`,fragmentShader:`\n uniform float intensity;\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n\n void main() {\n vec4 texel = texture2D( tDiffuse, vUv );\n gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);\n }`};function PF(e=5){let t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=FF(t),r=n.length,i=new Uint8Array(r*4);for(let e=0;e<r;++e){let t=n[e],a=2*Math.PI*t/r,o=new Z(Math.cos(a),Math.sin(a),0).normalize();i[e*4]=(o.x*.5+.5)*255,i[e*4+1]=(o.y*.5+.5)*255,i[e*4+2]=127,i[e*4+3]=255}let a=new Dx(i,t,t);return a.wrapS=pg,a.wrapT=pg,a.needsUpdate=!0,a}function FF(e){let t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,r=Array(n).fill(0),i=Math.floor(t/2),a=t-1;for(let e=1;e<=n;)i===-1&&a===t?(a=t-2,i=0):(a===t&&(a=0),i<0&&(i=t-1)),r[i*t+a]===0?(r[i*t+a]=e++,a++,i--):(a-=2,i++);return r}var IF={name:`PoissonDenoiseShader`,defines:{SAMPLES:16,SAMPLE_VECTORS:LF(16,2,1),NORMAL_VECTOR_TYPE:1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new X},cameraProjectionMatrixInverse:{value:new $v},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }`,fragmentShader:`\n\n varying vec2 vUv;\n\n uniform sampler2D tDiffuse;\n uniform sampler2D tNormal;\n uniform sampler2D tDepth;\n uniform sampler2D tNoise;\n uniform vec2 resolution;\n uniform mat4 cameraProjectionMatrixInverse;\n uniform float lumaPhi;\n uniform float depthPhi;\n uniform float normalPhi;\n uniform float radius;\n uniform int index;\n\n #include <common>\n #include <packing>\n\n #ifndef SAMPLE_LUMINANCE\n #define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n #endif\n\n #ifndef FRAGMENT_OUTPUT\n #define FRAGMENT_OUTPUT vec4(denoised, 1.)\n #endif\n\n float getLuminance(const in vec3 a) {\n return SAMPLE_LUMINANCE;\n }\n\n const vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\n vec3 getViewPosition( const in vec2 screenPosition, const in float depth ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n vec4 clipSpacePosition = vec4( vec2( screenPosition ) * 2.0 - 1.0, depth, 1.0 );\n #else\n vec4 clipSpacePosition = vec4( vec3( screenPosition, depth ) * 2.0 - 1.0, 1.0 );\n #endif\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n }\n\n float getDepth(const vec2 uv) {\n return textureLod(tDepth, uv.xy, 0.0).r;\n }\n\n float fetchDepth(const ivec2 uv) {\n return texelFetch(tDepth, uv.xy, 0).r;\n }\n\n vec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n }\n\n vec3 getViewNormal(const vec2 uv) {\n #if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n #elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n #else\n return computeNormalFromDepth(uv);\n #endif\n }\n\n void denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {\n vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n float sampleDepth = getDepth(sampleUv);\n vec3 sampleNormal = getViewNormal(sampleUv);\n vec3 neighborColor = sampleTexel.rgb;\n vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n\n float normalDiff = dot(viewNormal, sampleNormal);\n float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n float lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n float lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);\n float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n float w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\n denoised += w * neighborColor;\n totalWeight += w;\n }\n\n void main() {\n float depth = getDepth(vUv.xy);\n vec3 viewNormal = getViewNormal(vUv);\n if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n discard;\n return;\n }\n vec4 texel = textureLod(tDiffuse, vUv, 0.0);\n vec3 center = texel.rgb;\n vec3 viewPos = getViewPosition(vUv, depth);\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\n float totalWeight = 1.0;\n vec3 denoised = texel.rgb;\n for (int i = 0; i < SAMPLES; i++) {\n vec3 sampleDir = poissonDisk[i];\n vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n vec2 sampleUv = vUv + offset;\n denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n }\n\n if (totalWeight > 0.) {\n denoised /= totalWeight;\n }\n gl_FragColor = FRAGMENT_OUTPUT;\n }`};function LF(e,t,n){let r=RF(e,t,n),i=`vec3[SAMPLES](`;for(let t=0;t<e;t++){let n=r[t];i+=`vec3(${n.x}, ${n.y}, ${n.z})${t<e-1?`,`:`)`}`}return i}function RF(e,t,n){let r=[];for(let i=0;i<e;i++){let a=2*Math.PI*t*i/e,o=(i/(e-1))**n;r.push(new Z(Math.cos(a),Math.sin(a),o))}return r}var zF=class{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,r,i,a=.5*(Math.sqrt(3)-1),o=(e+t)*a,s=Math.floor(e+o),c=Math.floor(t+o),l=(3-Math.sqrt(3))/6,u=(s+c)*l,d=s-u,f=c-u,p=e-d,m=t-f,h,g;p>m?(h=1,g=0):(h=0,g=1);let _=p-h+l,v=m-g+l,y=p-1+2*l,b=m-1+2*l,x=s&255,S=c&255,C=this.perm[x+this.perm[S]]%12,w=this.perm[x+h+this.perm[S+g]]%12,T=this.perm[x+1+this.perm[S+1]]%12,E=.5-p*p-m*m;E<0?n=0:(E*=E,n=E*E*this._dot(this.grad3[C],p,m));let D=.5-_*_-v*v;D<0?r=0:(D*=D,r=D*D*this._dot(this.grad3[w],_,v));let O=.5-y*y-b*b;return O<0?i=0:(O*=O,i=O*O*this._dot(this.grad3[T],y,b)),70*(n+r+i)}noise3d(e,t,n){let r,i,a,o,s=(e+t+n)*(1/3),c=Math.floor(e+s),l=Math.floor(t+s),u=Math.floor(n+s),d=1/6,f=(c+l+u)*d,p=c-f,m=l-f,h=u-f,g=e-p,_=t-m,v=n-h,y,b,x,S,C,w;g>=_?_>=v?(y=1,b=0,x=0,S=1,C=1,w=0):g>=v?(y=1,b=0,x=0,S=1,C=0,w=1):(y=0,b=0,x=1,S=1,C=0,w=1):_<v?(y=0,b=0,x=1,S=0,C=1,w=1):g<v?(y=0,b=1,x=0,S=0,C=1,w=1):(y=0,b=1,x=0,S=1,C=1,w=0);let T=g-y+d,E=_-b+d,D=v-x+d,O=g-S+2*d,k=_-C+2*d,A=v-w+2*d,j=g-1+3*d,M=_-1+3*d,N=v-1+3*d,P=c&255,ee=l&255,te=u&255,ne=this.perm[P+this.perm[ee+this.perm[te]]]%12,re=this.perm[P+y+this.perm[ee+b+this.perm[te+x]]]%12,ie=this.perm[P+S+this.perm[ee+C+this.perm[te+w]]]%12,ae=this.perm[P+1+this.perm[ee+1+this.perm[te+1]]]%12,oe=.6-g*g-_*_-v*v;oe<0?r=0:(oe*=oe,r=oe*oe*this._dot3(this.grad3[ne],g,_,v));let se=.6-T*T-E*E-D*D;se<0?i=0:(se*=se,i=se*se*this._dot3(this.grad3[re],T,E,D));let ce=.6-O*O-k*k-A*A;ce<0?a=0:(ce*=ce,a=ce*ce*this._dot3(this.grad3[ie],O,k,A));let le=.6-j*j-M*M-N*N;return le<0?o=0:(le*=le,o=le*le*this._dot3(this.grad3[ae],j,M,N)),32*(r+i+a+o)}noise4d(e,t,n,r){let i=this.grad4,a=this.simplex,o=this.perm,s=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20,l,u,d,f,p,m=(e+t+n+r)*s,h=Math.floor(e+m),g=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(r+m),y=(h+g+_+v)*c,b=h-y,x=g-y,S=_-y,C=v-y,w=e-b,T=t-x,E=n-S,D=r-C,O=w>T?32:0,k=w>E?16:0,A=T>E?8:0,j=w>D?4:0,M=T>D?2:0,N=+(E>D),P=O+k+A+j+M+N,ee=+(a[P][0]>=3),te=+(a[P][1]>=3),ne=+(a[P][2]>=3),re=+(a[P][3]>=3),ie=+(a[P][0]>=2),ae=+(a[P][1]>=2),oe=+(a[P][2]>=2),se=+(a[P][3]>=2),ce=+(a[P][0]>=1),le=+(a[P][1]>=1),ue=+(a[P][2]>=1),de=+(a[P][3]>=1),fe=w-ee+c,pe=T-te+c,me=E-ne+c,he=D-re+c,ge=w-ie+2*c,_e=T-ae+2*c,ve=E-oe+2*c,ye=D-se+2*c,be=w-ce+3*c,xe=T-le+3*c,Se=E-ue+3*c,Ce=D-de+3*c,F=w-1+4*c,we=T-1+4*c,Te=E-1+4*c,Ee=D-1+4*c,I=h&255,De=g&255,L=_&255,R=v&255,Oe=o[I+o[De+o[L+o[R]]]]%32,ke=o[I+ee+o[De+te+o[L+ne+o[R+re]]]]%32,Ae=o[I+ie+o[De+ae+o[L+oe+o[R+se]]]]%32,je=o[I+ce+o[De+le+o[L+ue+o[R+de]]]]%32,Me=o[I+1+o[De+1+o[L+1+o[R+1]]]]%32,Ne=.6-w*w-T*T-E*E-D*D;Ne<0?l=0:(Ne*=Ne,l=Ne*Ne*this._dot4(i[Oe],w,T,E,D));let Pe=.6-fe*fe-pe*pe-me*me-he*he;Pe<0?u=0:(Pe*=Pe,u=Pe*Pe*this._dot4(i[ke],fe,pe,me,he));let Fe=.6-ge*ge-_e*_e-ve*ve-ye*ye;Fe<0?d=0:(Fe*=Fe,d=Fe*Fe*this._dot4(i[Ae],ge,_e,ve,ye));let Ie=.6-be*be-xe*xe-Se*Se-Ce*Ce;Ie<0?f=0:(Ie*=Ie,f=Ie*Ie*this._dot4(i[je],be,xe,Se,Ce));let Le=.6-F*F-we*we-Te*Te-Ee*Ee;return Le<0?p=0:(Le*=Le,p=Le*Le*this._dot4(i[Me],F,we,Te,Ee)),27*(l+u+d+f+p)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r}_dot4(e,t,n,r,i){return e[0]*t+e[1]*n+e[2]*r+e[3]*i}},BF=class e extends SF{constructor(e,t,n=512,r=512,i,a,o){super(),this.width=n,this.height=r,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=PF(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new Xv(this.width,this.height,{type:kg,depthBuffer:!1}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new bS({defines:Object.assign({},jF.defines),uniforms:_S.clone(jF.uniforms),vertexShader:jF.vertexShader,fragmentShader:jF.fragmentShader,blending:0,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=+!!this.camera.isPerspectiveCamera,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new wS,this.normalMaterial.blending=0,this.pdMaterial=new bS({defines:Object.assign({},IF.defines),uniforms:_S.clone(IF.uniforms),vertexShader:IF.vertexShader,fragmentShader:IF.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new bS({defines:Object.assign({},MF.defines),uniforms:_S.clone(MF.uniforms),vertexShader:MF.vertexShader,fragmentShader:MF.fragmentShader,blending:0}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new bS({uniforms:_S.clone(xF.uniforms),vertexShader:xF.vertexShader,fragmentShader:xF.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this.blendMaterial=new bS({uniforms:_S.clone(NF.uniforms),vertexShader:NF.vertexShader,fragmentShader:NF.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:5,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this._fsQuad=new TF(null),this._originalClearColor=new Q,this.setGBuffer(i?i.depthTexture:void 0,i?i.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget&&this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget&&this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){if(e!==void 0)this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1;else{if(this.normalRenderTarget===void 0){let e=new $x;e.format=zg,e.type=Mg,this.normalRenderTarget=new Xv(this.width,this.height,{minFilter:gg,magFilter:gg,type:kg,depthTexture:e})}this.depthTexture=this.normalRenderTarget.depthTexture,this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0}let n=+!!this.normalTexture;this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.needsUpdate=!0,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.needsUpdate=!0,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&+!!e.screenSpaceRadius!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=+!!e.screenSpaceRadius,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=LF(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,n,r){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case e.OUTPUT.Off:break;case e.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalTexture||null,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(t,this.blendMaterial,this.renderToScreen?null:n);break;default:console.warn(`THREE.GTAOPass: Unknown output type.`)}}_renderPass(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r=t.clearColor||r,i=t.clearAlpha||i,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(e){(e.isPoints||e.isLine||e.isLine2)&&e.visible&&(e.visible=!1,t.push(e))})}_restoreVisibility(){let e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){let t=new zF,n=e*e*4,r=new Uint8Array(n);for(let n=0;n<e;n++)for(let i=0;i<e;i++){let a=n,o=i;r[(n*e+i)*4]=(t.noise(a,o)*.5+.5)*255,r[(n*e+i)*4+1]=(t.noise(a+e,o)*.5+.5)*255,r[(n*e+i)*4+2]=(t.noise(a,o+e)*.5+.5)*255,r[(n*e+i)*4+3]=(t.noise(a+e,o+e)*.5+.5)*255}let i=new Dx(r,e,e,Lg,Sg);return i.wrapS=pg,i.wrapT=pg,i.needsUpdate=!0,i}};BF.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};var VF={name:`SMAAEdgesShader`,defines:{SMAA_THRESHOLD:`0.1`},uniforms:{tDiffuse:{value:null},resolution:{value:new X(1/1024,1/512)}},vertexShader:`\n\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 3 ];\n\n void SMAAEdgeDetectionVS( vec2 texcoord ) {\n vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n vOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component\n }\n\n void main() {\n\n vUv = uv;\n\n SMAAEdgeDetectionVS( vUv );\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }`,fragmentShader:`\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 3 ];\n\n vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {\n vec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );\n\n // Calculate color deltas:\n vec4 delta;\n vec3 C = texture2D( colorTex, texcoord ).rgb;\n\n vec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;\n vec3 t = abs( C - Cleft );\n delta.x = max( max( t.r, t.g ), t.b );\n\n vec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;\n t = abs( C - Ctop );\n delta.y = max( max( t.r, t.g ), t.b );\n\n // We do the usual threshold:\n vec2 edges = step( threshold, delta.xy );\n\n // Then discard if there is no edge:\n if ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )\n discard;\n\n // Calculate right and bottom deltas:\n vec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;\n t = abs( C - Cright );\n delta.z = max( max( t.r, t.g ), t.b );\n\n vec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;\n t = abs( C - Cbottom );\n delta.w = max( max( t.r, t.g ), t.b );\n\n // Calculate the maximum delta in the direct neighborhood:\n float maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );\n\n // Calculate left-left and top-top deltas:\n vec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;\n t = abs( C - Cleftleft );\n delta.z = max( max( t.r, t.g ), t.b );\n\n vec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;\n t = abs( C - Ctoptop );\n delta.w = max( max( t.r, t.g ), t.b );\n\n // Calculate the final maximum delta:\n maxDelta = max( max( maxDelta, delta.z ), delta.w );\n\n // Local contrast adaptation in action:\n edges.xy *= step( 0.5 * maxDelta, delta.xy );\n\n return vec4( edges, 0.0, 0.0 );\n }\n\n void main() {\n\n gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );\n\n }`},HF={name:`SMAAWeightsShader`,defines:{SMAA_MAX_SEARCH_STEPS:`8`,SMAA_AREATEX_MAX_DISTANCE:`16`,SMAA_AREATEX_PIXEL_SIZE:`( 1.0 / vec2( 160.0, 560.0 ) )`,SMAA_AREATEX_SUBTEX_SIZE:`( 1.0 / 7.0 )`},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new X(1/1024,1/512)}},vertexShader:`\n\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 3 ];\n varying vec2 vPixcoord;\n\n void SMAABlendingWeightCalculationVS( vec2 texcoord ) {\n vPixcoord = texcoord / resolution;\n\n // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components\n vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components\n\n // And these for the searches, they indicate the ends of the loops:\n vOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );\n\n }\n\n void main() {\n\n vUv = uv;\n\n SMAABlendingWeightCalculationVS( vUv );\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }`,fragmentShader:`\n\n #define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )\n\n uniform sampler2D tDiffuse;\n uniform sampler2D tArea;\n uniform sampler2D tSearch;\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[3];\n varying vec2 vPixcoord;\n\n #if __VERSION__ == 100\n vec2 round( vec2 x ) {\n return sign( x ) * floor( abs( x ) + 0.5 );\n }\n #endif\n\n float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {\n // Not required if searchTex accesses are set to point:\n // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n e.r = bias + e.r * scale;\n return 255.0 * texture2D( searchTex, e, 0.0 ).r;\n }\n\n float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n /**\n * @PSEUDO_GATHER4\n * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to\n * sample between edge, thus fetching four edges in a row.\n * Sampling with different offsets in each direction allows to disambiguate\n * which edges are active from the four fetched ones.\n */\n vec2 e = vec2( 0.0, 1.0 );\n\n for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n e = texture2D( edgesTex, texcoord, 0.0 ).rg;\n texcoord -= vec2( 2.0, 0.0 ) * resolution;\n if ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n }\n\n // We correct the previous (-0.25, -0.125) offset we applied:\n texcoord.x += 0.25 * resolution.x;\n\n // The searches are bias by 1, so adjust the coords accordingly:\n texcoord.x += resolution.x;\n\n // Disambiguate the length added by the last step:\n texcoord.x += 2.0 * resolution.x; // Undo last step\n texcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);\n\n return texcoord.x;\n }\n\n float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n vec2 e = vec2( 0.0, 1.0 );\n\n for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n e = texture2D( edgesTex, texcoord, 0.0 ).rg;\n texcoord += vec2( 2.0, 0.0 ) * resolution;\n if ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n }\n\n texcoord.x -= 0.25 * resolution.x;\n texcoord.x -= resolution.x;\n texcoord.x -= 2.0 * resolution.x;\n texcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );\n\n return texcoord.x;\n }\n\n float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n vec2 e = vec2( 1.0, 0.0 );\n\n for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n e = texture2D( edgesTex, texcoord, 0.0 ).rg;\n texcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n if ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n }\n\n texcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign\n texcoord.y -= resolution.y; // WebGL port note: Changed sign\n texcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign\n texcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign\n\n return texcoord.y;\n }\n\n float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n vec2 e = vec2( 1.0, 0.0 );\n\n for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n e = texture2D( edgesTex, texcoord, 0.0 ).rg;\n texcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n if ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n }\n\n texcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign\n texcoord.y += resolution.y; // WebGL port note: Changed sign\n texcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign\n texcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign\n\n return texcoord.y;\n }\n\n vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {\n // Rounding prevents precision errors of bilinear filtering:\n vec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;\n\n // We do a scale and bias for mapping to texel space:\n texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );\n\n // Move to proper place, according to the subpixel offset:\n texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;\n\n return texture2D( areaTex, texcoord, 0.0 ).rg;\n }\n\n vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {\n vec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n vec2 e = texture2D( edgesTex, texcoord ).rg;\n\n if ( e.g > 0.0 ) { // Edge at north\n vec2 d;\n\n // Find the distance to the left:\n vec2 coords;\n coords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );\n coords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)\n d.x = coords.x;\n\n // Now fetch the left crossing edges, two at a time using bilinear\n // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n // discern what value each edge has:\n float e1 = texture2D( edgesTex, coords, 0.0 ).r;\n\n // Find the distance to the right:\n coords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );\n d.y = coords.x;\n\n // We want the distances to be in pixel units (doing this here allow to\n // better interleave arithmetic and memory accesses):\n d = d / resolution.x - pixcoord.x;\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n vec2 sqrt_d = sqrt( abs( d ) );\n\n // Fetch the right crossing edges:\n coords.y -= 1.0 * resolution.y; // WebGL port note: Added\n float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;\n\n // Ok, we know how this pattern looks like, now it is time for getting\n // the actual area:\n weights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );\n }\n\n if ( e.r > 0.0 ) { // Edge at west\n vec2 d;\n\n // Find the distance to the top:\n vec2 coords;\n\n coords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );\n coords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;\n d.x = coords.y;\n\n // Fetch the top crossing edges:\n float e1 = texture2D( edgesTex, coords, 0.0 ).g;\n\n // Find the distance to the bottom:\n coords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );\n d.y = coords.y;\n\n // We want the distances to be in pixel units:\n d = d / resolution.y - pixcoord.y;\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n vec2 sqrt_d = sqrt( abs( d ) );\n\n // Fetch the bottom crossing edges:\n coords.y -= 1.0 * resolution.y; // WebGL port note: Added\n float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;\n\n // Get the area for this direction:\n weights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );\n }\n\n return weights;\n }\n\n void main() {\n\n gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );\n\n }`},UF={name:`SMAABlendShader`,uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new X(1/1024,1/512)}},vertexShader:`\n\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 2 ];\n\n void SMAANeighborhoodBlendingVS( vec2 texcoord ) {\n vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n }\n\n void main() {\n\n vUv = uv;\n\n SMAANeighborhoodBlendingVS( vUv );\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }`,fragmentShader:`\n\n uniform sampler2D tDiffuse;\n uniform sampler2D tColor;\n uniform vec2 resolution;\n\n varying vec2 vUv;\n varying vec4 vOffset[ 2 ];\n\n vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {\n // Fetch the blending weights for current pixel:\n vec4 a;\n a.xz = texture2D( blendTex, texcoord ).xz;\n a.y = texture2D( blendTex, offset[ 1 ].zw ).g;\n a.w = texture2D( blendTex, offset[ 1 ].xy ).a;\n\n // Is there any blending weight with a value greater than 0.0?\n if ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {\n return texture2D( colorTex, texcoord, 0.0 );\n } else {\n // Up to 4 lines can be crossing a pixel (one through each edge). We\n // favor blending by choosing the line with the maximum weight for each\n // direction:\n vec2 offset;\n offset.x = a.a > a.b ? a.a : -a.b; // left vs. right\n offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs\n\n // Then we go in the direction that has the maximum weight:\n if ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical\n offset.y = 0.0;\n } else {\n offset.x = 0.0;\n }\n\n // Fetch the opposite color and lerp by hand:\n vec4 C = texture2D( colorTex, texcoord, 0.0 );\n texcoord += sign( offset ) * resolution;\n vec4 Cop = texture2D( colorTex, texcoord, 0.0 );\n float s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );\n\n // WebGL port note: Added gamma correction\n C.xyz = pow(C.xyz, vec3(2.2));\n Cop.xyz = pow(Cop.xyz, vec3(2.2));\n vec4 mixed = mix(C, Cop, s);\n mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));\n\n return mixed;\n }\n }\n\n void main() {\n\n gl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );\n\n }`},WF=class extends SF{constructor(){super(),this._edgesRT=new Xv(1,1,{depthBuffer:!1,type:kg}),this._edgesRT.texture.name=`SMAAPass.edges`,this._weightsRT=new Xv(1,1,{depthBuffer:!1,type:kg}),this._weightsRT.texture.name=`SMAAPass.weights`;let e=this,t=new Image;t.src=this._getAreaTexture(),t.onload=function(){e._areaTexture.needsUpdate=!0},this._areaTexture=new qv,this._areaTexture.name=`SMAAPass.area`,this._areaTexture.image=t,this._areaTexture.minFilter=yg,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let n=new Image;n.src=this._getSearchTexture(),n.onload=function(){e._searchTexture.needsUpdate=!0},this._searchTexture=new qv,this._searchTexture.name=`SMAAPass.search`,this._searchTexture.image=n,this._searchTexture.magFilter=gg,this._searchTexture.minFilter=gg,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._uniformsEdges=_S.clone(VF.uniforms),this._materialEdges=new bS({defines:Object.assign({},VF.defines),uniforms:this._uniformsEdges,vertexShader:VF.vertexShader,fragmentShader:VF.fragmentShader}),this._uniformsWeights=_S.clone(HF.uniforms),this._uniformsWeights.tDiffuse.value=this._edgesRT.texture,this._uniformsWeights.tArea.value=this._areaTexture,this._uniformsWeights.tSearch.value=this._searchTexture,this._materialWeights=new bS({defines:Object.assign({},HF.defines),uniforms:this._uniformsWeights,vertexShader:HF.vertexShader,fragmentShader:HF.fragmentShader}),this._uniformsBlend=_S.clone(UF.uniforms),this._uniformsBlend.tDiffuse.value=this._weightsRT.texture,this._materialBlend=new bS({uniforms:this._uniformsBlend,vertexShader:UF.vertexShader,fragmentShader:UF.fragmentShader}),this._fsQuad=new TF(null)}render(e,t,n){this._uniformsEdges.tDiffuse.value=n.texture,this._fsQuad.material=this._materialEdges,e.setRenderTarget(this._edgesRT),this.clear&&e.clear(),this._fsQuad.render(e),this._fsQuad.material=this._materialWeights,e.setRenderTarget(this._weightsRT),this.clear&&e.clear(),this._fsQuad.render(e),this._uniformsBlend.tColor.value=n.texture,this._fsQuad.material=this._materialBlend,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this._fsQuad.render(e))}setSize(e,t){this._edgesRT.setSize(e,t),this._weightsRT.setSize(e,t),this._materialEdges.uniforms.resolution.value.set(1/e,1/t),this._materialWeights.uniforms.resolution.value.set(1/e,1/t),this._materialBlend.uniforms.resolution.value.set(1/e,1/t)}dispose(){this._edgesRT.dispose(),this._weightsRT.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose(),this._fsQuad.dispose()}_getAreaTexture(){return`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQESb4gImexGMDouhGLx1Cst0Saa4b4AqO4Hk4gxo+3DHAV/nx27p3JziPM2pVgoiia5MdEzCGULprIN7gEEeQ5IQxEBBBQnxhsDb5auGmAAYcHMA9eAAz8PBol8/xij9+C4Djlim4gJjWcwZBhCBgMIIYxGAVIkH3ZtcBuLdtRFMWsPGoY9rN+HoBji9VBYdwD2ZQg4cnO7OSq/z4rU5KKdwVbFAjNojCQzTlCLPFSxtamwh2jMUcEgg2Wm/6XgErIBhBckQtGN3CzbVacERgCnfgLswhnvqf7QyAq/z4rRZm1YglYE3affGITaZsdIe2FmMIpnOCap25I6jt2kCwCW0D1uAD9sZctNGXcQIHCkINDQgc78aCr+zjtw3BU/ijdpw3zhCwcaONwBvdeS2YZKkJNJsMPf2JKEvC28RXxxI0ASJyzQCjCEQrO4Q7sFArEzjZhaFc4cdv+/JFdKULM4px0DfUBI2hIsy06BqLhGTQEVdbfAIZXYMPesq6VoCHICzUyjwInO4Y411//LYLs6TDa9wvg2CC2rElgAnpTBziThxaL22MYhzfkghz6GAs2VHbbdM91VZu1MEEpupMMwKyVTb5ij9+u4VJG/5EgEMMmFF01cFai3isRbKbzb+YaU/MQbAm2XSMoUPAmvZzbuKYRIFApbtlrfFuUGd6vq2hXNnH78ZLh/iFhsQG3T4D1ib7k5CC6vY0DCbtrohgLEIClXiGtl10zc0CnEGIhhatLBva7NP58Tvw0qE8yWhARLQ8h4+AhQSP+I4F5xoU+VilGRJs6wnS7ruti/4KvAY/CfdgqjsMy4pf8fodQO8/gnuX3f/3xi3om1/h7THr+co3x93PP9+FBUfbNUjcjEmhcrkT+8K7ml7V10Jo05mpIEFy1NmCJWx9SIKKt+EjAL4Ez8EBVOB6havuT/rByPvHXK+9zUcfcbb254+9fydJknYnRr1oGfdaiAgpxu1Rx/Rek8KISftx3L+DfsLWAANn8Hvw0/AFeAGO9DFV3c6D+CcWbL8Dj9e7f+T1k8AZv/d7+PXWM/Z+VvdCrIvuAKO09RpEEQJM0Ci6+B4xhTWr4cZNOvhktabw0ta0rSJmqz3Yw5/AKXwenod7cAhTmBSPKf6JBdvH8IP17h95pXqw50/+BFnj88fev4NchyaK47OPhhtI8RFSvAfDSNh0Ck0p2gLxGkib5NJj/JWCr90EWQJvwBzO4AHcgztwAFN1evHPUVGwfXON+0debT1YeGON9Yy9/63X+OguiwmhIhQhD7l4sMqlG3D86Suc3qWZ4rWjI1X7u0Ytw6x3rIMeIOPDprfe2XzNgyj6PahhBjO4C3e6puDgXrdg+/5l948vF3bqwZetZ+z9Rx9zdIY5pInPK4Nk0t+l52xdK2B45Qd87nM8fsD5EfUhIcJcERw4RdqqH7Yde5V7m1vhNmtedkz6EDzUMF/2jJYWbC+4fzzA/Y+/8PPH3j9dcBAPIRP8JLXd5BpAu03aziOL3VVHZzz3CXWDPWd+SH2AnxIqQoTZpo9Ckc6HIrFbAbzNmlcg8Ag8NFDDAhbJvTBZXbC94P7t68EXfv6o+21gUtPETU7bbkLxvNKRFG2+KXzvtObonPP4rBvsgmaKj404DlshFole1Glfh02fE7bYR7dZ82oTewIBGn1Md6CG6YUF26X376oevOLzx95vhUmgblI6LBZwTCDY7vMq0op5WVXgsObOXJ+1x3qaBl9j1FeLxbhU9w1F+Wiba6s1X/TBz1LnUfuYDi4r2C69f1f14BWfP+p+W2GFKuC9phcELMYRRLur9DEZTUdEH+iEqWdaM7X4WOoPGI+ZYD2+wcQ+y+ioHUZ9dTDbArzxmi/bJI9BND0Ynd6lBdve/butBw8+f/T9D3ABa3AG8W3VPX4hBin+bj8dMMmSpp5pg7fJ6xrBFE2WQQEWnV8Qg3FbAWzYfM1rREEnmvkN2o1+acG2d/9u68GDzx91v3mAjb1zkpqT21OipPKO0b9TO5W0nTdOmAQm0TObts3aBKgwARtoPDiCT0gHgwnbArzxmtcLc08HgF1asN0C4Ms/fvD5I+7PhfqyXE/b7RbbrGyRQRT9ARZcwAUmgdoz0ehJ9Fn7QAhUjhDAQSw0bV3T3WbNa59jzmiP6GsWbGXDX2ytjy8+f9T97fiBPq9YeLdBmyuizZHaqXITnXiMUEEVcJ7K4j3BFPurtB4bixW8wTpweL8DC95szWMOqucFYGsWbGU7p3TxxxefP+r+oTVktxY0v5hbq3KiOKYnY8ddJVSBxuMMVffNbxwIOERShst73HZ78DZrHpmJmH3K6sGz0fe3UUj0eyRrSCGTTc+rjVNoGzNSv05srAxUBh8IhqChiQgVNIIBH3AVPnrsnXQZbLTm8ammv8eVXn/vWpaTem5IXRlt+U/LA21zhSb9cye6jcOfCnOwhIAYXAMVTUNV0QhVha9xjgA27ODJbLbmitt3tRN80lqG6N/khgot4ZVlOyO4WNg3OIMzhIZQpUEHieg2im6F91hB3I2tubql6BYNN9Hj5S7G0G2tahslBWKDnOiIvuAEDzakDQKDNFQT6gbn8E2y4BBubM230YIpBnDbMa+y3dx0n1S0BtuG62lCCXwcY0F72T1VRR3t2ONcsmDjbmzNt9RFs2LO2hQNyb022JisaI8rAWuw4HI3FuAIhZdOGIcdjLJvvObqlpqvWTJnnQbyi/1M9O8UxWhBs//H42I0q1Yb/XPGONzcmm+ri172mHKvZBpHkJaNJz6v9jxqiklDj3U4CA2ugpAaYMWqNXsdXbmJNd9egCnJEsphXNM+MnK3m0FCJ5S1kmJpa3DgPVbnQnPGWIDspW9ozbcO4K/9LkfaQO2KHuqlfFXSbdNzcEcwoqNEFE9zcIXu9/6n/ym/BC/C3aJLzEKPuYVlbFnfhZ8kcWxV3dbv4bKl28566wD+8C53aw49lTABp9PWbsB+knfc/Li3eVizf5vv/xmvnPKg5ihwKEwlrcHqucuVcVOxEv8aH37E3ZqpZypUulrHEtIWKUr+txHg+ojZDGlwnqmkGlzcVi1dLiNSJiHjfbRNOPwKpx9TVdTn3K05DBx4psIk4Ei8aCkJahRgffk4YnEXe07T4H2RR1u27E6wfQsBDofUgjFUFnwC2AiVtA+05J2zpiDK2Oa0c5fmAecN1iJzmpqFZxqYBCYhFTCsUNEmUnIcZ6aEA5rQVhEywG6w7HSW02XfOoBlQmjwulOFQAg66SvJblrTEX1YtJ3uG15T/BH1OfOQeuR8g/c0gdpT5fx2SKbs9EfHTKdM8A1GaJRHLVIwhcGyydZsbifAFVKl5EMKNU2Hryo+06BeTgqnxzYjThVySDikbtJPieco75lYfKAJOMEZBTjoITuWHXXZVhcUDIS2hpiXHV9Ku4u44bN5OYLDOkJo8w+xJSMbhBRHEdEs9JZUCkQrPMAvaHyLkxgkEHxiNkx/x2YB0mGsQ8EUWj/stW5YLhtS5SMu+/YBbNPDCkGTUybN8krRLBGPlZkVOA0j+a1+rkyQKWGaPHPLZOkJhioQYnVZ2hS3zVxMtgC46KuRwbJNd9nV2PHgb36F194ecf/Yeu2vAFe5nm/bRBFrnY4BauE8ERmZRFUn0k8hbftiVYSKMEme2dJCJSCGYAlNqh87bXOPdUkGy24P6d1ll21MBqqx48Fvv8ZHH8HZFY7j/uAq1xMJUFqCSUlJPmNbIiNsmwuMs/q9CMtsZsFO6SprzCS1Z7QL8xCQClEelpjTduDMsmWD8S1PT152BtvmIGvUeDA/yRn83u/x0/4qxoPHjx+PXY9pqX9bgMvh/Nz9kpP4pOe1/fYf3axUiMdHLlPpZCNjgtNFAhcHEDxTumNONhHrBduW+vOyY++70WWnPXj98eA4kOt/mj/5E05l9+O4o8ePx67HFqyC+qSSnyselqjZGaVK2TadbFLPWAQ4NBhHqDCCV7OTpo34AlSSylPtIdd2AJZlyzYQrDJ5lcWGNceD80CunPLGGzsfD+7wRb95NevJI5docQ3tgCyr5bGnyaPRlmwNsFELViOOx9loebGNq2moDOKpHLVP5al2cymWHbkfzGXL7kfRl44H9wZy33tvt+PB/Xnf93e+nh5ZlU18wCiRUa9m7kib9LYuOk+hudQNbxwm0AQqbfloimaB2lM5fChex+ylMwuTbfmXQtmWlenZljbdXTLuOxjI/fDDHY4Hjx8/Hrse0zXfPFxbUN1kKqSCCSk50m0Ajtx3ub9XHBKHXESb8iO6E+qGytF4nO0OG3SXzbJlhxBnKtKyl0NwybjvYCD30aMdjgePHz8eu56SVTBbgxJMliQ3Oauwg0QHxXE2Ez/EIReLdQj42Gzb4CLS0YJD9xUx7bsi0vJi5mUbW1QzL0h0PFk17rtiIPfJk52MB48fPx67npJJwyrBa2RCCQRTbGZSPCxTPOiND4G2pYyOQ4h4jINIJh5wFU1NFZt+IsZ59LSnDqBjZ2awbOku+yInunLcd8VA7rNnOxkPHj9+PGY9B0MWJJNozOJmlglvDMXDEozdhQWbgs/U6oBanGzLrdSNNnZFjOkmbi5bNt1lX7JLLhn3vXAg9/h4y/Hg8ePHI9dzQMEkWCgdRfYykYKnkP7D4rIujsujaKPBsB54vE2TS00ccvFY/Tth7JXeq1hz+qgVy04sAJawTsvOknHfCwdyT062HA8eP348Zj0vdoXF4pilKa2BROed+9fyw9rWRXeTFXESMOanvDZfJuJaSXouQdMdDJZtekZcLLvEeK04d8m474UDuaenW44Hjx8/Xns9YYqZpszGWB3AN/4VHw+k7WSFtJ3Qicuqb/NlVmgXWsxh570xg2UwxUw3WfO6B5nOuO8aA7lnZxuPB48fPx6znm1i4bsfcbaptF3zNT78eFPtwi1OaCNOqp1x3zUGcs/PN++AGD1+fMXrSVm2baTtPhPahbPhA71wIHd2bXzRa69nG+3CraTtPivahV/55tXWg8fyRY/9AdsY8VbSdp8V7cKrrgdfM//z6ILQFtJ2nxHtwmuoB4/kf74+gLeRtvvMaBdeSz34+vifx0YG20jbfTa0C6+tHrwe//NmOG0L8EbSdp8R7cLrrQe/996O+ai3ujQOskpTNULa7jOjXXj99eCd8lHvoFiwsbTdZ0a78PrrwTvlo966pLuRtB2fFe3Cm6oHP9kNH/W2FryxtN1nTLvwRurBO+Kj3pWXHidtx2dFu/Bm68Fb81HvykuPlrb7LGkX3mw9eGs+6h1Y8MbSdjegXcguQLjmevDpTQLMxtJ2N6NdyBZu9AbrwVvwUW+LbteULUpCdqm0HTelXbhNPe8G68Gb8lFvVfYfSNuxvrTdTWoXbozAzdaDZzfkorOj1oxVxlIMlpSIlpLrt8D4hrQL17z+c3h6hU/wv4Q/utps4+bm+6P/hIcf0JwQ5oQGPBL0eKPTYEXTW+eL/2DKn73J9BTXYANG57hz1cEMviVf/4tf5b/6C5pTQkMIWoAq7hTpOJjtAM4pxKu5vg5vXeUrtI09/Mo/5H+4z+Mp5xULh7cEm2QbRP2tFIKR7WM3fPf/jZ3SWCqLM2l4NxID5zB72HQXv3jj/8mLR5xXNA5v8EbFQEz7PpRfl1+MB/hlAN65qgDn3wTgH13hK7T59bmP+NIx1SHHU84nLOITt3iVz8mNO+lPrjGAnBFqmioNn1mTyk1ta47R6d4MrX7tjrnjYUpdUbv2rVr6YpVfsGG58AG8Ah9eyUN8CX4WfgV+G8LVWPDGb+Zd4cU584CtqSbMKxauxTg+dyn/LkVgA+IR8KHtejeFKRtTmLLpxN6mYVLjYxwXf5x2VofiZcp/lwKk4wGOpYDnoIZPdg/AAbwMfx0+ge9dgZvYjuqKe4HnGnykYo5TvJbG0Vj12JagRhwKa44H95ShkZa5RyLGGdfYvG7aw1TsF6iapPAS29mNS3NmsTQZCmgTzFwgL3upCTgtBTRwvGMAKrgLn4evwin8+afJRcff+8izUGUM63GOOuAs3tJkw7J4kyoNreqrpO6cYLQeFUd7TTpr5YOTLc9RUUogUOVJQ1GYJaFLAW0oTmKyYS46ZooP4S4EON3xQ5zC8/CX4CnM4c1PE8ApexpoYuzqlP3d4S3OJP8ZDK7cKWNaTlqmgDiiHwl1YsE41w1zT4iRTm3DBqxvOUsbMKKDa/EHxagtnta072ejc3DOIh5ojvh8l3tk1JF/AV6FU6jh3U8HwEazLgdCLYSQ+MYiAI2ltomkzttUb0gGHdSUUgsIYjTzLG3mObX4FBRaYtpDVNZrih9TgTeYOBxsEnN1gOCTM8Bsw/ieMc75w9kuAT6A+/AiHGvN/+Gn4KRkiuzpNNDYhDGFndWRpE6SVfm8U5bxnSgVV2jrg6JCKmneqey8VMFgq2+AM/i4L4RUbfSi27lNXZ7R7W9RTcq/q9fk4Xw3AMQd4I5ifAZz8FcVtm9SAom/dyN4lczJQW/kC42ZrHgcCoIf1oVMKkVItmMBi9cOeNHGLqOZk+QqQmrbc5YmYgxELUUN35z2iohstgfLIFmcMV7s4CFmI74L9+EFmGsi+tGnAOD4Yk9gIpo01Y4cA43BWGygMdr4YZekG3OBIUXXNukvJS8tqa06e+lSDCtnqqMFu6hWHXCF+WaYt64m9QBmNxi7Ioy7D+fa1yHw+FMAcPt7SysFLtoG4PXAk7JOA3aAxBRqUiAdU9Yp5lK3HLSRFtOim0sa8euEt08xvKjYjzeJ2GU7YawexrnKI9tmobInjFXCewpwriY9+RR4aaezFhMhGCppKwom0ChrgFlKzyPKkGlTW1YQrE9HJqu8hKGgMc6hVi5QRq0PZxNfrYNgE64utmRv6KKHRpxf6VDUaOvNP5jCEx5q185My/7RKz69UQu2im5k4/eownpxZxNLwiZ1AZTO2ZjWjkU9uaB2HFn6Q3u0JcsSx/qV9hTEApRzeBLDJQXxYmTnq7bdLa3+uqFrxLJ5w1TehnNHx5ECvCh2g2c3hHH5YsfdaSKddztfjQ6imKFGSyFwlLzxEGPp6r5IevVjk1AMx3wMqi1NxDVjLBiPs9tbsCkIY5we5/ML22zrCScFxnNtzsr9Wcc3CnD+pYO+4VXXiDE0oc/vQQ/fDK3oPESJMYXNmJa/DuloJZkcTpcYE8lIH8Dz8DJMiynNC86Mb2lNaaqP/+L7f2fcE/yP7/Lde8xfgSOdMxvOixZf/9p3+M4hT1+F+zApxg9XfUvYjc8qX2lfOOpK2gNRtB4flpFu9FTKCp2XJRgXnX6olp1zyYjTKJSkGmLE2NjUr1bxFM4AeAAHBUFIeSLqXR+NvH/M9fOnfHzOD2vCSyQJKzfgsCh+yi/Mmc35F2fUrw7miW33W9hBD1vpuUojFphIyvg7aTeoymDkIkeW3XLHmguMzbIAJejN6B5MDrhipE2y6SoFRO/AK/AcHHZHNIfiWrEe/C6cr3f/yOvrQKB+zMM55/GQdLDsR+ifr5Fiuu+/y+M78LzOE5dsNuXC3PYvYWd8NXvphLSkJIasrlD2/HOqQ+RjcRdjKTGWYhhVUm4yxlyiGPuMsZR7sMCHUBeTuNWA7if+ifXgc/hovftHXs/DV+Fvwe+f8shzMiMcweFgBly3//vwJfg5AN4450fn1Hd1Rm1aBLu22Dy3y3H2+OqMemkbGZ4jozcDjJf6596xOLpC0eMTHbKnxLxH27uZ/bMTGs2jOaMOY4m87CfQwF0dw53oa1k80JRuz/XgS+8fX3N9Af4qPIMfzKgCp4H5TDGe9GGeFPzSsZz80SlPTxXjgwJmC45njzgt2vbQ4b4OAdUK4/vWhO8d8v6EE8fMUsfakXbPpFJeLs2ubM/qdm/la3WP91uWhxXHjoWhyRUq2iJ/+5mA73zwIIo+LoZ/SgvIRjAd1IMvvn98PfgOvAJfhhm8scAKVWDuaRaK8aQ9f7vuPDH6Bj47ZXau7rqYJ66mTDwEDU6lLbCjCK0qTXyl5mnDoeNRxanj3FJbaksTk0faXxHxLrssgPkWB9LnA/MFleXcJozzjwsUvUG0X/QCve51qkMDXp9mtcyOy3rwBfdvVJK7D6/ACSzg3RoruIq5UDeESfEmVclDxnniU82vxMLtceD0hGZWzBNPMM/jSPne2OVatiTKUpY5vY7gc0LdUAWeWM5tH+O2I66AOWw9xT2BuyRVLGdoDHUsVRXOo/c+ZdRXvFfnxWyIV4upFLCl9eAL7h8Zv0QH8Ry8pA2cHzQpGesctVA37ZtklBTgHjyvdSeKY/RZw/kJMk0Y25cSNRWSigQtlULPTw+kzuJPeYEkXjQRpoGZobYsLF79pyd1dMRHInbgFTZqNLhDqiIsTNpoex2WLcy0/X6rHcdMMQvFSd5dWA++4P7xv89deACnmr36uGlL69bRCL6BSZsS6c0TU2TKK5gtWCzgAOOwQcurqk9j8whvziZSMLcq5hbuwBEsYjopUBkqw1yYBGpLA97SRElEmx5MCInBY5vgLk94iKqSWmhIGmkJ4Bi9m4L645J68LyY4wsFYBfUg5feP/6gWWm58IEmKQM89hq7KsZNaKtP5TxxrUZZVkNmMJtjbKrGxLNEbHPJxhqy7lAmbC32ZqeF6lTaknRWcYaFpfLUBh/rwaQycCCJmW15Kstv6jRHyJFry2C1ahkkIW0LO75s61+owxK1y3XqweX9m5YLM2DPFeOjn/iiqCKJ+yKXF8t5Yl/kNsqaSCryxPq5xWTFIaP8KSW0RYxqupaUf0RcTNSSdJZGcKYdYA6kdtrtmyBckfKXwqk0pHpUHlwWaffjNRBYFPUDWa8e3Lt/o0R0CdisKDM89cX0pvRHEfM8ca4t0s2Xx4kgo91MPQJ/0c9MQYq0co8MBh7bz1fio0UUHLR4aAIOvOmoYO6kwlEVODSSTliWtOtH6sPkrtctF9ZtJ9GIerBskvhdVS5cFNv9s1BU0AbdUgdK4FG+dRnjFmDTzniRMdZO1QhzMK355vigbdkpz9P6qjUGE5J2qAcXmwJ20cZUiAD0z+pGMx6xkzJkmEf40Hr4qZfVg2XzF9YOyoV5BjzVkUJngKf8lgNYwKECEHrCNDrWZzMlflS3yBhr/InyoUgBc/lKT4pxVrrC6g1YwcceK3BmNxZcAtz3j5EIpqguh9H6wc011YN75cKDLpFDxuwkrPQmUwW4KTbj9mZTwBwLq4aQMUZbHm1rylJ46dzR0dua2n3RYCWZsiHROeywyJGR7mXKlpryyCiouY56sFkBWEnkEB/raeh/Sw4162KeuAxMQpEkzy5alMY5wamMsWKKrtW2WpEWNnReZWONKWjrdsKZarpFjqCslq773PLmEhM448Pc3+FKr1+94vv/rfw4tEcu+lKTBe4kZSdijBrykwv9vbCMPcLQTygBjzVckSLPRVGslqdunwJ4oegtFOYb4SwxNgWLCmD7T9kVjTv5YDgpo0XBmN34Z/rEHp0sgyz7lngsrm4lvMm2Mr1zNOJYJ5cuxuQxwMGJq/TP5emlb8fsQBZviK4t8hFL+zbhtlpwaRSxQRWfeETjuauPsdGxsBVdO7nmP4xvzSoT29pRl7kGqz+k26B3Oy0YNV+SXbbQas1ctC/GarskRdFpKczVAF1ZXnLcpaMuzVe6lZ2g/1ndcvOVgRG3sdUAY1bKD6achijMPdMxV4muKVorSpiDHituH7rSTs7n/4y5DhRXo4FVBN4vO/zbAcxhENzGbHCzU/98Mcx5e7a31kWjw9FCe/zNeYyQjZsWb1uc7U33pN4Mji6hCLhivqfa9Ss6xLg031AgfesA/l99m9fgvnaF9JoE6bYKmkGNK3aPbHB96w3+DnxFm4hs0drLsk7U8kf/N/CvwQNtllna0rjq61sH8L80HAuvwH1tvBy2ChqWSCaYTaGN19sTvlfzFD6n+iKTbvtayfrfe9ueWh6GJFoxLdr7V72a5ZpvHcCPDzma0wTO4EgbLyedxstO81n57LYBOBzyfsOhUKsW1J1BB5vr/tz8RyqOFylQP9Tvst2JALsC5lsH8PyQ40DV4ANzYa4dedNiKNR1s+x2wwbR7q4/4cTxqEk4LWDebfisuo36JXLiWFjOtLrlNWh3K1rRS4xvHcDNlFnNmWBBAl5SWaL3oPOfnvbr5pdjVnEaeBJSYjuLEkyLLsWhKccadmOphZkOPgVdalj2QpSmfOsADhMWE2ZBu4+EEJI4wKTAuCoC4xwQbWXBltpxbjkXJtKxxabo9e7tyhlgb6gNlSbUpMh+l/FaqzVwewGu8BW1Zx7pTpQDJUjb8tsUTW6+GDXbMn3mLbXlXJiGdggxFAoUrtPS3wE4Nk02UZG2OOzlk7fRs7i95QCLo3E0jtrjnM7SR3uS1p4qtS2nJ5OwtQVHgOvArLBFijZUV9QtSl8dAY5d0E0hM0w3HS2DpIeB6m/A1+HfhJcGUq4sOxH+x3f5+VO+Ds9rYNI7zPXOYWPrtf8bYMx6fuOAX5jzNR0PdsuON+X1f7EERxMJJoU6GkTEWBvVolVlb5lh3tKCg6Wx1IbaMDdJ+9sUCc5KC46hKGCk3IVOS4TCqdBNfUs7Kd4iXf2RjnT/LLysJy3XDcHLh/vde3x8DoGvwgsa67vBk91G5Pe/HbOe7xwym0NXbtiuuDkGO2IJDh9oQvJ4cY4vdoqLDuoH9Zl2F/ofsekn8lkuhIlhQcffUtSjytFyp++p6NiE7Rqx/lodgKVoceEp/CP4FfjrquZaTtj2AvH5K/ywpn7M34K/SsoYDAdIN448I1/0/wveW289T1/lX5xBzc8N5IaHr0XMOQdHsIkDuJFifj20pBm5jzwUv9e2FhwRsvhAbalCIuIw3bhJihY3p6nTFFIZgiSYjfTf3aXuOjmeGn4bPoGvwl+CFzTRczBIuHBEeImHc37/lGfwZR0cXzVDOvaKfNHvwe+suZ771K/y/XcBlsoN996JpBhoE2toYxOznNEOS5TJc6Id5GEXLjrWo+LEWGNpPDU4WAwsIRROu+1vM+0oW37z/MBN9kqHnSArwPfgFJ7Cq/Ai3Ie7g7ncmI09v8sjzw9mzOAEXoIHxURueaAce5V80f/DOuuZwHM8vsMb5wBzOFWM7wymTXPAEvm4vcFpZ2ut0VZRjkiP2MlmLd6DIpbGSiHOjdnUHN90hRYmhTnmvhzp1iKDNj+b7t5hi79lWGwQ+HN9RsfFMy0FXbEwhfuczKgCbyxYwBmcFhhvo/7a44v+i3XWcwDP86PzpGQYdWh7csP5dBvZ1jNzdxC8pBGuxqSW5vw40nBpj5JhMwvOzN0RWqERHMr4Lv1kWX84xLR830G3j6yqZ1a8UstTlW+qJPOZ+sZ7xZPKTJLhiNOAFd6tk+jrTH31ncLOxid8+nzRb128HhUcru/y0Wn6iT254YPC6FtVSIMoW2sk727AhvTtrWKZTvgsmckfXYZWeNRXx/3YQ2OUxLDrbHtN11IwrgXT6c8dATDwLniYwxzO4RzuQqTKSC5gAofMZ1QBK3zQ4JWobFbcvJm87FK+6JXrKahLn54m3p+McXzzYtP8VF/QpJuh1OwieElEoI1pRxPS09FBrkq2tWCU59+HdhNtTIqKm8EBrw2RTOEDpG3IKo2Y7mFdLm3ZeVjYwVw11o/oznceMve4CgMfNym/utA/d/ILMR7gpXzRy9eDsgLcgbs8O2Va1L0zzIdwGGemTBuwROHeoMShkUc7P+ISY3KH5ZZeWqO8mFTxQYeXTNuzvvK5FGPdQfuu00DwYFY9dyhctEt+OJDdnucfpmyhzUJzfsJjr29l8S0bXBfwRS9ZT26tmMIdZucch5ZboMz3Nio3nIOsYHCGoDT4kUA9MiXEp9Xsui1S8th/kbWIrMBxDGLodWUQIWcvnXy+9M23xPiSMOiRPqM+YMXkUN3gXFrZJwXGzUaMpJfyRS9ZT0lPe8TpScuRlbMHeUmlaKDoNuy62iWNTWNFYjoxFzuJs8oR+RhRx7O4SVNSXpa0ZJQ0K1LAHDQ+D9IepkMXpcsq5EVCvClBUIzDhDoyKwDw1Lc59GbTeORivugw1IcuaEOaGWdNm+Ps5fQ7/tm0DjMegq3yM3vb5j12qUId5UZD2oxDSEWOZMSqFl/W+5oynWDa/aI04tJRQ2eTXusg86SQVu/nwSYwpW6wLjlqIzwLuxGIvoAvul0PS+ZNz0/akp/pniO/8JDnGyaCkzbhl6YcqmK/69prxPqtpx2+Km9al9sjL+rwMgHw4jE/C8/HQ3m1vBuL1fldbzd8mOueVJ92syqdEY4KJjSCde3mcRw2TA6szxedn+zwhZMps0XrqEsiUjnC1hw0TELC2Ek7uAAdzcheXv1BYLagspxpzSAoZZUsIzIq35MnFQ9DOrlNB30jq3L4pkhccKUAA8/ocvN1Rzx9QyOtERs4CVsJRK/DF71kPYrxYsGsm6RMh4cps5g1DOmM54Ly1ii0Hd3Y/BMk8VWFgBVmhqrkJCPBHAolwZaWzLR9Vb7bcWdX9NyUYE+uB2BKfuaeBUcjDljbYVY4DdtsVWvzRZdWnyUzDpjNl1Du3aloAjVJTNDpcIOVVhrHFF66lLfJL1zJr9PQ2nFJSBaKoDe+sAvLufZVHVzYh7W0h/c6AAZ+7Tvj6q9j68G/cTCS/3n1vLKHZwNi+P+pS0WkZNMBMUl+LDLuiE4omZy71r3UFMwNJV+VJ/GC5ixVUkBStsT4gGKh0Gm4Oy3qvq7Lbmq24nPdDuDR9deR11XzP4vFu3TYzfnIyiSVmgizUYGqkIXNdKTY9pgb9D2Ix5t0+NHkVzCdU03suWkkVZAoCONCn0T35gAeW38de43mf97sMOpSvj4aa1KYUm58USI7Wxxes03bAZdRzk6UtbzMaCQ6IxO0dy7X+XsjoD16hpsBeGz9dfzHj+R/Hp8nCxZRqkEDTaCKCSywjiaoMJ1TITE9eg7Jqnq8HL6gDwiZb0u0V0Rr/rmvqjxKuaLCX7ZWXTvAY+uvm3z8CP7nzVpngqrJpZKwWnCUjIviYVlirlGOzPLI3SMVyp/elvBUjjDkNhrtufFFErQ8pmdSlbK16toBHlt/HV8uHMX/vEGALkV3RJREiSlopxwdMXOZPLZ+ix+kAHpMKIk8UtE1ygtquttwxNhphrIZ1IBzjGF3IIGxGcBj6q8bHJBG8T9vdsoWrTFEuebEZuVxhhClH6P5Zo89OG9fwHNjtNQTpD0TG9PJLEYqvEY6Rlxy+ZZGfL0Aj62/bnQCXp//eeM4KzfQVJbgMQbUjlMFIm6TpcfWlZje7NBSV6IsEVmumWIbjiloUzQX9OzYdo8L1wjw2PrrpimONfmfNyzKklrgnEkSzT5QWYQW40YShyzqsRmMXbvVxKtGuYyMKaU1ugenLDm5Ily4iT14fP11Mx+xJv+zZ3MvnfdFqxU3a1W/FTB4m3Qfsyc1XUcdVhDeUDZXSFHHLQj/Y5jtC7ZqM0CXGwB4bP11i3LhOvzPGygYtiUBiwQV/4wFO0majijGsafHyRLu0yG6q35cL1rOpVxr2s5cM2jJYMCdc10Aj6q/blRpWJ//+dmm5psMl0KA2+AFRx9jMe2WbC4jQxnikd4DU8TwUjRVacgdlhmr3bpddzuJ9zXqr2xnxJfzP29RexdtjDVZqzkqa6PyvcojGrfkXiJ8SEtml/nYskicv0ivlxbqjemwUjMw5evdg8fUX9nOiC/lf94Q2i7MURk9nW1MSj5j8eAyV6y5CN2S6qbnw3vdA1Iwq+XOSCl663udN3IzLnrt+us25cI1+Z83SXQUldqQq0b5XOT17bGpLd6ssN1VMPf8c+jG8L3NeCnMdF+Ra3fRa9dft39/LuZ/3vwHoHrqGmQFafmiQw6eyzMxS05K4bL9uA+SKUQzCnSDkqOGokXyJvbgJ/BHI+qvY69//4rl20NsmK2ou2dTsyIALv/91/8n3P2Aao71WFGi8KKv1fRC5+J67Q/507/E/SOshqN5TsmYIjVt+kcjAx98iz/4SaojbIV1rexE7/C29HcYD/DX4a0rBOF5VTu7omsb11L/AWcVlcVZHSsqGuXLLp9ha8I//w3Mv+T4Ew7nTBsmgapoCrNFObIcN4pf/Ob/mrvHTGqqgAupL8qWjWPS9m/31jAe4DjA+4+uCoQoT/zOzlrNd3qd4SdphFxsUvYwGWbTWtISc3wNOWH+kHBMfc6kpmpwPgHWwqaSUG2ZWWheYOGQGaHB+eQ/kn6b3pOgLV+ODSn94wDvr8Bvb70/LLuiPPEr8OGVWfDmr45PZyccEmsVXZGe1pRNX9SU5+AVQkNTIVPCHF/jGmyDC9j4R9LfWcQvfiETmgMMUCMN1uNCakkweZsowdYobiMSlnKA93u7NzTXlSfe+SVbfnPQXmg9LpYAQxpwEtONyEyaueWM4FPjjyjG3uOaFmBTWDNgBXGEiQpsaWhnAqIijB07Dlsy3fUGeP989xbWkyf+FF2SNEtT1E0f4DYYVlxFlbaSMPIRMk/3iMU5pME2SIWJvjckciebkQuIRRyhUvkHg/iUljG5kzVog5hV7vIlCuBrmlhvgPfNHQM8lCf+FEGsYbMIBC0qC9a0uuy2wLXVbLBaP5kjHokCRxapkQyzI4QEcwgYHRZBp+XEFTqXFuNVzMtjXLJgX4gAid24Hjwc4N3dtVSe+NNiwTrzH4WVUOlDobUqr1FuAgYllc8pmzoVrELRHSIW8ViPxNy4xwjBpyR55I6J220qQTZYR4guvUICJiSpr9gFFle4RcF/OMB7BRiX8sSfhpNSO3lvEZCQfLUVTKT78Ek1LRLhWN+yLyTnp8qWUZ46b6vxdRGXfHVqx3eI75YaLa4iNNiK4NOW7wPW6lhbSOF9/M9qw8e/aoB3d156qTzxp8pXx5BKAsYSTOIIiPkp68GmTq7sZtvyzBQaRLNxIZ+paozHWoLFeExIhRBrWitHCAHrCF7/thhD8JhYz84wg93QRV88wLuLY8zF8sQ36qF1J455bOlgnELfshKVxYOXKVuKx0jaj22sczTQqPqtV/XDgpswmGTWWMSDw3ssyUunLLrVPGjYRsH5ggHeHSWiV8kT33ycFSfMgkoOK8apCye0J6VW6GOYvffgU9RWsukEi2kUV2nl4dOYUzRik9p7bcA4ggdJ53LxKcEe17B1R8eqAd7dOepV8sTXf5lhejoL85hUdhDdknPtKHFhljOT+bdq0hxbm35p2nc8+Ja1Iw+tJykgp0EWuAAZYwMVwac5KzYMslhvgHdHRrxKnvhTYcfKsxTxtTETkjHO7rr3zjoV25lAQHrqpV7bTiy2aXMmUhTBnKS91jhtR3GEoF0oLnWhWNnYgtcc4N0FxlcgT7yz3TgNIKkscx9jtV1ZKpWW+Ub1tc1eOv5ucdgpx+FJy9pgbLE7xDyXb/f+hLHVGeitHOi6A7ybo3sF8sS7w7cgdk0nJaOn3hLj3uyD0Zp5pazFIUXUpuTTU18d1EPkDoX8SkmWTnVIozEdbTcZjoqxhNHf1JrSS/AcvHjZ/SMHhL/7i5z+POsTUh/8BvNfYMTA8n+yU/MlTZxSJDRStqvEuLQKWwDctMTQogUDyQRoTQG5Kc6oQRE1yV1jCA7ri7jdZyK0sYTRjCR0Hnnd+y7nHxNgTULqw+8wj0mQKxpYvhjm9uSUxg+TTy7s2GtLUGcywhXSKZN275GsqlclX90J6bRI1aouxmgL7Q0Nen5ziM80SqMIo8cSOo+8XplT/5DHNWsSUr/6lLN/QQ3rDyzLruEW5enpf7KqZoShEduuSFOV7DLX7Ye+GmXb6/hnNNqKsVXuMDFpb9Y9eH3C6NGEzuOuI3gpMH/I6e+zDiH1fXi15t3vA1czsLws0TGEtmPEJdiiFPwlwKbgLHAFk4P6ZyPdymYYHGE0dutsChQBl2JcBFlrEkY/N5bQeXQ18gjunuMfMfsBlxJSx3niO485fwO4fGD5T/+3fPQqkneWVdwnw/3bMPkW9Wbqg+iC765Zk+xcT98ibKZc2EdgHcLoF8cSOo/Oc8fS+OyEULF4g4sJqXVcmfMfsc7A8v1/yfGXmL9I6Fn5pRwZhsPv0TxFNlAfZCvG+Oohi82UC5f/2IsJo0cTOm9YrDoKhFPEUr/LBYTUNht9zelHXDqwfPCIw4owp3mOcIQcLttWXFe3VZ/j5H3cIc0G6oPbCR+6Y2xF2EC5cGUm6wKC5tGEzhsWqw5hNidUiKX5gFWE1GXh4/Qplw4sVzOmx9QxU78g3EF6wnZlEN4FzJ1QPSLEZz1KfXC7vd8ssGdIbNUYpVx4UapyFUHzJoTOo1McSkeNn1M5MDQfs4qQuhhX5vQZFw8suwWTcyYTgioISk2YdmkhehG4PkE7w51inyAGGaU+uCXADabGzJR1fn3lwkty0asIo8cROm9Vy1g0yDxxtPvHDAmpu+PKnM8Ix1wwsGw91YJqhteaWgjYBmmQiebmSpwKKzE19hx7jkzSWOm66oPbzZ8Yj6kxVSpYjVAuvLzYMCRo3oTQecOOjjgi3NQ4l9K5/hOGhNTdcWVOTrlgYNkEXINbpCkBRyqhp+LdRB3g0OU6rMfW2HPCFFMV9nSp+uB2woepdbLBuJQyaw/ZFysXrlXwHxI0b0LovEkiOpXGA1Ijagf+KUNC6rKNa9bQnLFqYNkEnMc1uJrg2u64ELPBHpkgWbmwKpJoDhMwNbbGzAp7Yg31wS2T5rGtzit59PrKhesWG550CZpHEzpv2NGRaxlNjbMqpmEIzygJqQfjypycs2pg2cS2RY9r8HUqkqdEgKTWtWTKoRvOBPDYBltja2SO0RGjy9UHtxwRjA11ujbKF+ti5cIR9eCnxUg6owidtyoU5tK4NLji5Q3HCtiyF2IqLGYsHViOXTXOYxucDqG0HyttqYAKqYo3KTY1ekyDXRAm2AWh9JmsVh/ccg9WJ2E8YjG201sPq5ULxxX8n3XLXuMInbft2mk80rRGjCGctJ8/GFdmEQ9Ug4FlE1ll1Y7jtiraqm5Fe04VV8lvSVBL8hiPrfFVd8+7QH3Qbu2ipTVi8cvSGivc9cj8yvH11YMHdNSERtuOslM97feYFOPKzGcsI4zW0YGAbTAOaxCnxdfiYUmVWslxiIblCeAYr9VYR1gM7GmoPrilunSxxeT3DN/2eBQ9H11+nk1adn6VK71+5+Jfct4/el10/7KBZfNryUunWSCPxPECk1rdOv1WVSrQmpC+Tl46YD3ikQYcpunSQgzVB2VHFhxHVGKDgMEY5GLlQnP7FMDzw7IacAWnO6sBr12u+XanW2AO0wQ8pknnFhsL7KYIqhkEPmEXFkwaN5KQphbkUmG72wgw7WSm9RiL9QT925hkjiVIIhphFS9HKI6/8QAjlpXqg9W2C0apyaVDwKQwrwLY3j6ADR13ZyUNByQXHQu6RY09Hu6zMqXRaNZGS/KEJs0cJEe9VH1QdvBSJv9h09eiRmy0V2uJcqHcShcdvbSNg5fxkenkVprXM9rDVnX24/y9MVtncvbKY706anNl3ASll9a43UiacVquXGhvq4s2FP62NGKfQLIQYu9q1WmdMfmUrDGt8eDS0cXozH/fjmUH6Jruvm50hBDSaEU/2Ru2LEN/dl006TSc/g7tfJERxGMsgDUEr104pfWH9lQaN+M4KWQjwZbVc2rZVNHsyHal23wZtIs2JJqtIc/WLXXRFCpJkfE9jvWlfFbsNQ9pP5ZBS0zKh4R0aMFj1IjTcTnvi0Zz2rt7NdvQb2mgbju1plsH8MmbnEk7KbK0b+wC2iy3aX3szW8xeZvDwET6hWZYwqTXSSG+wMETKum0Dq/q+x62gt2ua2ppAo309TRk9TPazfV3qL9H8z7uhGqGqxNVg/FKx0HBl9OVUORn8Q8Jx9gFttGQUDr3tzcXX9xGgN0EpzN9mdZ3GATtPhL+CjxFDmkeEU6x56kqZRusLzALXVqkCN7zMEcqwjmywDQ6OhyUe0Xao1Qpyncrg6wKp9XfWDsaZplElvQ/b3sdweeghorwBDlHzgk1JmMc/wiERICVy2VJFdMjFuLQSp3S0W3+sngt2njwNgLssFGVQdJ0tu0KH4ky1LW4yrbkuaA6Iy9oz/qEMMXMMDWyIHhsAyFZc2peV9hc7kiKvfULxCl9iddfRK1f8kk9qvbdOoBtOg7ZkOZ5MsGrSHsokgLXUp9y88smniwWyuFSIRVmjplga3yD8Uij5QS1ZiM4U3Qw5QlSm2bXjFe6jzzBFtpg+/YBbLAWG7OPynNjlCw65fukGNdkJRf7yM1fOxVzbxOJVocFoYIaGwH22mIQkrvu1E2nGuebxIgW9U9TSiukPGU+Lt++c3DJPKhyhEEbXCQLUpae2exiKy6tMPe9mDRBFCEMTWrtwxN8qvuGnt6MoihKWS5NSyBhbH8StXoAz8PLOrRgLtOT/+4vcu+7vDLnqNvztOq7fmd8sMmY9Xzn1zj8Dq8+XVdu2Nv0IIySgEdQo3xVHps3Q5i3fLFsV4aiqzAiBhbgMDEd1uh8qZZ+lwhjkgokkOIv4xNJmyncdfUUzgB4oFMBtiu71Xumpz/P+cfUP+SlwFExwWW62r7b+LSPxqxn/gvMZ5z9C16t15UbNlq+jbGJtco7p8wbYlL4alSyfWdeuu0j7JA3JFNuVAwtst7F7FhWBbPFNKIUORndWtLraFLmMu7KFVDDOzqkeaiN33YAW/r76wR4XDN/yN1z7hejPau06EddkS/6XThfcz1fI/4K736fO48vlxt2PXJYFaeUkFS8U15XE3428xdtn2kc8GQlf1vkIaNRRnOMvLTWrZbElEHeLWi1o0dlKPAh1MVgbbVquPJ5+Cr8LU5/H/+I2QlHIU2ClXM9G8v7Rr7oc/hozfUUgsPnb3D+I+7WF8kNO92GY0SNvuxiE+2Bt8prVJTkzE64sfOstxuwfxUUoyk8VjcTlsqe2qITSFoSj6Epd4KsT6BZOWmtgE3hBfir8IzZDwgV4ZTZvD8VvPHERo8v+vL1DASHTz/i9OlKueHDjK5Rnx/JB1Vb1ioXdBra16dmt7dgik10yA/FwJSVY6XjA3oy4SqM2frqDPPSRMex9qs3XQtoWxMj7/Er8GWYsXgjaVz4OYumP2+9kbxvny/6kvWsEBw+fcb5bInc8APdhpOSs01tEqIkoiZjbAqKMruLbJYddHuHFRIyJcbdEdbl2sVLaySygunutBg96Y2/JjKRCdyHV+AEFtTvIpbKIXOamknYSiB6KV/0JetZITgcjjk5ZdaskBtWO86UF0ap6ozGXJk2WNiRUlCPFir66lzdm/SLSuK7EUdPz8f1z29Skq6F1fXg8+5UVR6bszncP4Tn4KUkkdJ8UFCY1zR1i8RmL/qQL3rlei4THG7OODlnKko4oI01kd3CaM08Ia18kC3GNoVaO9iDh+hWxSyTXFABXoau7Q6q9OxYg/OVEMw6jdbtSrJ9cBcewGmaZmg+bvkUnUUaGr+ZfnMH45Ivevl61hMcXsxYLFTu1hTm2zViCp7u0o5l+2PSUh9bDj6FgYypufBDhqK2+oXkiuHFHR3zfj+9PtA8oR0xnqX8qn+sx3bFODSbbF0X8EUvWQ8jBIcjo5bRmLOljDNtcqNtOe756h3l0VhKa9hDd2l1eqmsnh0MNMT/Cqnx6BInumhLT8luljzQ53RiJeA/0dxe5NK0o2fA1+GLXr6eNQWHNUOJssQaTRlGpLHKL9fD+IrQzTOMZS9fNQD4AnRNVxvTdjC+fJdcDDWQcyB00B0t9BDwTxXgaAfzDZ/DBXzRnfWMFRwuNqocOmX6OKNkY63h5n/fFcB28McVHqnXZVI27K0i4rDLNE9lDKV/rT+udVbD8dFFu2GGZ8mOt0kAXcoX3ZkIWVtw+MNf5NjR2FbivROHmhV1/pj2egv/fMGIOWTIWrV3Av8N9imV9IWml36H6cUjqEWNv9aNc+veb2sH46PRaHSuMBxvtW+twxctq0z+QsHhux8Q7rCY4Ct8lqsx7c6Sy0dl5T89rIeEuZKoVctIk1hNpfavER6yyH1Vvm3MbsUHy4ab4hWr/OZPcsRBphnaV65/ZcdYPNNwsjN/djlf9NqCw9U5ExCPcdhKxUgLSmfROpLp4WSUr8ojdwbncbvCf+a/YzRaEc6QOvXcGO256TXc5Lab9POvB+AWY7PigWYjzhifbovuunzRawsO24ZqQQAqguBtmpmPB7ysXJfyDDaV/aPGillgz1MdQg4u5MYaEtBNNHFjkRlSpd65lp4hd2AVPTfbV7FGpyIOfmNc/XVsPfg7vzaS/3nkvLL593ANLvMuRMGpQIhiF7kUEW9QDpAUbTWYBcbp4WpacHHY1aacqQyjGZS9HI3yCBT9kUZJhVOD+zUDvEH9ddR11fzPcTDQ5TlgB0KwqdXSavk9BC0pKp0WmcuowSw07VXmXC5guzSa4p0UvRw2lbDiYUx0ExJJRzWzi6Gm8cnEkfXXsdcG/M/jAJa0+bmCgdmQ9CYlNlSYZOKixmRsgiFxkrmW4l3KdFKv1DM8tk6WxPYJZhUUzcd8Kdtgrw/gkfXXDT7+avmfVak32qhtkg6NVdUS5wgkru1YzIkSduTW1FDwVWV3JQVJVuieTc0y4iDpFwc7/BvSalvKdQM8sv662cevz/+8sQVnjVAT0W2wLllw1JiMhJRxgDjCjLQsOzSFSgZqx7lAW1JW0e03yAD3asC+GD3NbQhbe+mN5GXH1F83KDOM4n/e5JIuH4NpdQARrFPBVptUNcjj4cVMcFSRTE2NpR1LEYbYMmfWpXgP9KejaPsLUhuvLCsVXznAG9dfx9SR1ud/3hZdCLHb1GMdPqRJgqDmm76mHbvOXDtiO2QPUcKo/TWkQ0i2JFXpBoo7vij1i1Lp3ADAo+qvG3V0rM//vFnnTE4hxd5Ka/Cor5YEdsLVJyKtDgVoHgtW11pWSjolPNMnrlrVj9Fv2Qn60twMwKPqr+N/wvr8z5tZcDsDrv06tkqyzESM85Ycv6XBWA2birlNCXrI6VbD2lx2L0vQO0QVTVVLH4SE67fgsfVXv8n7sz7/85Z7cMtbE6f088wSaR4kCkCm10s6pKbJhfqiUNGLq+0gLWC6eUAZFPnLjwqtKd8EwGvWX59t7iPW4X/eAN1svgRVSY990YZg06BD1ohLMtyFTI4pKTJsS9xREq9EOaPWiO2gpms7397x6nQJkbh+Fz2q/rqRROX6/M8bJrqlVW4l6JEptKeUFuMYUbtCQ7CIttpGc6MY93x1r1vgAnRXvY5cvwWPqb9uWQm+lP95QxdNMeWhOq1x0Db55C7GcUv2ZUuN6n8iKzsvOxibC//Yfs9Na8r2Rlz02vXXDT57FP/zJi66/EJSmsJKa8QxnoqW3VLQ+jZVUtJwJ8PNX1NQCwfNgdhhHD9on7PdRdrdGPF28rJr1F+3LBdeyv+8yYfLoMYet1vX4upNAjVvwOUWnlNXJXlkzk5Il6kqeoiL0C07qno+/CYBXq/+utlnsz7/Mzvy0tmI4zm4ag23PRN3t/CWryoUVJGm+5+K8RJ0V8Hc88/XHUX/HfiAq7t+BH+x6v8t438enWmdJwFA6ZINriLGKv/95f8lT9/FnyA1NMVEvQyaXuu+gz36f/DD73E4pwqpLcvm/o0Vle78n//+L/NPvoefp1pTJye6e4A/D082FERa5/opeH9zpvh13cNm19/4v/LDe5xMWTi8I0Ta0qKlK27AS/v3/r+/x/2GO9K2c7kVMonDpq7//jc5PKCxeNPpFVzaRr01wF8C4Pu76hXuX18H4LduTr79guuFD3n5BHfI+ZRFhY8w29TYhbbLi/bvBdqKE4fUgg1pBKnV3FEaCWOWyA+m3WpORZr/j+9TKJtW8yBTF2/ZEODI9/QavHkVdGFp/Pjn4Q+u5hXapsP5sOH+OXXA1LiKuqJxiMNbhTkbdJTCy4llEt6NnqRT4dhg1V3nbdrm6dYMecA1yTOL4PWTE9L5VzPFlLBCvlG58AhehnN4uHsAYinyJ+AZ/NkVvELbfOBUuOO5syBIEtiqHU1k9XeISX5bsimrkUUhnGDxourN8SgUsCZVtKyGbyGzHXdjOhsAvOAswSRyIBddRdEZWP6GZhNK/yjwew9ehBo+3jEADu7Ay2n8mDc+TS7awUHg0OMzR0LABhqLD4hJEh/BEGyBdGlSJoXYXtr+3HS4ijzVpgi0paWXtdruGTknXBz+11qT1Q2inxaTzQCO46P3lfLpyS4fou2PH/PupwZgCxNhGlj4IvUuWEsTkqMWm6i4xCSMc9N1RDQoCVcuGItJ/MRWefais+3synowi/dESgJjkilnWnBTGvRWmaw8oR15257t7CHmCf8HOn7cwI8+NQBXMBEmAa8PMRemrNCEhLGEhDQKcGZWS319BX9PFBEwGTbRBhLbDcaV3drFcDqk5kCTd2JF1Wp0HraqBx8U0wwBTnbpCadwBA/gTH/CDrcCs93LV8E0YlmmcyQRQnjBa8JESmGUfIjK/7fkaDJpmD2QptFNVJU1bbtIAjjWQizepOKptRjbzR9Kag6xZmMLLjHOtcLT3Tx9o/0EcTT1XN3E45u24AiwEypDJXihKjQxjLprEwcmRKclaDNZCVqr/V8mYWyFADbusiY5hvgFoU2vio49RgJLn5OsReRFN6tabeetiiy0V7KFHT3HyZLx491u95sn4K1QQSPKM9hNT0wMVvAWbzDSVdrKw4zRjZMyJIHkfq1VAVCDl/bUhNKlGq0zGr05+YAceXVPCttVk0oqjVwMPt+BBefx4yPtGVkUsqY3CHDPiCM5ngupUwCdbkpd8kbPrCWHhkmtIKLEetF2499eS1jZlIPGYnlcPXeM2KD9vLS0bW3ktYNqUllpKLn5ZrsxlIzxvDu5eHxzGLctkZLEY4PgSOg2IUVVcUONzUDBEpRaMoXNmUc0tFZrTZquiLyKxrSm3DvIW9Fil+AkhXu5PhEPx9mUNwqypDvZWdKlhIJQY7vn2OsnmBeOWnYZ0m1iwbbw1U60by5om47iHRV6fOgzjMf/DAZrlP40Z7syxpLK0lJ0gqaAK1c2KQKu7tabTXkLFz0sCftuwX++MyNeNn68k5Buq23YQhUh0SNTJa1ioQ0p4nUG2y0XilF1JqODqdImloPS4Bp111DEWT0jJjVv95uX9BBV7eB3bUWcu0acSVM23YZdd8R8UbQUxJ9wdu3oMuhdt929ME+mh6JXJ8di2RxbTi6TbrDquqV4aUKR2iwT6aZbyOwEXN3DUsWr8Hn4EhwNyHuXHh7/pdaUjtR7vnDh/d8c9xD/s5f501eQ1+CuDiCvGhk1AN/4Tf74RfxPwD3toLarR0zNtsnPzmS64KIRk861dMWCU8ArasG9T9H0ZBpsDGnjtAOM2+/LuIb2iIUGXNgl5ZmKD/Tw8TlaAuihaFP5yrw18v4x1898zIdP+DDAX1bM3GAMvPgRP/cJn3zCW013nrhHkrITyvYuwOUkcHuKlRSW5C6rzIdY4ppnF7J8aAJbQepgbJYBjCY9usGXDKQxq7RZfh9eg5d1UHMVATRaD/4BHK93/1iAgYZ/+jqPn8Dn4UExmWrpa3+ZOK6MvM3bjwfzxNWA2dhs8+51XHSPJiaAhGSpWevEs5xHLXcEGFXYiCONySH3fPWq93JIsBiSWvWyc3CAN+EcXoT7rCSANloPPoa31rt/5PUA/gp8Q/jDD3hyrjzlR8VkanfOvB1XPubt17vzxAfdSVbD1pzAnfgyF3ycadOTOTXhpEUoLC1HZyNGW3dtmjeXgr2r56JNmRwdNNWaQVBddd6rh4MhviEB9EFRD/7RGvePvCbwAL4Mx/D6M541hHO4D3e7g6PafdcZVw689z7NGTwo5om7A8sPhccT6qKcl9NJl9aM/9kX+e59Hh1yPqGuCCZxuITcsmNaJ5F7d0q6J3H48TO1/+M57085q2icdu2U+W36Ldllz9Agiv4YGljoEN908EzvDOrBF98/vtJwCC/BF2AG75xxEmjmMIcjxbjoaxqOK3/4hPOZzhMPBpYPG44CM0dTVm1LjLtUWWVz1Bcf8tEx0zs8O2A2YVHRxKYOiy/aOVoAaMu0i7ubu43njjmd4ibMHU1sIDHaQNKrZND/FZYdk54oCXetjq7E7IVl9eAL7t+oHnwXXtLx44czzoRFHBztYVwtH1d+NOMkupZ5MTM+gUmq90X+Bh9zjRlmaQ+m7YMqUL/veemcecAtOJ0yq1JnVlN27di2E0+Klp1tAJ4KRw1eMI7aJjsO3R8kPSI3fUFXnIOfdQe86sIIVtWDL7h//Ok6vj8vwDk08NEcI8zz7OhBy+WwalzZeZ4+0XniRfst9pAJqQHDGLzVQ2pheZnnv1OWhwO43/AgcvAEXEVVpa4db9sGvNK8wjaENHkfFQ4Ci5i7dqnQlPoLQrHXZDvO3BIXZbJOBrOaEbML6sFL798I4FhKihjHMsPjBUZYCMFr6nvaArxqXPn4lCa+cHfSa2cP27g3Z3ziYTRrcbQNGLQmGF3F3cBdzzzX7AILx0IB9rbwn9kx2G1FW3Inic+ZLIsVvKR8Zwfj0l1fkqo8LWY1M3IX14OX3r9RKTIO+d9XzAI8qRPGPn/4NC2n6o4rN8XJ82TOIvuVA8zLKUHRFgBCetlDZlqR1gLKjS39xoE7Bt8UvA6BxuEDjU3tFsEijgA+615tmZkXKqiEENrh41iLDDZNq4pKTWR3LZfnos81LOuNa15cD956vLMsJd1rqYp51gDUQqMYm2XsxnUhD2jg1DM7SeuJxxgrmpfISSXVIJIS5qJJSvJPEQ49DQTVIbYWJ9QWa/E2+c/oPK1drmC7WSfJRNKBO5Yjvcp7Gc3dmmI/Xh1kDTEuiSnWqQf37h+fTMhGnDf6dsS8SQfQWlqqwXXGlc/PEZ/SC5mtzIV0nAshlQdM/LvUtYutrEZ/Y+EAFtq1k28zQhOwLr1AIeANzhF8t9qzTdZf2qRKO6MWE9ohBYwibbOmrFtNmg3mcS+tB28xv2uKd/agYCvOP+GkSc+0lr7RXzyufL7QbkUpjLjEWFLqOIkAGu2B0tNlO9Eau2W1qcOUvVRgKzypKIQZ5KI3q0MLzqTNRYqiZOqmtqloIRlmkBHVpHmRYV6/HixbO6UC47KOFJnoMrVyr7wYz+SlW6GUaghYbY1I6kkxA2W1fSJokUdSh2LQ1GAimRGm0MT+uu57H5l7QgOWxERpO9moLRPgTtquWCfFlGlIjQaRly9odmzMOWY+IBO5tB4sW/0+VWGUh32qYk79EidWKrjWuiLpiVNGFWFRJVktyeXWmbgBBzVl8anPuXyNJlBJOlKLTgAbi/EYHVHxWiDaVR06GnHQNpJcWcK2jJtiCfG2sEHLzuI66sGrMK47nPIInPnu799935aOK2cvmvubrE38ZzZjrELCmXM2hM7UcpXD2oC3+ECVp7xtIuxptJ0jUr3sBmBS47TVxlvJ1Sqb/E0uLdvLj0lLr29ypdd/eMX3f6lrxGlKwKQxEGvw0qHbkbwrF3uHKwVENbIV2wZ13kNEF6zD+x24aLNMfDTCbDPnEikZFyTNttxWBXDaBuM8KtI2rmaMdUY7cXcUPstqTGvBGSrFWIpNMfbdea990bvAOC1YX0qbc6smDS1mPxSJoW4fwEXvjMmhlijDRq6qale6aJEuFGoppYDoBELQzLBuh/mZNx7jkinv0EtnUp50lO9hbNK57lZaMAWuWR5Yo9/kYwcYI0t4gWM47Umnl3YmpeBPqSyNp3K7s2DSAS/39KRuEN2bS4xvowV3dFRMx/VFcp2Yp8w2nTO9hCXtHG1kF1L4KlrJr2wKfyq77R7MKpFKzWlY9UkhYxyHWW6nBWPaudvEAl3CGcNpSXPZ6R9BbBtIl6cHL3gIBi+42CYXqCx1gfGWe7Ap0h3luyXdt1MKy4YUT9xSF01G16YEdWsouW9mgDHd3veyA97H+Ya47ZmEbqMY72oPztCGvK0onL44AvgC49saZKkWRz4veWljE1FHjbRJaWv6ZKKtl875h4CziFCZhG5rx7tefsl0aRT1bMHZjm8dwL/6u7wCRysaQblQoG5yAQN5zpatMNY/+yf8z+GLcH/Qn0iX2W2oEfXP4GvwQHuIL9AYGnaO3zqAX6946nkgqZNnUhx43DIdQtMFeOPrgy/y3Yd85HlJWwjLFkU3kFwq28xPnuPhMWeS+tDLV9Otllq7pQCf3uXJDN9wFDiUTgefHaiYbdfi3b3u8+iY6TnzhgehI1LTe8lcd7s1wJSzKbahCRxKKztTLXstGAiu3a6rPuQs5pk9TWAan5f0BZmGf7Ylxzzk/A7PAs4QPPPAHeFQ2hbFHszlgZuKZsJcUmbDC40sEU403cEjczstOEypa+YxevL4QBC8oRYqWdK6b7sK25tfE+oDZgtOQ2Jg8T41HGcBE6fTWHn4JtHcu9S7uYgU5KSCkl/mcnq+5/YBXOEr6lCUCwOTOM1taOI8mSxx1NsCXBEmLKbMAg5MkwbLmpBaFOPrNSlO2HnLiEqW3tHEwd8AeiQLmn+2gxjC3k6AxREqvKcJbTEzlpLiw4rNZK6oJdidbMMGX9FULKr0AkW+2qDEPBNNm5QAt2Ik2nftNWHetubosHLo2nG4vQA7GkcVCgVCgaDixHqo9UUn1A6OshapaNR/LPRYFV8siT1cCtJE0k/3WtaNSuUZYKPnsVIW0xXWnMUxq5+En4Kvw/MqQmVXnAXj9Z+9zM98zM/Agy7F/qqj2Nh67b8HjFnPP3iBn/tkpdzwEJX/whIcQUXOaikeliCRGUk7tiwF0rItwMEhjkZ309hikFoRAmLTpEXWuHS6y+am/KB/fM50aLEhGnSMwkpxzOov4H0AvgovwJ1iGzDLtJn/9BU+fAINfwUe6FHSLhu83viV/+/HrOePX+STT2B9uWGbrMHHLldRBlhS/CJQmcRxJFqZica01XixAZsYiH1uolZxLrR/SgxVIJjkpQP4PE9sE59LKLr7kltSBogS5tyszzH8Fvw8/AS8rNOg0xUS9fIaHwb+6et8Q/gyvKRjf5OusOzGx8evA/BP4IP11uN/grca5O0lcsPLJ5YjwI4QkJBOHa0WdMZYGxPbh2W2nR9v3WxEWqgp/G3+6VZbRLSAAZ3BhdhAaUL33VUSw9yjEsvbaQ9u4A/gGXwZXoEHOuU1GSj2chf+Mo+f8IcfcAxfIKVmyunRbYQVnoevwgfw3TXXcw++xNuP4fhyueEUNttEduRVaDttddoP0eSxLe2LENk6itYxlrxBNBYrNNKSQmeaLcm9c8UsaB5WyO6675yyQIAWSDpBVoA/gxmcwEvwoDv0m58UE7gHn+fJOa8/Ywan8EKRfjsopF83eCglX/Sfr7OeaRoQfvt1CGvIDccH5BCvw1sWIzRGC/66t0VTcLZQZtm6PlAasbOJ9iwWtUo7biktTSIPxnR24jxP1ZKaqq+2RcXM9OrBAm/AAs7hDJ5bNmGb+KIfwCs8a3jnjBrOFeMjHSCdbKr+2uOLfnOd9eiA8Hvvwwq54VbP2OqwkB48Ytc4YEOiH2vTXqodabfWEOzso4qxdbqD5L6tbtNPECqbhnA708DZH4QOJUXqScmUlks7Ot6FBuZw3n2mEbaUX7kDzxHOOQk8nKWMzAzu6ZZ8sOFw4RK+6PcuXo9tB4SbMz58ApfKDXf3szjNIIbGpD5TKTRxGkEMLjLl+K3wlWXBsCUxIDU+jbOiysESqAy1MGUJpXgwbTWzNOVEziIXZrJ+VIztl1PUBxTSo0dwn2bOmfDRPD3TRTGlfbCJvO9KvuhL1hMHhB9wPuPRLGHcdOWG2xc0U+5bQtAJT0nRTewXL1pgk2+rZAdeWmz3jxAqfNQQdzTlbF8uJ5ecEIWvTkevAHpwz7w78QujlD/Lr491bD8/1vhM2yrUQRrWXNQY4fGilfctMWYjL72UL/qS9eiA8EmN88nbNdour+PBbbAjOjIa4iBhfFg6rxeKdEGcL6p3EWR1Qq2Qkhs2DrnkRnmN9tG2EAqmgPw6hoL7Oza7B+3SCrR9tRftko+Lsf2F/mkTndN2LmzuMcKTuj/mX2+4Va3ki16+nnJY+S7MefpkidxwnV+4wkXH8TKnX0tsYzYp29DOOoSW1nf7nTh2akYiWmcJOuTidSaqESrTYpwjJJNVGQr+rLI7WsqerHW6Kp/oM2pKuV7T1QY9gjqlZp41/WfKpl56FV/0kvXQFRyeQ83xaTu5E8p5dNP3dUF34ihyI3GSpeCsywSh22ZJdWto9winhqifb7VRvgktxp13vyjrS0EjvrRfZ62uyqddSWaWYlwTPAtJZ2oZ3j/Sgi/mi+6vpzesfAcWNA0n8xVyw90GVFGuZjTXEQy+6GfLGLMLL523f5E0OmxVjDoOuRiH91RKU+vtoCtH7TgmvBLvtFXWLW15H9GTdVw8ow4IlRLeHECN9ym1e9K0I+Cbnhgv4Yu+aD2HaQJ80XDqOzSGAV4+4yCqBxrsJAX6ZTIoX36QnvzhhzzMfFW2dZVLOJfo0zbce5OvwXMFaZ81mOnlTVXpDZsQNuoYWveketKb5+6JOOsgX+NTm7H49fUTlx+WLuWL7qxnOFh4BxpmJx0p2gDzA/BUARuS6phR+pUsY7MMboAHx5xNsSVfVZcYSwqCKrqon7zM+8ecCkeS4nm3rINuaWvVNnMRI1IRpxTqx8PZUZ0Br/UEduo3B3hNvmgZfs9gQPj8vIOxd2kndir3awvJ6BLvoUuOfFWNYB0LR1OQJoUySKb9IlOBx74q1+ADC2G6rOdmFdJcD8BkfualA+BdjOOzP9uUhGUEX/TwhZsUduwRr8wNuXKurCixLBgpQI0mDbJr9dIqUuV+92ngkJZ7xduCk2yZKbfWrH1VBiTg9VdzsgRjW3CVXCvAwDd+c1z9dWw9+B+8MJL/eY15ZQ/HqvTwVdsZn5WQsgRRnMaWaecu3jFvMBEmgg+FJFZsnSl0zjB9OqPYaBD7qmoVyImFvzi41usesV0julaAR9dfR15Xzv9sEruRDyk1nb+QaLU67T885GTls6YgcY+UiMa25M/pwGrbCfzkvR3e0jjtuaFtnwuagHTSb5y7boBH119HXhvwP487jJLsLJ4XnUkHX5sLbS61dpiAXRoZSCrFJ+EjpeU3puVfitngYNo6PJrAigKktmwjyQdZpfq30mmtulaAx9Zfx15Xzv+cyeuiBFUs9zq8Kq+XB9a4PVvph3GV4E3y8HENJrN55H1X2p8VyqSKwVusJDKzXOZzplWdzBUFK9e+B4+uv468xvI/b5xtSAkBHQaPvtqWzllVvEOxPbuiE6+j2pvjcKsbvI7txnRErgfH7LdXqjq0IokKzga14GzQ23SSbCQvO6r+Or7SMIr/efOkkqSdMnj9mBx2DRsiY29Uj6+qK9ZrssCKaptR6HKURdwUYeUWA2kPzVKQO8ku2nU3Anhs/XWkBx3F/7wJtCTTTIKftthue1ty9xvNYLY/zo5KSbIuKbXpbEdSyeRyYdAIwKY2neyoc3+k1XUaufYga3T9daMUx/r8z1s10ITknIO0kuoMt+TB8jK0lpayqqjsJ2qtXAYwBU932zinimgmd6mTRDnQfr88q36NAI+tv24E8Pr8zxtasBqx0+xHH9HhlrwsxxNUfKOHQaZBITNf0uccj8GXiVmXAuPEAKSdN/4GLHhs/XWj92dN/uetNuBMnVR+XWDc25JLjo5Mg5IZIq226tmCsip2zZliL213YrTlL2hcFjpCduyim3M7/eB16q/blQsv5X/esDRbtJeabLIosWy3ycavwLhtxdWzbMmHiBTiVjJo6lCLjXZsi7p9PEPnsq6X6wd4bP11i0rD5fzPm/0A6brrIsllenZs0lCJlU4abakR59enZKrKe3BZihbTxlyZ2zl1+g0wvgmA166/bhwDrcn/7Ddz0eWZuJvfSESug6NzZsox3Z04FIxz0mUjMwVOOVTq1CQ0AhdbBGVdjG/CgsfUX7esJl3K/7ytWHRv683praW/8iDOCqWLLhpljDY1ZpzK75QiaZoOTpLKl60auHS/97oBXrv+umU9+FL+5+NtLFgjqVLCdbmj7pY5zPCPLOHNCwXGOcLquOhi8CmCWvbcuO73XmMUPab+ug3A6/A/78Bwe0bcS2+tgHn4J5pyS2WbOck0F51Vq3LcjhLvZ67p1ABbaL2H67bg78BfjKi/jr3+T/ABV3ilLmNXTI2SpvxWBtt6/Z//D0z/FXaGbSBgylzlsEGp+5//xrd4/ae4d8DUUjlslfIYS3t06HZpvfQtvv0N7AHWqtjP2pW08QD/FLy//da38vo8PNlKHf5y37Dxdfe/oj4kVIgFq3koLReSR76W/bx//n9k8jonZxzWTANVwEniDsg87sOSd/z7//PvMp3jQiptGVWFX2caezzAXwfgtzYUvbr0iozs32c3Uge7varH+CNE6cvEYmzbPZ9hMaYDdjK4V2iecf6EcEbdUDVUARda2KzO/JtCuDbNQB/iTeL0EG1JSO1jbXS+nLxtPMDPw1fh5+EPrgSEKE/8Gry5A73ui87AmxwdatyMEBCPNOCSKUeRZ2P6Myb5MRvgCHmA9ywsMifU+AYXcB6Xa5GibUC5TSyerxyh0j6QgLVpdyhfArRTTLqQjwe4HOD9s92D4Ap54odXAPBWLAwB02igG5Kkc+piN4lvODIFGAZgT+EO4Si1s7fjSR7vcQETUkRm9O+MXyo9OYhfe4xt9STQ2pcZRLayCV90b4D3jR0DYAfyxJ+eywg2IL7NTMXna7S/RpQ63JhWEM8U41ZyQGjwsVS0QBrEKLu8xwZsbi4wLcCT+OGidPIOCe1PiSc9Qt+go+vYqB7cG+B9d8cAD+WJPz0Am2gxXgU9IneOqDpAAXOsOltVuMzpdakJXrdPCzXiNVUpCeOos5cxnpQT39G+XVLhs1osQVvJKPZyNq8HDwd4d7pNDuWJPxVX7MSzqUDU6gfadKiNlUFTzLeFHHDlzO4kpa7aiKhBPGKwOqxsBAmYkOIpipyXcQSPlRTf+Tii0U3EJGaZsDER2qoB3h2hu0qe+NNwUooYU8y5mILbJe6OuX+2FTKy7bieTDAemaQyQ0CPthljSWO+xmFDIYiESjM5xKd6Ik5lvLq5GrQ3aCMLvmCA9wowLuWJb9xF59hVVP6O0CrBi3ZjZSNOvRy+I6klNVRJYRBaEzdN+imiUXQ8iVF8fsp+W4JXw7WISW7fDh7lptWkCwZ4d7QTXyBPfJMYK7SijjFppGnlIVJBJBYj7eUwtiP1IBXGI1XCsjNpbjENVpSAJ2hq2LTywEly3hUYazt31J8w2+aiLx3g3fohXixPfOMYm6zCGs9LVo9MoW3MCJE7R5u/WsOIjrqBoHUO0bJE9vxBpbhsd3+Nb4/vtPCZ4oZYCitNeYuC/8UDvDvy0qvkiW/cgqNqRyzqSZa/s0mqNGjtKOoTm14zZpUauiQgVfqtQiZjq7Q27JNaSK5ExRcrGCXO1FJYh6jR6CFqK7bZdQZ4t8g0rSlPfP1RdBtqaa9diqtzJkQ9duSryi2brQXbxDwbRUpFMBHjRj8+Nt7GDKgvph9okW7LX47gu0SpGnnFQ1S1lYldOsC7hYteR574ZuKs7Ei1lBsfdz7IZoxzzCVmmVqaSySzQbBVAWDek+N4jh9E/4VqZrJjPwiv9BC1XcvOWgO8275CVyBPvAtTVlDJfZkaZGU7NpqBogAj/xEHkeAuJihWYCxGN6e8+9JtSegFXF1TrhhLGP1fak3pebgPz192/8gB4d/6WT7+GdYnpH7hH/DJzzFiYPn/vjW0SgNpTNuPIZoAEZv8tlGw4+RLxy+ZjnKa5NdFoC7UaW0aduoYse6+bXg1DLg6UfRYwmhGEjqPvF75U558SANrElK/+MdpXvmqBpaXOa/MTZaa1DOcSiLaw9j0NNNst3c+63c7EKTpkvKHzu6bPbP0RkuHAVcbRY8ijP46MIbQeeT1mhA+5PV/inyDdQipf8LTvMXbwvoDy7IruDNVZKTfV4CTSRUYdybUCnGU7KUTDxLgCknqUm5aAW6/1p6eMsOYsphLzsHrE0Y/P5bQedx1F/4yPHnMB3/IOoTU9+BL8PhtjuFKBpZXnYNJxTuv+2XqolKR2UQgHhS5novuxVySJhBNRF3SoKK1XZbbXjVwWNyOjlqWJjrWJIy+P5bQedyldNScP+HZ61xKSK3jyrz+NiHG1hcOLL/+P+PDF2gOkekKGiNWKgJ+8Z/x8Iv4DdQHzcpZyF4v19I27w9/yPGDFQvmEpKtqv/TLiWMfn4sofMm9eAH8Ao0zzh7h4sJqYtxZd5/D7hkYPneDzl5idlzNHcIB0jVlQ+8ULzw/nc5/ojzl2juE0apD7LRnJxe04dMz2iOCFNtGFpTuXA5AhcTRo8mdN4kz30nVjEC4YTZQy4gpC7GlTlrePKhGsKKgeXpCYeO0MAd/GH7yKQUlXPLOasOH3FnSphjHuDvEu4gB8g66oNbtr6eMbFIA4fIBJkgayoXriw2XEDQPJrQeROAlY6aeYOcMf+IVYTU3XFlZufMHinGywaW3YLpObVBAsbjF4QJMsVUSayjk4voPsHJOQfPWDhCgDnmDl6XIRerD24HsGtw86RMHOLvVSHrKBdeVE26gKB5NKHzaIwLOmrqBWJYZDLhASG16c0Tn+CdRhWDgWXnqRZUTnPIHuMJTfLVpkoYy5CzylHVTGZMTwkGAo2HBlkQplrJX6U+uF1wZz2uwS1SQ12IqWaPuO4baZaEFBdukksJmkcTOm+YJSvoqPFzxFA/YUhIvWxcmSdPWTWwbAKVp6rxTtPFUZfKIwpzm4IoMfaYQLWgmlG5FME2gdBgm+J7J+rtS/XBbaVLsR7bpPQnpMFlo2doWaVceHk9+MkyguZNCJ1He+kuHTWyQAzNM5YSUg/GlTk9ZunAsg1qELVOhUSAK0LABIJHLKbqaEbHZLL1VA3VgqoiOKXYiS+HRyaEKgsfIqX64HYWbLRXy/qWoylIV9gudL1OWBNgBgTNmxA6b4txDT4gi3Ri7xFSLxtXpmmYnzAcWDZgY8d503LFogz5sbonDgkKcxGsWsE1OI+rcQtlgBBCSOKD1mtqYpIU8cTvBmAT0yZe+zUzeY92fYjTtGipXLhuR0ePoHk0ofNWBX+lo8Z7pAZDk8mEw5L7dVyZZoE/pTewbI6SNbiAL5xeygW4xPRuLCGbhcO4RIeTMFYHEJkYyEO9HmJfXMDEj/LaH781wHHZEtqSQ/69UnGpzH7LKIAZEDSPJnTesJTUa+rwTepI9dLJEawYV+ZkRn9g+QirD8vF8Mq0jFQ29js6kCS3E1+jZIhgPNanHdHFqFvPJLHqFwQqbIA4jhDxcNsOCCQLDomaL/dr5lyJaJU6FxPFjO3JOh3kVMcROo8u+C+jo05GjMF3P3/FuDLn5x2M04xXULPwaS6hBYki+MrMdZJSgPHlcB7nCR5bJ9Kr5ACUn9jk5kivdd8tk95SOGrtqu9lr2IhK65ZtEl7ZKrp7DrqwZfRUSN1el7+7NJxZbywOC8neNKTch5vsTEMNsoCCqHBCqIPRjIPkm0BjvFODGtto99rCl+d3wmHkW0FPdpZtC7MMcVtGFQjJLX5bdQ2+x9ypdc313uj8xlsrfuLgWXz1cRhZvJYX0iNVBRcVcmCXZs6aEf3RQF2WI/TcCbKmGU3IOoDJGDdDub0+hYckt6PlGu2BcxmhbTdj/klhccLGJMcqRjMJP1jW2ETqLSWJ/29MAoORluJ+6LPffBZbi5gqi5h6catQpmOT7/OFf5UorRpLzCqcMltBLhwd1are3kztrSzXO0LUbXRQcdLh/RdSZ+swRm819REDrtqzC4es6Gw4JCKlSnjYVpo0xeq33PrADbFLL3RuCmObVmPN+24kfa+AojDuM4umKe2QwCf6EN906HwjujaitDs5o0s1y+k3lgbT2W2i7FJdnwbLXhJUBq/9liTctSmFC/0OqUinb0QddTWamtjbHRFuWJJ6NpqZ8vO3fZJ37Db+2GkaPYLGHs7XTTdiFQJ68SkVJFVmY6McR5UycflNCsccHFaV9FNbR4NttLxw4pQ7wJd066Z0ohVbzihaxHVExd/ay04oxUKWt+AsdiQ9OUyZ2krzN19IZIwafSTFgIBnMV73ADj7V/K8u1MaY2sJp2HWm0f41tqwajEvdHWOJs510MaAqN4aoSiPCXtN2KSi46dUxHdaMquar82O1x5jqhDGvqmoE9LfxcY3zqA7/x3HA67r9ZG4O6Cuxu12/+TP+eLP+I+HErqDDCDVmBDO4larujNe7x8om2rMug0MX0rL1+IWwdwfR+p1TNTyNmVJ85ljWzbWuGv8/C7HD/izjkHNZNYlhZcUOKVzKFUxsxxN/kax+8zPWPSFKw80rJr9Tizyj3o1gEsdwgWGoxPezDdZ1TSENE1dLdNvuKL+I84nxKesZgxXVA1VA1OcL49dFlpFV5yJMhzyCmNQ+a4BqusPJ2bB+xo8V9u3x48VVIEPS/mc3DvAbXyoYr6VgDfh5do5hhHOCXMqBZUPhWYbWZECwVJljLgMUWOCB4MUuMaxGNUQDVI50TQ+S3kFgIcu2qKkNSHVoM0SHsgoZxP2d5HH8B9woOk4x5bPkKtAHucZsdykjxuIpbUrSILgrT8G7G5oCW+K0990o7E3T6AdW4TilH5kDjds+H64kS0mz24grtwlzDHBJqI8YJQExotPvoC4JBq0lEjjQkyBZ8oH2LnRsQ4Hu1QsgDTJbO8fQDnllitkxuVskoiKbRF9VwzMDvxHAdwB7mD9yCplhHFEyUWHx3WtwCbSMMTCUCcEmSGlg4gTXkHpZXWQ7kpznK3EmCHiXInqndkQjunG5kxTKEeGye7jWz9cyMR2mGiFQ15ENRBTbCp+Gh86vAyASdgmJq2MC6hoADQ3GosP0QHbnMHjyBQvQqfhy/BUbeHd5WY/G/9LK/8Ka8Jd7UFeNWEZvzPb458Dn8DGLOe3/wGL/4xP+HXlRt+M1PE2iLhR8t+lfgxsuh7AfO2AOf+owWhSZRYQbd622hbpKWKuU+XuvNzP0OseRDa+mObgDHJUSc/pKx31QdKffQ5OIJpt8GWjlgTwMc/w5MPCR/yl1XC2a2Yut54SvOtMev55Of45BOat9aWG27p2ZVORRvnEk1hqWMVUmqa7S2YtvlIpspuF1pt0syuZS2NV14mUidCSfzQzg+KqvIYCMljIx2YK2AO34fX4GWdu5xcIAb8MzTw+j/lyWM+Dw/gjs4GD6ehNgA48kX/AI7XXM/XAN4WHr+9ntywqoCakCqmKP0rmQrJJEErG2Upg1JObr01lKQy4jskWalKYfJ/EDLMpjNSHFEUAde2fltaDgmrNaWQ9+AAb8I5vKjz3L1n1LriB/BXkG/wwR9y/oRX4LlioHA4LzP2inzRx/DWmutRweFjeP3tNeSGlaE1Fde0OS11yOpmbIp2u/jF1n2RRZviJM0yBT3IZl2HWImKjQOxIyeU325b/qWyU9Moj1o07tS0G7qJDoGHg5m8yeCxMoEH8GU45tnrNM84D2l297DQ9t1YP7jki/7RmutRweEA77/HWXOh3HCxkRgldDQkAjNTMl2Iloc1qN5JfJeeTlyTRzxURTdn1Ixv2uKjs12AbdEWlBtmVdk2k7FFwj07PCZ9XAwW3dG+8xKzNFr4EnwBZpy9Qzhh3jDXebBpYcpuo4fQ44u+fD1dweEnHzI7v0xuuOALRUV8rXpFyfSTQYkhd7IHm07jpyhlkCmI0ALYqPTpUxXS+z4jgDj1Pflvmz5ecuItpIBxyTHpSTGWd9g1ApfD/bvwUhL4nT1EzqgX7cxfCcNmb3mPL/qi9SwTHJ49oj5ZLjccbTG3pRmlYi6JCG0mQrAt1+i2UXTZ2dv9IlQpN5naMYtviaXlTrFpoMsl3bOAFEa8sqPj2WCMrx3Yjx99qFwO59Aw/wgx+HlqNz8oZvA3exRDvuhL1jMQHPaOJ0+XyA3fp1OfM3qObEVdhxjvynxNMXQV4+GJyvOEFqeQBaIbbO7i63rpxCltdZShPFxkjM2FPVkn3TG+Rp9pO3l2RzFegGfxGDHIAh8SteR0C4HopXzRF61nheDw6TFN05Ebvq8M3VKKpGjjO6r7nhudTEGMtYM92HTDaR1FDMXJ1eThsbKfywyoWwrzRSXkc51flG3vIid62h29bIcFbTGhfV+faaB+ohj7dPN0C2e2lC96+XouFByen9AsunLDJZ9z7NExiUc0OuoYW6UZkIyx2YUR2z6/TiRjyKMx5GbbjLHvHuf7YmtKghf34LJfx63Yg8vrvN2zC7lY0x0tvKezo4HmGYDU+Gab6dFL+KI761lDcNifcjLrrr9LWZJctG1FfU1uwhoQE22ObjdfkSzY63CbU5hzs21WeTddH2BaL11Gi7lVdlxP1nkxqhnKhVY6knS3EPgVGg1JpN5cP/hivujOelhXcPj8HC/LyI6MkteVjlolBdMmF3a3DbsuAYhL44dxzthWSN065xxUd55Lmf0wRbOYOqH09/o9WbO2VtFdaMb4qBgtFJoT1SqoN8wPXMoXLb3p1PUEhxfnnLzGzBI0Ku7FxrKsNJj/8bn/H8fPIVOd3rfrklUB/DOeO+nkghgSPzrlPxluCMtOnDL4Yml6dK1r3vsgMxgtPOrMFUZbEUbTdIzii5beq72G4PD0DKnwjmBULUVFmy8t+k7fZ3pKc0Q4UC6jpVRqS9Umv8bxw35flZVOU1X7qkjnhZlsMbk24qQ6Hz7QcuL6sDC0iHHki96Uh2UdvmgZnjIvExy2TeJdMDZNSbdZyAHe/Yd1xsQhHiKzjh7GxQ4yqMPaywPkjMamvqrYpmO7Knad+ZQC5msCuAPWUoxrxVhrGv7a+KLXFhyONdTMrZ7ke23qiO40ZJUyzgYyX5XyL0mV7NiUzEs9mjtbMN0dERqwyAJpigad0B3/zRV7s4PIfXSu6YV/MK7+OrYe/JvfGMn/PHJe2fyUdtnFrKRNpXV0Y2559aWPt/G4BlvjTMtXlVIWCnNyA3YQBDmYIodFz41PvXPSa6rq9lWZawZ4dP115HXV/M/tnFkkrBOdzg6aP4pID+MZnTJ1SuuB6iZlyiox4HT2y3YBtkUKWooacBQUDTpjwaDt5poBHl1/HXltwP887lKKXxNUEyPqpGTyA699UqY/lt9yGdlUKra0fFWS+36iylVWrAyd7Uw0CZM0z7xKTOduznLIjG2Hx8cDPLb+OvK6Bv7n1DYci4CxUuRxrjBc0bb4vD3rN5Zz36ntLb83eVJIB8LiIzCmn6SMPjlX+yNlTjvIGjs+QzHPf60Aj62/jrzG8j9vYMFtm1VoRWCJdmw7z9N0t+c8cxZpPeK4aTRicS25QhrVtUp7U578chk4q04Wx4YoQSjFryUlpcQ1AbxZ/XVMknIU//OGl7Q6z9Zpxi0+3yFhSkjUDpnCIUhLWVX23KQ+L9vKvFKI0ZWFQgkDLvBoylrHNVmaw10zwCPrr5tlodfnf94EWnQ0lFRWy8pW9LbkLsyUVDc2NSTHGDtnD1uMtchjbCeb1mpxFP0YbcClhzdLu6lfO8Bj6q+bdT2sz/+8SZCV7VIxtt0DUn9L7r4cLYWDSXnseEpOGFuty0qbOVlS7NNzs5FOGJUqQpl2Q64/yBpZf90sxbE+//PGdZ02HSipCbmD6NItmQ4Lk5XUrGpDMkhbMm2ZVheNYV+VbUWTcv99+2NyX1VoafSuC+AN6q9bFIMv5X/eagNWXZxEa9JjlMwNWb00akGUkSoepp1/yRuuqHGbUn3UdBSTxBU6SEVklzWRUkPndVvw2PrrpjvxOvzPmwHc0hpmq82npi7GRro8dXp0KXnUQmhZbRL7NEVp1uuZmO45vuzKsHrktS3GLWXODVjw+vXXLYx4Hf7njRPd0i3aoAGX6W29GnaV5YdyDj9TFkakje7GHYzDoObfddHtOSpoi2SmzJHrB3hM/XUDDEbxP2/oosszcRlehWXUvzHv4TpBVktHqwenFo8uLVmy4DKLa5d3RtLrmrM3aMFr1183E4sewf+85VWeg1c5ag276NZrM9IJVNcmLEvDNaV62aq+14IAOGFsBt973Ra8Xv11YzXwNfmft7Jg2oS+XOyoC8/cwzi66Dhmgk38kUmP1CUiYWOX1bpD2zWXt2FCp7uq8703APAa9dfNdscR/M/bZLIyouVxqJfeWvG9Je+JVckHQ9+CI9NWxz+blX/KYYvO5n2tAP/vrlZ7+8/h9y+9qeB/Hnt967e5mevX10rALDWK//FaAT5MXdBXdP0C/BAes792c40H+AiAp1e1oH8HgH94g/Lttx1gp63op1eyoM/Bvw5/G/7xFbqJPcCXnmBiwDPb/YKO4FX4OjyCb289db2/Noqicw4i7N6TVtoz8tNwDH+8x/i6Ae7lmaQVENzJFb3Di/BFeAwz+Is9SjeQySpPqbLFlNmyz47z5a/AF+AYFvDmHqibSXTEzoT4Gc3OALaqAP4KPFUJ6n+1x+rGAM6Zd78bgJ0a8QN4GU614vxwD9e1Amy6CcskNrczLx1JIp6HE5UZD/DBHrFr2oNlgG4Odv226BodoryjGJ9q2T/AR3vQrsOCS0ctXZi3ruLlhpFDJYl4HmYtjQCP9rhdn4suySLKDt6wLcC52h8xPlcjju1fn+yhuw4LZsAGUuo2b4Fx2UwQu77uqRHXGtg92aN3tQCbFexc0uk93vhTXbct6y7MulLycoUljx8ngDMBg1tvJjAazpEmOtxlzclvj1vQf1Tx7QlPDpGpqgtdSKz/d9/hdy1vTfFHSmC9dGDZbLiezz7Ac801HirGZsWjydfZyPvHXL/Y8Mjzg8BxTZiuwKz4Eb8sBE9zznszmjvFwHKPIWUnwhqfVRcd4Ck0K6ate48m1oOfrX3/yOtvAsJ8zsPAM89sjnddmuLuDPjX9Bu/L7x7xpMzFk6nWtyQfPg278Gn4Aekz2ZgOmU9eJ37R14vwE/BL8G3aibCiWMWWDQ0ZtkPMnlcGeAu/Ag+8ZyecU5BPuy2ILD+sQqyZhAKmn7XZd+jIMTN9eBL7x95xVLSX4On8EcNlXDqmBlqS13jG4LpmGbkF/0CnOi3H8ETOIXzmnmtb0a16Tzxj1sUvQCBiXZGDtmB3KAefPH94xcUa/6vwRn80GOFyjEXFpba4A1e8KQfFF+259tx5XS4egYn8fQsLGrqGrHbztr+uByTahWuL1NUGbDpsnrwBfePPwHHIf9X4RnM4Z2ABWdxUBlqQ2PwhuDxoS0vvqB1JzS0P4h2nA/QgTrsJFn+Y3AOjs9JFC07CGWX1oNX3T/yHOzgDjwPn1PM3g9Jk9lZrMEpxnlPmBbjyo2+KFXRU52TJM/2ALcY57RUzjObbjqxVw++4P6RAOf58pcVsw9Daje3htriYrpDOonre3CudSe6bfkTEgHBHuDiyu5MCsc7BHhYDx7ePxLjqigXZsw+ijMHFhuwBmtoTPtOxOrTvYJDnC75dnUbhfwu/ZW9AgYd+peL68HD+0emKquiXHhWjJg/UrkJYzuiaL3E9aI/ytrCvAd4GcYZMCkSQxfUg3v3j8c4e90j5ZTPdvmJJGHnOCI2nHS8081X013pHuBlV1gB2MX1YNmWLHqqGN/TWmG0y6clJWthxNUl48q38Bi8vtMKyzzpFdSDhxZ5WBA5ZLt8Jv3895DduBlgbPYAj8C4B8hO68FDkoh5lydC4FiWvBOVqjYdqjiLv92t8yPDjrDaiHdUD15qkSURSGmXJwOMSxWAXYwr3zaAufJ66l+94vv3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/wHuD9tQd4f+0B3l97gPfXHuD9tQd4f+0B3l97gG8LwP8G/AL8O/A5OCq0Ys2KIdv/qOIXG/4mvFAMF16gZD+2Xvu/B8as5+8bfllWyg0zaNO5bfXj6vfhhwD86/Aq3NfRS9t9WPnhfnvCIw/CT8GLcFTMnpntdF/z9V+PWc/vWoIH+FL3Znv57PitcdGP4R/C34avw5fgRVUInCwbsn1yyA8C8zm/BH8NXoXnVE6wVPjdeCI38kX/3+Ct9dbz1pTmHFRu+Hm4O9Ch3clr99negxfwj+ER/DR8EV6B5+DuQOnTgUw5rnkY+FbNU3gNXh0o/JYTuWOvyBf9FvzX663HH/HejO8LwAl8Hl5YLTd8q7sqA3wbjuExfAFegQdwfyDoSkWY8swzEf6o4Qyewefg+cHNbqMQruSL/u/WWc+E5g7vnnEXgDmcDeSGb/F4cBcCgT+GGRzDU3hZYburAt9TEtHgbM6JoxJ+6NMzzTcf6c2bycv2+KK/f+l6LBzw5IwfqZJhA3M472pWT/ajKxnjv4AFnMEpnBTPND6s2J7qHbPAqcMK74T2mZ4VGB9uJA465It+/eL1WKhYOD7xHOkr1ajK7d0C4+ke4Hy9qXZwpgLr+Znm/uNFw8xQOSy8H9IzjUrd9+BIfenYaylf9FsXr8fBAadnPIEDna8IBcwlxnuA0/Wv6GAWPd7dDIKjMdSWueAsBj4M7TOd06qBbwDwKr7oleuxMOEcTuEZTHWvDYUO7aHqAe0Bbq+HEFRzOz7WVoTDQkVds7A4sIIxfCQdCefFRoIOF/NFL1mPab/nvOakSL/Q1aFtNpUb/nFOVX6gzyg/1nISyDfUhsokIzaBR9Kxm80s5mK+6P56il1jXic7nhQxsxSm3OwBHl4fFdLqi64nDQZvqE2at7cWAp/IVvrN6/BFL1mPhYrGMBfOi4PyjuSGf6wBBh7p/FZTghCNWGgMzlBbrNJoPJX2mW5mwZfyRffXo7OFi5pZcS4qZUrlViptrXtw+GQoyhDPS+ANjcGBNRiLCQDPZPMHuiZfdFpPSTcQwwKYdRNqpkjm7AFeeT0pJzALgo7g8YYGrMHS0iocy+YTm2vyRUvvpXCIpQ5pe666TJrcygnScUf/p0NDs/iAI/nqDHC8TmQT8x3NF91l76oDdQGwu61Z6E0ABv7uO1dbf/37Zlv+Zw/Pbh8f1s4Avur6657/+YYBvur6657/+YYBvur6657/+YYBvur6657/+aYBvuL6657/+VMA8FXWX/f8zzcN8BXXX/f8zzcNMFdbf93zP38KLPiK6697/uebtuArrr/u+Z9vGmCusP6653/+1FjwVdZf9/zPN7oHX339dc//fNMu+irrr3v+50+Bi+Zq6697/uebA/jz8Pudf9ht/fWv517J/XUzAP8C/BAeX9WCDrUpZ3/dEMBxgPcfbtTVvsYV5Yn32u03B3Ac4P3b8I+vxNBKeeL9dRMAlwO83959qGO78sT769oB7g3w/vGVYFzKE++v6wV4OMD7F7tckFkmT7y/rhHgpQO8b+4Y46XyxPvrugBeNcB7BRiX8sT767oAvmCA9woAHsoT76+rBJjLBnh3txOvkifeX1dswZcO8G6N7sXyxPvr6i340gHe3TnqVfLE++uKAb50gHcXLnrX8sR7gNdPRqwzwLu7Y/FO5Yn3AK9jXCMGeHdgxDuVJ75VAI8ljP7PAb3/RfjcZfePHBB+79dpfpH1CanN30d+mT1h9GqAxxJGM5LQeeQ1+Tb+EQJrElLb38VHQ94TRq900aMIo8cSOo+8Dp8QfsB8zpqE1NO3OI9Zrj1h9EV78PqE0WMJnUdeU6E+Jjyk/hbrEFIfeWbvId8H9oTRFwdZaxJGvziW0Hn0gqYB/wyZ0PwRlxJST+BOw9m77Amj14ii1yGM/txYQudN0qDzGe4EqfA/5GJCagsHcPaEPWH0esekSwmjRxM6b5JEcZ4ww50ilvAOFxBSx4yLW+A/YU8YvfY5+ALC6NGEzhtmyZoFZoarwBLeZxUhtY4rc3bKnjB6TKJjFUHzJoTOozF2YBpsjcyxDgzhQ1YRUse8+J4wenwmaylB82hC5w0zoRXUNXaRBmSMQUqiWSWkLsaVqc/ZE0aPTFUuJWgeTei8SfLZQeMxNaZSIzbII4aE1Nmr13P2hNHjc9E9guYNCZ032YlNwESMLcZiLQHkE4aE1BFg0yAR4z1h9AiAGRA0jyZ03tyIxWMajMPWBIsxYJCnlITU5ShiHYdZ94TR4wCmSxg9jtB5KyPGYzymAYexWEMwAPIsAdYdV6aObmNPGD0aYLoEzaMJnTc0Ygs+YDw0GAtqxBjkuP38bMRWCHn73xNGjz75P73WenCEJnhwyVe3AEe8TtKdJcYhBl97wuhNAObK66lvD/9J9NS75v17wuitAN5fe4D31x7g/bUHeH/tAd5fe4D3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/w/toDvAd4f/24ABzZ8o+KLsSLS+Pv/TqTb3P4hKlQrTGh+fbIBT0Axqznnb+L/V2mb3HkN5Mb/nEHeK7d4IcDld6lmDW/iH9E+AH1MdOw/Jlu2T1xNmY98sv4wHnD7D3uNHu54WUuOsBTbQuvBsPT/UfzNxGYzwkP8c+Yz3C+r/i6DcyRL/rZ+utRwWH5PmfvcvYEt9jLDS/bg0/B64DWKrQM8AL8FPwS9beQCe6EMKNZYJol37jBMy35otdaz0Bw2H/C2Smc7+WGB0HWDELBmOByA3r5QONo4V+DpzR/hFS4U8wMW1PXNB4TOqYz9urxRV++ntWCw/U59Ty9ebdWbrgfRS9AYKKN63ZokZVygr8GZ/gfIhZXIXPsAlNjPOLBby5c1eOLvmQ9lwkOy5x6QV1j5TYqpS05JtUgUHUp5toHGsVfn4NX4RnMCe+AxTpwmApTYxqMxwfCeJGjpXzRF61nbcHhUBPqWze9svwcHJ+S6NPscKrEjug78Dx8Lj3T8D4YxGIdxmJcwhi34fzZUr7olevZCw5vkOhoClq5zBPZAnygD/Tl9EzDh6kl3VhsHYcDEb+hCtJSvuiV69kLDm+WycrOTArHmB5/VYyP6jOVjwgGawk2zQOaTcc1L+aLXrKeveDwZqlKrw8U9Y1p66uK8dEzdYwBeUQAY7DbyYNezBfdWQ97weEtAKYQg2xJIkuveAT3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII=`}_getSearchTexture(){return`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=`}},GF={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`\n precision highp float;\n\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }`,fragmentShader:`\n\n precision highp float;\n\n uniform sampler2D tDiffuse;\n\n #include <tonemapping_pars_fragment>\n #include <colorspace_pars_fragment>\n\n varying vec2 vUv;\n\n void main() {\n\n gl_FragColor = texture2D( tDiffuse, vUv );\n\n // tone mapping\n\n #ifdef LINEAR_TONE_MAPPING\n\n gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\n #elif defined( REINHARD_TONE_MAPPING )\n\n gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\n #elif defined( CINEON_TONE_MAPPING )\n\n gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\n #elif defined( ACES_FILMIC_TONE_MAPPING )\n\n gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\n #elif defined( AGX_TONE_MAPPING )\n\n gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\n #elif defined( NEUTRAL_TONE_MAPPING )\n\n gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\n #elif defined( CUSTOM_TONE_MAPPING )\n\n gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\n #endif\n\n // color space\n\n #ifdef SRGB_TRANSFER\n\n gl_FragColor = sRGBTransferOETF( gl_FragColor );\n\n #endif\n\n }`},KF=class extends SF{constructor(){super(),this.isOutputPass=!0,this.uniforms=_S.clone(GF.uniforms),this.material=new xS({name:GF.name,uniforms:this.uniforms,vertexShader:GF.vertexShader,fragmentShader:GF.fragmentShader}),this._fsQuad=new TF(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},Lv.getTransfer(this._outputColorSpace)===`srgb`&&(this.material.defines.SRGB_TRANSFER=``),this._toneMapping===1?this.material.defines.LINEAR_TONE_MAPPING=``:this._toneMapping===2?this.material.defines.REINHARD_TONE_MAPPING=``:this._toneMapping===3?this.material.defines.CINEON_TONE_MAPPING=``:this._toneMapping===4?this.material.defines.ACES_FILMIC_TONE_MAPPING=``:this._toneMapping===6?this.material.defines.AGX_TONE_MAPPING=``:this._toneMapping===7?this.material.defines.NEUTRAL_TONE_MAPPING=``:this._toneMapping===5&&(this.material.defines.CUSTOM_TONE_MAPPING=``),this.material.needsUpdate=!0),this.renderToScreen===!0?(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()}},qF={name:`LuminosityHighPassShader`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new Q(0)},defaultOpacity:{value:0}},vertexShader:`\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }`,fragmentShader:`\n\n uniform sampler2D tDiffuse;\n uniform vec3 defaultColor;\n uniform float defaultOpacity;\n uniform float luminosityThreshold;\n uniform float smoothWidth;\n\n varying vec2 vUv;\n\n void main() {\n\n vec4 texel = texture2D( tDiffuse, vUv );\n\n float v = luminance( texel.xyz );\n\n vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );\n\n float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );\n\n gl_FragColor = mix( outputColor, texel, alpha );\n\n }`},JF=class e extends SF{constructor(e,t=1,n,r){super(),this.strength=t,this.radius=n,this.threshold=r,this.resolution=e===void 0?new X(256,256):new X(e.x,e.y),this.clearColor=new Q(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new Xv(i,a,{type:kg,depthBuffer:!1}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){let t=new Xv(i,a,{type:kg,depthBuffer:!1});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);let n=new Xv(i,a,{type:kg,depthBuffer:!1});n.texture.name=`UnrealBloomPass.v`+e,n.texture.generateMipmaps=!1,this.renderTargetsVertical.push(n),i=Math.round(i/2),a=Math.round(a/2)}let o=qF;this.highPassUniforms=_S.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new bS({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];let s=[6,10,14,18,22];i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(s[e])),this.separableBlurMaterials[e].uniforms.invSize.value=new X(1/i,1/a),i=Math.round(i/2),a=Math.round(a/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;let c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new Z(1,1,1),new Z(1,1,1),new Z(1,1,1),new Z(1,1,1),new Z(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=_S.clone(xF.uniforms),this.blendMaterial=new bS({uniforms:this.copyUniforms,vertexShader:xF.vertexShader,fragmentShader:xF.fragmentShader,premultipliedAlpha:!0,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new Q,this._oldClearAlpha=1,this._basic=new fx,this._fsQuad=new TF(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(n,r);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(n,r),this.renderTargetsVertical[e].setSize(n,r),this.separableBlurMaterials[e].uniforms.invSize.value=new X(1/n,1/r),n=Math.round(n/2),r=Math.round(r/2)}render(t,n,r,i,a){t.getClearColor(this._oldClearColor),this._oldClearAlpha=t.getClearAlpha();let o=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),a&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=r.texture,t.setRenderTarget(null),t.clear(),this._fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this._fsQuad.render(t);let s=this.renderTargetBright;for(let n=0;n<this.nMips;n++)this._fsQuad.material=this.separableBlurMaterials[n],this.separableBlurMaterials[n].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[n]),t.clear(),this._fsQuad.render(t),this.separableBlurMaterials[n].uniforms.colorTexture.value=this.renderTargetsHorizontal[n].texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[n]),t.clear(),this._fsQuad.render(t),s=this.renderTargetsVertical[n];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this._fsQuad.render(t),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(r),this._fsQuad.render(t)),t.setClearColor(this._oldClearColor,this._oldClearAlpha),t.autoClear=o}_getSeparableBlurMaterial(e){let t=[],n=e/3;for(let r=0;r<e;r++)t.push(.39894*Math.exp(-.5*r*r/(n*n))/n);let r=[],i=[];for(let n=1;n<e;n+=2){let a=t[n],o=n+1<e?t[n+1]:0,s=a+o;r.push((n*a+(n+1)*o)/s),i.push(s)}return new bS({defines:{KERNEL_PAIRS:r.length},uniforms:{colorTexture:{value:null},invSize:{value:new X(.5,.5)},direction:{value:new X(.5,.5)},centerWeight:{value:t[0]},gaussianOffsets:{value:r},gaussianWeights:{value:i}},vertexShader:`\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }`,fragmentShader:`\n\n #include <common>\n\n varying vec2 vUv;\n\n uniform sampler2D colorTexture;\n uniform vec2 invSize;\n uniform vec2 direction;\n uniform float centerWeight;\n uniform float gaussianOffsets[KERNEL_PAIRS];\n uniform float gaussianWeights[KERNEL_PAIRS];\n\n void main() {\n\n vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * centerWeight;\n\n for ( int i = 0; i < KERNEL_PAIRS; i ++ ) {\n\n vec2 uvOffset = direction * invSize * gaussianOffsets[ i ];\n vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n diffuseSum += ( sample1 + sample2 ) * gaussianWeights[ i ];\n\n }\n\n gl_FragColor = vec4( diffuseSum, 1.0 );\n\n }`})}_getCompositeMaterial(e){return new bS({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }`,fragmentShader:`\n\n varying vec2 vUv;\n\n uniform sampler2D blurTexture1;\n uniform sampler2D blurTexture2;\n uniform sampler2D blurTexture3;\n uniform sampler2D blurTexture4;\n uniform sampler2D blurTexture5;\n uniform float bloomStrength;\n uniform float bloomRadius;\n uniform float bloomFactors[NUM_MIPS];\n uniform vec3 bloomTintColors[NUM_MIPS];\n\n float lerpBloomFactor( const in float factor ) {\n\n float mirrorFactor = 1.2 - factor;\n return mix( factor, mirrorFactor, bloomRadius );\n\n }\n\n void main() {\n\n // 3.0 for backwards compatibility with previous alpha-based intensity\n vec3 bloom = 3.0 * bloomStrength * (\n lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +\n lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +\n lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +\n lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +\n lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb\n );\n\n float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );\n gl_FragColor = vec4( bloom, bloomAlpha );\n\n }`})}};JF.BlurDirectionX=new X(1,0),JF.BlurDirectionY=new X(0,1);var YF={type:`change`},XF={type:`start`},ZF={type:`end`},QF=new dx,$F=new Hb,eI=Math.cos(70*Ov.DEG2RAD),tI=new Z,nI=2*Math.PI,rI={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},iI=1e-6,aI=class extends rw{constructor(e,t=null){super(e,t),this.state=rI.NONE,this.target=new Z,this.cursor=new Z,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:dg.ROTATE,MIDDLE:dg.DOLLY,RIGHT:dg.PAN},this.touches={ONE:fg.ROTATE,TWO:fg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle=`auto`,this._domElementKeyEvents=null,this._lastPosition=new Z,this._lastQuaternion=new kv,this._lastTargetPosition=new Z,this._quat=new kv().setFromUnitVectors(e.up,new Z(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new JC,this._sphericalDelta=new JC,this._scale=1,this._panOffset=new Z,this._rotateStart=new X,this._rotateEnd=new X,this._rotateDelta=new X,this._panStart=new X,this._panEnd=new X,this._panDelta=new X,this._dollyStart=new X,this._dollyEnd=new X,this._dollyDelta=new X,this._dollyDirection=new Z,this._mouse=new X,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=sI.bind(this),this._onPointerDown=oI.bind(this),this._onPointerUp=cI.bind(this),this._onContextMenu=hI.bind(this),this._onMouseWheel=dI.bind(this),this._onKeyDown=fI.bind(this),this._onTouchStart=pI.bind(this),this._onTouchMove=mI.bind(this),this._onMouseDown=lI.bind(this),this._onMouseMove=uI.bind(this),this._interceptControlDown=gI.bind(this),this._interceptControlUp=_I.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e===`grab`?this.domElement.style.cursor=`grab`:this.domElement.style.cursor=`auto`}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerUp),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.ownerDocument.addEventListener(`keydown`,this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction=`none`}disconnect(){this.state=rI.NONE,this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerUp),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.ownerDocument.removeEventListener(`keydown`,this._interceptControlDown,{capture:!0}),this.domElement.ownerDocument.removeEventListener(`keyup`,this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction=``,this.domElement.style.cursor=`auto`}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(YF),this.update(),this.state=rI.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;tI.copy(t).sub(this.target),tI.applyQuaternion(this._quat),this._spherical.setFromVector3(tI),this.autoRotate&&this.state===rI.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=nI:n>Math.PI&&(n-=nI),r<-Math.PI?r+=nI:r>Math.PI&&(r-=nI),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(tI.setFromSpherical(this._spherical),tI.applyQuaternion(this._quatInverse),t.copy(this.target).add(tI),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=tI.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 Z(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 Z(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=tI.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):(QF.origin.copy(this.object.position),QF.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(QF.direction))<eI?this.object.lookAt(this.target):($F.setFromNormalAndCoplanarPoint(this.object.up,this.target),QF.intersectPlane($F,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>iI||8*(1-this._lastQuaternion.dot(this.object.quaternion))>iI||this._lastTargetPosition.distanceToSquared(this.target)>iI?(this.dispatchEvent(YF),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?nI/60/60*this.autoRotateSpeed:nI/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){tI.setFromMatrixColumn(t,0),tI.multiplyScalar(-e),this._panOffset.add(tI)}_panUp(e,t){this.screenSpacePanning===!0?tI.setFromMatrixColumn(t,1):(tI.setFromMatrixColumn(t,0),tI.crossVectors(this.object.up,tI)),tI.multiplyScalar(e),this._panOffset.add(tI)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;tI.copy(r).sub(this.target);let i=tI.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.clientY),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(nI*this._rotateDelta.x/t.clientHeight),this._rotateUp(nI*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.zoomToCursor&&(this._performCursorZoom=!0,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()),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(nI*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(-nI*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(nI*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(-nI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(nI*this._rotateDelta.x/t.clientHeight),this._rotateUp(nI*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new X,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function oI(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e),this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grabbing`)))}function sI(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function cI(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.dispatchEvent(ZF),this.state=rI.NONE,this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grab`);break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y})}}function lI(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case dg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=rI.DOLLY;break;case dg.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=rI.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=rI.ROTATE}break;case dg.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=rI.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=rI.PAN}break;default:this.state=rI.NONE}this.state!==rI.NONE&&this.dispatchEvent(XF)}function uI(e){switch(this.state){case rI.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case rI.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case rI.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e)}}function dI(e){this.enabled!==!1&&this.enableZoom!==!1&&this.state===rI.NONE&&(e.preventDefault(),this.dispatchEvent(XF),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(ZF))}function fI(e){this.enabled!==!1&&this._handleKeyDown(e)}function pI(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case fg.ROTATE:if(this.enableRotate===!1){this.state=rI.NONE;break}this._handleTouchStartRotate(e),this.state=rI.TOUCH_ROTATE;break;case fg.PAN:if(this.enablePan===!1){this.state=rI.NONE;break}this._handleTouchStartPan(e),this.state=rI.TOUCH_PAN;break;default:this.state=rI.NONE}break;case 2:switch(this.touches.TWO){case fg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=rI.TOUCH_DOLLY_PAN;break;case fg.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=rI.TOUCH_DOLLY_ROTATE;break;default:this.state=rI.NONE}break;default:this.state=rI.NONE}this.state!==rI.NONE&&this.dispatchEvent(XF)}function mI(e){switch(this._trackPointer(e),this.state){case rI.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case rI.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case rI.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case rI.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=rI.NONE}}function hI(e){this.enabled!==!1&&e.preventDefault()}function gI(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.ownerDocument.addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function _I(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.ownerDocument.removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var vI=class extends nC{constructor(e){super(e),this.type=kg}parse(e){let t=function(e,t){switch(e){case 1:throw Error(`THREE.HDRLoader: Read Error: `+(t||``));case 2:throw Error(`THREE.HDRLoader: Write Error: `+(t||``));case 3:throw Error(`THREE.HDRLoader: Bad File Format: `+(t||``));default:case 4:throw Error(`THREE.HDRLoader: Memory Error: `+(t||``))}},n=function(e,t,n){t||=1024;let r=e.pos,i=-1,a=0,o=``,s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));for(;0>(i=s.indexOf(`\n`))&&a<t&&r<e.byteLength;)o+=s,a+=s.length,r+=128,s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=a+i+1),o+s.slice(0,i))},r=function(e){let r=/^#\\?(\\S+)/,i=/^\\s*GAMMA\\s*=\\s*(\\d+(\\.\\d+)?)\\s*$/,a=/^\\s*EXPOSURE\\s*=\\s*(\\d+(\\.\\d+)?)\\s*$/,o=/^\\s*FORMAT=(\\S+)\\s*$/,s=/^\\s*\\-Y\\s+(\\d+)\\s+\\+X\\s+(\\d+)\\s*$/,c={valid:0,string:``,comments:``,programtype:`RGBE`,format:``,gamma:1,exposure:1,width:0,height:0},l,u;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,`no header found`),(u=l.match(r))||t(3,`bad initial token`),c.valid|=1,c.programtype=u[1],c.string+=l+`\n`;l=n(e),!1!==l;)if(c.string+=l+`\n`,l.charAt(0)===`#`)c.comments+=l+`\n`;else if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break;return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&s<e.byteLength;){s+4>e.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n<c&&s<e.byteLength;){r=e[s++];let i=r>128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e<r;e++)u[n++]=t}else u.set(e.subarray(s,s+r),n),n+=r,s+=r}let f=i;for(let e=0;e<f;e++){let t=0;a[o]=u[e+t],t+=i,a[o+1]=u[e+t],t+=i,a[o+2]=u[e+t],t+=i,a[o+3]=u[e+t],o+=4}d--}return a},a=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=e[t+0]*i,n[r+1]=e[t+1]*i,n[r+2]=e[t+2]*i,n[r+3]=1},o=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=hb.toHalfFloat(Math.min(e[t+0]*i,65504)),n[r+1]=hb.toHalfFloat(Math.min(e[t+1]*i,65504)),n[r+2]=hb.toHalfFloat(Math.min(e[t+2]*i,65504)),n[r+3]=hb.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let c=r(s),l=c.width,u=c.height,d=i(s.subarray(s.pos),l,u),f,p,m;switch(this.type){case Og:m=d.length/4;let e=new Float32Array(m*4);for(let t=0;t<m;t++)a(d,t*4,e,t*4);f=e,p=Og;break;case kg:m=d.length/4;let t=new Uint16Array(m*4);for(let e=0;e<m;e++)o(d,e*4,t,e*4);f=t,p=kg;break;default:throw Error(`THREE.HDRLoader: Unsupported type: `+this.type)}return{width:l,height:u,data:f,header:c.string,gamma:c.gamma,exposure:c.exposure,type:p,colorSpace:I_,minFilter:yg,magFilter:yg,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}},yI=`user`,bI=`app:`;function xI(e){return`${bI}${e}`}function SI(e){return typeof e!=`string`||!e.startsWith(bI)?null:e.slice(4)||null}function CI(e){let t=e.userData?.source;return t===`user`||SI(t)!==null}function wI(e,t){return t===void 0?CI(e):e.userData?.source===xI(t)}var TI=2.5,EI=11,DI=4.5,OI=3.5,kI=.05,AI=.06,jI=.65,MI=.8,NI=10;function PI(e,t,n,r){let i=new wx(new lS(t,n),new fx({color:new Q().setScalar(e),side:2}));return i.position.set(...r),i.lookAt(0,0,0),i}function FI(){let e=new Fy,t=new wx(II(),new fx({vertexColors:!0,side:1})),n=new wx(new lS(NI,NI),new fx({color:new Q().setScalar(kI)}));return n.rotation.x=-Math.PI/2,n.position.y=-4,e.add(t,n,PI(TI,6.5,4.5,[0,4.8,.6]),PI(EI,1.4,5.5,[-4.7,.8,1.6]),PI(DI,.9,5,[4.7,.5,2.4]),PI(OI,5,.8,[.6,2.2,-4.7])),e}function II(){let e=new nS(NI,NI,NI,1,16,1),t=e.attributes.position,n=new Float32Array(t.count*3);for(let e=0;e<t.count;e++){let r=t.getY(e)/(NI/2),i=r<0?Ov.lerp(jI,AI,-r):Ov.lerp(jI,MI,r);n.fill(i,e*3,e*3+3)}return e.setAttribute(`color`,new yb(n,3)),e}function LI(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}var RI=.5,zI=.03,BI=`selvaReflectionEnvironment`;function VI(e,t,n){let r=new Dw(t),i=FI(),a=r.fromScene(i,zI).texture;LI(i),r.dispose(),HI(e,a,n)}function HI(e,t,n){let r={texture:t,rotation:n.clone()};e.userData[BI]=r,WI(e,e)}function UI(e){e.userData[BI]?.texture.dispose(),delete e.userData[BI]}function WI(e,t){let n=t.userData[BI];n&&e.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r){if(!(e instanceof SS)||e.envMap&&e.envMap!==n.texture)continue;let t=e.metalness>RI?n.texture:null;e.envMap!==t&&(e.envMap=t,e.envMapRotation.copy(n.rotation),e.needsUpdate=!0)}})}function GI(e){let t=e.clone().normalize(),n=new Z(0,0,1),r=new Z(0,1,0),i=Math.abs(t.dot(n))>.9?r:n,a=new Z().crossVectors(i,t).normalize();return{up:t,forward:new Z().crossVectors(t,a).normalize(),right:a}}function KI(e,t){let{forward:n,right:r,up:i}=GI(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function qI(e,t,n){let{forward:r,right:i,up:a}=GI(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function JI(e){let t=e.clone().normalize(),n=new Z(0,1,0);if(t.dot(n)>.9999)return new ly;if(t.dot(n)<-.9999)return new ly(Math.PI,0,0);let r=new kv().setFromUnitVectors(n,t);return new ly().setFromQuaternion(r)}function YI(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}var XI=new Z(0,0,1);function ZI(){return(window.matchMedia?.(`(pointer: coarse)`).matches??!1)&&Math.min(window.screen.width,window.screen.height)<600}function QI(e){let t=e.sceneScale||`m`,n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],r=e.look??`technical`,i=e.render?.lowPower??ZI(),a=SD(r,i);return{sceneScale:t,look:r,camera:{position:e.camera?.position||KI(e.environment?.sceneUp??XI,n.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new Z(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||qI(e.environment?.sceneUp??XI,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new Q(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath===!1?!1:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new Q(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||XI,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new Q(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||1024,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,lowPower:i,idleRefineFrames:e.render?.idleRefineFrames??(i?0:32),lightOrbitFrameMs:e.render?.lightOrbitFrameMs??22,ambientOcclusion:e.render?.ambientOcclusion??a.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,bloom:e.render?.bloom??a.bloom,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??YI(e.environment?.sceneUp??XI)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,maxOverlays:e.edges?.maxOverlays,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||`#ff0000`,enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}var $I=150,eL=8,tL=12;function nL(e,t){let n=0,r=1/t;for(let i=e;i>0;i=Math.floor(i/t))n+=i%t*r,r/=t;return n}function rL(e){let t=0;return e.traverseVisible(e=>{t+=1;let{material:n}=e;for(let e of Array.isArray(n)?n:n?[n]:[])t+=e.version*31}),t}function iL(e){let{scene:t,renderer:n,getPipeline:r,frames:i,lightOrbitFrameMs:a,jitterLights:o,restoreLights:s}=e,c=0,l=0,u=0,d=new X,f=i>0&&a<=0,p=1,m=[],h=e=>{p=Math.min(1,Math.max(0,e)),r()?.setAoWeight(p)},g=e=>{m.push(e),!(m.length<tL)&&(m.sort((e,t)=>e-t),f=m[6]>a,m.length=0)},_=(e,t)=>{let r=e;if(!r.setViewOffset)return;n.getDrawingBufferSize(d);let i=t?nL(t,2)-.5:0,a=t?nL(t,3)-.5:0;r.setViewOffset(d.x,d.y,i,a,d.x,d.y)};return{reset:e=>{c=0,l=e},moving:e=>{i!==0&&(f?h(p-1/eL):g(e))},wants:e=>(c<i||p<1)&&e-l>=$I&&!!r(),step:e=>{let n=r();n&&(p<1?(h(p+1/eL),n.setCamera(e),n.accumulate(0)):(c>0&&o(c),_(e,c),n.setCamera(e),n.accumulate(c),e.clearViewOffset?.(),c>0&&s(),c+=1,c===i&&(u=rL(t))))},present:()=>i===0||c<i?!1:(r()?.presentAccumulated(),!!r()),isHolding:()=>i>0&&c>=i&&!!r()&&u===rL(t)}}var aL=.02,oL=6,sL=.62,cL=.018,lL=`sun-target`;function uL(e,t){let n=new CC(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(n);let r=null;if(t.lighting.enableHemisphereLight){r=new aC(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let n=t.environment.sceneUp??XI;r.position.copy(n),e.add(r)}if(!t.lighting.enableSunlight)return{ambient:n,hemisphere:r,sun:null};let i=new SC(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),a=t.lighting.sunlightPosition;return a&&i.position.set(a.x,a.y,a.z),t.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=t.render.shadowMapSize,i.shadow.mapSize.height=t.render.shadowMapSize,i.shadow.bias=-1e-4,i.shadow.normalBias=aL,i.shadow.radius=oL,i.shadow.blurSamples=12,i.shadow.intensity=sL,e.add(i),i.target.userData.id=lL,e.add(i.target),{ambient:n,hemisphere:r,sun:i}):(e.add(i),{ambient:n,hemisphere:r,sun:null})}function dL(e,t){let n=e.position.clone(),r=n.clone().sub(e.target.position),i=new Z(0,0,1).cross(r);i.lengthSq()===0&&i.set(1,0,0),i.setLength(r.length()*cL);let a=r.clone().cross(i).setLength(i.length()),o=nL(t,2)*Math.PI*2,s=Math.sqrt(nL(t,3));return e.position.addScaledVector(i,Math.cos(o)*s).addScaledVector(a,Math.sin(o)*s),()=>e.position.copy(n)}function fL(e,t){if(t.isEmpty())return;let n=t.getCenter(new Z),r=t.getSize(new Z).length()*.5*1.2;if(r===0)return;e.shadow.normalBias=Math.min(aL,r*.0015);let i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r;let a=e.position.clone().sub(e.target.position).normalize();e.target.position.copy(n),e.target.updateMatrixWorld();let o=r*2;e.position.copy(n).addScaledVector(a,o),e.updateMatrixWorld(),i.near=o-r,i.far=o+r,i.updateProjectionMatrix()}var pL={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function mL(e,t,n,r,i){if(xL(e,yL(t)),t.length===0)return;t.forEach(t=>{e.add(t),WI(t,e)});let a=AD(t),o=a.getCenter(new Z),s=a.getSize(new Z),c=Math.max(s.x,s.y,s.z);if(c/Math.min(s.x||1,s.y||1,s.z||1)>pL.SCALE_RATIO_THRESHOLD||c>pL.HUGE_THRESHOLD?(n.near=c*pL.NEAR_PLANE_FACTOR.TINY,n.far=c*pL.FAR_PLANE_FACTOR.HUGE):c>pL.LARGE_THRESHOLD?(n.near=c*pL.NEAR_PLANE_FACTOR.SMALL,n.far=c*pL.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*pL.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*pL.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),!i){let e=c*pL.INITIAL_DISTANCE_MULTIPLIER;n.position.copy(o).add(KI(n.up,e)),r.target.copy(o),r.update()}}var hL=new Set([`grid`,`floor`,`label-layer`,`measure`,lL]);function gL(e){return typeof e.userData.id==`string`&&hL.has(e.userData.id)}function _L(e){let t=e;for(;t;){if(gL(t))return!0;t=t.parent}return!1}function vL(e){e.updateMatrixWorld(!0);let t=new Xy;return e.traverse(e=>{let n=e;e.visible&&!_L(e)&&n.geometry&&t.expandByObject(e)}),t}function yL(e){let t=new Set;for(let n of e)n.traverse(e=>{let n=e.geometry,r=n&&ug(n);r&&t.add(r)});return t}var bL=new Set([`floor`,`grid`,`label-layer`,lL]);function xL(e,t=new Set){let n=[],r=[];for(let t of e.children)t.isLight===!0||bL.has(t.userData.id)||CI(t)?n.push(t):r.push(t);e.children.length=0;for(let t of n)e.children.push(t);for(let n of r)BD(n,{keepUploaded:t}),n.parent=null,n.dispatchEvent({type:`removed`}),e.dispatchEvent({type:`childremoved`,child:n})}function SL(e){let{up:t,forward:n,right:r}=GI(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function CL(e){let{scene:t,perspective:n,controls:r,onActiveCameraChange:i}=e,a=(e.up??n.up).clone().normalize(),o=SL(a),s=new bC(-1,1,1,-1,n.near,n.far);s.up.copy(a);let c=`perspective`,l=n.aspect,u=()=>c===`perspective`?n:s,d=null,f=()=>{d?.cancel(),d=null},p=()=>{let e=(c===`orthographic`?s:n).position.distanceTo(r.target)*Math.tan(n.fov*Math.PI/360),t=e*l;s.left=-t,s.right=t,s.top=e,s.bottom=-e,s.near=n.near,s.far=n.far,s.updateProjectionMatrix()},m=e=>{if(e!==c){if(f(),e===`orthographic`)s.position.copy(n.position),s.up.copy(n.up),s.lookAt(r.target),s.zoom=1,p();else{let e=(s.top-s.bottom)/(2*s.zoom)/Math.tan(n.fov*Math.PI/360),t=s.position.clone().sub(r.target);t.lengthSq()<1e-12&&t.copy(a),t.normalize(),n.position.copy(r.target).add(t.multiplyScalar(e))}c=e,r.object=u(),r.update(),i(u())}},h=(e,t,i,o)=>{let l=n.fov*(Math.PI/180),m=t/(2*Math.tan(l/2))*1.5,h=wL(i,a),g=e.clone().add(h.clone().multiplyScalar(m)),_=u();c===`orthographic`&&(s.zoom=1),f(),o?d=EL(_,r,g,e,()=>{c===`orthographic`&&p()}):(_.position.copy(g),r.target.copy(e),c===`orthographic`&&p(),r.update())},g=(e,n=!0)=>{let i=vL(t),a=i.isEmpty()?r.target.clone():i.getCenter(new Z),o=i.isEmpty()?new Z(1,1,1):i.getSize(new Z),s=Math.max(o.x,o.y,o.z)||1;h(a,s,e,n)};return{getActiveCamera:u,getProjection:()=>c,setProjection:m,toggleProjection:()=>(m(c===`perspective`?`orthographic`:`perspective`),c),setView:(e,t=!0)=>{g(o[e],t)},setViewDirection:g,frameBounds:(e,t=!0)=>{if(e.isEmpty())return;let n=e.getCenter(new Z),i=e.getSize(new Z),a=Math.max(i.x,i.y,i.z)||1,s=u().position.clone().sub(r.target);s.lengthSq()<1e-12&&s.copy(o.iso),h(n,a,s.normalize(),t)},setRotateEnabled:e=>{r.enableRotate=e},isRotateEnabled:()=>r.enableRotate,updateAspect:(e,t)=>{l=t===0?l:e/t,c===`orthographic`&&p()},dispose:f}}function wL(e,t){let{up:n,forward:r}=GI(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}var TL=e=>1-(1-e)**3;function EL(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=TL(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}var DL=.15,OL=4096;function kL(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/OL)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*DL))])}function AL(e){let t=new WD;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:kL(e)}}function jL(e,t,n){let r=1e4,i=Math.cos(Math.PI/180*n),a=e.length/3;if(a>=67108864)throw Error(`extractEdgeSegments: ${a} vertices exceeds 2^26 limit`);let o=new Float64Array(a),s=new Float64Array(a),c=new Float64Array(a);for(let t=0;t<a;t++)o[t]=Math.round(e[3*t]*r),s[t]=Math.round(e[3*t+1]*r),c[t]=Math.round(e[3*t+2]*r);let l=16;for(;l<a*2;)l<<=1;let u=l-1,d=new Int32Array(l).fill(-1),f=new Int32Array(a);for(let e=0;e<a;e++){let t=(Math.imul(o[e]|0,73856093)^Math.imul(s[e]|0,19349663)^Math.imul(c[e]|0,83492791))&u;for(;;){let n=d[t];if(n===-1){d[t]=e,f[e]=e;break}if(o[n]===o[e]&&s[n]===s[e]&&c[n]===c[e]){f[e]=n;break}t=t+1&u}}let p=new Float32Array(6144),m=0,h=new Uint32Array(1024),g=(t,n,r)=>{if(m+6>p.length){let e=new Float32Array(p.length*2);e.set(p),p=e;let t=new Uint32Array(p.length/6);t.set(h),h=t}h[m/6]=r,p[m++]=e[3*t],p[m++]=e[3*t+1],p[m++]=e[3*t+2],p[m++]=e[3*n],p[m++]=e[3*n+1],p[m++]=e[3*n+2]},_=(t?t.length:a)/3,v=new Int32Array(a+1);for(let e=0;e<_;e++){let n=f[t?t[3*e]:3*e],r=f[t?t[3*e+1]:3*e+1],i=f[t?t[3*e+2]:3*e+2];n!==r&&r!==i&&i!==n&&(v[n+1]++,v[r+1]++,v[i+1]++)}for(let e=0;e<a;e++)v[e+1]+=v[e];let y=new Int32Array(v[a]);{let e=v.slice(0,a);for(let n=0;n<_;n++){let r=f[t?t[3*n]:3*n],i=f[t?t[3*n+1]:3*n+1],a=f[t?t[3*n+2]:3*n+2];r!==i&&i!==a&&a!==r&&(y[e[r]++]=i,y[e[i]++]=a,y[e[a]++]=r)}}let b=new Int32Array(y.length).fill(-2),x=(e,t)=>{for(let n=v[e],r=v[e+1];n<r;n++)if(y[n]===t)return n;return-1},S=(e,n)=>t?t[3*e+n]:3*e+n,C=new Float64Array(3),w=t=>{let n=S(t,0),r=S(t,1),i=S(t,2),a=e[3*i]-e[3*r],o=e[3*i+1]-e[3*r+1],s=e[3*i+2]-e[3*r+2],c=e[3*n]-e[3*r],l=e[3*n+1]-e[3*r+1],u=e[3*n+2]-e[3*r+2],d=o*u-s*l,f=s*c-a*u,p=a*l-o*c,m=d*d+f*f+p*p;if(m>0){let e=1/Math.sqrt(m);d*=e,f*=e,p*=e}else d=0,f=0,p=0;C[0]=d,C[1]=f,C[2]=p},T=0,E=new Uint32Array(Math.max(16,y.length>>1)),D=new Int32Array(E.length),O=()=>{let e=new Uint32Array(E.length*2);e.set(E),E=e;let t=new Int32Array(e.length);t.set(D),D=t};for(let e=0;e<_;e++){let t=S(e,0),n=S(e,1),r=S(e,2),a=f[t],o=f[n],s=f[r];if(a===o||o===s||s===a)continue;let c=!1,l=0,u=0,d=0;for(let f=0;f<3;f++){let p=f===0?a:f===1?o:s,m=f===0?o:f===1?s:a,h=x(m,p),_=h===-1?-2:b[h];if(_>=0)c||=(w(e),l=C[0],u=C[1],d=C[2],!0),w(Math.floor(E[_]/3)),l*C[0]+u*C[1]+d*C[2]<=i&&g(f===0?t:f===1?n:r,f===0?n:f===1?r:t,e),b[h]=-1;else{let t=x(p,m);if(b[t]===-2){T===E.length&&O();let n=T++;b[t]=n,E[n]=3*e+f,D[n]=t}}}}for(let e=0;e<T;e++){if(b[D[e]]!==e)continue;let t=E[e],n=Math.floor(t/3),r=t-3*n;g(S(n,r),S(n,r===2?0:r+1),n)}return{segments:p.slice(0,m),faces:h.slice(0,m/6)}}function ML(){return[`const extract = ${jL.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const { segments, faces } = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments, faces }, [segments.buffer, faces.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`\n`)}var NL=`edge-overlay`,PL=`triangle-cap`,FL=`overlay-budget`,IL=2236962,LL=1.5,RL=44,zL=.75,BL=8e6,VL=2e6,HL=1500;function UL(e){return{forcedColor:e.color==null?null:new Q(e.color),darken:Ov.clamp(e.darken??zL,0,1),width:e.width??LL,thresholdAngle:e.thresholdAngle??RL,distanceFade:e.distanceFade??!0,maxTriangles:e.maxTriangles??BL,maxSegments:e.maxSegments??VL,maxOverlays:e.maxOverlays??HL}}function WL(e){let t=e.getAttribute(`position`);return t?(e.index?e.index.count:t.count)/3:0}function GL(e){let t=e.getAttribute(`position`);if(!t||t.isInterleavedBufferAttribute||t.itemSize!==3||!(t.array instanceof Float32Array)||t.count>=67108864)return null;let n=e.index;return n&&!(n.array instanceof Uint32Array)&&!(n.array instanceof Uint16Array)?null:{positions:t.array,index:n?n.array:null,version:`${t.version}:${n?.version??0}`}}function KL(e,t){let n=4096,r=2166136261,i=e=>{r^=e,r=Math.imul(r,16777619)},a=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),o=Math.min(n,a.length);for(let e=0;e<o;e++)i(a[e]);for(let e=Math.max(o,a.length-n);e<a.length;e++)i(a[e]);let s=0;if(e.index){s=e.index.length;let t=Math.min(n,s);for(let n=0;n<t;n++)i(e.index[n]);for(let r=Math.max(t,s-n);r<s;r++)i(e.index[r])}return`${t}:${e.positions.length}:${s}:${r>>>0}`}function qL(e,t){let n=new cS(e,t),r=n.attributes.position?n.attributes.position.array:new Float32Array;return n.dispose(),{segments:r,faces:null}}var JL=new WeakMap,YL={};function XL(e,t){let n=JL.get(e.positions)?.get(e.index??YL)?.get(t);return n?.version===e.version?n.edges:void 0}function ZL(e,t,n){let r=JL.get(e.positions);r||JL.set(e.positions,r=new WeakMap);let i=r.get(e.index??YL);return i||r.set(e.index??YL,i=new Map),i.set(t,{version:e.version,edges:n}),n}function QL(e,t){let n=GL(e);return n?XL(n,t)??ZL(n,t,jL(n.positions,n.index,t)):qL(e,t)}var $L,eR=new Map,tR=1;function nR(){if($L!==void 0)return $L;if(typeof Worker>`u`||typeof Blob>`u`||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return $L=null,null;try{let e=URL.createObjectURL(new Blob([ML()],{type:`text/javascript`})),t=new Worker(e);t.onmessage=e=>{let{id:t,segments:n,faces:r,error:i}=e.data,a=eR.get(t);a&&(eR.delete(t),n?a.resolve({segments:n,faces:r??null}):a.reject(Error(i??`edge extraction failed in worker`)))},t.onerror=()=>{for(let e of eR.values())e.reject(Error(`edge extraction worker crashed`));eR.clear(),t.terminate(),$L=null},$L=t}catch{$L=null}return $L}function rR(e,t,n){return new Promise((r,i)=>{let a=tR++;eR.set(a,{resolve:r,reject:i});let o=t.positions.slice(),s=t.index?t.index.slice():null,c=[o.buffer];s&&c.push(s.buffer),e.postMessage({id:a,positions:o,index:s,thresholdAngle:n},c)})}var iR=new Map;function aR(e,t){let n=GL(e);if(!n||WL(e)<25e3)return Promise.resolve(QL(e,t));let r=XL(n,t);if(r)return Promise.resolve(r);let i=KL(n,t),a=iR.get(i);if(a)return a;let o=nR();if(!o)return Promise.resolve(QL(e,t));let s=rR(o,n,t).catch(()=>jL(n.positions,n.index,t)).then(e=>ZL(n,t,e)).finally(()=>{iR.delete(i)});return iR.set(i,s),s}function oR(e){let t=e.userData?.members;return Array.isArray(t)&&t.length>0?t:null}function sR(e){let t=oR(e.object);if(!t||e.faceIndex==null)return null;let n=e.faceIndex*3,r=0,i=t.length-1;for(;r<=i;){let e=r+i>>1,a=t[e];if(a.indexStart==null||a.indexCount==null)return null;if(n<a.indexStart)i=e-1;else if(n>=a.indexStart+a.indexCount)r=e+1;else return{member:a,index:e}}return null}function cR(e,t,n){let r=[];return e.traverse(e=>{let i=oR(e);if(i)i.forEach((i,a)=>{i.trackingKey===t&&(i.layer??``)===n&&r.push({object:e,memberIndex:a})});else{let i=e.userData;i?.trackingKey===t&&(i.layer??``)===n&&r.push({object:e,memberIndex:null})}}),r}function lR(e,t){let n=sR(t),r=n?n.member:t.object.userData,i={object:t.object,memberIndex:n?.index??null};if(typeof r?.trackingKey!=`string`||!r.trackingKey)return[i];let a=cR(e,r.trackingKey,r.layer??``);return a.length>1?a:[i]}function uR(e,t){let n=new Xy,r=e.geometry.getIndex(),i=e.geometry.getAttribute(`position`);if(!r||!i||t.indexStart==null||t.indexCount==null)return n;e.updateMatrixWorld();let a=new Z,o=Math.min(t.indexStart+t.indexCount,r.count);for(let s=t.indexStart;s<o;s++)a.fromBufferAttribute(i,r.getX(s)).applyMatrix4(e.matrixWorld),n.expandByPoint(a);return n}function dR(e,t,n,r){return hM(e,t,n,r),()=>gM(e,r)}function fR(e,t){let n=oR(e);if(!n)return null;let r=[];for(let e of n){if(e.indexStart==null)return null;r.push(e.indexStart)}let i=new Uint32Array(t.length);for(let e=0;e<t.length;e++){let n=t[e]*3,a=0,o=r.length-1;for(;a<o;){let e=a+o+1>>1;r[e]<=n?a=e:o=e-1}i[e]=a}return i}function pR(e,t,n){let r=0;for(let e=0;e<t.length;e++)n.has(t[e])||r++;let i=new Float32Array(r*6),a=0;for(let r=0;r<t.length;r++)n.has(t[r])||(i.set(e.subarray(r*6,r*6+6),a),a+=6);return i}function mR(e,t,n){let{segments:r,faces:i}=n;if(!i||!oR(t))return;let a,o=!1,s=()=>{let n=fM(t);if(n.size===0&&!o||(a??=fR(t,i),!a))return;let s=n.size===0?r:pR(r,a,n);e.geometry.dispose(),e.geometry=AL(s).geometry,o=n.size>0};s();let c=_M(t,s);e.addEventListener(`removed`,c)}function hR(e,t){let n=(Array.isArray(e.material)?e.material[0]:e.material)?.color;return n?n.clone().multiplyScalar(1-t):new Q(IL)}var gR=class{options;byKey=new Map;constructor(e){this.options=e}for(e,t){let n=this.options.forcedColor??hR(e,this.options.darken),r=n.getHex()*2+ +!!t,i=this.byKey.get(r);return i||(i=_R(n,this.options.width,t),this.byKey.set(r,i)),i}disposeUnused(e){let t=new Set(e.map(e=>e.material));for(let e of this.byKey.values())t.has(e)||e.dispose()}};function _R(e,t,n){let r=new GD({color:e});return r.linewidth=t,r.polygonOffset=!0,r.polygonOffsetFactor=0,r.polygonOffsetUnits=-1,n&&(r.transparent=!0),r}function vR(e,t,n){let r=new uO(e.geometry,t);return r.userData.kind=NL,r.raycast=()=>{},n&&SR(r,e.edgeSpacing),r}var yR=new Z,bR=new Z;function xR(e,t,n){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let r=e.geometry.boundingSphere;if(!r)return 1/0;if(t.isPerspectiveCamera){let i=t;yR.copy(r.center).applyMatrix4(e.matrixWorld);let a=bR.setFromMatrixPosition(t.matrixWorld).distanceTo(yR);if(a<=r.radius*e.matrixWorld.getMaxScaleOnAxis())return 1/0;let o=Math.tan(Ov.degToRad(i.fov)*.5),s=2*a*o;return s>0?n/s:1/0}if(t.isOrthographicCamera){let e=t,r=(e.top-e.bottom)/e.zoom;return r>0?n/r:1/0}return 1/0}function SR(e,t){e.onBeforeRender=(n,r,i)=>{uO.prototype.onBeforeRender.call(e,n);let a=e.material,o=t*xR(e,i,a.resolution.y);a.opacity=Ov.clamp((o-1)/3,0,1)}}function CR(e){return e.userData?.kind===NL}function wR(e,t){let n=[],r=0;e.traverse(e=>{e instanceof wx&&e.userData.id!==`floor`&&e.userData.id!==`grid`&&e.userData.kind!==`edge-overlay`&&(e.children.some(e=>e.userData?.kind===`edge-overlay`)?r++:e.geometry&&(WL(e.geometry)>t.maxTriangles?e.userData.edgesSkipped=PL:n.push(e)))});let i=Math.max(0,t.maxOverlays-r),a=n.slice(0,i);for(let e of a)delete e.userData.edgesSkipped;for(let e of n.slice(i))e.userData.edgesSkipped=FL;return n.length>i&&console.debug(`[edges] overlay budget reached: ${n.length} meshes want overlays, ${i} allowed — the rest fall back to the screen-space edge pass.`),a}function TR(e,t,n,r){let i=AL(t.segments),a=r.distanceFade&&i.segmentCount<=r.maxSegments,o=vR(i,n.for(e,a),a);return e.add(o),mR(o,e,t),o}var ER=new WeakMap;function DR(e){return ER.get(e)??0}function OR(e,t){for(let n=e;n;n=n.parent)if(n===t)return!0;return!1}async function kR(e,t={}){let n=UL(t),r=new gR(n),i=DR(e),a=[],o=wR(e,n).map(async t=>{let o=await aR(t.geometry,n.thresholdAngle);DR(e)===i&&OR(t,e)&&(t.children.some(e=>e.userData?.kind===`edge-overlay`)||a.push(TR(t,o,r,n)))});return await Promise.all(o),r.disposeUnused(a),a}function AR(e){ER.set(e,DR(e)+1);let t=[];e.traverse(e=>{e instanceof uO&&CR(e)&&t.push(e)});let n=new Set;for(let e of t)e.geometry.dispose(),n.add(e.material),e.removeFromParent();return n.forEach(e=>e.dispose()),t.length}function jR(e){if(!(e>0)||!Number.isFinite(e))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n>=5?5:n>=2?2:1)*t}var MR=`\n varying vec3 vWorldPos;\n void main() {\n vec4 world = modelMatrix * vec4(position, 1.0);\n vWorldPos = world.xyz;\n gl_Position = projectionMatrix * viewMatrix * world;\n }\n`,NR=`\n precision highp float;\n varying vec3 vWorldPos;\n\n uniform vec2 uAxes; // indices (0=x,1=y,2=z) of the two in-plane world axes\n uniform float uCell;\n uniform float uMajor;\n uniform vec3 uCellColor;\n uniform vec3 uMajorColor;\n uniform vec3 uCenter; // fade center (camera position projected onto the plane)\n uniform float uFade;\n\n // Screen-space derivatives keep grid lines ~1px regardless of zoom (\"pristine grid\" technique).\n float gridLine(vec2 coord, float spacing) {\n vec2 c = coord / spacing;\n vec2 d = fwidth(c);\n vec2 g = abs(fract(c - 0.5) - 0.5) / max(d, 1e-6);\n float line = min(g.x, g.y);\n return 1.0 - clamp(line, 0.0, 1.0);\n }\n\n // Index a vec3 by a float axis id (0/1/2) without dynamic indexing (WebGL1-safe).\n float axis(vec3 v, float i) {\n return i < 0.5 ? v.x : (i < 1.5 ? v.y : v.z);\n }\n\n void main() {\n // Pick the two in-plane world coordinates.\n vec2 coord = vec2(axis(vWorldPos, uAxes.x), axis(vWorldPos, uAxes.y));\n\n float minor = gridLine(coord, uCell);\n float major = gridLine(coord, uCell * uMajor);\n\n vec3 color = mix(uCellColor, uMajorColor, major);\n float alpha = max(minor, major);\n\n // Radial fade from the camera-projected center.\n float dist = distance(vWorldPos, uCenter);\n float fade = 1.0 - clamp(dist / uFade, 0.0, 1.0);\n alpha *= fade * fade;\n\n if (alpha < 0.001) discard;\n gl_FragColor = vec4(color, alpha);\n }\n`;function PR(e={}){let{cellSize:t=1,majorEvery:n=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:a=100,plane:o=`y`}=e,s=o===`y`?new X(0,2):o===`z`?new X(0,1):new X(1,2),c=2.5,l=new lS(1,1);o===`y`?l.rotateX(-Math.PI/2):o===`x`&&l.rotateY(Math.PI/2);let u=new bS({vertexShader:MR,fragmentShader:NR,transparent:!0,depthWrite:!1,side:2,uniforms:{uAxes:{value:s},uCell:{value:t},uMajor:{value:n},uCellColor:{value:new Q(r)},uMajorColor:{value:new Q(i)},uCenter:{value:new Z},uFade:{value:a}}}),d=new wx(l,u);d.name=`grid`,d.userData.id=`grid`,d.renderOrder=-1;let f=a,p=a*c,m=new Z;return{object:d,update:e=>{o===`y`?(d.position.set(e.x,0,e.z),m.set(e.x,0,e.z)):o===`z`?(d.position.set(e.x,e.y,0),m.set(e.x,e.y,0)):(d.position.set(0,e.y,e.z),m.set(0,e.y,e.z)),u.uniforms.uCenter.value.copy(m),d.scale.setScalar(p)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new Z),n=(e,t)=>t===0?e.x:t===1?e.y:e.z,r=Math.max(n(t,s.x),n(t,s.y));r>0&&Number.isFinite(r)&&(u.uniforms.uCell.value=jR(r/20),f=r*2,u.uniforms.uFade.value=f,p=f*c)},setVisible:e=>{d.visible=e},dispose:()=>{d.removeFromParent(),l.dispose(),u.dispose()}}}function FR(e,t){let n=new wM,r=n.domElement;r.style.position=`absolute`,r.style.top=`0`,r.style.left=`0`,r.style.overflow=`hidden`,r.style.pointerEvents=`none`,r.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};n.setSize(i.width,i.height);let a=new Dy;a.name=`label-layer`,a.userData.id=`label-layer`,t.add(a);let o=new Set;return{addLabel:(e,t,n)=>{let r=document.createElement(`div`);r.textContent=e,n?r.className=n:Object.assign(r.style,{padding:`2px 6px`,borderRadius:`4px`,background:`rgba(20, 20, 20, 0.78)`,color:`#fff`,font:`12px/1.3 system-ui, sans-serif`,whiteSpace:`pre`,textAlign:`center`,userSelect:`none`}),r.style.pointerEvents=`none`;let i=new vM(r);return i.position.copy(t),a.add(i),o.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),o.delete(i)}}},render:(e,t)=>n.render(e,t),setSize:(e,t)=>n.setSize(e,t),dispose:()=>{o.forEach(e=>{e.removeFromParent(),e.element.remove()}),o.clear(),a.removeFromParent(),r.remove()}}}var IR=new WeakMap;function LR(e){return e?.version??0}function RR(e){let t=e.attributes.position;if(!t||t.count===0)return null;let n=e.index,r=n??t,i=IR.get(r);if(i===null)return null;if(i&&i.position===t&&i.positionVersion===LR(t)&&i.indexVersion===LR(n))return i.bvh;let a=new Pb;a.setAttribute(`position`,t),n&&a.setIndex(n);try{let e=new yF(a,{indirect:!0});return IR.set(r,{position:t,positionVersion:LR(t),indexVersion:LR(n),bvh:e}),e}catch{return IR.set(r,null),null}}function zR(e){let t=e;return t.isMesh===!0&&!t.isInstancedMesh&&!t.isSkinnedMesh&&!t.isBatchedMesh&&!t.isLineSegments2&&!e.morphTargetInfluences?.length}function BR(e,t=[]){for(let n of e.children)!n.visible||gL(n)||CR(n)||(t.push(n),BR(n,t));return t}function VR(e){let{groups:t}=e.geometry;if(!Array.isArray(e.material)||t.length===0)return null;let n=e.material;return t.filter(e=>n[e.materialIndex??0]?.visible!==!1).map(e=>({start:e.start,end:e.start+e.count}))}var HR=new $v,UR=new dx,WR=new Eb;function GR(e,t,n){HR.copy(e.matrixWorld).invert(),UR.copy(n.ray).applyMatrix4(HR);let r=VR(e),i=null;if(!r)i=t.raycastFirst(UR,2);else for(let e of t.raycast(UR,2)){let t=(e.faceIndex??0)*3;r.some(e=>t>=e.start&&t<e.end)&&(!i||e.distance<i.distance)&&(i=e)}return!i||(i.point.applyMatrix4(e.matrixWorld),i.distance=i.point.distanceTo(n.ray.origin),i.object=e,i.distance<n.near||i.distance>n.far)?null:i}function KR(e,t){let n=[];for(let r of BR(e))if(r.layers.test(t.layers)){if(zR(r)){let{geometry:e}=r;if(e.boundingSphere||e.computeBoundingSphere(),!e.boundingSphere||(WR.copy(e.boundingSphere).applyMatrix4(r.matrixWorld),!t.ray.intersectsSphere(WR)))continue;let i=RR(e);if(i){let e=GR(r,i,t);e&&n.push(e);continue}}r.raycast(t,n)}return n.sort((e,t)=>e.distance-t.distance)}function qR(e){let t=BR(e).filter(zR),n=typeof requestIdleCallback==`function`?e=>requestIdleCallback(e,{timeout:500}):e=>setTimeout(e,16),r=typeof cancelIdleCallback==`function`?cancelIdleCallback:e=>clearTimeout(e),i=0,a=!1,o=()=>{if(a)return;let e=t.shift();e&&(RR(e.geometry),i=n(o))};return i=n(o),()=>{a=!0,r(i)}}var JR=12,YR=16763904,XR=.015,ZR=998,QR=999,$R=1e3,ez={Millimeters:{metersPerUnit:1/1e3,suffix:`mm`},Centimeters:{metersPerUnit:1/100,suffix:`cm`},Meters:{metersPerUnit:1,suffix:`m`},Inches:{metersPerUnit:1/39.37,suffix:`in`},Feet:{metersPerUnit:1/3.28084,suffix:`ft`}};function tz(e){let t=e&&ez[e]||ez.Meters;return e=>{let n=e/t.metersPerUnit,r=Math.abs(n),i=r===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(r))));return`${n.toFixed(i)} ${t.suffix}`}}function nz(e){return(t,n)=>{let r=t*1e-6,i=[`x`,`y`,`z`].filter(e=>n[e]>r);return i.length<2?e(t):`${e(t)}\\n${i.map(t=>`Δ${t} ${e(n[t])}`).join(` `)}`}}function rz(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*XR}return((t?e.position.distanceTo(t):e.position.length())||1)*XR}function iz(e){let t=e.object,n=t.geometry;if(!n)return null;if(t.isLineSegments2){let t=n.attributes.instanceStart,r=n.attributes.instanceEnd,i=e.faceIndex;return!t||!r||i==null||i>=t.count?null:[new Z().fromBufferAttribute(t,i),new Z().fromBufferAttribute(r,i)]}let r=n.attributes.position;if(!r)return null;let i=e=>e.filter(e=>e<r.count).map(e=>new Z().fromBufferAttribute(r,e));if(t instanceof wx)return e.face?i([e.face.a,e.face.b,e.face.c]):null;if(t instanceof Yx)return e.index==null?null:i([e.index]);if(t instanceof Hx){if(e.index==null)return null;let t=n.index;return t?e.index+1>=t.count?null:i([t.getX(e.index),t.getX(e.index+1)]):i([e.index,e.index+1])}return null}function az(e,t,n){let r=e.clone().project(t);return new X((r.x+1)/2*n.width,(1-r.y)/2*n.height)}function oz(e){return e.pointOnLine??e.point}function sz(e,t,n,r){let i=oz(e).clone(),a=iz(e);if(!a)return{point:i,snapped:!1};let o=az(i,t,n),s={point:i,snapped:!1},c=r;for(let r of a){let i=r.applyMatrix4(e.object.matrixWorld),a=az(i,t,n).distanceTo(o);a<c&&(c=a,s={point:i,snapped:!0})}return s}function cz(e){let{canvas:t,scene:n,getActiveCamera:r,getViewTarget:i,labelLayer:a,options:o={}}=e,s=e.requestRender??(()=>{}),c=o.snapPixels??JR,l=new Q(o.color??YR),u=o.format??nz(tz(o.displayUnit)),d=new GC,f=new X,p=!1,m=null,h=[],g=new Wx({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),_=new Wx({color:l,size:12,sizeAttenuation:!1,depthTest:!1}),v=new Wx({color:l,size:7,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.6}),y=(e,t)=>(e.renderOrder=t,e.userData.id=`measure`,e.raycast=()=>{},e.frustumCulled=!1,e),b=(...e)=>{let t=new Pb;t.setAttribute(`position`,new Sb(e.flatMap(e=>[e.x,e.y,e.z]),3));let r=y(new Yx(t,g),QR);return n.add(r),r},x=(e,t,r=1)=>{let i=new dO;i.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let a=new GD({color:l,transparent:r<1,opacity:r});a.linewidth=2,a.depthTest=!1;let o=y(new fO(i,a),ZR);return n.add(o),o},S=(e,t,n)=>{let r=e.geometry.attributes.instanceStart.data;r.array.set([t.x,t.y,t.z,n.x,n.y,n.z]),r.needsUpdate=!0},C=e=>{e.geometry.dispose(),e.material.dispose(),e.removeFromParent()},w=e=>{e.geometry.dispose(),e.removeFromParent()},T=(e,t)=>{let n=new Z(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));return u(e.distanceTo(t),n)},E=(e,t)=>e.clone().add(t).multiplyScalar(.5),D=null,O=null,k=null,A=()=>{D&&(D.visible=!1),O&&(O.visible=!1),k?.remove(),k=null},j=e=>{if(!e){A();return}if(D||(D=b(new Z),D.renderOrder=$R),D.material=e.snapped?_:v,D.position.copy(e.point),D.visible=!0,!m){O&&(O.visible=!1),k?.remove(),k=null;return}O||=x(m.point,e.point,.7),S(O,m.point,e.point),O.visible=!0;let t=T(m.point,e.point),n=E(m.point,e.point);k?(k.setText(t),k.setPosition(n)):k=a.addLabel(t,n,o.labelClassName)},M=e=>{let a=t.getBoundingClientRect(),o=e.clientX-a.left,s=e.clientY-a.top;f.x=o/a.width*2-1,f.y=-(s/a.height)*2+1;let l=r();d.setFromCamera(f,l);let u=rz(l,i?.())*2;d.params.Line.threshold=u,d.params.Points.threshold=u,d.params.Line2={threshold:c/2};let p={width:a.width,height:a.height},m=new X(o,s);for(let e of KR(n,d))if(!(!(e.object.isMesh&&e.face!=null)&&az(oz(e),l,p).distanceTo(m)>c))return sz(e,l,p,c);return null},N=null,P=0,ee=()=>{P&&=(cancelAnimationFrame(P),0),N=null},te=e=>{p&&(N=e,!P&&(P=requestAnimationFrame(()=>{P=0;let e=N;N=null,p&&e&&(j(M(e)),s())})))},ne=()=>{ee(),A(),s()},re=()=>{m&&=(w(m.marker),null)},ie=()=>{re();for(let e of h)w(e.markers),C(e.line),e.label.remove();h.length=0,A(),s()},ae=()=>{m?(re(),A(),s()):ie()},oe=e=>{if(!p)return!1;ee();let t=M(e);if(!t)return!0;if(!m)m={point:t.point,marker:b(t.point)};else if(!t.point.equals(m.point)){let e=m.point,n=t.point;re(),h.push({markers:b(e,n),line:x(e,n),label:a.addLabel(T(e,n),E(e,n),o.labelClassName)})}return j(t),s(),!0},se=e=>{e.key===`Escape`&&(e.target?.closest?.(`input, textarea, select, [contenteditable]`)||ae())},ce=``,le=null,ue=e=>{e!==p&&(p=e,e?(ce=t.style.cursor,t.style.cursor=`crosshair`,t.addEventListener(`mouseleave`,ne),window.addEventListener(`keydown`,se),le=qR(n)):(t.style.cursor=ce,t.removeEventListener(`mouseleave`,ne),window.removeEventListener(`keydown`,se),le?.(),le=null,ee(),ie()))};return{setEnabled:ue,isEnabled:()=>p,handleClick:oe,handleMove:te,cancel:ae,clear:ie,dispose:()=>{ue(!1),ie(),D&&w(D),O&&C(O),D=null,O=null,g.dispose(),_.dispose(),v.dispose()}}}var lz=.5,uz=.01,dz=.05,fz=256,pz=[];function mz({camera:e,scene:t,groundNormals:n=()=>pz}){let r=e.near,i=e.near,a=hz();return{update:()=>{e.near!==i&&(r=e.near);let o=a.measure(t,e),s=r;if(o!==null){let t=o;for(let r of n())t=Math.min(t,Math.abs(e.position.dot(r)));s=Ov.clamp(t*lz,r,e.far*uz)}Math.abs(s-i)>i*dz&&(e.near=s,e.updateProjectionMatrix(),i=s)}}}function hz(){let e=new WeakMap,t=new jx,n=new $v,r=new Z,i=new Xy,a=new Float64Array(20),o=new Float64Array(20),s=new Float32Array(6),c=new Float64Array(21),l=new Float64Array(21),u=1/0,d=!1,f=(t,n)=>{let r=n.getAttribute(`position`),i=n.getIndex(),a=e.get(n);if(a&&a.position===r&&a.positionVersion===_z(r)&&a.index===i&&a.indexVersion===(i?.version??-1))return a;let o={...yz(r,i,vz(t)),position:r,positionVersion:_z(r),index:i,indexVersion:i?.version??-1};return e.set(n,o),o},p=(e,t,n)=>{let{position:r,index:i}=e,a=i?.array,o=1/0;for(let i=e.ranges[t*2];i<e.ranges[t*2+1];i++){for(let e=0;e<3;e++){let t=a?a[i*3+e]:i*3+e;c[e*3]=r.getX(t),c[e*3+1]=r.getY(t),c[e*3+2]=r.getZ(t)}let e=3;for(let t=0;t<16&&e>0;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=n[t+3],s=0;for(let t=0;t<e;t++){let n=(t+1)%e,u=c[t*3],d=c[t*3+1],f=c[t*3+2],p=c[n*3],m=c[n*3+1],h=c[n*3+2],g=r*u+i*d+a*f+o,_=r*p+i*m+a*h+o;if(g>=0&&(l[s*3]=u,l[s*3+1]=d,l[s*3+2]=f,s++),g>=0!=_>=0){let e=g/(g-_);l[s*3]=u+(p-u)*e,l[s*3+1]=d+(m-d)*e,l[s*3+2]=f+(h-f)*e,s++}}[c,l]=[l,c],e=s}for(let t=0;t<e;t++){let e=n[16]*c[t*3]+n[17]*c[t*3+1]+n[18]*c[t*3+2]+n[19];e<o&&(o=e)}}return o},m=e=>{let t=e.elements;for(let e=0;e<20;e+=4){let n=a[e],r=a[e+1],i=a[e+2];o[e]=t[0]*n+t[1]*r+t[2]*i,o[e+1]=t[4]*n+t[5]*r+t[6]*i,o[e+2]=t[8]*n+t[9]*r+t[10]*i,o[e+3]=n*t[12]+r*t[13]+i*t[14]+a[e+3]}return o},h=(e,t,n)=>{outer:for(let r=0;r<e.length;r+=6){let i=e[r],a=e[r+1],o=e[r+2],s=e[r+3],c=e[r+4],l=e[r+5];for(let e=0;e<16;e+=4){let n=t[e],r=t[e+1],u=t[e+2];if(n*(n>0?s:i)+r*(r>0?c:a)+u*(u>0?l:o)+t[e+3]<0)continue outer}let d=t[16],f=t[17],m=t[18],h=d*(d>0?i:s)+f*(f>0?a:c)+m*(m>0?o:l)+t[19];h>=u||(u=n?Math.min(u,p(n,r/6,t)):h)}},g=e=>{let t=e.geometry;if(!t?.getAttribute?.(`position`))return;if(d=!0,gz(e)){let n=f(e,t);h(n.boxes,m(e.matrixWorld),n);return}let n=e;n.isInstancedMesh?(n.boundingBox||n.computeBoundingBox(),i.copy(n.boundingBox)):(t.boundingBox||t.computeBoundingBox(),i.copy(t.boundingBox)),!i.isEmpty()&&(s[0]=i.min.x,s[1]=i.min.y,s[2]=i.min.z,s[3]=i.max.x,s[4]=i.max.y,s[5]=i.max.z,h(s,m(e.matrixWorld)))},_=e=>{if(e.visible&&!gL(e)&&e.userData.kind!==`edge-overlay`){g(e);for(let t of e.children)_(t)}};return{measure:(e,i)=>{e.updateMatrixWorld(),i.updateMatrixWorld(),n.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),t.setFromProjectionMatrix(n);for(let e=0;e<4;e++){let n=t.planes[e];a[e*4]=n.normal.x,a[e*4+1]=n.normal.y,a[e*4+2]=n.normal.z,a[e*4+3]=n.constant}i.getWorldDirection(r),a[16]=r.x,a[17]=r.y,a[18]=r.z,a[19]=-r.dot(i.position),u=1/0,d=!1;for(let t of e.children)_(t);return d?u:null}}}function gz(e){let t=e;if(!t.isMesh||t.isInstancedMesh||t.isSkinnedMesh)return!1;let n=t.geometry;return!n.isInstancedBufferGeometry&&Object.keys(n.morphAttributes).length===0}function _z(e){return e.isInterleavedBufferAttribute?e.data.version:e.version}function vz(e){let t=[];for(let n of oR(e)??[])n.indexStart!==void 0&&t.push(n.indexStart/3);return t.sort((e,t)=>e-t)}function yz(e,t,n){let r=Math.floor((t?t.count:e.count)/3),i=[],a=0;for(let e=0;e<r;){for(;a<n.length&&n[a]<=e;)a++;let t=Math.min(r,e+fz,n[a]??r);i.push(e,t),e=t}let o=i.length/2,s=new Float32Array(o*6),c=!e.isInterleavedBufferAttribute,l=e.array,u=c&&e.itemSize===3&&!e.normalized,d=t?.array;for(let t=0;t<o;t++){let n=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,f=-1/0,p=i[t*2+1]*3;for(let s=i[t*2]*3;s<p;s++){let t=d?d[s]:s,i=u?l[t*3]:e.getX(t),p=u?l[t*3+1]:e.getY(t),m=u?l[t*3+2]:e.getZ(t);i<n&&(n=i),p<r&&(r=p),m<a&&(a=m),i>o&&(o=i),p>c&&(c=p),m>f&&(f=m)}let m=t*6;s[m]=n,s[m+1]=r,s[m+2]=a,s[m+3]=o,s[m+4]=c,s[m+5]=f}return{boxes:s,ranges:Uint32Array.from(i)}}function bz(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function xz(e){let{camera:t,domElement:n,controller:r}=e,i=new bF(t,n);i.setLabels(`X`,`Y`,`Z`);let a=!0,o=new GC,s=new bC(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new Z(1,0,0),negX:new Z(-1,0,0),posY:new Z(0,1,0),negY:new Z(0,-1,0),posZ:new Z(0,0,1),negZ:new Z(0,0,-1)},l=e=>{let r=n.getBoundingClientRect(),a=r.left+n.offsetWidth-128-i.location.right,l=r.top+n.offsetHeight-128-i.location.bottom,u=new X((e.clientX-a)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(u.x)>1||Math.abs(u.y)>1)return null;i.quaternion.copy(t.quaternion).invert(),i.updateMatrixWorld(),o.setFromCamera(u,s);let d=o.intersectObjects(i.children,!1);for(let e of d){let t=e.object.userData?.type;if(typeof t==`string`&&t in c)return t}return null};return{render:e=>{if(!a)return;let t=e.autoClear;e.autoClear=!1,i.render(e),e.autoClear=t},handleClick:e=>{if(!a)return!1;let t=l(e);return t?(r.getProjection()===`orthographic`&&r.setProjection(`perspective`),r.setViewDirection(c[t],!1),!0):!1},setVisible:e=>{a=e},isVisible:()=>a,dispose:()=>i.dispose()}}function Sz(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m=!0,h){let g=null,_=performance.now(),v=!0,y=0,b=new $v,x=new $v,S=null,C=()=>{v=!0},w=e=>{e.updateMatrixWorld();let t=S!==e||!b.equals(e.matrixWorld)||!x.equals(e.projectionMatrix);return t&&(S=e,b.copy(e.matrixWorld),x.copy(e.projectionMatrix)),t},T=e.domElement,E=[`pointerdown`,`pointerup`,`wheel`];if(m)for(let e of E)T.addEventListener(e,C,{passive:!0});let D=()=>{let{width:t,height:r}=o();if(t===0||r===0)return;let a=s(),c=Math.floor(t*a),l=Math.floor(r*a);(e.domElement.width!==c||e.domElement.height!==l)&&(e.setPixelRatio(a),e.setSize(t,r,!1),n.aspect=t/r,n.updateProjectionMatrix(),i.updateAspect(t,r),d?.()?.setSize(t,r,a),f?.setSize(t,r),C())},O=n=>{f&&f.render(t,n),u&&u.render(e)},k=(n,r)=>{let i=d?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),O(n)},A=()=>{let e=r();h?.present()?O(e):k(e,0)},j=function(){g=requestAnimationFrame(j);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),p&&p.update(),c?.(t);let n=r();if(m){let r=w(n);r&&h?.moving(t*1e3);let i=v||r;if(!i&&h?.wants(e)){h.step(n),O(n);return}let a=e-y>=500;if(!i&&!a||(y=e,!i&&h?.isHolding()))return;v=!1,h?.reset(e)}k(n,t)};return{animate:j,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),m)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:A}}var Cz=3,wz=2,Tz=1024,Ez=1/3,Dz=.05,Oz=160/(4*Math.PI)*.005,kz=.07,Az=7,jz=.15;function Mz(e){let t=pM(e);return t?.userData.selvaEmissive?t:null}function Nz(e){let t=oR(e);if(!t)return[new Xy().setFromObject(e)];let n=fM(e);return t.filter((e,t)=>!n.has(t)).map(t=>uR(e,t)).filter(e=>!e.isEmpty())}function Pz(e,t){let n=e=>e.getSize(new Z).length(),r=Math.max(n(e),n(t))*Dz;return e.clone().expandByScalar(r).intersectsBox(t)}function Fz(e,t){let n=[];for(let r of e){let i={bounds:r.bounds.clone(),meshes:new Set([r.mesh])},a=[];for(let e of n)if(Pz(e.bounds,r.bounds)){i.bounds.union(e.bounds);for(let t of e.meshes)i.meshes.add(t)}else a.push(e);if(n=[...a,i],n.length>t){let t=new Xy;for(let n of e)t.union(n.bounds);return[{bounds:t,meshes:new Set(e.map(e=>e.mesh))}]}}return n}function Iz(e,t){let n=new Map;for(let t of e){let{emissive:e,emissiveIntensity:r,userData:i}=t.material,a=`${e.getHexString()}|${r}|${i[wD]}`,o=n.get(a);o?o.push(t):n.set(a,[t])}return[...n.values()].flatMap(e=>{let{emissive:n,emissiveIntensity:r,userData:i}=e[0].material;return Fz(e,t).map(e=>({...e,color:n,strength:r,light:i[wD]}))})}function Lz(e,t=Cz){let n=Math.max(0,...e.map(e=>e.strength));return e.filter(e=>e.strength>=n*Ez).sort((e,t)=>t.strength-e.strength).slice(0,t)}function Rz(e){let t=[],n=new Set,r=new Z,i=n=>{let r=new yC(16777215,1,0,2),i=new yC(16777215,1,0,1);n&&(r.castShadow=!0,r.shadow.mapSize.setScalar(Tz),r.shadow.radius=Az,r.shadow.autoUpdate=!1);let a={key:r,bounce:i,home:new Z,size:new Z};return t.push(a),e.add(r,i),a},a=()=>{let t=new Xy,n=[];return e.traverseVisible(e=>{let r=e;if(!r.isMesh||e.userData.source!==`compute`)return;t.union(new Xy().setFromObject(r));let i=Mz(r);if(i)for(let e of Nz(r))n.push({mesh:r,material:i,bounds:e})}),{parts:n,radius:t.getSize(new Z).length()/2}},o=(e,r)=>{for(let{mesh:i,bounds:a}of e)r.some((e,n)=>e.meshes.has(i)||a.containsPoint(t[n].key.position))&&i.castShadow&&(i.castShadow=!1,n.add(i))},s=(r,s=Cz,c=1)=>{for(let e of n)e.castShadow=!0;n.clear();let{parts:l,radius:u}=r?a():{parts:[],radius:0},d=Lz(Iz(l,s),s);for(d.forEach((e,n)=>{let{key:r,bounce:a,home:o,size:s}=t[n]??i(n<wz),l=(e.light??e.strength*Oz)*c;r.color.copy(e.color);let d=e.bounds.getSize(new Z).length()/2/u;r.intensity=!e.light&&d>jz?0:l,e.bounds.getCenter(r.position),o.copy(r.position),e.bounds.getSize(s),a.color.copy(e.color),a.intensity=l*kz/u,a.position.copy(r.position),r.castShadow&&(r.shadow.camera.near=u*.005,r.shadow.camera.far=u*4,r.shadow.camera.updateProjectionMatrix(),r.shadow.bias=-.002,r.shadow.normalBias=u*.002,r.shadow.needsUpdate=!0)});t.length>d.length;){let{key:n,bounce:r}=t.pop();e.remove(n,r),n.dispose(),r.dispose()}o(l,d)},c=e=>{for(let{key:n,home:r,size:i}of t)n.position.copy(e(r,i)),n.castShadow&&(n.shadow.needsUpdate=!0)};return{sync:s,jitter:e=>c((t,n)=>r.set(nL(e,2)-.5,nL(e,3)-.5,nL(e,5)-.5).multiply(n).add(t)),settle:()=>c(e=>e),dispose:()=>s(!1)}}var zz=`__selvaLookBaseline`;function Bz(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.emissiveIntensity!==void 0&&(e.emissiveIntensity=t.emissiveIntensity),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe),e.side=t.side}function Vz(e){let t=e[zz];t&&(Bz(e,t),delete e[zz])}function Hz(e,t){let n=e;t?(n[zz]?Bz(n,n[zz]):n[zz]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,emissiveIntensity:n.emissiveIntensity??0,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1,side:n.side},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.emissiveIntensity!==void 0&&n.userData.selvaEmissive&&(n.emissiveIntensity=t.emissiveIntensity),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(n.side=t.side),n.needsUpdate=!0):(Vz(n),n.needsUpdate=!0)}function Uz(e,t){if(t.materialOverride)return t.envMapIntensity;let n=e.userData[TD];if(n!=null)return n;let r=e,i=r[zz]?.metalness??r.metalness??0;return ED(t.envMapIntensity,i,t.metalReflection)}function Wz(e,t){return Math.min(e,t.maxPixelRatio??e)}function Gz(e){let{scene:t,renderer:n,lights:r,config:i,pipeline:a,fullPixelRatio:o,requestRender:s}=e,c=e=>SD(e,i.render.lowPower),l=i.look,u=Rz(t),d=n.shadowMap.type,f=e=>{let t=e.emissiveLights?1:d;n.shadowMap.type!==t&&(n.shadowMap.type=t,n.shadowMap.needsUpdate=!0)},p,m=e=>{e.background===void 0?(p!==void 0&&(t.background=p),p=void 0):(p??=t.background,t.background=new Q(e.background))};m(c(l)),f(c(l));let h=e=>{e.ambientIntensity!==void 0&&(r.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!r.hemisphere&&e.hemisphereIntensity>0&&(r.hemisphere=new aC(e.hemisphereSkyColor??i.lighting.hemisphereSkyColor,e.hemisphereGroundColor??i.lighting.hemisphereGroundColor,e.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??XI),t.add(r.hemisphere)),r.hemisphere&&(e.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},g=e=>{i.environment.environmentIntensity=e,t.environmentIntensity=e,s()},_=e=>{i.render.toneMappingExposure=e,n.toneMappingExposure=e,a.get()&&a.rebuild()},v=e=>{i.render.aoIntensity=e,a.get()&&a.rebuild()},y=()=>{let{emissiveLights:e,maxEmissiveLights:t,emissiveLightScale:n}=c(l);u.sync(!!e,t,n),s()};return{setFillLights:h,setEnvironmentIntensity:g,setToneMappingExposure:_,setAoIntensity:v,setLook:(e,s)=>{let u=c(e);l=e,n.toneMapping=u.toneMapping,n.toneMappingExposure=u.toneMappingExposure,i.render.toneMapping=u.toneMapping,i.render.toneMappingExposure=u.toneMappingExposure,h({hemisphereIntensity:u.hemisphereIntensity,ambientIntensity:u.ambientIntensity}),g(u.environmentIntensity),r.sun&&(r.sun.intensity=u.sunlightIntensity,i.lighting.sunlightIntensity=u.sunlightIntensity),m(u),f(u),i.render.bloom=u.bloom,i.render.pixelRatio=Wz(o,u),a.setAmbientOcclusion(u.ambientOcclusion),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,n=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of n)`envMapIntensity`in e&&(e.envMapIntensity=Uz(e,u)),Hz(e,u.materialOverride)}),WI(t,t),s?.deferEmissiveLights||y()},syncEmissiveLights:y,jitterEmissiveLights:u.jitter,settleEmissiveLights:u.settle,getMaterialAppearance:()=>DD(l)}}function Kz(e,t){let n=t.parentElement,r=n?n.clientWidth:window.innerWidth,i=n?n.clientHeight:window.innerHeight,a=new _C(e.camera.fov,r/i,e.camera.near,e.camera.far),o=e.camera.position;return o&&a.position.set(o.x,o.y,o.z),a}function qz(e){let t=new Fy;return t.background=(typeof e.environment.backgroundColor==`string`?new Q(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function Jz(e,t){BD(e,t),e.environment?.dispose(),UI(e),e.background instanceof qv&&e.background.dispose()}var Yz={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new X(1,1)},uColor:{value:new Q(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,fragmentShader:`\n uniform sampler2D tDiffuse;\n uniform sampler2D tNormal;\n uniform sampler2D tDepth;\n uniform vec2 uResolution;\n uniform vec3 uColor;\n uniform float uOpacity;\n uniform float uNormalThreshold;\n uniform float uDepthThreshold;\n uniform float uThickness;\n uniform float uNear;\n uniform float uFar;\n uniform float uPerspective;\n varying vec2 vUv;\n\n float viewZOf(const in float depth) {\n float perspective = (uNear * uFar) / ((uFar - uNear) * depth - uFar);\n float orthographic = -(depth * (uFar - uNear) + uNear);\n return mix(orthographic, perspective, uPerspective);\n }\n\n void main() {\n vec4 color = texture2D(tDiffuse, vUv);\n vec2 texel = uThickness / uResolution;\n\n vec2 offsetA = vec2(texel.x, texel.y);\n vec2 offsetB = vec2(texel.x, -texel.y);\n\n float z0 = viewZOf(texture2D(tDepth, vUv + offsetA).x);\n float z1 = viewZOf(texture2D(tDepth, vUv - offsetA).x);\n float z2 = viewZOf(texture2D(tDepth, vUv + offsetB).x);\n float z3 = viewZOf(texture2D(tDepth, vUv - offsetB).x);\n float zCenter = viewZOf(texture2D(tDepth, vUv).x);\n // Normalized by center depth, not absolute Z: keeps the response scale-invariant (an\n // absolute threshold would be noise far away, blind up close).\n float depthDelta = (abs(z0 - z1) + abs(z2 - z3)) / max(abs(zCenter), 1e-6);\n float depthEdge = step(uDepthThreshold, depthDelta);\n\n vec3 n0 = texture2D(tNormal, vUv + offsetA).rgb * 2.0 - 1.0;\n vec3 n1 = texture2D(tNormal, vUv - offsetA).rgb * 2.0 - 1.0;\n vec3 n2 = texture2D(tNormal, vUv + offsetB).rgb * 2.0 - 1.0;\n vec3 n3 = texture2D(tNormal, vUv - offsetB).rgb * 2.0 - 1.0;\n float normalDelta = (1.0 - dot(n0, n1)) + (1.0 - dot(n2, n3));\n float normalEdge = step(uNormalThreshold, normalDelta);\n\n float edge = max(depthEdge, normalEdge) * uOpacity;\n gl_FragColor = vec4(mix(color.rgb, uColor, edge), color.a);\n }\n `},Xz=class extends SF{camera;scene;normalMaterial;edgeMaterial;fsQuad;normalTarget=null;width;height;constructor(e,t,n,r,i={}){super(),this.scene=e,this.camera=t,this.width=Math.max(1,n),this.height=Math.max(1,r),this.normalMaterial=new wS,this.normalMaterial.blending=0,this.edgeMaterial=new bS({uniforms:_S.clone(Yz.uniforms),vertexShader:Yz.vertexShader,fragmentShader:Yz.fragmentShader});let a=this.edgeMaterial.uniforms;a.uColor.value=new Q(i.color??2236962),a.uOpacity.value=i.opacity??1,a.uNormalThreshold.value=i.normalThreshold??.4,a.uDepthThreshold.value=i.depthThreshold??.02,a.uThickness.value=i.thickness??1,this.fsQuad=new TF(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let e=new $x(this.width,this.height);this.normalTarget=new Xv(this.width,this.height,{minFilter:gg,magFilter:gg,depthTexture:e})}return this.normalTarget}setSize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.normalTarget?.setSize(this.width,this.height)}render(e,t,n){let r=this.acquireNormalTarget(),i=e.getRenderTarget(),a=e.autoClear,o=e.getClearColor(new Q),s=e.getClearAlpha(),c=this.scene.overrideMaterial;e.setRenderTarget(r),e.setClearColor(7829503,1),e.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial;let l=LD(this.scene);e.render(this.scene,this.camera),l(),this.scene.overrideMaterial=c,e.setClearColor(o,s),e.autoClear=a;let u=this.edgeMaterial.uniforms;u.tDiffuse.value=n.texture,u.tNormal.value=r.texture,u.tDepth.value=r.depthTexture,u.uResolution.value.set(this.width,this.height);let d=this.camera;u.uPerspective.value=+!!d.isPerspectiveCamera,u.uNear.value=this.camera.near??.1,u.uFar.value=this.camera.far??1e3,e.setRenderTarget(this.renderToScreen?null:t),this.fsQuad.render(e),e.setRenderTarget(i)}dispose(){this.normalTarget?.dispose(),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}},Zz={name:`HdrClamp`,uniforms:{tDiffuse:{value:null}},vertexShader:`\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }`,fragmentShader:`\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n const float MAX_RADIANCE = 64.0;\n float safe(float v) {\n return isnan(v) ? 0.0 : clamp(v, 0.0, MAX_RADIANCE);\n }\n void main() {\n vec4 color = texture2D(tDiffuse, vUv);\n gl_FragColor = vec4(safe(color.r), safe(color.g), safe(color.b), color.a);\n }`},Qz={vertexShader:`\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = vec4(position.xy, 0.0, 1.0);\n }`,fragmentShader:`\n uniform sampler2D tFrame;\n varying vec2 vUv;\n void main() {\n gl_FragColor = texture2D(tFrame, vUv);\n }`};function $z(e){let t=new Xv(1,1,{type:kg,depthBuffer:!1}),n=new bS({...Qz,uniforms:{tFrame:{value:null}},depthTest:!1,depthWrite:!1,toneMapped:!1,blending:5,blendSrc:213,blendDst:214}),r=new TF(n),i=(t,i)=>{n.uniforms.tFrame.value=t,n.blendAlpha=i;let a=e.autoClear;e.autoClear=!1,r.render(e),e.autoClear=a},a=()=>{e.setRenderTarget(null),i(t.texture,1)};return{add:(n,r,o,s)=>{(t.width!==o||t.height!==s)&&t.setSize(o,s),e.setRenderTarget(t),i(n,1/(r+1)),a()},present:a,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function eB(e){return e>=2?0:4}function tB(e){let t=e,n=t._overrideVisibility.bind(e),r=t._restoreVisibility.bind(e),i=()=>{};t._overrideVisibility=()=>{n(),i=LD(e.scene)},t._restoreVisibility=()=>{i(),r()}}function nB(e,t,n,r,i,a){let o=new Xv(r,i,{type:kg}),s=new kF(e,o);s.renderTarget2.samples=0;let c=e=>{s.readBuffer=o,s.writeBuffer=s.renderTarget2,s.render(e)},l=new AF(t,n);s.addPass(l);let u=null;(a.ambientOcclusion??!0)&&(u=new BF(t,n,r,i),u.blendIntensity=a.aoIntensity??1,u.updateGtaoMaterial({screenSpaceRadius:!0}),tB(u),s.addPass(u));let d=null,f=null;if(a.bloom){let{strength:e,radius:t,threshold:n}=a.bloom;d=new EF(Zz),s.addPass(d),f=new JF(new X(r,i),e,t,n),s.addPass(f)}let p=new Xz(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});p.enabled=!!a.edgeDetection,s.addPass(p);let m=new WF;s.addPass(m);let h=new KF;s.addPass(h),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let g=null,_=a.aoPixelRatio??1,v=1;if(u){let e=u.setSize.bind(u);u.setSize=(t,n)=>e(Math.max(1,Math.round(t*v)),Math.max(1,Math.round(n*v)))}let y=e=>{v=Math.min(e,_)/e;let t=eB(e);o.samples!==t&&(o.samples=t,o.dispose()),s.setPixelRatio(e)};return y(e.getPixelRatio()),s.setSize(r,i),{render:c,setSize:(e,t,n)=>{y(n),s.setSize(e,t)},setCamera:e=>{if(l.camera=e,p.camera=e,!u)return;u.camera=e;let t=+!!e.isPerspectiveCamera;u.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==t&&(u.gtaoMaterial.defines.PERSPECTIVE_CAMERA=t,u.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:e=>{p.enabled=e},edgeDetectionEnabled:()=>p.enabled,accumulate:t=>{s.renderToScreen=!1,c(0),s.renderToScreen=!0,g??=$z(e);let{texture:n,width:r,height:i}=s.readBuffer;g.add(n,t,r,i)},presentAccumulated:()=>g?.present(),setAoWeight:e=>{u&&(u.enabled=e>0,u.blendIntensity=(a.aoIntensity??1)*e)},dispose:()=>{s.dispose(),g?.dispose(),u?.dispose(),d?.dispose(),f?.dispose(),p.dispose(),m.dispose(),h.dispose()}}}function rB(e){let{renderer:t,scene:n,getActiveCamera:r,getCanvasSize:i,config:a,requestRender:o}=e,s=null,c=!!a.render.ambientOcclusion,l=!1,u=()=>({ambientOcclusion:c,bloom:a.render.bloom,toneMapping:a.render.toneMapping,toneMappingExposure:a.render.toneMappingExposure}),d=u(),f=()=>{let e=u();return e.ambientOcclusion!==d.ambientOcclusion||e.bloom!==d.bloom||e.toneMapping!==d.toneMapping||e.toneMappingExposure!==d.toneMappingExposure},p=()=>{let{width:e,height:o}=i(),s=nB(t,n,r(),Math.max(1,e),Math.max(1,o),{toneMapping:a.render.toneMapping??7,toneMappingExposure:a.render.toneMappingExposure??1,ambientOcclusion:c,aoIntensity:a.render.aoIntensity,aoPixelRatio:a.render.aoPixelRatio,bloom:a.render.bloom,edgeDetection:!1});return s.setSize(Math.max(1,e),Math.max(1,o),a.render.pixelRatio),s},m=()=>{c||l||a.render.bloom?((!s||f())&&(s?.dispose(),s=p(),d=u()),s.setEdgeDetection(l),o()):(s?.dispose(),s=null,o())};return{get:()=>s,sync:m,rebuild:()=>{s?.dispose(),s=null,m()},setAmbientOcclusion:e=>{c=e,m()},setEdgeFallback:e=>{e!==l&&(l=e,m())},isEdgeFallbackActive:()=>l,dispose:()=>{s?.dispose(),s=null}}}function iB(e,t,n){let r=new aI(e,t),i=n.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=n.controls.enableDamping||!1,r.dampingFactor=n.controls.dampingFactor||.05,r.autoRotate=n.controls.autoRotate||!1,r.autoRotateSpeed=n.controls.autoRotateSpeed||.5,r.enableZoom=n.controls.enableZoom??!0,r.enablePan=n.controls.enablePan??!0,r.minDistance=n.controls.minDistance||.001,r.maxDistance=n.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}function aB(e,t,n,r){if(n.environment.enableEnvironmentLighting){if(VI(e,t,JI(n.environment.sceneUp??XI)),n.environment.hdrPath===!1){n.events.onReady?.();return}new vI().load(n.environment.hdrPath||`/baseHDR.hdr`,function(i){if(r()){i.dispose();return}if(!i?.image){bD().warn(`HDR loaded without image data; skipping environment map.`),i?.dispose(),n.events.onReady?.();return}i.mapping=303;let a=new Dw(t);a.compileEquirectangularShader();let o=a.fromEquirectangular(i).texture;a.dispose(),e.environment=o,e.environmentIntensity=n.environment.environmentIntensity??1;let s=JI(n.environment.sceneUp??XI);e.environmentRotation.copy(s),n.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),n.events.onReady?.()},void 0,function(e){r()||(bD().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),n.events.onReady?.())})}else n.events.onReady?.()}function oB(e,t){let n=t.floor.size,r=new wx(new lS(n,n),new SS({color:typeof t.floor.color==`string`?new Q(t.floor.color):t.floor.color,roughness:t.floor.roughness,metalness:t.floor.metalness,side:2}));r.userData.id=`floor`,r.name=`floor`;let i=(t.environment?.sceneUp||XI).clone().normalize();r.quaternion.setFromUnitVectors(new Z(0,0,1),i),r.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(r.receiveShadow=!0),e.add(r)}var sB=.75,cB=.6,lB=.2,uB=1,dB=`#ffb020`,fB=[8,16],pB=8,mB=300,hB=30,gB=.35,_B=new Q(`#2f7bff`);function vB(e,t){let n=e.color;return n&&Math.hypot(n.r-t.r,n.g-t.g,n.b-t.b)<gB?_B:t}function yB(e,t,n){let r=vB(e,t);if(n&&`emissive`in e){let t=e;t.emissive=r.clone(),t.emissiveIntensity=cB,t.color.lerp(r,sB),t.metalness=Math.min(t.metalness,lB),t.opacity<uB&&(t.opacity=uB,t.transparent=!1,t.depthWrite=!0)}else`color`in e&&(e.color=r.clone())}function bB(e,t,n,r,i){let a=new Set,o=new Map,s=[],c=null,l=!1,u=new GC,d=new X,f=()=>n.getActiveCamera(),p=()=>{let e=vL(t);e.isEmpty()?bD().warn(`No objects to fit to view`):n.frameBounds(e,!1)},m=typeof r.events.selectionColor==`string`?new Q(r.events.selectionColor):r.events.selectionColor instanceof Q?r.events.selectionColor:new Q(`#ff0000`),h=new Q(dB),g=[],_=[],v=(e,n)=>{let r=e;for(;r.parent;)r=r.parent;r!==t&&(n instanceof Wb?n.dispose():n.forEach(e=>e.dispose()))},y=()=>{for(let{restore:e,material:t}of _)e(),t.dispose();_.length=0;for(let{object:e,original:t}of g){let n=e.material;n instanceof Wb&&n.dispose(),e.material=t,v(e,t)}g.length=0},b=e=>{let t=[],n=new Map;for(let{object:r,memberIndex:i}of e){if(i===null){t.push(r);continue}let e=n.get(r);e||n.set(r,e=new Set),e.add(i)}return{whole:t,membersByMesh:n}},x=(e,t=null)=>{if(y(),!e)return;let n=e instanceof Ey?[{object:e,memberIndex:t}]:e,{whole:r,membersByMesh:i}=b(n);for(let[e,t]of i){if(!(e instanceof wx)){r.push(e);continue}let n=pM(e).clone();yB(n,h,!0),_.push({restore:dR(e,t,n,`hover`),material:n})}for(let e of r){if(a.has(e))continue;let t=e;if(!(t.material instanceof Wb))continue;let n=mM(t.material);yB(n,h,e instanceof wx),g.push({object:t,original:t.material}),t.material=n}},S=()=>{for(let{restore:e,material:t}of s)e(),t.dispose();s.length=0,a.forEach(e=>{let t=e;if(o.has(e)){let n=o.get(e),r=t.material;r instanceof Wb?r.dispose():Array.isArray(r)&&r.forEach(e=>e.dispose()),t.material=n,o.delete(e),v(e,n)}}),a.clear(),c=null,l=!1},C=(e,t)=>{if(t&&e instanceof wx){let n=pM(e).clone();return yB(n,m,!0),s.push({restore:dR(e,t,n),material:n}),!0}let n=e;if(!(n.material instanceof Wb))return!1;let r=mM(n.material);return yB(r,m,e instanceof wx),o.set(e,n.material),n.material=r,!0},w=e=>{let{whole:t,membersByMesh:n}=b(e);for(let e of t)a.add(e),C(e,null);for(let[e,t]of n)a.add(e),C(e,t)},T=e=>{(e.length!==0||l)&&(y(),S(),w(e),l=e.length>0)},E=null,D=-1,O=()=>{if(E===null||t.children.length!==D){let e=vL(t);E=e.isEmpty()?1:e.getSize(new Z).length(),D=t.children.length}u.params.Points.threshold=E*.01},k=(t,n)=>{let r=e.getBoundingClientRect();d.x=(t-r.left)/r.width*2-1,d.y=-((n-r.top)/r.height)*2+1},A=(e,n)=>(k(e,n),O(),u.setFromCamera(d,f()),KR(t,u)[0]??null),j=(e,t,n)=>{let r=A(e,t);if(r||!n)return r;for(let n of fB){let r=null;for(let i=0;i<pB;i++){let a=i/pB*Math.PI*2,o=A(e+Math.cos(a)*n,t+Math.sin(a)*n);o&&(!r||o.distance<r.distance)&&(r=o)}if(r)return r}return null},M=null,N=e=>{let t=M;if(M={time:e.timeStamp,x:e.clientX,y:e.clientY},!t)return!1;let n=e.timeStamp-t.time<=mB&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=hB;return n&&(M=null),n},P=e=>{if(!i.wasTap())return;let n=i.pointerType()!==`mouse`;if(n&&N(e)){te(e.clientX,e.clientY,!0);return}let a=j(e.clientX,e.clientY,n);if(!a){S(),k(e.clientX,e.clientY),r.events?.onBackgroundClicked?.({x:d.x,y:d.y});return}let o=a.object,s=sR(a),u=s?.index??null;(l||c?.object!==o||c.memberIndex!==u)&&(y(),S(),c={object:o,memberIndex:u},w(lR(t,a)),r.events?.onObjectSelected?.(o),s?r.events?.onMeshMetadataClicked?.({source:o.userData?.source,name:s.member.name,layer:s.member.layer,trackingKey:s.member.trackingKey,metadata:s.member.metadata}):o instanceof wx&&Object.keys(o.userData).length>0&&r.events?.onMeshMetadataClicked?.(o.userData))},ee=e=>{i.wasTap()&&i.pointerType()===`mouse`&&te(e.clientX,e.clientY,!1)},te=(e,i,a)=>{let o=j(e,i,a);if(!o){r.events?.enableDoubleClickZoom&&n.frameBounds(vL(t),!0);return}let s=o.object;if(r.events?.onMeshDoubleClicked?.(s),!r.events?.enableDoubleClickZoom)return;let c=new Xy;for(let{object:e,memberIndex:n}of lR(t,o)){let t=n===null?null:oR(e)?.[n];c.union(t&&e instanceof wx?uR(e,t):new Xy().setFromObject(e))}c.isEmpty()||n.frameBounds(c,!0)},ne=e=>{if(r.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),S();break;case` `:e.preventDefault(),p()}};return r.events?.enableClickToFocus&&(e.addEventListener(`click`,P),e.addEventListener(`dblclick`,ee)),r.events?.enableKeyboardControls&&(e.setAttribute(`tabindex`,`0`),e.addEventListener(`keydown`,ne)),{dispose:()=>{e.removeEventListener(`click`,P),e.removeEventListener(`dblclick`,ee),e.removeEventListener(`keydown`,ne),y(),S()},fitToView:p,clearSelection:S,selectEntries:T,setHover:x}}var xB=5,SB=10,CB=500;function wB(e){let t=new Map,n=`mouse`,r=0,i=0,a=0,o=!1,s=!1,c=e=>{let n=t.get(e.pointerId);n&&(a=Math.max(a,Math.hypot(e.clientX-n.x,e.clientY-n.y)))},l=e=>{t.size===0&&(n=e.pointerType,r=e.timeStamp,i=0,a=0,o=!1),t.set(e.pointerId,{x:e.clientX,y:e.clientY}),i=Math.max(i,t.size)},u=e=>c(e),d=e=>{if(!t.has(e.pointerId)||(c(e),e.type===`pointercancel`&&(o=!0),t.delete(e.pointerId),t.size>0))return;let l=n===`mouse`;s=!o&&i===1&&a<=(l?xB:SB)&&(l||e.timeStamp-r<=CB)},f={capture:!0,passive:!0};return e.addEventListener(`pointerdown`,l,f),e.addEventListener(`pointermove`,u,f),e.addEventListener(`pointerup`,d,f),e.addEventListener(`pointercancel`,d,f),{wasTap:()=>s,pointerType:()=>n,dispose:()=>{e.removeEventListener(`pointerdown`,l,f),e.removeEventListener(`pointermove`,u,f),e.removeEventListener(`pointerup`,d,f),e.removeEventListener(`pointercancel`,d,f)}}}function TB(e,t,n){let r=new gD({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,a=i?i.clientWidth:window.innerWidth,o=i?i.clientHeight:window.innerHeight;return i&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),r.setSize(a,o,!1),r.setPixelRatio(n),t.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=3),r.toneMapping=t.render.toneMapping,r.toneMappingExposure=t.render.toneMappingExposure??1,r.outputColorSpace=F_,r.sortObjects=!0,r}var EB=function(e,t){let n=QI(t||{}),r=n.environment?.sceneUp||XI,i=n.render.pixelRatio??Math.min(window.devicePixelRatio,2),a=Wz(i,SD(n.look,n.render.lowPower));n.render.pixelRatio=a;let o=qz(n),s=Kz(n,e);s.up.copy(r);let c=TB(e,n,a);ND(c.capabilities.getMaxAnisotropy()),t?.onMaxAnisotropy?.(c.capabilities.getMaxAnisotropy());let l=iB(s,e,n),u=CL({scene:o,perspective:s,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>u.getActiveCamera(),f=!1;aB(o,c,n,()=>f);let p=uL(o,n),m=p.sun,h=()=>{m&&fL(m,vL(o))};n.floor?.enabled&&oB(o,n);let g=n.floor?.enabled?o.children.find(e=>e.userData.id===`floor`)??null:null,_=n.grid.enabled?PR({cellSize:n.grid.cellSize,majorEvery:n.grid.majorEvery,cellColor:n.grid.cellColor,majorColor:n.grid.majorColor,fadeDistance:n.grid.fadeDistance,plane:n.grid.plane}):null;_&&o.add(_.object);let v=()=>{_&&_.fitToContent(vL(o))},y=n.gizmo.enabled?xz({camera:s,domElement:e,controller:u}):null,b=n.grid.plane??YI(r),x=new Z(+(b===`x`),+(b===`y`),+(b===`z`)),S=r.clone().normalize(),C=n.camera.dynamicNear?mz({camera:s,scene:o,groundNormals:()=>{let e=[];return _?.object.visible&&e.push(x),n.floor.enabled&&g?.visible&&e.push(S),e}}):null,w=FR(e.parentElement??e,o),T=n.measure.enabled?cz({canvas:e,scene:o,getActiveCamera:d,getViewTarget:()=>l.target,requestRender:()=>j(),labelLayer:w,options:{snapPixels:n.measure.snapPixels,color:n.measure.color,labelClassName:n.measure.labelClassName,displayUnit:n.measure.displayUnit,format:n.measure.format}}):null,E=wB(e),D=n.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{},selectEntries:()=>{},setHover:()=>{}}:bB(e,o,u,n,E),O=bz();T&&O.register({id:`measure`,tool:T,priority:0}),y&&O.register({id:`gizmo`,tool:y,priority:-100});let k=e=>{E.wasTap()&&O.handleClick(e)&&e.stopImmediatePropagation()};e.addEventListener(`click`,k,{capture:!0});let A=e=>O.handleMove(e);e.addEventListener(`mousemove`,A,{passive:!0});let j=()=>{},M=(e,t)=>{kR(e,{color:n.edges.color,darken:n.edges.darken,width:n.edges.width,thresholdAngle:n.edges.thresholdAngle,distanceFade:n.edges.distanceFade,maxTriangles:n.edges.maxTriangles,maxSegments:n.edges.maxSegments,maxOverlays:n.edges.maxOverlays,...t}).then(()=>{N(e),j()})},N=e=>{if(n.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{let n=e.userData?.edgesSkipped;(n===`triangle-cap`||n===`overlay-budget`)&&(t=!0)}),ne.setEdgeFallback(t)},P=e=>{AR(e),ne.setEdgeFallback(!1),j()},ee=e.parentElement,te=()=>ee?{width:ee.clientWidth,height:ee.clientHeight}:{width:window.innerWidth,height:window.innerHeight},ne=rB({renderer:c,scene:o,getActiveCamera:d,getCanvasSize:te,config:n,requestRender:()=>j()});ne.sync();let re=Gz({scene:o,renderer:c,lights:p,config:n,pipeline:ne,fullPixelRatio:i,requestRender:()=>j()}),ie,ae=iL({scene:o,renderer:c,getPipeline:()=>ne.get(),frames:n.render.idleRefineFrames,lightOrbitFrameMs:n.render.lightOrbitFrameMs,jitterLights:e=>{m&&(ie=dL(m,e)),re.jitterEmissiveLights(e)},restoreLights:()=>{ie?.(),re.settleEmissiveLights()}}),{animate:oe,dispose:se,invalidate:ce,renderNow:le}=Sz(c,o,s,d,u,l,te,()=>n.render.pixelRatio,n.events.onFrame,_,y,()=>ne.get(),w,C,n.render.onDemand??!0,ae);return j=ce,oe(),o.up.set(r.x,r.y,r.z),h(),v(),{scene:o,camera:s,controls:l,renderer:c,cameraController:u,grid:_,gizmo:y,measureTool:T,labelLayer:w,tools:O,applyEdges:M,clearEdges:P,invalidate:ce,captureImage:(e=`image/png`,t)=>(le(),new Promise(n=>c.domElement.toBlob(n,e,t))),setAmbientOcclusion:ne.setAmbientOcclusion,setLook:re.setLook,syncEmissiveLights:re.syncEmissiveLights,setFillLights:re.setFillLights,setEnvironmentIntensity:re.setEnvironmentIntensity,setToneMappingExposure:re.setToneMappingExposure,setAoIntensity:re.setAoIntensity,getMaterialAppearance:re.getMaterialAppearance,updateShadowBounds:h,updateGridScale:v,dispose:()=>{f||(f=!0,se(),D.dispose(),E.dispose(),e.removeEventListener(`click`,k,{capture:!0}),e.removeEventListener(`mousemove`,A),T?.dispose(),w?.dispose(),y?.dispose(),_?.dispose(),ne.dispose(),u.dispose(),l.dispose(),c.dispose(),c.forceContextLoss(),Jz(o))},fitToView:D.fitToView,clearSelection:D.clearSelection,selectEntries:e=>{D.selectEntries(e),ce()},setHover:(e,t)=>{D.setHover(e,t),ce()},addUserGeometry:(e,t)=>{e.userData.source=t===void 0?yI:xI(t),o.add(e),j()},removeUserGeometry:e=>{e.removeFromParent(),BD(e),j()},clearUserGeometry:e=>{o.children.filter(t=>wI(t,e)).forEach(e=>{e.removeFromParent(),BD(e)}),j()}}},DB=`selva/solve-view`;function OB(e){e&&(e.theme&&Zh(e.theme),e.styles?.variables&&Qh(e.styles.variables),e.styles?.css?.fonts&&$h(e.styles.css.fonts))}async function kB(e,t){let n=new tg(e);return n.addEventListener(`hostcontextchanged`,OB),t?.(n),await n.connect(),OB(n.getHostContext()),n}function AB(e){return(e.content??[]).flatMap(e=>{let t=e;return t.type===`text`&&t.text?[t.text]:[]}).join(`\n`)}function jB(e){return e._meta?.[DB]}async function MB(e,t){if(t.response!==void 0)return t.response;if(!t.load)return;let n=await e.callServerTool({name:t.load.tool,arguments:t.load.arguments??{}});if(n.isError)throw Error(AB(n)||`${t.load.tool} failed`);return jB(n)?.response}function NB(e){let t=document.createElement(`canvas`);t.style.cssText=`display:block;width:100%;height:100%;touch-action:none`,e.append(t);let n=EB(t,{onMaxAnisotropy:TA,environment:{hdrPath:!1}}),r=!1;return{async show(e){let t=await qj(e);return mL(n.scene,t,n.camera,n.controls,r),r||=t.length>0,n.updateGridScale(),n.invalidate(),t.length},fitToView:()=>n.fitToView(),dispose(){n.dispose(),xj(),t.remove()}}}function PB(e,t,n){e.replaceChildren();let r=[],i=[];for(let n of t.inputs){let t=document.createElement(`label`);t.className=`field`;let a=document.createElement(`span`);a.className=`name`,a.textContent=n.unit?`${n.name} (${n.unit})`:n.name,n.description&&(t.title=n.description),t.append(a);let o;if(n.kind===`choice`){let e=document.createElement(`select`);typeof n.value!=`string`&&e.add(new Option(``,``));for(let t of n.options??[])e.add(new Option(t,t));e.value=typeof n.value==`string`?n.value:``,o=e,r.push(()=>e.value===``?void 0:[n.name,e.value])}else if(n.kind===`boolean`){let e=document.createElement(`input`);e.type=`checkbox`,e.checked=n.value===!0,o=e,r.push(()=>[n.name,e.checked]),t.classList.add(`inline`)}else{let e=document.createElement(`input`);e.type=n.kind===`number`?`number`:`text`,n.min!==void 0&&(e.min=String(n.min)),n.max!==void 0&&(e.max=String(n.max)),e.step=n.step===void 0?`any`:String(n.step);let t=n.value!==void 0&&n.value!==null?String(n.value):``;e.value=t,o=e,r.push(()=>n.kind===`number`?e.value===``?void 0:[n.name,Number(e.value)]:e.value===``&&t===``?void 0:[n.name,e.value])}i.push(o),t.append(o),e.append(t)}let a=document.createElement(`button`);a.type=`button`,a.className=`solve`,a.textContent=`Solve`,i.push(a),e.append(a);let o=()=>Object.fromEntries(r.map(e=>e()).filter(e=>e!==void 0));return a.addEventListener(`click`,()=>n(o())),e.addEventListener(`keydown`,e=>{e.key===`Enter`&&!a.disabled&&n(o())}),{values:o,setBusy(e){for(let t of i)t.disabled=e;a.textContent=e?`Solving…`:`Solve`}}}var FB=e=>document.getElementById(e),IB=FB(`title`),LB=FB(`status`),RB=FB(`fit`),zB=FB(`fullscreen`),BB=FB(`form`),VB=e=>{LB.textContent=e,LB.hidden=e===``},HB=e=>e instanceof Error?e.message:String(e),UB,WB=0,GB=await kB({name:`Selva solve view`,version:`1.0.0`},e=>e.addEventListener(`toolresult`,t=>void KB(e,t)));async function KB(e,t){let n=++WB,r=()=>n===WB,i=jB(t);if(IB.textContent=i?.title??``,i?.form&&qB(e,i.form),t.isError)VB(AB(t)||`The solve failed.`);else if(!i)VB(AB(t)||`This result has no geometry.`);else{VB(`Loading geometry…`);try{let t=await MB(e,i);if(!r())return;if(t===void 0){VB(`This result has no geometry.`);return}UB??=NB(FB(`stage`));let n=await UB.show(t);if(!r())return;VB(n>0?``:`The solve drew nothing.`),RB.hidden=n===0}catch(e){r()&&VB(`Could not draw the solve: ${HB(e)}`)}}}function qB(e,t){BB.hidden=t.inputs.length===0;let n=PB(BB,t,r=>{n.setBusy(!0),VB(`Solving…`),e.callServerTool({name:t.tool,arguments:{...t.arguments,[t.valuesKey]:r}}).then(async t=>{await KB(e,t);let n=AB(t);await e.updateModelContext({content:[{type:`text`,text:`The user solved again from the 3D view with ${JSON.stringify(r)}.\\n${n}`}]}).catch(()=>{})}).catch(e=>VB(`Could not solve: ${HB(e)}`)).finally(()=>n.setBusy(!1))})}RB.addEventListener(`click`,()=>UB?.fitToView());var JB=e=>{document.body.classList.toggle(`fullscreen`,e===`fullscreen`),zB.textContent=e===`fullscreen`?`Exit fullscreen`:`Fullscreen`},YB=()=>{let e=GB.getHostContext();zB.hidden=!(e?.availableDisplayModes??[]).includes(`fullscreen`),e?.displayMode&&JB(e.displayMode)};YB(),GB.addEventListener(`hostcontextchanged`,YB),zB.addEventListener(`click`,()=>{let e=document.body.classList.contains(`fullscreen`)?`inline`:`fullscreen`;GB.requestDisplayMode({mode:e}).then(({mode:e})=>JB(e),e=>VB(`Could not change the display: ${HB(e)}`))});<\/script>\n </head>\n <body>\n <header>\n <h1 id=\"title\">Solve in 3D</h1>\n <button id=\"fit\" type=\"button\" hidden>Fit</button>\n <button id=\"fullscreen\" type=\"button\" hidden>Fullscreen</button>\n </header>\n <main>\n <div id=\"form\" hidden></div>\n <div id=\"stage\"><div id=\"status\">Waiting for the solve…</div></div>\n </main>\n </body>\n</html>\n";
|
|
3
|
+
export { solve_default as default };
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=solve.js.map
|